1
$\begingroup$

I am using the Moment function to calculate the moments of an exponential random variable.

as follows,

Moment[ExponentialDistribution[3], 9]

However, I need to calculate the moments of a truncated (between 0 and 5) exponential random variable as well, however, I have checked the available documentation and I don't find anything. Can someone please tell me what I have to add to my current code for it to be truncated in the interval [0, 5]?

$\endgroup$
1
  • 5
    $\begingroup$ Try: Moment[TruncatedDistribution[{0, 5}, ExponentialDistribution[3]], 1] $\endgroup$ Sep 14, 2022 at 14:38

1 Answer 1

3
$\begingroup$
$Version

(* "13.1.0 for Mac OS X x86 (64-bit) (June 16, 2022)" *)

Clear["Global`*"]

More generally, the truncated distribution is given by

tdist = TruncatedDistribution[{0, xmax}, ExponentialDistribution[λ]];

tdist inherits the assumption on the parameter for ExponentialDistribution and adds the assumption that xmax is positive real.

dpa = DistributionParameterAssumptions[tdist]

(* λ > 0 && Im[xmax] == 0 && xmax > 0 *)

The PDF is

PDF[tdist, x]

enter image description here

Verifying the PDF

Assuming[dpa,
 Integrate[PDF[tdist, x], {x, -Infinity, Infinity}]]

(* 1 *)

The moments are then

Moment[tdist, r]

(* (λ^-r (Gamma[1 + r] - 
   Gamma[1 + r, xmax λ]))/(1 - E^(-xmax λ)) *)

CentralMoment[tdist, r]

(* (1/(-1 + E^(xmax λ)))E^(-1 + (1 + 
     1/(-1 + E^(xmax λ))) xmax λ) λ^-r (Gamma[
    1 + r, -1 + (xmax λ)/(-1 + E^(xmax λ))] - 
   Gamma[1 + r, -1 + (1 + 1/(-1 + E^(xmax λ))) xmax λ]) *)

For example,

Assuming[dpa,
 #[tdist] & /@ {Mean, Moment[#, 1] &, Moment[#, 2] &,
   Variance, CentralMoment[#, 2] &}]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.