C# Normal Random Number(C# 普通随机数)
问题描述
我想创建一个接受双均值
、双偏差
并返回一个正态分布的随机数的函数.
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% 的时间我会得到一个介于 3.00 和 7.00 之间的数字
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
我的统计数据有点弱......任何人都知道我应该如何处理这个问题?我的实现将是 C# 2.0,但只要数学函数是标准的,就可以用您选择的语言回答.
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.
我认为这个实际上可能成为我正在寻找的东西.任何帮助将其转换为代码?
I think this might actually be what I am looking for. Any help converting this to code?
预先感谢您的帮助.
推荐答案
参见这篇 CodeProject 文章:简单的随机数生成.代码很短,可以从均匀分布、正态分布和指数分布中生成样本.
See this CodeProject article: Simple Random Number Generation. The code is very short, and it generates samples from uniform, normal, and exponential distributions.
这篇关于C# 普通随机数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:C# 普通随机数


基础教程推荐
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- 全局 ASAX - 获取服务器名称 2022-01-01