# How to change type order in PearsonDistribution?

I need to estimate a Pearson distribution from a batch of tables tab:

EstimatedDistribution[tab, PearsonDistribution[a1,a0,b2,b1,b0], ParameterEstimator -> "MethodOfMoments"]

I don't want to specify the type, but rather have it automatically picked. Mathematica does this in the order: 4, 1, 6, 3, 5, 2, and 7. Is it possible to change this default order?

-

## 2 Answers

Along the same lines as VLC's suggestion:

Using

data = RandomVariate[PearsonDistribution[4, 5, 3, 2, 10], 10000];
ordering1 = RandomSample@Range@7
(* {3, 2, 5, 4, 6, 7, 1} *)
ordering2 = RandomSample@Range@7
(* {3, 1, 2, 5, 4, 7, 6} *)


and

i = 1;
pearsonType = ordering1[[i]];
While[(Quiet@
DistributionParameterAssumptions[
EstimatedDistribution[data,
PearsonDistribution[pearsonType, a1, a0, b2, b1, b0],
ParameterEstimator -> "MethodOfMoments"]] =!= True),
pearsonType = ordering1[[i]]; i++];
EstimatedDistribution[data,
PearsonDistribution[pearsonType, a1, a0, b2, b1, b0],
ParameterEstimator -> "MethodOfMoments"]


gives

PearsonDistribution[5, 3.960577237166583, 5.1789544794566986*^11,1., 5.123787720579541*^11, 6.563300151390422*^22]


For the same data, you get

PearsonDistribution[1, 0.17852976914824442, 4.083885578478384*^12, 1., 4.084324691133497*^12, -9.944999191995846*^20]


if you use ordering2 instead of ordering1.

-
thanks, this works perfectly. only one thing: perhaps the i++ bit should go before pearsonType = ordering1[[i]], right? – Valerio Aug 14 '12 at 14:42
@Valerio, thank your for the accept. Increment i++ increases the value of x by 1, returning the old value of x. – kglr Aug 14 '12 at 15:31

By default the first type whose parameter assumptions are not explicitly violated is assumed and the types are tried in the order: 4, 1, 6, 3, 5, 2, and 7.

You could check if assumptions are met for each type in your preferred order by using DistributionParameterAssumptions.

Edit

The idea was to use something along this line:

data = RandomVariate[PearsonDistribution[45, -80, 30, 30, 20], 1000];

type=1;

DistributionParameterAssumptions[
EstimatedDistribution[data,
PearsonDistribution[type, a1, a0, b2, b1, b0],
ParameterEstimator -> "MethodOfMoments"]]

(* True *)


We just checked if the assumptions are met for the type 1 Pearson distribution, and the output True tell us that they are. You can do this for all the other types in the order you prefer.

-
could you be more specific? thanks – Valerio Aug 7 '12 at 19:16
@Valerio see edit. – VLC Aug 8 '12 at 6:40