New in Wolfram
Mathematica
8: Parameter Estimation and Testing
◄
previous
|
next
►
Core Algorithms
Model Word Lengths by Binomial Distributions
Fit word lengths in different languages to binomial distributions and compare the empirical and fitted distributions.
In[1]:=
X
languages = {"Dutch", "English", "French", "German", "Hebrew", "Polish", "Russian", "Spanish", "Swedish"}; worddata = Table[StringLength /@ DictionaryLookup[{l, All}], {l, languages}];
In[2]:=
X
binom = Table[ EstimatedDistribution[i, BinomialDistribution[n, p], ParameterEstimator -> {"MaximumLikelihood", Method -> {"FindRoot", MaxIterations -> 1000}}], {i, worddata}];
In[3]:=
X
Partition[ Table[Show[ Histogram[worddata[[i]], {Range[25] - 1/2}, "PDF", PlotLabel -> languages[[i]], ChartStyle -> Directive[Opacity[.2], ColorData[35, i]]], DiscretePlot[PDF[binom[[i]], x], {x, 0, 25}, PlotRange -> All, PlotStyle -> {{PointSize[.02], Darker@ColorData[35, i]}}]], {i, Length[languages]}], 3] // Grid
Out[3]=