Path: news.mathworks.com!not-for-mail
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$1@fred.mathworks.com>
References: <hvulnk$4uf$1@fred.mathworks.com> <hvv7dt$s0m$1@fred.mathworks.com> <hvvbih$p2c$1@fred.mathworks.com> <hvvhpr$5nd$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1277397544 8987 172.30.248.35 (24 Jun 2010 16:39:04 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 24 Jun 2010 16:39:04 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:647798

"dhaskantha " <dharen10@gmail.com> wrote in message <hvvhpr$5nd$1@fred.mathworks.com>...
> 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