![]() |
MATLAB生成随机数
嗨,我正在尝试在MATLAB中使用随机MEAN值生成随机数。
例如,如果我使用 e = mean(rand(1000,1)) e的答案将始终接近0.5 。我想要的是e (均值)的值是随机的,以便e可以是0.1、0.2、0.3等。 使用e = mean( unifrnd(0,1,[1000,1]) )对我来说正确吗? 谢谢 回答: 也许您想使用[URL="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/randn.html"]randn[/URL]生成[B]正态分布的[/B]随机数[URL="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/randn.html"]X〜N[/URL] X~N(0,1) 。然后,您可以将平均值和标准偏差更改为随机数。举个例子: N = 1000; mu = rand*10 - 5; %# mean in the range of [-5.0 5.0] sigma = randi(5); %# std in range of 1:5 X = randn(N, 1)*sigma + mu; %# normally distributed with mean=mu and std=sigma [url=https://stackoverflow.com/questions/1892375]更多&回答...[/url] |
所有时间均为北京时间。现在的时间是 01:04。 |
Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.