From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: How to make the output always be between 0 and 1
Date: Thu, 24 Jun 2010 16:39:04 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 8
Message-ID: <i001n8$8or$>
References: <hvulnk$4uf$> <hvv7dt$s0m$> <hvvbih$p2c$> <hvvhpr$5nd$>
Reply-To: <HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: 1277397544 8987 (24 Jun 2010 16:39:04 GMT)
NNTP-Posting-Date: Thu, 24 Jun 2010 16:39:04 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: comp.soft-sys.matlab:647798

"dhaskantha " <> wrote in message <hvvhpr$5nd$>...
> Thank you, Jan. I will try.
- - - - - - - - -
  Rather than changing values which lie outside of [0,1] to a 0 or 1, from a statistical point of view it is probably preferable to simply reject them and repeat the call on normrnd or whatever your source is until you have a sufficient number of random values.  Otherwise you may get a number of values that are artificially stacked up at exactly 0 or 1 and this would skew your statistical distribution.  You can accomplish this with a while loop.

  Always remember that when you truncate a normal distribution in this manner, strictly speaking you no longer have a normal distribution, which is supposed to be free to extend to an unlimited amount either up or down.  Both the mean and variance will be different from what  you might expect.

Roger Stafford