http://www.mathworks.com/matlabcentral/newsreader/view_thread/242467
MATLAB Central Newsreader  generate long random vector by repeating 12 means and stds
Feed for thread: generate long random vector by repeating 12 means and stds
enus
©19942015 by MathWorks, Inc.
webmaster@mathworks.com
MATLAB Central Newsreader
http://blogs.law.harvard.edu/tech/rss
60
MathWorks
http://www.mathworks.com/images/membrane_icon.gif

Thu, 15 Jan 2009 15:37:02 +0000
generate long random vector by repeating 12 means and stds
http://www.mathworks.com/matlabcentral/newsreader/view_thread/242467#621834
Kirk
I need to generate 1200 random elements from 12 mean values and 12 standard deviations. <br>
<br>
I have created the vectors:<br>
y_mu = [7.22,3.67,2.40,11.25,19.11,23.89,26.73,25.26,19.61,12.78,2.38,4.82]<br>
y_sigma = [3.04,2.82,2.48,2.73,2.26,1.78,1.64,1.77,1.79,2.06,2.46,2.63]<br>
<br>
I then used normrnd to generate a new vector of 12 random elments:<br>
y_rand = normrnd(y_mu,y_sigma,1,12);<br>
<br>
My trouble is that I need to do this 100 times, generating a vector with a dimension of 1,1200 every 12 elements represent a new call to the function normrand generating 12 new random elements based on the 12 y_mu and y_sigma. <br>
<br>
Should this be done in a loop? or is there a more elegant Matlabish approach?

Thu, 15 Jan 2009 16:11:02 +0000
Re: generate long random vector by repeating 12 means and stds
http://www.mathworks.com/matlabcentral/newsreader/view_thread/242467#621852
Roger Stafford
"Kirk" <kwythers.nospam@umn.edu> wrote in message <gknl6u$p5t$1@fred.mathworks.com>...<br>
> I need to generate 1200 random elements from 12 mean values and 12 standard deviations. <br>
> <br>
> I have created the vectors:<br>
> y_mu = [7.22,3.67,2.40,11.25,19.11,23.89,26.73,25.26,19.61,12.78,2.38,4.82]<br>
> y_sigma = [3.04,2.82,2.48,2.73,2.26,1.78,1.64,1.77,1.79,2.06,2.46,2.63]<br>
> <br>
> I then used normrnd to generate a new vector of 12 random elments:<br>
> y_rand = normrnd(y_mu,y_sigma,1,12);<br>
> <br>
> My trouble is that I need to do this 100 times, generating a vector with a dimension of 1,1200 every 12 elements represent a new call to the function normrand generating 12 new random elements based on the 12 y_mu and y_sigma. <br>
> <br>
> Should this be done in a loop? or is there a more elegant Matlabish approach? <br>
> <br>
You can do it with one call to 'normrnd' if you do a 'repmat' on 'y_mu' and 'y_sigma'.<br>
<br>
y_rand = normrnd(repmat(y_mu,1,100),repmat(y_sigma,1,100));<br>
<br>
Note: This advice is based on reading the documentation. I haven't actually used 'normrnd' myself.<br>
<br>
Roger Stafford

Thu, 15 Jan 2009 16:34:04 +0000
Re: generate long random vector by repeating 12 means and stds
http://www.mathworks.com/matlabcentral/newsreader/view_thread/242467#621860
Kirk
"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <br>
> > <br>
> > Should this be done in a loop? or is there a more elegant Matlabish approach? <br>
> > <br>
> You can do it with one call to 'normrnd' if you do a 'repmat' on 'y_mu' and 'y_sigma'.<br>
> <br>
> y_rand = normrnd(repmat(y_mu,1,100),repmat(y_sigma,1,100));<br>
> <br>
> Note: This advice is based on reading the documentation. I haven't actually used 'normrnd' myself.<br>
> <br>
> Roger Stafford<br>
<br>
That's a nice solution. Thank you.