How to divide the interval of any distribution in N equal parts based on its area?

53 visualizaciones (últimos 30 días)
Can anyone please help me with this
How to divide a normal distribution or log normal distribtuion with mean and standard deviation into N equal intervals
X2: Normally dist. with mean = 0.6, standard deviation= 0.1
Let us suppose I have to divide X2 into 4 (N=4) equal parts. The interval will be as follows
Interval of X2 : (-∞,0.533) (0.533,0.6) (0.6,0.667) (0.667, ∞).
So how could I do this in matlab ?

Respuesta aceptada

John D'Errico
John D'Errico el 30 de Ag. de 2021
Editada: John D'Errico el 30 de Ag. de 2021
As long as you have the cumulative distribution, and most importantly, an inverse for the cumulative, this is all you need. For example, suppose you want to find the points where you can divide that area into 3 equal parts, given a normal distribution.
Here, I'll use a normal distribution with mean 3, and variance 4, so standard deviation 2. I want three equal parts, so the break points in the area will be:
areabreaks = linspace(0,1,4)
areabreaks = 1×4
0 0.3333 0.6667 1.0000
There must always be one extra break point. Now, we can ignore the first and last such point, because they must live at -inf and +inf.
Now, use the inverse cumulative distribution, for a normal with those parameters. If you don't know how to use norminv, then READ THE HELP.
help norminv
NORMINV Inverse of the normal cumulative distribution function (cdf). X = NORMINV(P,MU,SIGMA) returns the inverse cdf for the normal distribution with mean MU and standard deviation SIGMA, evaluated at the values in P. The size of X is the common size of the input arguments. A scalar input functions as a constant matrix of the same size as the other inputs. Default values for MU and SIGMA are 0 and 1, respectively. [X,XLO,XUP] = NORMINV(P,MU,SIGMA,PCOV,ALPHA) produces confidence bounds for X when the input parameters MU and SIGMA are estimates. PCOV is a 2-by-2 matrix containing the covariance matrix of the estimated parameters. ALPHA has a default value of 0.05, and specifies 100*(1-ALPHA)% confidence bounds. XLO and XUP are arrays of the same size as X containing the lower and upper confidence bounds. See also ERFINV, ERFCINV, NORMCDF, NORMFIT, NORMLIKE, NORMPDF, NORMRND, NORMSTAT. Documentation for norminv doc norminv Other functions named norminv distributed/norminv
Now, we want to find the corresponding points where the cumulative area is 1/3 and 2/3, in our case, because I chose 3 area segments. In fact, norminv is smart enough to know that 0 maps to -inf, and 1 maps to +inf.
mu = 3;
sigma = 2;
z = norminv(areabreaks,mu,sigma)
z = 1×4
-Inf 2.1385 3.8615 Inf
intervals = [z(1:end-1);z(2:end)]
intervals = 2×3
-Inf 2.1385 3.8615 2.1385 3.8615 Inf
Nothing difficult. And only a couple of lines of code. The same will apply to your problem. TRY IT!
What is the corresponding inverse cumulative distribution function for a lognormal?
help logninv

Más respuestas (1)

Walter Roberson
Walter Roberson el 30 de Ag. de 2021
Editada: Walter Roberson el 30 de Ag. de 2021
If you have the Statistics and Machine Learning Toolbox, and the distribution can be specified with makedist(), then you can use icdf() asking for (1:N)/N probabilities

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by