<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/165921</link>
    <title>MATLAB Central Newsreader - random number generation</title>
    <description>Feed for thread: random number generation</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2008 by The MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>The MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Wed, 19 Mar 2008 14:01:56 -0400</pubDate>
      <title>Re: random number generation</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/165921#421714</link>
      <author>Greg Heath</author>
      <description>On Mar 18, 3:46=A0pm, richardsta...@comcast.net wrote:&lt;br&gt;
&amp;gt; On Tue, 18 Mar 2008 19:42:01 +0000 (UTC), "Roger Stafford"&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;lt;ellieandrogerxy...@mindspring.com.invalid&amp;gt; wrote:&lt;br&gt;
&amp;gt; &amp;gt;"AMMAL " &amp;lt;alan...@ualberta.ca&amp;gt; wrote in message &amp;lt;frp525$8i&lt;br&gt;
&amp;gt; &amp;gt;$...@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; Hellow everybody,&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; I need a hand on how to generate a 100 positive numbers&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; that follow a normal distribution curve (Bell Shape).In&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; otherwords, if i histogram the data, a bell shape will be&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; generated. i am not transforming my data, instead, i want&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; to generate a posirtive one hundred values that will follow&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; a bell shape.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; Thanks,&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; Ammal&lt;br&gt;
&amp;gt; &amp;gt;------&lt;br&gt;
&amp;gt; &amp;gt; =A0You can use "s*randn(1,100)+m" to generate a hundred normal distribut=&lt;br&gt;
ion&lt;br&gt;
&amp;gt; &amp;gt;numbers with mean m and standard deviation s, but you cannot be sure all =&lt;br&gt;
of&lt;br&gt;
&amp;gt; &amp;gt;them will be positive. =A0You cannot have a normal distribution and at th=&lt;br&gt;
e same&lt;br&gt;
&amp;gt; &amp;gt;time have only positive numbers. =A0That is a contradiction in terms. =A0=&lt;br&gt;
The "bell&lt;br&gt;
&amp;gt; &amp;gt;shape" extends all the way to minus and plus infinity.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt;Roger Stafford&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Roger's advice is correct of course.&lt;br&gt;
&amp;gt; Having said that, you can insure that a *sample*is entirely positive.&lt;br&gt;
&amp;gt; For example:&lt;br&gt;
&amp;gt; x =3D s*randn(1,100)+m;&lt;br&gt;
&amp;gt; if min(x)&amp;lt;0&lt;br&gt;
&amp;gt; =A0x =3D x + abs(min(x));&lt;br&gt;
&amp;gt; end&lt;br&gt;
&lt;br&gt;
Alternatively, you can reject negative values&lt;br&gt;
and keep generating until you have 100.&lt;br&gt;
&lt;br&gt;
In either case, the resulting distribution is ...&lt;br&gt;
&lt;br&gt;
ABNORMAL! (;&amp;gt;)&lt;br&gt;
&lt;br&gt;
Greg&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Wed, 19 Mar 2008 08:20:04 -0400</pubDate>
      <title>Re: random number generation</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/165921#421651</link>
      <author>Vihang Patil</author>
      <description>"AMMAL " &amp;lt;alanazi@ualberta.ca&amp;gt; wrote in message &amp;lt;frp525&lt;br&gt;
$8i$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Hellow everybody,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I need a hand on how to generate a 100 positive numbers &lt;br&gt;
&amp;gt; that follow a normal distribution curve (Bell Shape).In &lt;br&gt;
&amp;gt; otherwords, if i histogram the data, a bell shape will &lt;br&gt;
be &lt;br&gt;
&amp;gt; generated. i am not transforming my data, instead, i &lt;br&gt;
want &lt;br&gt;
&amp;gt; to generate a posirtive one hundred values that will &lt;br&gt;
follow &lt;br&gt;
&amp;gt; a bell shape.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks,&lt;br&gt;
&amp;gt; Ammal&lt;br&gt;
&lt;br&gt;
Hello&lt;br&gt;
I am not sure about the Bell thing, but if you want to &lt;br&gt;
generate 100 random positive numbers then you can use this&lt;br&gt;
n = 100;&lt;br&gt;
f = ceil(n.*rand(100,1));&lt;br&gt;
&lt;br&gt;
HTH&lt;br&gt;
Vihang &lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Tue, 18 Mar 2008 20:17:01 -0400</pubDate>
      <title>Re: random number generation</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/165921#421587</link>
      <author>ammal</author>
      <description>Thank you all for your answer,&lt;br&gt;
I am wondering now how i would include the codition &lt;br&gt;
statement you wrote in the block code to ensure the samples &lt;br&gt;
are positive.Could you please show me how to include it in &lt;br&gt;
a for loop maybe. &lt;br&gt;
&lt;br&gt;
Thanks,&lt;br&gt;
Ammal &lt;br&gt;
&lt;br&gt;
richardstartz@comcast.net wrote in message &lt;br&gt;
&amp;lt;8r60u3p6eauu99plunl4oo31dd1o242jq2@4ax.com&amp;gt;...&lt;br&gt;
&amp;gt; On Tue, 18 Mar 2008 19:42:01 +0000 (UTC), "Roger Stafford"&lt;br&gt;
&amp;gt; &amp;lt;ellieandrogerxyzzy@mindspring.com.invalid&amp;gt; wrote:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &amp;gt;"AMMAL " &amp;lt;alanazi@ualberta.ca&amp;gt; wrote in message &amp;lt;frp525&lt;br&gt;
$8i&lt;br&gt;
&amp;gt; &amp;gt;$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; Hellow everybody,&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; &lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; I need a hand on how to generate a 100 positive &lt;br&gt;
numbers &lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; that follow a normal distribution curve (Bell &lt;br&gt;
Shape).In &lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; otherwords, if i histogram the data, a bell shape will &lt;br&gt;
be &lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; generated. i am not transforming my data, instead, i &lt;br&gt;
want &lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; to generate a posirtive one hundred values that will &lt;br&gt;
follow &lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; a bell shape.&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; &lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; Thanks,&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; Ammal&lt;br&gt;
&amp;gt; &amp;gt;------&lt;br&gt;
&amp;gt; &amp;gt;  You can use "s*randn(1,100)+m" to generate a hundred &lt;br&gt;
normal distribution &lt;br&gt;
&amp;gt; &amp;gt;numbers with mean m and standard deviation s, but you &lt;br&gt;
cannot be sure all of &lt;br&gt;
&amp;gt; &amp;gt;them will be positive.  You cannot have a normal &lt;br&gt;
distribution and at the same &lt;br&gt;
&amp;gt; &amp;gt;time have only positive numbers.  That is a &lt;br&gt;
contradiction in terms.  The "bell &lt;br&gt;
&amp;gt; &amp;gt;shape" extends all the way to minus and plus infinity.&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt;Roger Stafford&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Roger's advice is correct of course.&lt;br&gt;
&amp;gt; Having said that, you can insure that a *sample*is &lt;br&gt;
entirely positive.&lt;br&gt;
&amp;gt; For example:&lt;br&gt;
&amp;gt; x = s*randn(1,100)+m;&lt;br&gt;
&amp;gt; if min(x)&amp;lt;0&lt;br&gt;
&amp;gt;  x = x + abs(min(x));&lt;br&gt;
&amp;gt; end&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; -Dick Startz&lt;br&gt;
&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Tue, 18 Mar 2008 19:46:06 -0400</pubDate>
      <title>Re: random number generation</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/165921#421581</link>
      <author>richardstartz@comcast.net</author>
      <description>On Tue, 18 Mar 2008 19:42:01 +0000 (UTC), "Roger Stafford"&lt;br&gt;
&amp;lt;ellieandrogerxyzzy@mindspring.com.invalid&amp;gt; wrote:&lt;br&gt;
&lt;br&gt;
&amp;gt;"AMMAL " &amp;lt;alanazi@ualberta.ca&amp;gt; wrote in message &amp;lt;frp525$8i&lt;br&gt;
&amp;gt;$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt;&amp;gt; Hellow everybody,&lt;br&gt;
&amp;gt;&amp;gt; &lt;br&gt;
&amp;gt;&amp;gt; I need a hand on how to generate a 100 positive numbers &lt;br&gt;
&amp;gt;&amp;gt; that follow a normal distribution curve (Bell Shape).In &lt;br&gt;
&amp;gt;&amp;gt; otherwords, if i histogram the data, a bell shape will be &lt;br&gt;
&amp;gt;&amp;gt; generated. i am not transforming my data, instead, i want &lt;br&gt;
&amp;gt;&amp;gt; to generate a posirtive one hundred values that will follow &lt;br&gt;
&amp;gt;&amp;gt; a bell shape.&lt;br&gt;
&amp;gt;&amp;gt; &lt;br&gt;
&amp;gt;&amp;gt; Thanks,&lt;br&gt;
&amp;gt;&amp;gt; Ammal&lt;br&gt;
&amp;gt;------&lt;br&gt;
&amp;gt;  You can use "s*randn(1,100)+m" to generate a hundred normal distribution &lt;br&gt;
&amp;gt;numbers with mean m and standard deviation s, but you cannot be sure all of &lt;br&gt;
&amp;gt;them will be positive.  You cannot have a normal distribution and at the same &lt;br&gt;
&amp;gt;time have only positive numbers.  That is a contradiction in terms.  The "bell &lt;br&gt;
&amp;gt;shape" extends all the way to minus and plus infinity.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt;Roger Stafford&lt;br&gt;
&lt;br&gt;
Roger's advice is correct of course.&lt;br&gt;
Having said that, you can insure that a *sample*is entirely positive.&lt;br&gt;
For example:&lt;br&gt;
x = s*randn(1,100)+m;&lt;br&gt;
if min(x)&amp;lt;0&lt;br&gt;
&amp;nbsp;x = x + abs(min(x));&lt;br&gt;
end&lt;br&gt;
&lt;br&gt;
-Dick Startz&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Tue, 18 Mar 2008 19:42:01 -0400</pubDate>
      <title>Re: random number generation</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/165921#421579</link>
      <author>Roger Stafford</author>
      <description>"AMMAL " &amp;lt;alanazi@ualberta.ca&amp;gt; wrote in message &amp;lt;frp525$8i&lt;br&gt;
$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Hellow everybody,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I need a hand on how to generate a 100 positive numbers &lt;br&gt;
&amp;gt; that follow a normal distribution curve (Bell Shape).In &lt;br&gt;
&amp;gt; otherwords, if i histogram the data, a bell shape will be &lt;br&gt;
&amp;gt; generated. i am not transforming my data, instead, i want &lt;br&gt;
&amp;gt; to generate a posirtive one hundred values that will follow &lt;br&gt;
&amp;gt; a bell shape.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks,&lt;br&gt;
&amp;gt; Ammal&lt;br&gt;
------&lt;br&gt;
&amp;nbsp;&amp;nbsp;You can use "s*randn(1,100)+m" to generate a hundred normal distribution &lt;br&gt;
numbers with mean m and standard deviation s, but you cannot be sure all of &lt;br&gt;
them will be positive.  You cannot have a normal distribution and at the same &lt;br&gt;
time have only positive numbers.  That is a contradiction in terms.  The "bell &lt;br&gt;
shape" extends all the way to minus and plus infinity.&lt;br&gt;
&lt;br&gt;
Roger Stafford&lt;br&gt;
&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Tue, 18 Mar 2008 19:34:08 -0400</pubDate>
      <title>Re: random number generation</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/165921#421578</link>
      <author>Randy Poe</author>
      <description>On Mar 18, 3:27 pm, "AMMAL " &amp;lt;alan...@ualberta.ca&amp;gt; wrote:&lt;br&gt;
&amp;gt; Hellow everybody,&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; I need a hand on how to generate a 100 positive numbers&lt;br&gt;
&amp;gt; that follow a normal distribution curve (Bell Shape).In&lt;br&gt;
&amp;gt; otherwords, if i histogram the data, a bell shape will be&lt;br&gt;
&amp;gt; generated. i am not transforming my data, instead, i want&lt;br&gt;
&amp;gt; to generate a posirtive one hundred values that will follow&lt;br&gt;
&amp;gt; a bell shape.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Thanks,&lt;br&gt;
&amp;gt; Ammal&lt;br&gt;
&lt;br&gt;
The function RANDN will generate samples from a&lt;br&gt;
standard normal distribution. Note that if you histogram&lt;br&gt;
the results, you won't get a perfect bell shape since samples,&lt;br&gt;
being random, have a little variation in them. The mean&lt;br&gt;
of your samples won't be exactly 0, but something close.&lt;br&gt;
The variance won't be exactly 1, but something close.&lt;br&gt;
&lt;br&gt;
That's the nature of random variables and samples.&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;- Randy&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Tue, 18 Mar 2008 19:27:01 -0400</pubDate>
      <title>random number generation</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/165921#421576</link>
      <author>ammal</author>
      <description>Hellow everybody,&lt;br&gt;
&lt;br&gt;
I need a hand on how to generate a 100 positive numbers &lt;br&gt;
that follow a normal distribution curve (Bell Shape).In &lt;br&gt;
otherwords, if i histogram the data, a bell shape will be &lt;br&gt;
generated. i am not transforming my data, instead, i want &lt;br&gt;
to generate a posirtive one hundred values that will follow &lt;br&gt;
a bell shape.&lt;br&gt;
&lt;br&gt;
Thanks,&lt;br&gt;
Ammal&lt;br&gt;
</description>
    </item>
  </channel>
</rss>
