code on sageCell
me retrouvant oisif a la retraite, comme l’oisiveté est mere de tous les vices,
j’ai essayé de retrouver ne serait ce que approximativement par le calcul les valeurs données dans le document page 8, sur l’esperance de vie non en partant de l’age zero, mais 65 ans,75 ans 85 ans et 95 ans (pour les femmes Francaises, j’ai utilisé la deviation standard correspondant a l’Allemagne que j’ai trouvé ici :
https://www.thinkingaheadinstitute.org/ ... -to-answer
):
Recent Trends in Life Expectancy at Older Ages: Update to 2014
(en partant de l’hypothese que toute l’information figure dans la courbe de Gauss de l’esperance de vie d’une femme partant de la naissance avec :
mu_0=85.4 # Mean starting from birth
sigma_0=12.7 # Standard Deviation starting from birth )
Bon, ca colle a peu prés jusqu’à 85 ans avec les résultats de l’étude
par contre pas du tout pour la dernière valeur 95 ans .
Le calcul donne une moyenne d’années a vivre de 7,33 ans alors que l’étude donne environs 3.5 années. Je pense que c’est a cause du fait que l’on modélise par une courbe de Gauss, et que la queue de la Gaussienne ne correspond pas a la réalité, jusqu’ici on n’a pas connu un humain ayant une durée de vie supérieur a 123 ans ( Jeanne Calment ).
Peut être que quelqu’un a une explication autre du pourquoi ca dérape a 95 ans, peut etre que ma façon de calculer n’est pas correcte ?
- Code: Tout sélectionner
print ("https://assets.publishing.service.gov.uk/\
government/uploads/system/uploads/attachment_data/file/499252/\
Recent_trends_in_life_expectancy_at_older_ages_2014_update.pdf")
from sage.symbolic.integration.integral import definite_integral
var('x mu sigma')
mu_0=85.4 # Mean starting from birth
sigma_0=12.7 # Standard Deviation starting from birth for Germany not too different from France
print ("https://www.thinkingaheadinstitute.org/en/News/Public/News/2018/12/\
A-basic-question-about-life-expectancy-that-even-actuaries-struggle-to-answer")
normalPDF=1/(sqrt(2*pi*(sigma^2))) * e^(-(((x-mu)/sigma )^2)/2)
normalPDF_0=normalPDF.subs(mu=mu_0,sigma=sigma_0)
normalCDF=(1/2 * ( 1+erf((x-mu)/( sigma*sqrt(2))) ) )
normalCDF_0=normalCDF.subs(mu=mu_0,sigma=sigma_0)
redim_65=(1-normalCDF_0.subs(x=65))
redim_75=(1-normalCDF_0.subs(x=75))
redim_85=(1-normalCDF_0.subs(x=85))
redim_95=(1-normalCDF_0.subs(x=95))
# redim_X verification each should be equals to 1
#show("Aged 65 redim : \t",((definite_integral(normalPDF_0,x,65,infinity))/redim_65).n())
#show("Aged 75 redim : \t",((definite_integral(normalPDF_0,x,75,infinity))/redim_75).n())
#show("Aged 85 redim : \t",((definite_integral(normalPDF_0,x,85,infinity))/redim_85).n())
#show("Aged 95 redim : \t",((definite_integral(normalPDF_0,x,95,infinity))/redim_95).n())
#show( "redim_65 :\t", redim_65.n())
#show( "redim_65 :\t", redim_75.n())
#show( "redim_65 :\t", redim_85.n())
#show( "redim_65 :\t", redim_95.n())
mu_65=((definite_integral(x*normalPDF_0,x,65,infinity))/redim_65)
sigma_65=(sqrt(integral((x-mu_0)^2*normalPDF_0,x,65,infinity,algorithm='sympy')/redim_65))
normalPDF_65=normalPDF.subs(mu=mu_65,sigma=sigma_65)
mu_85=((definite_integral(x*normalPDF_0,x,85,infinity))/redim_85)
sigma_85=(sqrt(integral((x-mu_0)^2*normalPDF_0,x,85,infinity,algorithm='sympy')/redim_85))
normalPDF_85=normalPDF.subs(mu=mu_85,sigma=sigma_85)
show("Aged 0 expectation : \t",((definite_integral(x*normalPDF_0,x,0,infinity))-0).n())
show("Aged 0 Standard Deviation : \t",(sqrt(integral((x-mu_0)^2*normalPDF_0,x,0,infinity,algorithm='sympy'))).n())
show("Aged 65 expectation : \t",((definite_integral(x*normalPDF_0,x,65,infinity))/redim_65-65).n())
show("Aged 65 Standard Deviation : \t",(sqrt(integral((x-mu_0)^2*normalPDF_0,x,65,infinity,algorithm='sympy')/redim_65)).n())
show("Aged 75 expectation : \t",((definite_integral(x*normalPDF_0,x,75,infinity))/redim_75-75).n())
show("Aged 75 Standard Deviation : \t",(sqrt(integral((x-mu_0)^2*normalPDF_0,x,75,infinity,algorithm='sympy')/redim_75)).n())
show("Aged 85 expectation : \t",((definite_integral(x*normalPDF_0,x,85,infinity))/redim_85-85).n())
show("Aged 85 Standard Deviation : \t",(sqrt(integral((x-mu_0)^2*normalPDF_0,x,85,infinity,algorithm='sympy')/redim_85)).n())
show("Aged 95 expectation : \t",((definite_integral(x*normalPDF_0,x,95,infinity))/redim_95-95).n())
show("Aged 95 Standard Deviation : \t",(sqrt(integral((x-mu_0)^2*normalPDF_0,x,infinity,125,algorithm='sympy')/redim_95)).n())
normalCDF=(1/2 * ( 1+erf((x-mu)/( sigma*sqrt(2))) ) )
pdfViewFactor=1/10
normalCDF_0forGraph=normalCDF_0*pdfViewFactor # shrinked CDF by a factor 10 to be graph
debPlot=0
finPlot=130
yminA=0;ymaxA=pdfViewFactor
P=plot(normalPDF_0, (x,debPlot,finPlot),ymin=yminA,ymax=ymaxA ,color='red')
P+=plot(normalPDF_65, (x,debPlot,finPlot),ymin=yminA,ymax=ymaxA ,color='green')
P+=plot(normalPDF_85, (x,debPlot,finPlot),ymin=yminA,ymax=ymaxA ,color='yellow')
#P+= text("normalPDF from 0 ", (mu_0, normalPDF_0(mu_0)), fontsize=16, color='red')
P+= text("normalPDF from 0 ", (50, 0.08), fontsize=16, color='red')
P+= text("normalPDF from 65 ", (50, 0.07), fontsize=16, color='green')
P+= text("normalPDF from 85 ", (50, 0.06), fontsize=16, color='yellow')
P+= text("normalCDF from 0 1/10 ", (50, 0.05), fontsize=16, color='black')
P+=plot(normalCDF_0forGraph, (x,debPlot,finPlot),ymin=yminA,ymax=ymaxA ,color='black')
show(P)