# PDF of double truncated exponential function [closed]

I am trying to find the pdf of a double truncated exponential distribution using the following code:

x = TruncatedDistribution[{t1, t2}, ExponentialDistribution] // PiecewiseExpand
fx = PDF[x]
fx


but an errror occurs.

• The correct syntax would be: x = TruncatedDistribution[{t1, t2}, ExponentialDistribution[\[Lambda]]] // PiecewiseExpand and then PDF[x, z]. Jun 22 at 5:49
• how to get pdf of double truncated exponential distribution? Jun 22 at 7:49
• How are your tags related to your post in any way? Please edit post to improve capitalization, sentences and include code blocks to your post. You say "an error occurs"; please be more specific and include the error message. Thanks.
– Syed
Jun 22 at 8:12

You can obtain it as follows:

truncated = TruncatedDistribution[{t1, t2}, ExponentialDistribution[lambda]];
Assuming[{t1 > 0, t2 > t1}, PDF[truncated, x]]

(* Out:
Piecewise[
{
{lambda/(E^(lambda*x)*(E^((-lambda)*t1) - E^((-lambda)*t2))), t1 - x < 0 && t2 - x >= 0 && x >= 0},
{0, x < 0 || t1 - x >= 0 || x < 0 || t2 - x < 0}
},
Indeterminate
]
*) For a graphical comparison, invluding the full non-truncated distribution from which the truncated one derives (choosing arbitrary values of $$\lambda,t_1,t_2$$):

values = {lambda -> 1, t1 -> 1/2, t2 -> 2};
full = ExponentialDistribution[lambda];

Plot[
Evaluate[{
1/(CDF[full, t2] - CDF[full, t1]) PDF[full, x],
PDF[truncated, x]
} /. values
],
{x, 0, 6},
Exclusions -> None, PlotRange -> All, AspectRatio -> 1,
PlotLegends -> {"full", "truncated"},
AxesStyle -> Directive[Black, 14], Filling -> Axis
] • +1 For the PDF include FullSimplify, i.e., pdf = Assuming[{t1 > 0, t2 > t1}, PDF[truncated, x] // FullSimplify] Plotting Evaluate[PDF[#, x] & /@ {full, truncated} /. values] better illustrates that the total probability is always one. Jun 22 at 16:36