Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
scaling t-distributions

Subject: scaling t-distributions

From: Firat

Date: 7 Apr, 2010 23:55:25

Message: 1 of 7

Hi all,
I have 4 sets of 50 values. I want to generate, let's say 1000 random numbers, based on this data set , I know that these 4 sets are correlated with each other and I want it to be distributed with t-distribution. I can use mvtrnd function
r = mvtrnd(co,50,1000)

but that gives me mean of zero. Is there any way to add a mean for this function so that I can get my random numbers based on t-distribution, but around my data mean instead of zero ? or is there any method like scaling, or translation to do that ?

Hope it is clear,
Firat

Subject: scaling t-distributions

From: Peter Perkins

Date: 8 Apr, 2010 00:37:42

Message: 2 of 7

On 4/7/2010 7:55 PM, Firat wrote:

> Is there any way to add a mean for this
> function so that I can get my random numbers based on t-distribution,
> but around my data mean instead of zero ? or is there any method like
> scaling, or translation to do that ?

Firat, MVTRND won't do that, but it's easy to do:

mu = [row vector of component-wise means];
sigma = [row vector of component-wise scale factors];
t = bsxfun(@sum,mu,bsxfun(@times,sigma,mvtrnd(C,df,n)));

That probably looks a bit cryptic; you could also do this

mu = repmat([row vector of component-wise means],n,1);
sigma = repmat([row vector of component-wise scale factors],n,1);
t = mu + sigma.*mvtrnd(C,df,n);

Hope this helps.

Subject: scaling t-distributions

From: Firat

Date: 8 Apr, 2010 01:30:08

Message: 3 of 7

Thank you so much Peter. It worked.
At first it gave an error

??? Error using ==> bsxfun
Unsupported builtin function.

Error in ==> tdist at 8
t = bsxfun(@sum,mu,bsxfun(@times,sigma,mvtrnd(C,df,n)));

I assumed it was due to "sum" and changed it to "plus" and now it works. Thank you so much again!

Firat

Peter Perkins <Peter.Perkins@MathRemoveThisWorks.com> wrote in message <hpj8gm$mul$1@fred.mathworks.com>...
> On 4/7/2010 7:55 PM, Firat wrote:
>
> > Is there any way to add a mean for this
> > function so that I can get my random numbers based on t-distribution,
> > but around my data mean instead of zero ? or is there any method like
> > scaling, or translation to do that ?
>
> Firat, MVTRND won't do that, but it's easy to do:
>
> mu = [row vector of component-wise means];
> sigma = [row vector of component-wise scale factors];
> t = bsxfun(@sum,mu,bsxfun(@times,sigma,mvtrnd(C,df,n)));
>
> That probably looks a bit cryptic; you could also do this
>
> mu = repmat([row vector of component-wise means],n,1);
> sigma = repmat([row vector of component-wise scale factors],n,1);
> t = mu + sigma.*mvtrnd(C,df,n);
>
> Hope this helps.

Subject: scaling t-distributions

From: Peter Perkins

Date: 8 Apr, 2010 14:33:13

Message: 4 of 7

On 4/7/2010 9:30 PM, Firat wrote:
> Thank you so much Peter. It worked. At first it gave an error
>
> ??? Error using ==> bsxfun
> Unsupported builtin function.
>
> Error in ==> tdist at 8
> t = bsxfun(@sum,mu,bsxfun(@times,sigma,mvtrnd(C,df,n)));
>
> I assumed it was due to "sum" and changed it to "plus" and now it works.
> Thank you so much again!

Yes, thank you, I always get that wrong and I didn't run this code.

Subject: scaling t-distributions

From: Pinar

Date: 6 Mar, 2012 21:49:24

Message: 5 of 7

Dear Mr. Perkins,

I would like to ask a question to clarify one point as it seems that I may be misinterpreting what you and the Matlab help menu have written regarding the scaling. And due to this I have been getting weird results from my program and I am almost sure that the problem has to do with the mvtrnd function in the program.

If we want to draw from the multivariate t distribution with mean mu and variance sigma, you suggest the following:

mu = repmat([row vector of component-wise means],n,1);
sigma = repmat([row vector of component-wise scale factors],n,1);
t = mu + sigma.*mvtrnd(C,df,n);

Above, we multiply our draw from the multivariate distribution that we get using mvtrnd(C,df,n) with sigma because the variance we want in this case is sigma^2. What I do not understand is the following:

Aren't we already incorporating the variance (here, sigma^2) by using C in the mvtrnd function? So, when we multiply it with also sigma, isn't is like double counting? Or what you meant was indeed that C is an identity matrix (so that once we multiply mvtrnd(C,df,n) with sigma, we get draws from multivariate distribution with variance sigma^2)? Or, in short, doesn't mvtrnd(C,df,n) produce draws from multivariate t distribution with mean zero and variance C??

Thank you very much.

I would be appreciated if you could help me.

Kind regards

Pinar


Peter Perkins <Peter.Perkins@MathRemoveThisWorks.com> wrote in message <hpj8gm$mul$1@fred.mathworks.com>...
> On 4/7/2010 7:55 PM, Firat wrote:
>
> > Is there any way to add a mean for this
> > function so that I can get my random numbers based on t-distribution,
> > but around my data mean instead of zero ? or is there any method like
> > scaling, or translation to do that ?
>
> Firat, MVTRND won't do that, but it's easy to do:
>
> mu = [row vector of component-wise means];
> sigma = [row vector of component-wise scale factors];
> t = bsxfun(@sum,mu,bsxfun(@times,sigma,mvtrnd(C,df,n)));
>
> That probably looks a bit cryptic; you could also do this
>
> mu = repmat([row vector of component-wise means],n,1);
> sigma = repmat([row vector of component-wise scale factors],n,1);
> t = mu + sigma.*mvtrnd(C,df,n);
>
> Hope this helps.

Subject: scaling t-distributions

From: Peter Perkins

Date: 7 Mar, 2012 15:54:04

Message: 6 of 7

 >> help mvtrnd
  mvtrnd Random matrices from the multivariate t distribution.
     R = mvtrnd(C,DF,N) returns an N-by-D matrix R of random numbers from
     the multivariate t distribution with correlation parameters C and
     degrees of freedom DF.

     C is a symmetric, positive semi-definite, D-by-D correlation matrix.

     Note: mvtrnd computes random vectors from the standard multivariate
     Student's t, centered at the origin, with no scale parameters. If
     C is a covariance matrix, i.e. DIAG(C) is not all ones, mvtrnd
     rescales C to transform it to a correlation matrix.


On 3/6/2012 4:49 PM, Pinar wrote:
> Dear Mr. Perkins,
>
> I would like to ask a question to clarify one point as it seems that I
> may be misinterpreting what you and the Matlab help menu have written
> regarding the scaling. And due to this I have been getting weird results
> from my program and I am almost sure that the problem has to do with the
> mvtrnd function in the program.
>
> If we want to draw from the multivariate t distribution with mean mu and
> variance sigma, you suggest the following:
>
> mu = repmat([row vector of component-wise means],n,1);
> sigma = repmat([row vector of component-wise scale factors],n,1);
> t = mu + sigma.*mvtrnd(C,df,n);
>
> Above, we multiply our draw from the multivariate distribution that we
> get using mvtrnd(C,df,n) with sigma because the variance we want in this
> case is sigma^2. What I do not understand is the following:
>
> Aren't we already incorporating the variance (here, sigma^2) by using C
> in the mvtrnd function? So, when we multiply it with also sigma, isn't
> is like double counting? Or what you meant was indeed that C is an
> identity matrix (so that once we multiply mvtrnd(C,df,n) with sigma, we
> get draws from multivariate distribution with variance sigma^2)? Or, in
> short, doesn't mvtrnd(C,df,n) produce draws from multivariate t
> distribution with mean zero and variance C??
>
> Thank you very much.
>
> I would be appreciated if you could help me.
>
> Kind regards
>
> Pinar
>
>
> Peter Perkins <Peter.Perkins@MathRemoveThisWorks.com> wrote in message
> <hpj8gm$mul$1@fred.mathworks.com>...
>> On 4/7/2010 7:55 PM, Firat wrote:
>>
>> > Is there any way to add a mean for this
>> > function so that I can get my random numbers based on t-distribution,
>> > but around my data mean instead of zero ? or is there any method like
>> > scaling, or translation to do that ?
>>
>> Firat, MVTRND won't do that, but it's easy to do:
>>
>> mu = [row vector of component-wise means];
>> sigma = [row vector of component-wise scale factors];
>> t = bsxfun(@sum,mu,bsxfun(@times,sigma,mvtrnd(C,df,n)));
>>
>> That probably looks a bit cryptic; you could also do this
>>
>> mu = repmat([row vector of component-wise means],n,1);
>> sigma = repmat([row vector of component-wise scale factors],n,1);
>> t = mu + sigma.*mvtrnd(C,df,n);
>>
>> Hope this helps.

Subject: scaling t-distributions

From: Pinar

Date: 9 Mar, 2012 10:24:11

Message: 7 of 7

Dear Mr. Perkins,

Thank you for the information. Now it is clear and I know that I need to adjust my correlation matrix.

Best regards,

Pinar


Peter Perkins <Peter.Remove.Perkins.This@mathworks.com> wrote in message <jj80as$9e7$1@newscl01ah.mathworks.com>...
> >> help mvtrnd
> mvtrnd Random matrices from the multivariate t distribution.
> R = mvtrnd(C,DF,N) returns an N-by-D matrix R of random numbers from
> the multivariate t distribution with correlation parameters C and
> degrees of freedom DF.
>
> C is a symmetric, positive semi-definite, D-by-D correlation matrix.
>
> Note: mvtrnd computes random vectors from the standard multivariate
> Student's t, centered at the origin, with no scale parameters. If
> C is a covariance matrix, i.e. DIAG(C) is not all ones, mvtrnd
> rescales C to transform it to a correlation matrix.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us