[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Working with histogram data
From: |
Jaroslav Hajek |
Subject: |
Re: Working with histogram data |
Date: |
Mon, 4 Jan 2010 21:38:41 +0100 |
On Mon, Jan 4, 2010 at 7:53 PM, Shaun Jackman <address@hidden> wrote:
> How can I use functions that expect a set of samples with data in the
> form of a histogram? I have vectors x and n (the observation x was seen
> n times; x is integer), and I'd like to calculate the mean and standard
> deviation (for example). My best idea so far is to write a function
> unhistogram like so:
>
> samples = unhistogram(x, n);
> mean(samples)
> std(samples)
>
This is certainly a possible, but as you are probably aware, such an
approach may be rather inefficient compared to direct formulas, if n
contains large values.
> For this limited example it would be easy enough to write forms of mean
> and std that take histograms rather than samples, but I'd like to be
> able to use the gamut of stock functions that expect a set of
> observations.
>
I don't think there's any other magic that would get you there. Such a
set of functions would perhaps form a valuable addition to the
statistics package.
--
RNDr. Jaroslav Hajek, PhD
computing expert & GNU Octave developer
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz