<p>Right now I am using the <strong>math/rand</strong> package, but it seems kind of basic, especially when it comes to generating random Float32's. Additionally there seems to be no method for generating floats between a certain range. Right now I am just randomly generating normal integers and using a float like 13.0 as a dominator. </p>
<p>What is Go's version of NPM? I seem to have a hard time finding open source libraries for Go.</p>
<hr/>**评论:**<br/><br/>coltstrgj: <pre><p>You cannot generate numbers in a range and still be Gaussian. You can specify an certainty that a value falls in a range, but cannot guarantee it. This is just a math thing, but really doesn't matter that much to you because the numbers we generate are close. </p>
<p>You can approximate Gaussian by averaging a few of these linearly distributed random numbers from math/rand. </p>
<p><a href="https://play.golang.org/p/n93Sc-u7Mq" rel="nofollow">Here</a> is some example code that I think will do what you are looking for. </p>
<p><a href="https://docs.google.com/spreadsheets/d/1CmSrNbiU8O_7wy4hZtPyc-lhxNKzILW4Cug4E57Ca44/edit?usp=sharing" rel="nofollow">Here</a> is a quick sample of what the example code I posted generates.</p></pre>TheBeardofGilgamesh: <pre><p>That's awesome thanks! Also, yeah certainty is what I was looking for since it's a simulation I just wanted to contain the fluctuations so that the variance falls in a normal distribution on par with the Forex/Stocks actual historical range[June 2016]. The actual implementation I made that produces floats via division of a random Int within a range over a Float64 denominator looks really weird since the chart looks like a zig zag always contained within it's Y axis range, like Homer Simpson's hair. </p>
<p>Anyways, this is great stuff, thanks a lot I really appreciate it! </p></pre>coltstrgj: <pre><p>No problem, I was something I had to figure out for a project recently as well. </p></pre>whiteraven-: <pre><p>You can search for open source projects at <a href="https://godoc.org" rel="nofollow">godoc</a></p></pre>epiris: <pre><p>Search go-faker. If I recall some people have inenebted the python / nodejs faker libraries (I don't remember which came first, pardon my ignorance here). If you want more structured bulk data from real world stuff, the government has probably the best site I've found for this. I've used it numerous times for all kinda of purposes. It can be a bit less boring to look at as you develop too. <a href="HTTP://data.gov" rel="nofollow">HTTP://data.gov</a> (might need to click developers or API or something, sorry, on mobile.)</p></pre>intermernet: <pre><p>A Google search for "golang gaussian" had <a href="https://github.com/leesper/go_rng" rel="nofollow">this</a> as the fourth result. Hopefully it's approximately what you're after. I've not used it, or read the code, but it definitely has a <a href="https://github.com/leesper/go_rng/blob/master/gauss.go" rel="nofollow">Gaussian PRNG function</a>.</p>
<p>It says it has implementations of:</p>
<ul>
<li>Uniform Distribution </li>
<li>Bernoulli Distribution </li>
<li>Chi-Squared Distribution </li>
<li>Gamma Distribution </li>
<li>Beta Distribution </li>
<li>Fisher's F Distribution </li>
<li>Cauchy Distribution </li>
<li>Weibull Distribution </li>
<li>Pareto Distribution </li>
<li>Log Normal Distribution </li>
<li>Exponential Distribution </li>
<li>Student's t-Distribution </li>
<li>Binomial Distribution </li>
<li>Poisson Distribution </li>
<li>Geometric Distribution </li>
<li>Gaussian Distribution </li>
<li>Logistic Distribution </li>
<li>Dirichlet Distribution</li>
</ul>
<p>But I have no idea if they are implemented correctly or not.</p>
<p>General rule of thumb: The language is called "Go", but always Google for "golang" :-) </p></pre>coltstrgj: <pre><p>This last part is a good tip. It took me a very long time to figure out to search for golang instead of Go. </p></pre>
Does anyone know of any good Random Data libraries, that come with some Johann Carl Friedrich Gauss style algorithms?
blov · · 438 次点击这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传