<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/174396</link>
    <title>MATLAB Central Newsreader - help with generating skewed distribution?</title>
    <description>Feed for thread: help with generating skewed distribution?</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by 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>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Fri, 15 Aug 2008 15:09:02 -0400</pubDate>
      <title>help with generating skewed distribution?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/174396#449328</link>
      <author>Anna Chen</author>
      <description>Hello,&lt;br&gt;
I would like to generate a population of numbers, from 1-&lt;br&gt;
100 for example, distributed almost uniformly.  However, I &lt;br&gt;
want the larger numbers to have more chance of popping up, &lt;br&gt;
so the population skews to the left.  &lt;br&gt;
how would i be able to do this with matlab 2008?  i had &lt;br&gt;
thought of using randsrc, but for some reason it's not in &lt;br&gt;
my version?  i have the statistics toolbox, if that helps.&lt;br&gt;
thanks!</description>
    </item>
    <item>
      <pubDate>Fri, 15 Aug 2008 15:32:03 -0400</pubDate>
      <title>Re: help with generating skewed distribution?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/174396#449332</link>
      <author>Donn Shull</author>
      <description>&quot;Anna Chen&quot; &amp;lt;icedredtea@yahoo.com&amp;gt; wrote in message &lt;br&gt;
&amp;lt;g8466e$amb$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Hello,&lt;br&gt;
&amp;gt; I would like to generate a population of numbers, from 1-&lt;br&gt;
&amp;gt; 100 for example, distributed almost uniformly.  However, &lt;br&gt;
I &lt;br&gt;
&amp;gt; want the larger numbers to have more chance of popping &lt;br&gt;
up, &lt;br&gt;
&amp;gt; so the population skews to the left.  &lt;br&gt;
&amp;gt; how would i be able to do this with matlab 2008?  i had &lt;br&gt;
&amp;gt; thought of using randsrc, but for some reason it's not in &lt;br&gt;
&amp;gt; my version?  i have the statistics toolbox, if that helps.&lt;br&gt;
&amp;gt; thanks!&lt;br&gt;
&lt;br&gt;
randsrc is part of the Communications Toolbox.</description>
    </item>
    <item>
      <pubDate>Wed, 20 Aug 2008 12:05:02 -0400</pubDate>
      <title>Re: help with generating skewed distribution?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/174396#596514</link>
      <author>Bruno Eklund</author>
      <description>&quot;Anna Chen&quot; &amp;lt;icedredtea@yahoo.com&amp;gt; wrote in message &lt;br&gt;
&amp;lt;g8466e$amb$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Hello,&lt;br&gt;
&amp;gt; I would like to generate a population of numbers, from 1-&lt;br&gt;
&amp;gt; 100 for example, distributed almost uniformly.  However, &lt;br&gt;
I &lt;br&gt;
&amp;gt; want the larger numbers to have more chance of popping &lt;br&gt;
up, &lt;br&gt;
&amp;gt; so the population skews to the left.  &lt;br&gt;
&amp;gt; how would i be able to do this with matlab 2008?  i had &lt;br&gt;
&amp;gt; thought of using randsrc, but for some reason it's not &lt;br&gt;
in &lt;br&gt;
&amp;gt; my version?  i have the statistics toolbox, if that &lt;br&gt;
helps.&lt;br&gt;
&amp;gt; thanks!&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Hi Anna,&lt;br&gt;
this is how you can do it. It's actually a general way of &lt;br&gt;
drawing random numbers from any distribution. Start by &lt;br&gt;
defining what kind of distribution you want. You said you &lt;br&gt;
used a uniform distribution, p(x) = 1/100 for x=1,...,100. &lt;br&gt;
Let's assume you instead want to use, for example, a &lt;br&gt;
triangular distribution, p(x) = constant * x for &lt;br&gt;
x=1,...,100. Of course, you need to set the constant such &lt;br&gt;
that the function sum to one, that is p(1)+...+p(100)=1. &lt;br&gt;
In this case the constant is 1/5050, so p(1) = 1/5050 and p&lt;br&gt;
(100) = 100/5050. Next step is to construct the cumulative &lt;br&gt;
distribution, which in fact would correspond to stacking &lt;br&gt;
the 100 probability bars on top of each other.&lt;br&gt;
Now draw a uniform random number between zero and one. &lt;br&gt;
Compare this number with your cumulative distribution and &lt;br&gt;
make a note within which probability bar the drawn random &lt;br&gt;
number lies. The x value corresponding to that probability &lt;br&gt;
bar would then be a draw from your desired triangular &lt;br&gt;
distribution. For example assume that, to make it more &lt;br&gt;
easy for me, you drew the number 0.9851 from the uniform &lt;br&gt;
distribution. Comparing this number with the cumulative &lt;br&gt;
distribution you'll see that it lies within the last &lt;br&gt;
probability bar, since the last bar is 0.0198 tall. You &lt;br&gt;
can thus conclude that x=100 is a draw from your desired &lt;br&gt;
triangular distribution. Continuing like this you'll note &lt;br&gt;
that, in the long run, the drawn uniform number will &quot;hit&quot; &lt;br&gt;
taller probability bars more often that shorter ones &lt;br&gt;
implying more frequent draws from larger x numbers, just &lt;br&gt;
as you wanted.&lt;br&gt;
Best of luck</description>
    </item>
    <item>
      <pubDate>Wed, 20 Aug 2008 13:44:01 -0400</pubDate>
      <title>Re: help with generating skewed distribution?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/174396#596544</link>
      <author>Peter Perkins</author>
      <description>Anna Chen wrote:&lt;br&gt;
&lt;br&gt;
&amp;gt; I would like to generate a population of numbers, from 1-&lt;br&gt;
&amp;gt; 100 for example, distributed almost uniformly.  However, I &lt;br&gt;
&amp;gt; want the larger numbers to have more chance of popping up, &lt;br&gt;
&amp;gt; so the population skews to the left.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
As long as you mean, &quot;the integers from 1 to 100&quot;, and as long as you're willing to actually specify all 100 probabilities, then RANDSAMPLE is just what you need.  You might take a look at DISTTOOL, and the beta distribution.  While this is a continuous dist'n defined on the unit interval, you can fiddle with the parameters to get roughly the shape you're looking for, a=3, b=1, for example.  Then use BETAPDF to evaluate the beta density on (1:100)/101, normalize those values to sum to 1, and pass that to RANDSAMPLE, something like&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;p = betapdf((1:100)/101,3,1);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;randsample(1:100,n,true,p/sum(p))&lt;br&gt;
&lt;br&gt;
Hope this helps.</description>
    </item>
  </channel>
</rss>

