Is there any built-in function in MATLAB to compute
0.025th quantile of Binomial distribution with parameter n=60 and p=0.4
0.975 quantile of standard normal distribution ?
Do you have the Statistics toolbox? If yes,
>> binoinv(.025,60,.4)
ans =
17
>> norminv(.975,0,1)
ans =
1.9600
If not, you could use the following equivalences:
erfinv functionbetainc functionFirst, the accepted answer is correct and provides the direct, distribution-specific functions. However, there are more general functions that can do this for those needing a wider array of functions and probability distributions.
For those with the Stats toolbox, MATLAB introduced probability distribution objects in 2013 which provide very convenient ways to work with distributions and statistical functions.
One can use makedist() to create the distribution objects needed.
% MATLAB R2022a
% Parameters
n = 60;
p = 0.4;
mu = 0;
sigma = 1;
% X ~ Binomial(n,p)
pdX = makedist('Binomial','N',n,'p',p)
% Y ~ Normal(0,1)
pdY = makedist('Normal','mu',mu,'sigma',sigma)
Remembering that the quantile function is the inverse cumulative distribution function, calling icdf() gets the job done.
x = icdf(pdX,0.025) % x = 17
y = icdf(pdY,0.975) % y = 1.9600
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With