boeingx37
(Alex Graham)
July 17, 2018, 6:39pm
1
Hello. I want to find percentile of beta distribution and I should get the answer like that 0.0023.
Clear["Global`*"]
a = 0.848;
b = 117.46;
NSolve[PDF[BetaDistribution[a, b], p] == 0.05 && 1 >= p >= 0, p]
But it takes infinite time to be solved, so what should I correct in the code?
neils
(Neil Singer)
July 17, 2018, 6:53pm
2
Alex,
You should use FindRoot because NSolve first tries to analytically solve it and that is what is taking so long.
In[4]:= FindRoot[PDF[BetaDistribution[a, b], p] == 0.05, {p, .1}]
Out[4]= {p -> 0.0611872}
Regards,
Neil
Clear[“Global`*”]
a = 0.848;
b = 117.46;
NSolve[Simplify[PDF[BetaDistribution[a, b], p] == 0.05, 0 < p < 1], p, Reals]
(* {{p -> 0.0611872}} *)
boeingx37
(Alex Graham)
July 17, 2018, 7:43pm
4
Thank you for your replies. Could you please take a look at the link, It seems I need to find something different to get 0.0027
With p=0.95 I get {{p → 0.0377553}}
What is more interesting this online thing with corresponding a and b gives the answer 0.0226 instaed of 0.0022… https://keisan.casio.com/exec/system/1180573227
Thanks in advance
boeingx37
(Alex Graham)
July 17, 2018, 10:44pm
5
According to the second link the it must have an integral inside. But I have some problem with integrate fucntion.
Clear["Global`*"]
a = 2.7817;
b = 129.8309;
NSolve[Simplify[
Integrate[PDF[BetaDistribution[a, b], t], {t, p, 1}] == 0.05 &&
1 > p > 0], p]
Hello Alex,
that’s simple: just use the Quantile function
Quantile[BetaDistribution[a, b], 0.05]
funcL = Integrate[
Simplify[PDF[BetaDistribution[a, b], t], 1 > t > 0], {t, 0, p},
Assumptions → {0 < p < 1, b > 0, a > 0}];
funcU = Integrate[
Simplify[PDF[BetaDistribution[a, b], t], 1 > t > 0], {t, p, 1},
Assumptions → {0 < p < 1, b > 0, a > 0}];
a = 2;(*I assume*)
b = 3;(*I assume*)
LowerP = FindRoot[funcL == 0.05, {p, 1/2}]
(* {p -> 0.0976115} *)
UpperQ = FindRoot[funcU == 0.05, {p, 1/2}]
(* {p -> 0.751395} *)
The results agree with the site
With a good hint of user Claude Mante
Quantile[BetaDistribution[a, b], #] & /@ {0.05, 0.95}
(* {0.0976115, 0.751395}*)
Input: PDF[BetaDistribution[a, b], p]
Output:
116
51 (1 - p)
-------------
0.15
p
this doesn’t look like a differential equation to me. using dsolve and even moreso integrating before using dsolve? perhaps there are some assumptions to make not mentioned above?