<p>Link here:</p>
<p><a href="https://golang.org/pkg/math/rand/#Zipf">https://golang.org/pkg/math/rand/#Zipf</a></p>
<p>Seems fairly arbitrary... No Gaussian?</p>
<hr/>**评论:**<br/><br/>jlund3: <pre><p>For sampling from a Gaussian, <a href="https://golang.org/pkg/math/rand/#NormFloat64">NormFloat64</a> has you covered. Just multiply the Normal distribution by your standard deviation and add in your mean.</p></pre>fancy_pantser: <pre><p>As for why it provides Zipf distributions: back in 12/2009 (long before Go 1, just a month after it was announced to the public), William Josephson added it with <a href="https://github.com/golang/go/commit/52114724b779d2826746dfc3c2475f659bbd7961" rel="nofollow">this commit</a> and we see some feedback in <a href="https://codereview.appspot.com/176070" rel="nofollow">this review</a> but no reasoning on why he wanted to add it. The <a href="http://golang-nuts.narkive.com/7cjy5i2N/release-2009-12-22" rel="nofollow">release notes</a> mention it but no reason either.</p>
<p>I can only imagine that Googlers wanted to have it in there because Zipf's law is often used in Natural Language Processing (NLP) and simulation thereof. The zeta distribution has many other uses, of course.</p>
<blockquote>
<p>Zipf's law states that given some corpus of natural language utterances, the frequency of any word is inversely proportional to its rank in the frequency table.</p>
</blockquote></pre>
Why does Go's Rand package provide a function to smaple from the Zipf Distribution?
polaris · · 358 次点击这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传