查找英语词频分布
计算美国宪法中出现的单词.
In[1]:=
text = ExampleData[{"Text", "USConstitution"}, "Words"];
wordCount = Values[Counts[text]];
找到单词计算的简单分布.
In[2]:=
e\[ScriptCapitalD] = FindDistribution[wordCount]
Out[2]=
将找到的分布与单词计数对比.
显示完整的 Wolfram 语言输入
Out[3]=
计算美国宪法中出现的单词.
text = ExampleData[{"Text", "USConstitution"}, "Words"];
wordCount = Values[Counts[text]];
找到单词计算的简单分布.
e\[ScriptCapitalD] = FindDistribution[wordCount]
将找到的分布与单词计数对比.
Show[Histogram[wordCount, {0.5, 15.5, 1}, "ProbabilityDensity",
PlotLabel -> "Word Count Distribution"],
DiscretePlot[PDF[e\[ScriptCapitalD], x], {x, 1, 15},
PlotStyle -> PointSize[Large],
PlotLegends -> {"e\[ScriptCapitalD]"}]]