Truncated exponential distribution

I need to find the mean of the maximum for n independent identical random variables in a Truncated exponential distribution.

I used the following code to find it for exponential distribution:

ed = {ExponentialDistribution[\[Lambda]], n};
m = Mean[OrderDistribution[ed, 1]] ;
Print[m];

What changes should I make to make the code work on a Truncated exponential distribution on the interval [a,b]?

Note: Edited from the original answer.

If you have specific values for n, then the following will work for the mean and variance of the maximum for a sample of size n=3:

trd = TruncatedDistribution[{a, b}, ExponentialDistribution[\[Lambda]]];
otrd = OrderDistribution[{trd, 3}, 3];
FullSimplify[Mean[otrd], Assumptions -> {b > a > 0, \[Lambda] > 0}]
\frac{(6 a \lambda +11) \left(-e^{3 b \lambda }\right)+18 (b \lambda +1) e^{\lambda (a+2 b)}-9 (2 b \lambda +1) e^{\lambda (2 a+b)}+e^{3 a \lambda } (6 b \lambda +2)}{6 \lambda \left(e^{a \lambda }-e^{b \lambda }\right)^3}
FullSimplify[Variance[otrd], Assumptions -> {b > a > 0, \[Lambda] > 0}]
\frac{-4 e^{3 \lambda (a+b)} (9 \lambda (a-b) (a \lambda -b \lambda +3)+155)+249 e^{2 \lambda (2 a+b)}-42 e^{\lambda (5 a+b)}-6 e^{\lambda (a+5 b)} (6 \lambda (a-b) (3 a \lambda -3 b \lambda +5)+55)+6 e^{2 \lambda (a+2 b)} (6 \lambda (a-b) (3 a \lambda -3 b \lambda +8)+115)+4 e^{6 a \lambda }+49 e^{6 b \lambda }}{36 \lambda ^2 \left(e^{a \lambda }-e^{b \lambda }\right)^6}

Thank you for your help, is this only for the mean? I tried to use it to find the variance but it didn’t work.

You only asked for the mean. How did it “not work” for the variance? Did you get an error? Can you show what you tried?

Yes, you are right, I used n in the variance and it showed the original equation without making any calculations. But when I used a specific value of n, it worked perfectly. Thank you a lot.

Just one more thing if you could help me with, any idea about finding the mean and variance of the maximum for n independent non-identical random variables in a Truncated exponential distribution.

You should now have enough to go on to do that yourself. If you get stuck at some point, please show what you’ve tried and explain where you are stuck. I would imagine you’ll get more help that way.