# Plot and fit exponential decay probability of population

10 views (last 30 days)
Peter Mühlenbrock on 16 Mar 2020
Commented: the cyclist on 23 Mar 2020
Hello
I have a population
example=[1,1,2,4,NaN,NaN,10,200,50]
were each value is the time were the respective element of the population "dies" with "NaN" being elements, that never "die".
I am looking for a way to plot the propability that an element "dies" by the funtion of time converging to the relative amount ('NaN') of elements "surviving" as well as to fit this with a exponential decay curve (I know from e.g. histfit, that my data resembles this behaviour).
I already tried to use the hazard function or to plot 1-cdf.

#### 1 Comment

Peter Mühlenbrock on 23 Mar 2020
I got so far to fit the data without taking the amount of "NaN" into account.
figure(1)
ecdf(y,'function','survivor');
h=gcf;
dataObjs = findobj(gcf,'-property','YData');
dmy3=dataObjs.XData;
x=dmy3';
dmy4=dataObjs.YData;
y2=dmy4';
Up until now the survival function converges to 0. How can i make it converge to the amount of "NaN" in "y"?

the cyclist on 23 Mar 2020
You are correct to use the ecdf function. I think the piece you are missing is the use of the 'censoring' input. Take a look at the example Empirical Hazard Function of Right-Censored Data