MathGroup Archive 1998

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Basic Statistics in Mathematica 3.0



Massy Soedirman wrote:

>The calculation of ,for example, the mean and the variance of a
>statistical  series is staighforward in Mathematica but I don't know
>how to do it if,  instead of having the complete list of values of the
>statistical variable I  only have the set of diifferent values that
>variable takes with their  respective frequencies. I have trouble
>thinking Mathematica cannot handle such  a basic task but I can't find
>a way to do it.

Massy,

The most straightforward way to do that is to regenerate the list you 
have and get the original, ungrouped data. Then use the statistical 
functions Mean, Variance, etc. For example, if

In[1]:=
           data = {{22,2},{23,5},{24,3},{25,1}}

where each sublist has a value and its frequency, then define an 
ungrouping function:

In[2]:=  unGroup[{a_, b_}] := Table[a, {b}]

and another to map it onto the original data:

In[3]:=  exdata[a_] := Flatten[unGroup[#]&/@a]

In the example above,

In[4] := exdata[data]

Out[4]=  {22, 22, 23, 23, 23, 23, 23, 24, 24, 24, 25}

Then use Mean[exdata[data]], Variance[exdata[data]],...

Good luck,

Tomas Garza
Mexico City



  • Prev by Date: Re: How does a rule get applied?
  • Next by Date: Re: Create Auto Save Package
  • Prev by thread: Basic Statistics in Mathematica 3.0
  • Next by thread: Re: Basic Statistics in Mathematica 3.0