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:
random number from beta distribution

Subject: random number from beta distribution

From: taffi

Date: 26 Jun, 2013 17:17:17

Message: 1 of 6

Hi

I need a random number from beta distribution. I have a following data.
max, min , mean and standard deviation. Can any one guide me how to do it.

Subject: random number from beta distribution

From: dpb

Date: 26 Jun, 2013 18:52:22

Message: 2 of 6

On 6/26/2013 12:17 PM, taffi wrote:
> Hi
> I need a random number from beta distribution. I have a following data.
> max, min , mean and standard deviation. Can any one guide me how to do it.

Roger Stafford gave you the technique...

You can generate a generalized beta between arbitrary limits by the
transform of x' = (x-L)/(U-L) and dividing by the range U-L.

You can then try to solve from the expressions for the mean and variance
to find a set of parameters that fulfills the other constraints but
there's no guarantee can do so within the feasibility range of >0.

--

Subject: random number from beta distribution

From: dpb

Date: 26 Jun, 2013 19:14:43

Message: 3 of 6

On 6/26/2013 1:52 PM, dpb wrote:
> On 6/26/2013 12:17 PM, taffi wrote:
>> Hi
>> I need a random number from beta distribution. I have a following data.
>> max, min , mean and standard deviation. Can any one guide me how to do
>> it.
>
> Roger Stafford gave you the technique...
>
> You can generate a generalized beta between arbitrary limits by the
> transform of x' = (x-L)/(U-L) and dividing by the range U-L.
>
> You can then try to solve from the expressions for the mean and variance
> to find a set of parameters that fulfills the other constraints but
> there's no guarantee can do so within the feasibility range of >0.

OBTW,

u (mean) = L + (U-L)*mean(beta)

and

var = (U-L)^2 * var(beta)

where mean()/var() are mean/variance of the beta distribution of the
same shape parameters w/o the bounds. I'm not going to try to write
them in text...

--

Subject: random number from beta distribution

From: taffi

Date: 27 Jun, 2013 08:40:16

Message: 4 of 6

dpb <none@non.net> wrote in message <kqfeiv$el3$1@speranza.aioe.org>...
> On 6/26/2013 1:52 PM, dpb wrote:
> > On 6/26/2013 12:17 PM, taffi wrote:
> >> Hi
> >> I need a random number from beta distribution. I have a following data.
> >> max, min , mean and standard deviation. Can any one guide me how to do
> >> it.
> >
> > Roger Stafford gave you the technique...
> >
> > You can generate a generalized beta between arbitrary limits by the
> > transform of x' = (x-L)/(U-L) and dividing by the range U-L.
> >
> > You can then try to solve from the expressions for the mean and variance
> > to find a set of parameters that fulfills the other constraints but
> > there's no guarantee can do so within the feasibility range of >0.
>
> OBTW,
>
> u (mean) = L + (U-L)*mean(beta)
>
> and
>
> var = (U-L)^2 * var(beta)
>
> where mean()/var() are mean/variance of the beta distribution of the
> same shape parameters w/o the bounds. I'm not going to try to write
> them in text...
>
> --


Thank you for your reply but still I m not clear. Look we can use 'beatrnd' to get a random number of beta distribution between (0,1). but I had to change the limits between my max. and min. around my mean value. so I used the following

x=a+(b-a)*betarnd((m-a)/(b-a),(b-m)/(b-a),100,1);

a=min, b=max., and m=mean

But I need it to follow my standard deviation without changing my mean. and I am un able to do so. :(

Subject: random number from beta distribution

From: taffi

Date: 27 Jun, 2013 09:16:06

Message: 5 of 6

"taffi" wrote in message <kqgtpg$ejv$1@newscl01ah.mathworks.com>...
> dpb <none@non.net> wrote in message <kqfeiv$el3$1@speranza.aioe.org>...
> > On 6/26/2013 1:52 PM, dpb wrote:
> > > On 6/26/2013 12:17 PM, taffi wrote:
> > >> Hi
> > >> I need a random number from beta distribution. I have a following data.
> > >> max, min , mean and standard deviation. Can any one guide me how to do
> > >> it.
> > >
> > > Roger Stafford gave you the technique...
> > >
> > > You can generate a generalized beta between arbitrary limits by the
> > > transform of x' = (x-L)/(U-L) and dividing by the range U-L.
> > >
> > > You can then try to solve from the expressions for the mean and variance
> > > to find a set of parameters that fulfills the other constraints but
> > > there's no guarantee can do so within the feasibility range of >0.
> >
> > OBTW,
> >
> > u (mean) = L + (U-L)*mean(beta)
> >
> > and
> >
> > var = (U-L)^2 * var(beta)
> >
> > where mean()/var() are mean/variance of the beta distribution of the
> > same shape parameters w/o the bounds. I'm not going to try to write
> > them in text...
> >
> > --
>
>
> Thank you for your reply but still I m not clear. Look we can use 'beatrnd' to get a random number of beta distribution between (0,1). but I had to change the limits between my max. and min. around my mean value. so I used the following
>
> x=a+(b-a)*betarnd((m-a)/(b-a),(b-m)/(b-a),100,1);
>
> a=min, b=max., and m=mean
>
> But I need it to follow my standard deviation without changing my mean. and I am un able to do so. :(


and If I do it like...I get parameter of beta distribution (alpha,beta) using

alpha=((m-a)/(b-a)*((((m-a)*(b-m))/std^2)-1));
beta=((m-a)/(b-a)*((((m-a)*(b-m))/std^2)-1));

and then x=m+std*betarnd(alpha,beta,100,1)

Will it give me the required beta random variables....really confused

Subject: random number from beta distribution

From: dpb

Date: 27 Jun, 2013 11:19:27

Message: 6 of 6

On 6/27/2013 4:16 AM, taffi wrote:
> "taffi" wrote in message <kqgtpg$ejv$1@newscl01ah.mathworks.com>...
>> dpb <none@non.net> wrote in message <kqfeiv$el3$1@speranza.aioe.org>...
>> > On 6/26/2013 1:52 PM, dpb wrote:
>> > > On 6/26/2013 12:17 PM, taffi wrote:
>> > >> Hi
>> > >> I need a random number from beta distribution. I have a following
>> data.
>> > >> max, min , mean and standard deviation. Can any one guide me how
>> to do
>> > >> it.
>> > >
>> > > Roger Stafford gave you the technique...
>> > >
>> > > You can generate a generalized beta between arbitrary limits by the
>> > > transform of x' = (x-L)/(U-L) and dividing by the range U-L.
>> > >
>> > > You can then try to solve from the expressions for the mean and
>> variance
>> > > to find a set of parameters that fulfills the other constraints but
>> > > there's no guarantee can do so within the feasibility range of >0.
>> > > OBTW,
>> > > u (mean) = L + (U-L)*mean(beta)
>> > > and
>> > > var = (U-L)^2 * var(beta)
>> > > where mean()/var() are mean/variance of the beta distribution of
>> the > same shape parameters w/o the bounds. I'm not going to try to
>> write > them in text...
>> > > --
>>
>>
>> Thank you for your reply but still I m not clear. Look we can use
>> 'beatrnd' to get a random number of beta distribution between (0,1).
>> but I had to change the limits between my max. and min. around my mean
>> value. so I used the following
>>
>> x=a+(b-a)*betarnd((m-a)/(b-a),(b-m)/(b-a),100,1);
>>
>> a=min, b=max., and m=mean
>>
>> But I need it to follow my standard deviation without changing my
>> mean. and I am un able to do so. :(
>
>
> and If I do it like...I get parameter of beta distribution (alpha,beta)
> using
>
> alpha=((m-a)/(b-a)*((((m-a)*(b-m))/std^2)-1));
> beta=((m-a)/(b-a)*((((m-a)*(b-m))/std^2)-1));
>
> and then x=m+std*betarnd(alpha,beta,100,1)
>
> Will it give me the required beta random variables....really confused

_IFF_ (the proverbial "Big If" combined w/ "only if") you can solve for
alpha and beta in the feasible region (>0) will you be able to generate
a sample of prn's of the generalized beta that fulfill all the desired
constraints.

That that is possible is certainly not a foregone conclusion depending
on the values you choose.

--

Tags for this Thread

No tags are associated with 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