[Numpy-discussion] Computing Simple Statistics When Only they Frequency Distribution is Known
Fri Nov 27 23:25:30 CST 2009
I actually wrote my own several days ago. When I began getting myself
more familiar with numpy, I was hoping there would be an easy to use
version in it for this frequency approach. If not, then I'll just stick
with what I have. It seems something like this should be common.
A simple way to do it with the present capabilities would be to "unwind"
the frequencies, For example, given [2,1,3] for some corresponding set
of x, say, [1,2,3], produce[1, 1, 2, 3, 3, 3]. I have no idea if numpy
does anything like that, but, if so, the typical mean, std, ... could be
used. In my case, it's sort of pointless. It would produce an array of
307,200 items for 256 x (0,1,2,...,255), and just slow down the
computations "unwinding" it in software. The sub-processor hardware
already produced the 256 frequencies.
Basically, this amounts to having a pdf, and values of x.
Mathematically, the statistics are produced directly from it.
> On Fri, Nov 27, 2009 at 9:47 PM, Wayne Watson
> <firstname.lastname@example.org> wrote:
>> How do I compute avg, std dev, min, max and other simple stats if I only
>> know the frequency distribution?
> If you are willing to assign to all observations in a bin the value at
> the bin midpoint, then you could do it with weights in the statistics
> calculations. However, numpy.average is, I think, the only statistic
> that takes weights. min max are independent of weight, but std and var
> need to be calculated indirectly.
> If you need more stats with weights, then the attachment in
> http://projects.scipy.org/scipy/ticket/604 is a good start.
>> Wayne Watson (Watson Adventures, Prop., Nevada City, CA)
>> (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
>> Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet
>> 350 350 350 350 350 350 350 350 350 350
>> Make the number famous. See 350.org
>> The major event has passed, but keep the number alive.
>> Web Page: <www.speckledwithstars.net/>
>> NumPy-Discussion mailing list
> NumPy-Discussion mailing list
Wayne Watson (Watson Adventures, Prop., Nevada City, CA)
(121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet
350 350 350 350 350 350 350 350 350 350
Make the number famous. See 350.org
The major event has passed, but keep the number alive.
Web Page: <www.speckledwithstars.net/>
More information about the NumPy-Discussion