Probability manipulations with Mathematica…
There comes a time that a statistician needs to do some ananytic calculations. There more than a bunch of tools to use but I usually prefer Mathematica or Maple. Today, I’m gonna use Mathematica to do a simple exhibition.
Let’s set this example upon the distribution.
pfun = PDF[UniformDistribution[{2*Subscript[θ, 1] - Subscript[θ, 2],
2*Subscript[θ, 1] + Subscript[θ, 2]}], x]
One of the most intensive calculations is the characteristic function (eq. the moment generating function). This is straightforward to derive.
cfun=CharacteristicFunction[UniformDistribution[
{2*Subscript[θ, 1]-Subscript[θ, 2],2*Subscript[θ, 1]+Subscript[θ, 2]}],x]
.
The Table[] command calculates for us the raw moments for our distribution.
Table[Limit[D[cfun, {x, n}], x -> 0]/I^n, {n, 4}]
.
Calculate the sample statistics.
T=List[8.23,6.9,1.05,4.8,2.03,6.95];
{Mean[T],Variance[T]}
.
Now, we can use a simple moment matching technique to get estimates for the parameters.
Solve[{Mean[T]-2*Subscript[θ, 1]==0,-(2*Subscript[θ, 1])^2+
1/3 (12 Subscript[θ, 1]^2+\!\*SubsuperscriptBox[\(θ\), \(2\), \(2\)])-
Variance[T]==0},{Subscript[θ, 2],Subscript[θ, 1]}]
.
Check the true value for the .
Reduce[2 Subscript[θ, 1]-Subscript[θ, 2]<=2 Subscript[θ, 1]+Subscript[θ, 2], Subscript[θ, 2]]
Then, .