Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I am wondering in Mathematica

Can we generate histogram plot with descriptive statistics, such as mean, median, and skewness, attached to the plot ?

For example, we may place all the statistics to the right of the plot

Here is what I have done. First I created the function:

descriptivestatistics[
  data_] := {{"Mean", "Median", "Stdv.", "Skewness", 
    "Kurtosis"}, {Mean[data], Median[data], StandardDeviation[data], 
    Skewness[data], Kurtosis[data]}} // TableForm

Then, I placed them on the same list as follows:

{Histogram[data,"PDF",Automatic],descriptivestatistics[data]},

but I think there is better way to do it.

Also, I want to export to be a report e.g., .doc or .pdf

Can any one give me suggestions ?

Thank you

share|improve this question

2 Answers 2

up vote 2 down vote accepted

Mathematica's symbolic graphics architecture gives you a lot of flexibility to construct composite graphics. A simple way could be:

d = RandomVariate[NormalDistribution[], 100];
descriptivestatistics[data_] := {{"Mean", "Median", "Stdv.", "Skewness", 
   "Kurtosis"}, {Mean[data], Median[data], 
   StandardDeviation[data], Skewness[data], Kurtosis[data]}} // 
 Transpose // Grid // Panel;
GraphicsGrid[{{Histogram@d, descriptivestatistics@d}}]

enter image description here

The documentation on Export will explain how you can export to various formats.

share|improve this answer
    
Thanks a lot. How do you move the box on the right to get close to the histogram plot? –  newbie Feb 26 at 7:46

Alternatively, with

d = RandomVariate[NormalDistribution[], 100];
descriptivestatistics[data_] := {Mean[data], Median[data], 
  StandardDeviation[data], Skewness[data], Kurtosis[data]}

we construct labels & legend

hdr = {"Mean", "Median", "Std. Dev.", "Skewn.", "Kurt"};
tds = ToString@PaddedForm[#, {5, 2}] & /@ descriptivestatistics[d];
ltxt = StringJoin[hdr[[#]], ": ", tds[[#]]] & /@ Range[5];
lgd = Text[Style[ltxt[[#]], Bold], {-3, 25 - 1.4 #}, {-1, 0}] & /@ 
   Range[5];

We can use this as

Histogram[d, 10,
 Frame -> True,
 FrameLabel -> {"Band", "Count"},
 ImagePadding -> {{Automatic, 2}, {Automatic, 2}},
 Epilog -> lgd
 ]

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.