# Histogram plot with descriptive statistics on the plot

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

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}}] The documentation on Export will explain how you can export to various formats.

• Thanks a lot. How do you move the box on the right to get close to the histogram plot? – newbie Feb 26 '14 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;
lgd = Text[Style[ltxt[[#]], Bold], {-3, 25 - 1.4 #}, {-1, 0}] & /@
Range;


We can use this as

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