Path: news.mathworks.com!not-for-mail
From: Peter Perkins <Peter.Perkins@MathRemoveThisWorks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: random number generator from t location scale distribution
Date: Thu, 01 Jul 2010 10:38:30 -0400
Organization: The MathWorks, Inc.
Lines: 45
Message-ID: <i0i997$i8c$1@fred.mathworks.com>
References: <i0hjq7$ajh$1@fred.mathworks.com>
NNTP-Posting-Host: perkinsp.dhcp.mathworks.com
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: fred.mathworks.com 1277995111 18700 172.31.57.40 (1 Jul 2010 14:38:31 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 1 Jul 2010 14:38:31 +0000 (UTC)
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.10) Gecko/20100512 Thunderbird/3.0.5
In-Reply-To: <i0hjq7$ajh$1@fred.mathworks.com>
Xref: news.mathworks.com comp.soft-sys.matlab:649632

On 7/1/2010 4:32 AM, ArA Arns wrote:
> Hi,
> I'm trying to create a random number generator from the t location scale
> distribution.

Roger's suggestion is straight-forward.  But since you have the 
Statistics Toolbox, here's another way:

You already used the MLE function to fit a t location scale 
distribution.  It turns out that you can also use the FITDIST function 
to do that, and return an object that the fitted t location scale 
distribution.  One of the things you can do with that is generate random 
values from the fitted distribution:

 >> t = trnd(5,100,1);
 >> dist = fitdist(t,'tlocationscale')
dist =
tlocationscale distribution
     mu = -0.0570683
     sigma = 1.07074
     nu = 3.64601
 >> random(dist,5,1)
ans =
      -0.99189
      -0.94726
      -0.46287
       -1.9822
       0.75744

Sometimes, you know the parameters you want to use, and don't want to 
fit to data.  You can do that too:

 >> dist = ProbDistUnivParam('tlocationscale',[2,3,4])
dist =
tlocationscale distribution
     mu = 2
     sigma = 3
     nu = 4
 >> random(dist,5,1)
ans =
      -0.49685
        4.8959
        4.6588
        1.6293
       -1.9462