U-shaped Beta distribution

#1
Hi,
I have a case in which I want to draw a random probability using beta distribution. I receive a value X between 1 and 5, and I want the probability becomes high if the value is very close to 1 or very close to 5. I thought to use beta distribution U-shaped with beta parameters a=b=0.5, as you can see in the following graph.


I got some help to draw it in R, here is the implementation in python:

Python:
import numpy as np
from scipy.stats import beta
import matplotlib.pyplot as plt
x = np.linspace(1,5,1000)
y= 1/4 * beta.pdf((x-1)/4,a=0.5,b=0.5)
plt.ylim(0,1)
plt.plot(x,y)
 

Attachments

Last edited:
#4
Thanks all, I can generate values between 0 and 1.
My issue is how to generate values based on a given value. If the given value is close to 0 or close to 10, the generated probability from beta distribution is high?
 
#5
Sorry, I missed the 10. Try =BETAINV(RAND(),0.5,0.5,0,10) or just use the method you have and multiply the x value by 10.
Or were you wanting to draw the graph? kat
 
#6
Hi, thanks a lot for your help.
I use scipy.stats.beta, so I have for example x = 3.5, how I can put this into the beta distribution, to say generate high probability (closer to one) or generate low (closer to 0) based on x either it's near 0 or 10?

I am not quite sure if BETAINV does the same?
 
#7
I'm not exactly sure what you mean by x = 3.5.
Do you want the height of the pdf graph at x = 3.5?
Do you want the area to the left of x = 3.5?
Do you want a random beta variable somewhere between 0 and 10 and if so, what does x = 3.5 mean?
As I see it, to generate random variables between 0 and 10 from a scaled beta(0.5, 0.5) you put in a random left area (probability) and the random x is returned.
kat
 
#8
Hi,
Basically, I receive a value x between 0 and 10, and I want to generate a beta distribution[01] based on the given value.

if x is closed to 0, then beta generates value close to 1
if x is closed to 10 then beta generates value close to 1

I hope I explained it clear?

Thank you
 

hlsmith

Not a robit
#9
Jumping in to confuse things, so do you have a sample of 10 and 3.5 had the event, probably not? How is data generated? Just tell us about what you are doing?
 
#10
I suspect you might have the problem the wrong way round. The way that generating random numbers usually works is that you receive a number p from 0 to 1. From that you generate a number x (from 0 to 10 in this case.) If p is close to 0 then x is close to 0 and if p is close to 1 then x is close to 10. In addition, if you are generating beta numbers you get lots near 0 and 10, and fewer in the middle. In this case the question might be "if p = 0.35, what is x?" In this case, 2.73
 
#11
Jumping in to confuse things, so do you have a sample of 10 and 3.5 had the event, probably not? How is data generated? Just tell us about what you are doing?
I only have a value(between 0 and 10 and it is computed in different event) and I want to get a beta distribution [0,1] based on that value, beta should give a probability that is larger on the edges.
 
#12
I suspect you might have the problem the wrong way round. The way that generating random numbers usually works is that you receive a number p from 0 to 1. From that you generate a number x (from 0 to 10 in this case.) If p is close to 0 then x is close to 0 and if p is close to 1 then x is close to 10. In addition, if you are generating beta numbers you get lots near 0 and 10, and fewer in the middle. In this case the question might be "if p = 0.35, what is x?" In this case, 2.73
I want the beta should only generate between 0,1. I am asking the question but not sure if it will be possible to use beta distribution. Because beta distribution has U-shaped, I thought it might serve, as I want to get a large probability with values close to the edges.
 

Dason

Ambassador to the humans
#13
It sounds like you have values between (0, 1) as you do with a beta distribution and you want to transform then into the range (a, b). If that's the case and you call your random value from the beta 'x' then simply apply the function f(x)=(x*(b-a) + a)
 
#14
Thanks guys, and sorry for the confusion I made.
I will rephrase my question somehow, how to draw a beta distribution if I have the value of the mean?

Thanks
 
#15
OK. Try generating beta(0.35,0.65) for a mean of 0.35, then scale it as Dason suggests. (x10 in this case) or =BETAINV(RAND(),0.35,0.65,0,10) in Excel.
 

Dason

Ambassador to the humans
#19
a is the lower limit. b is the upper limit. If you want to draw between 20 and 35 then a=20, b=35. It sounds like you want to draw between 0 and 10 so a=0, b=10.
 
#20
a is the lower limit. b is the upper limit. If you want to draw between 20 and 35 then a=20, b=35. It sounds like you want to draw between 0 and 10 so a=0, b=10.
I understood that beta distribution has alpha and beta parameters which define the shape of the distribution. Values from beta distribution are between 0 and 1. It means there is a difference between upper and lower limits and beta parameters(a,b)?