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

65 ビュー (過去 30 日間)
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 ?

採用された回答

John D'Errico
John D'Errico 2021 年 8 月 30 日
編集済み: John D'Errico 2021 年 8 月 30 日
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
  1 件のコメント
Raj Arora
Raj Arora 2021 年 8 月 30 日
編集済み: Raj Arora 2021 年 8 月 30 日
thanks john for your prompt reply. I think now I will solve my problem.

サインインしてコメントする。

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2021 年 8 月 30 日
編集済み: Walter Roberson 2021 年 8 月 30 日
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

カテゴリ

Help Center および File ExchangeDescriptive Statistics and Visualization についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by