生成具有相同标准差和均值的新列表
如何从与原始列表具有相同均值和标准差的随机数生成新列表?
我尝试了 newlist = Mean(list) + std(list)*randn(100,1);我在 Matlab 网站上找到了它,但它生成的标准差和均值与原始值略有不同,因为新的均值总是更大。
How do I generate a new list from random numbers that have the same mean and standard deviation from the original list?
I tried newlist = mean(list) + std(list)*randn(100,1); which I found on the Matlab website but it was generating slightly different std and mean from the original since the new mean is always bigger.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
诀窍是生成平均值为 0 且标准差为 1 的随机数。我们通过生成任何旧的随机数,然后修复平均值和标准差来实现这一点。
现在 newlist = Mean(list) + std(list) * r3 应该可以满足您的需求。
The trick is to generate random numbers with mean 0 and std dev 1. We do this by generating any old random numbers, then fixing the mean and standard deviation afterwards.
Now
newlist = mean(list) + std(list) * r3
should give you what you need.很抱歉用问题来回答问题,但我必须问...
为什么需要确保随机数向量的平均值与原始向量完全相同?同样,为什么标准差需要完全相同?
如果我运行蒙特卡洛模拟或类似的模拟,我会尝试发现可能会发生什么。
如果您调整随机数,使平均值恰好为 X,标准差恰好为 Y,您就会降低模拟包含极端事件的机会。反过来,这意味着出现问题的可能性较小。
这些类型的转换作为学术练习很好,但是,我对在现实世界中使用这种类型的方法感到非常担忧。
Sorry to answer a question with a question, but I have to ask...
Why do you need to ensure that the mean of your vector of random numbers is precisely same as your original vector? In a similar vein, why does the standard deviation need to be precisely the same?
If I run a monte carlo simulation or some such, I'm trying to discover what might happen.
If you adjust your random numbers so that the mean is precisely X and the standard deviation is exactly Y you're decreasing the chance that your simulation will contain an extreme event. In turn, this mean's that its less likely that something is going to go wrong.
These types of transforms are fine as an academic exercise, however, I'd have grave concerns about employing this type of method in the real world.