問(wèn)題描述
我想創(chuàng)建一個(gè)接受雙均值
、雙偏差
并返回一個(gè)正態(tài)分布的隨機(jī)數(shù)的函數(shù).
I would like to create a function that accepts Double mean
, Double deviation
and returns a random number with a normal distribution.
例如:如果我傳入 5.00 作為平均值和 2.00 作為偏差,68% 的時(shí)間我會(huì)得到一個(gè)介于 3.00 和 7.00 之間的數(shù)字
Example: if I pass in 5.00 as the mean and 2.00 as the deviation, 68% of the time I will get a number between 3.00 and 7.00
我的統(tǒng)計(jì)數(shù)據(jù)有點(diǎn)弱......任何人都知道我應(yīng)該如何處理這個(gè)問(wèn)題?我的實(shí)現(xiàn)將是 C# 2.0,但只要數(shù)學(xué)函數(shù)是標(biāo)準(zhǔn)的,就可以用您選擇的語(yǔ)言回答.
My statistics is a little weak…. Anyone have an idea how I should approach this? My implementation will be C# 2.0 but feel free to answer in your language of choice as long as the math functions are standard.
我認(rèn)為這個(gè)實(shí)際上可能成為我正在尋找的東西.任何幫助將其轉(zhuǎn)換為代碼?
I think this might actually be what I am looking for. Any help converting this to code?
預(yù)先感謝您的幫助.
推薦答案
參見這篇 CodeProject 文章:簡(jiǎn)單的隨機(jī)數(shù)生成.代碼很短,可以從均勻分布、正態(tài)分布和指數(shù)分布中生成樣本.
See this CodeProject article: Simple Random Number Generation. The code is very short, and it generates samples from uniform, normal, and exponential distributions.
這篇關(guān)于C# 普通隨機(jī)數(shù)的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!