Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Define distribution function to be zero if ecdf(X) is not defined

1 回表示 (過去 30 日間)
Nina
Nina 2017 年 11 月 9 日
閉鎖済み: Nina 2018 年 4 月 17 日
I have a distribution of random numbers X in the interval [50,100]. When using the function ecdf(X) to receive the empirical cumulative distribution function, the values for x<50 are not defined.
I the following, I want to integrate (1-ecdf(X)) from 0 to infinity and therefore need the ecdf(X) to be zero.
Is there a possibility to define the ecdf(X) to be zero for x<50?

採用された回答

Torsten
Torsten 2017 年 11 月 9 日
[f,x] = ecdf(X);
Ecdf=@(p) interp1(x,f,p)*(p>=50)
Best wishes
Torsten.
  6 件のコメント
Nina
Nina 2017 年 11 月 9 日
You are totally right, but the problem is that the CDF in my plot seems to be not defined as 0 for x<50. Before integrating I calculate 1-CDF and therefore get the decreasing function...
Torsten
Torsten 2017 年 11 月 9 日
編集済み: Torsten 2017 年 11 月 9 日
If you integrate from the first x-value to the last x-value (as the command
"trapz(x,Distribution_distorted)"
does), you automatically ensure that the CDF is counted to be zero outside the interval where its mass is concentrated (namely outside [x(1);x(end)]). And I guess this is what you want.
Best wishes
Torsten.

その他の回答 (0 件)

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by