# How to find the variance under the assumption that x follows some probability distribution

I am aware that we can find the expectation under the assumption that x follows some probability distribution, something like this:

Expectation[((1 - x)/x), x \[Distributed] BetaDistribution[alpha, beta]]


However, is it possible to find the variance of the above equation (1-x)/x under the same assumption that x follows a beta distribution?

Something like :

Expectation[(((1 - x)/x))^2, x \[Distributed] BetaDistribution[alpha, beta]] -
(Expectation[((1 - x)/x), x \[Distributed] BetaDistribution[alpha, beta]])^2 // Simplify

(* (beta (-1 + alpha + beta))/((-2 + alpha) (-1 + alpha)^2) *)

• ah, so we are using the fact that var(x)=E(x^2)-E(X)^2 thanks!! Oct 10, 2012 at 14:46

This is a perfect place to try out TransformedDistribution.

dist = TransformedDistribution[(1 - x)/x, x \[Distributed] BetaDistribution[alpha, beta]];

Variance[dist]

==> (beta (-1 + alpha + beta))/((-2 + alpha) (-1 + alpha)^2)


Edit:

Based on the comments it is worth pointing out that TransformedDistribution rarely auto-evaluates to a known distribution.

This happens when auto-evaluation to a known distribution either isn't possible or hasn't been added yet. That doesn't mean that the result isn't a perfectly good distribution to work with.

Here we see that the distribution remains unevaluated but we can still generate random numbers (and compute just about any other property) and then compare to the theoretical expectation.

Block[{alpha = 5, beta = 2},
ndist = TransformedDistribution[(1 - x)/x,

• I tried that and gave up because it just returned the TransformedDistribution line unchanged; I didn't know you could still proceed from there. Oct 10, 2012 at 15:26