# 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
{"ft_lang_label":"__label__en","ft_lang_prob":0.85175353,"math_prob":0.76746756,"size":886,"snap":"2020-24-2020-29","text_gpt3_token_len":234,"char_repetition_ratio":0.1122449,"word_repetition_ratio":0.03773585,"special_character_ratio":0.24717833,"punctuation_ratio":0.13218391,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.97904754,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-05-29T08:21:56Z\",\"WARC-Record-ID\":\"<urn:uuid:dff86eb3-0f22-468b-90ae-6183ccb2da87>\",\"Content-Length\":\"113460\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:fab9f47c-e396-4203-bcd5-ad5f399fa200>\",\"WARC-Concurrent-To\":\"<urn:uuid:4247229c-e0fd-48cc-ba4d-550193c43068>\",\"WARC-IP-Address\":\"23.66.56.59\",\"WARC-Target-URI\":\"https://fr.mathworks.com/matlabcentral/answers/511077-plot-and-fit-exponential-decay-probability-of-population\",\"WARC-Payload-Digest\":\"sha1:ODDLCFGWFHWCGFY7ZLJ3I3OCW5Y5Q4OT\",\"WARC-Block-Digest\":\"sha1:EZEZHYAHOMSR44YF3GZOBUERCZYRDMO6\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-24/CC-MAIN-2020-24_segments_1590347402457.55_warc_CC-MAIN-20200529054758-20200529084758-00287.warc.gz\"}"}