Re: Basic Statistics in Mathematica 3.0
- To: mathgroup@smc.vnet.net
- Subject: [mg12480] Re: [mg12439] Basic Statistics in Mathematica 3.0
- From: "Tomas Gargz" <tgarza@mail.internet.com.mx>
- Date: Tue, 19 May 1998 13:31:45 -0400
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