Compute Relative Frequency in Mathematica
With :
dalist = {{379, 219, 228, 401}, {387, 239, 230, 393},
{403, 238, 217, 429}, {377, 233, 225, 432}}
BarChart@dalist
I would like to compute / Plot the relative frequency instead of absolute count for each Bin for each condition.
Where :
{379, 219, 228, 401}
are the 4 bins count for one condition. So :
{379, 219, 228, 401}[[1]]/Total@{379, 219, 228, 401}
is the result I want to see of the first condition / fir开发者_JS百科st Bin, instead of the count itself.
belisarius beat me to it.
You might also want to explore BarChart[dalist, ChartLayout -> "Percentile"]
Isn't it
BarChart[dalist/Total /@ dalist]
?
All you have to do is this:
In[13]:= #/Total[#] & /@ dalist
Out[13]= {{379/1227, 73/409, 76/409, 401/1227}, {387/1249, 239/1249,
230/1249, 393/1249}, {31/99, 238/1287, 217/1287, 1/3}, {377/1267,
233/1267, 225/1267, 432/1267}}
and chart it instead
精彩评论