I want to build a distribution as U-shape, with the x-axis of values between [1,5] continuous, and the y-axis is probability [0,1]. I am thinking of beta distribution of alpha=beta=0.5 but couldn't figure it out. Ans suggestion?
Asked
Active
Viewed 844 times
0
-
3FYI, if the distribution is continuous, the y-axis isn't guaranteed to be between 0 and 1. Is it in fact a probability density function you are trying to draw, or a function that maps [0, 1] to [1, 5] with a u-shape? – Brash Equilibrium Feb 07 '20 at 23:58
-
Yes, the distribution is continuous. – hana Feb 08 '20 at 09:32
-
2If the range is 4, the probability density must average 0.25 per unit for the total probability to be 1. That doesn't rule out the density being above 1 per unit somewhere in the distribution. – Nick Cox Feb 08 '20 at 09:45
-
Adding a bit to the two comments so far, the reason this is so is that, for a continuous distribution, the chance of any particular, exact value of that distribution is 0. – Peter Flom Feb 10 '20 at 11:38
-
I don't find that anyone who hasn't independently studied analysis to the level that "probability zero" is already a familiar concept finds it a helpful concept in explanation. Conversely, what I don't see, and this surprises me, are many explanations that relate probability density to other kinds of density that people have already heard of, such as density in physics or population density in demography and geography. – Nick Cox Feb 10 '20 at 16:20
1 Answers
2
Here are two possible densities, a beta distribution in black (though at $1$ and $5$ the densities approach $\infty$) and a parabolic distribution in red (though at $1$ and $5$ the densities approach $\frac34$) so it rather depends on what limits you want at the extremes
using R code
dstretchbeta <- function(x){(1/4)*dbeta((x-1)/4, 1/2, 1/2)}
dparabola <- function(x){ifelse(x < 1 | x > 5, 0, (3/16)*(x-3)^2)}
curve(dstretchbeta, from=0, to=6, ylim=c(0,1))
curve(dparabola, from=0, to=6, col="red", add=TRUE)
Henry
- 39,459
-
Thank you so much for this!. How can I remove the lines from the curve at 1 and 5? – hana Feb 08 '20 at 10:54
-
@ghana In the R code, using
from=1, to=5,instead of the twofrom=0, to=6,will avoid the vertical and straight horizontal lines – Henry Feb 08 '20 at 12:04 -
Thank you @Henry. Do you know the equivalent to dbeta in Python? I tried
1/4*beta.pdf((1-x)/4,0.5,0.5,1,5)from scipy.stats but it gives me 0 always! – hana Feb 08 '20 at 21:00 -
@ghana It should probably be
(x-1)/4rather than(1-x)/4but I do not know this part of Python, as I found early courses in it less statistician friendly than R – Henry Feb 08 '20 at 21:08 -
Thank you. It works finally
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)– hana Feb 08 '20 at 22:29

