[Numpy-discussion] weighted mean; weighted standard error of the mean (sem)
Thu Sep 9 22:07:49 CDT 2010
On Thu, Sep 9, 2010 at 7:22 PM, cpblpublic <email@example.com> wrote:
> I am looking for some reaally basic statistical tools. I have some
> sample data, some sample weights for those measurements, and I want to
> calculate a mean and a standard error of the mean.
How about using a bootstrap?
Array and weights:
>> a = np.arange(100)
>> w = np.random.rand(100)
>> w = w / w.sum()
>> n = 1000
>> ma = np.zeros(n)
Save mean of each bootstrap sample:
>> for i in range(n):
....: idx = np.random.randint(0, 100, 100)
....: ma[i] = np.dot(a[idx], w[idx])
Error in mean:
>> np.dot(w, a)
Hmm...should w[idx] be renormalized to sum to one in each bootstrap sample?
More information about the NumPy-Discussion