This question builds on the great answers I got on an earlier question:
Can one extend the functionality of PDF, CDF, FindDistributionParameters etc in Mathematica?
To start I have PDFs and CDFs for two custom distributions: nlDist and dplDist as you can see from the code dplDist builds upon nlDist.
nlDist /: PDF[nlDist[alpha_, beta_, mu_, sigma_],
x_] := (1/(2*(alpha + beta)))*alpha*
beta*(E^(alpha*(mu + (alpha*sigma^2)/2 - x))*
Erfc[(mu + alpha*sigma^2 - x)/(Sqrt[2]*sigma)] +
E^(beta*(-mu + (beta*sigma^2)/2 + x))*
Erfc[(-mu + beta*sigma^2 + x)/(Sqrt[2]*sigma)]);
nlDist /:
CDF[nlDist[alpha_, beta_, mu_, sigma_],
x_] := ((1/(2*(alpha + beta)))*((alpha + beta)*E^(alpha*x)*
Erfc[(mu - x)/(Sqrt[2]*sigma)] -
beta*E^(alpha*mu + (alpha^2*sigma^2)/2)*
Erfc[(mu + alpha*sigma^2 - x)/(Sqrt[2]*sigma)] +
alpha*E^((-beta)*mu + (beta^2*sigma^2)/2 + alpha*x + beta*x)*
Erfc[(-mu + beta*sigma^2 + x)/(Sqrt[2]*sigma)]))/
E^(alpha*x);
dplDist /: PDF[dplDist[alpha_, beta_, mu_, sigma_], x_] :=
PDF[nlDist[alpha, beta, mu, sigma], Log[x]]/x;
dplDist /: CDF[dplDist[alpha_, beta_, mu_, sigma_], x_] :=
CDF[nlDist[alpha, beta, mu, sigma], Log[x]];
Plot[PDF[dplDist[3.77, 1.34, -2.65, 0.40], x], {x, 0, .3},
PlotRange -> All]
Plot[CDF[dplDist[3.77, 1.34, -2.65, 0.40], x], {x, 0, .3},
PlotRange -> All]
In my earlier question, joebolte's and sasha's answers and recommendation to use TagSet helped me get this far. Now, my questions relate to the dplDist.
I now need to calculate expectation from some point on the x axis of the PDF. In survival analysis they refer to this as mean residual life. Something like the following:
Expectation[X \[Conditioned] X > 0.1,
X \[Distributed] dplDist[3.77, 1.34, -2.65, 0.40]] - 0.1
This doesn't work, essentially just returning the inputs as text.
I understand how I can use TagSet to define PDFs and CDFs for custom distributions, how do I do something similar for Expectation[]?
I'll post more about this follow up in a separate question, but I also need a strategy for calculating goodness of fit of the dplDist relative to some data to which I've fit the distribution.
Many thanks to all.