Got Questions? Get Answers.
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:
generate random number for certain distribution

Subject: generate random number for certain distribution

From: edward kabanyas

Date: 27 May, 2008 17:16:02

Message: 1 of 10

Hi,

As we know that Matlab can generate random number with
several command. I need to generate random value for the
following gamma distribution:

f(D)=No*D^m*exp(-L*D);

No, m and L will be assumed. I need to generate randomly
distributed D in size of 0<D<10 that follows the above
distribution.

Do you have idea to do it in matlab?

Thanks for your help

Cheers
jq

Subject: generate random number for certain distribution

From: Peter Perkins

Date: 27 May, 2008 17:47:27

Message: 2 of 10

edward kabanyas wrote:

> As we know that Matlab can generate random number with
> several command. I need to generate random value for the
> following gamma distribution:

jq, If you have access to the Statistics Toolbox, use the GAMRND function. If
not, you may be able to find something on the MATLAB File Exchange
<http://www.mathworks.com/matlabcentral/fileexchange/loadCategory.do>

Hope this helps.

- Peter Perkins
   The MathWorks, Inc.

Subject: generate random number for certain distribution

From: edward kabanyas

Date: 28 May, 2008 05:35:02

Message: 3 of 10

Dear Peter;

Thanks for your reply.

> jq, If you have access to the Statistics Toolbox, use the
GAMRND function.

As you know, that gamrnd(A,B,m,n) generates gamma random
numbers with parameters A and B. In my case, the gamma
equation is as I sent before, contain 3 parameters (modified
gamma).


>If not, you may be able to find something on the MATLAB
>File Exchange
<http://www.mathworks.com/matlabcentral/fileexchange/loadCategory.do>

I try to visit the web, but I could not find the random
number generator there. It is too many. Could you show me one ?

Again, thanks for nice help

Cheers
juq

Subject: generate random number for certain distribution

From: Peter Perkins

Date: 28 May, 2008 13:38:07

Message: 4 of 10

edward kabanyas wrote:

> As we know that Matlab can generate random number with
> several command. I need to generate random value for the
> following gamma distribution:
>
> f(D)=No*D^m*exp(-L*D);


> As you know, that gamrnd(A,B,m,n) generates gamma random
> numbers with parameters A and B. In my case, the gamma
> equation is as I sent before, contain 3 parameters (modified
> gamma).

juq, if No in your expression is anything other than L^(m+1) / gamma(m+1),
you're going to have a hard time getting that "density" to integrate to 1. Your
density may be written with three parameters, but only two of them are independent.

Are you sure you're fitting a distribution, and not fitting a curve that just
happens to have the same shape as a gamma density?

Subject: generate random number for certain distribution

From: edward kabanyas

Date: 28 May, 2008 16:56:03

Message: 5 of 10

Dear Peter Perkins

Thanks very much for your reply.

> juq, if No in your expression is anything other than
>L^(m+1) > gamma(m+1),you're going to have a hard time
>getting that >"density" to integrate to 1.
> f(D)=No*D^m*exp(-L*D);

Actually, I do not have good knowledge in statistics.
However, the mentioned modified gamma distribution is
commonly used in meteorology to model raindrop or cloud drop
distribution. No is intercept, L is slope and m is shape
parameter. No is the same as the concept of No in the
following exponential distribution:

f(D) = No*exp(-L*D);

I try to find the theoretical background of the above
modified gammma distribution, but I can not find it. But I
am sure that the above modified gamma is gamma(m+1,L). If
so, is it No for gamma(m+1,L) is L^(m+1)/gamma(m+1)?

If No for the above modified gamma is L^(m+1)/gamma(m+1),
could we get the random value of D in interval of 0 <D< 10?

Again, thanks for your nice help. I really appreciate it.

Best regards;
Marzuki
 

> f(D)=No*D^m*exp(-L*D);
> density may be written with three parameters, but only two
of them are independent.
>
> Are you sure you're fitting a distribution, and not
fitting a curve that just
> happens to have the same shape as a gamma density?

Subject: generate random number for certain distribution

From: Peter Perkins

Date: 29 May, 2008 14:02:01

Message: 6 of 10

edward kabanyas wrote:

> However, the mentioned modified gamma distribution is
> commonly used in meteorology to model raindrop or cloud drop
> distribution. No is intercept, L is slope and m is shape
> parameter. No is the same as the concept of No in the
> following exponential distribution:
>
> f(D) = No*exp(-L*D);

But again, that's not an exponential density, or a density at all, unless No is
equal to L. A density must integrate to 1.

The above, and this:

> If No for the above modified gamma is L^(m+1)/gamma(m+1),
> could we get the random value of D in interval of 0 <D< 10?

sound suspiciously like you are trying to fit a curve, not a probability
distribution. This demo
<http://www.mathworks.com/products/statistics/demos.html?file=/products/demos/shipping/stats/cfitdfitdemo.html>
might help clear things up.

Subject: generate random number for certain distribution

From: edward kabanyas

Date: 29 May, 2008 14:44:03

Message: 7 of 10

Dear Peter Perkins;

Again, thanks very much for your nice discussion.

I m sorry to make mistake in informing you.

> sound suspiciously like you are trying to fit a curve, not
>a probability distribution.

Yes, you are correct. After I check some literatures, the
following modified gamma distribution f(D) =
No*D^m*exp(-L*D) is not probability gamma distribution but
frequency distribution and the parameters No, m and L is
derived from such fitting procedure.

If I select certain value for No, m and L, could we get the
random value of D in interval of 0 <D< 10 that follows the
above frequency distribution? Or can not we get random value
from frequency distribution ?

Again, thanks very much for nice help.

Best regards;
Juq


 


 <Peter.PerkinsRemoveThis@mathworks.com> wrote in message
<g1md0p$mkc$1@fred.mathworks.com>...
> edward kabanyas wrote:
>
> > However, the mentioned modified gamma distribution is
> > commonly used in meteorology to model raindrop or cloud drop
> > distribution. No is intercept, L is slope and m is shape
> > parameter. No is the same as the concept of No in the
> > following exponential distribution:
> >
> > f(D) = No*exp(-L*D);
>
> But again, that's not an exponential density, or a density
at all, unless No is
> equal to L. A density must integrate to 1.
>
> The above, and this:
>
> > If No for the above modified gamma is L^(m+1)/gamma(m+1),
> > could we get the random value of D in interval of 0 <D< 10?
>
> sound suspiciously like you are trying to fit a curve, not
a probability
> distribution. This demo
>
<http://www.mathworks.com/products/statistics/demos.html?file=/products/demos/shipping/stats/cfitdfitdemo.html>

> might help clear things up.

Subject: generate random number for certain distribution

From: Peter Perkins

Date: 29 May, 2008 18:05:47

Message: 8 of 10

edward kabanyas wrote:

> Yes, you are correct. After I check some literatures, the
> following modified gamma distribution f(D) =
> No*D^m*exp(-L*D) is not probability gamma distribution but
> frequency distribution and the parameters No, m and L is
> derived from such fitting procedure.

A "frequency distribution" to me would mean "a probability distribution times a
sample size", and it seems like you'd want No to be the sample size, and
therefore your expression is _still_ missing the appropriate normalizing
constant to make it integrate to 1*No.

Did you look at the demo link?


> If I select certain value for No, m and L, could we get the
> random value of D in interval of 0 <D< 10 that follows the
> above frequency distribution? Or can not we get random value
> from frequency distribution ?

I still don't know what that means. If D has a gamma distribution, it is not
limited to any finite range. It seems like you ought to consult with someone in
your field who has more of a background in statistics.

Subject: generate random number for certain distribution

From: edward kabanyas

Date: 1 Jun, 2008 15:24:01

Message: 9 of 10

Dear Peter;

Thanks very much for your nice help:

>I still don't know what that means.

As I explained before, my modified gamma distribution
(frequency distribution)is

f(D)=No*D^m*exp(-L*D). (1)

Probability is frequency/N (number of data).

I think we can change the above (Eq. 1) to yield the density
distribution:

p(D)= (No*D^m*exp(-L*D))/N;

how do you think ? Can we get random number from Eq. 1 if we
know No, m, L and N?

Again, thanks very much.

Best regards;






Peter Perkins <Peter.PerkinsRemoveThis@mathworks.com> wrote
in message <g1mr9s$954$1@fred.mathworks.com>...
> edward kabanyas wrote:
>
> > Yes, you are correct. After I check some literatures, the
> > following modified gamma distribution f(D) =
> > No*D^m*exp(-L*D) is not probability gamma distribution but
> > frequency distribution and the parameters No, m and L is
> > derived from such fitting procedure.
>
> A "frequency distribution" to me would mean "a probability
distribution times a
> sample size", and it seems like you'd want No to be the
sample size, and
> therefore your expression is _still_ missing the
appropriate normalizing
> constant to make it integrate to 1*No.
>
> Did you look at the demo link?
>
>
> > If I select certain value for No, m and L, could we get the
> > random value of D in interval of 0 <D< 10 that follows the
> > above frequency distribution? Or can not we get random value
> > from frequency distribution ?
>
> I still don't know what that means. If D has a gamma
distribution, it is not
> limited to any finite range. It seems like you ought to
consult with someone in
> your field who has more of a background in statistics.

Subject: generate random number for certain distribution

From: Peter Perkins

Date: 2 Jun, 2008 13:43:32

Message: 10 of 10

edward kabanyas wrote:
> Dear Peter;
>
> Thanks very much for your nice help:
>
>> I still don't know what that means.
>
> As I explained before, my modified gamma distribution
> (frequency distribution)is
>
> f(D)=No*D^m*exp(-L*D). (1)
>
> Probability is frequency/N (number of data).
>
> I think we can change the above (Eq. 1) to yield the density
> distribution:
>
> p(D)= (No*D^m*exp(-L*D))/N;
>
> how do you think ? Can we get random number from Eq. 1 if we
> know No, m, L and N?

You started out with one too many parameters; now you have two too many. I
can't answer your questions. I recommend that you consult with someone in your
field who has more of a statistical background.

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