From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Random Number Generation
Date: Thu, 27 Jun 2013 05:23:06 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 22
Message-ID: <kqgi7q$jpl$>
References: <i1fhko$rsc$> <i1g240$rho$> <i1g51j$5g4$> <kqf3he$rv4$>
Reply-To: <HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: 1372310586 20277 (27 Jun 2013 05:23:06 GMT)
NNTP-Posting-Date: Thu, 27 Jun 2013 05:23:06 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: comp.soft-sys.matlab:798406

"taffi" wrote in message <kqf3he$rv4$>...
> i need to use a std deviation as well. i have a max, min, mean and also a std value. How can i get random numbers of beta distribution wid a certain standard deviation.
  As I said back in 2010. "You can multiply the first two arguments of betarnd by any common factor to change the distribution's variance at your pleasure without affecting the mean."  This can be done as follows.  Call a = max, b = min, m = mean, and s = std.  Then you can generate the desired beta distribution with

 f = ((b-m)*(m-a)-s^2)/s^2;
 x = a+(b-a)*betarnd((m-a)/(b-a)*f,(b-m)/(b-a)*f,M,N);

As you can see, that "common factor" is the above 'f'.  Note that both m and s are constrained by the inequalities

 a < m < b
 0 < s < sqrt((b-m)*(m-a))

so the choice of s isn't fully "at your pleasure".

  You can consult the website

to check that the above formula results in the desired mean and standard deviation.

Roger Stafford