SmallChess
SmallChess

Reputation: 8126

Why my fitted genextreme distribution have no mean/variance?

I have the following code for estimating a generalized extreme value distribution from scipy.

from scipy.stats import genextreme
ys = [22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.3, 22.3, 22.3, 22.3, 22.3, 22.3, 22.3, 22.3, 22.3, 22.3, 22.3, 22.3, 22.3, 22.3, 22.3, 22.3, 23.3, 23.3, 23.3, 23.3, 23.3, 23.3, 23.3, 23.3, 23.3, 23.3, 23.3, 23.3, 23.3, 23.3, 23.3, 23.3, 23.3, 23.3, 23.3, 23.3, 23.3, 23.3, 23.3, 23.3, 23.3, 23.3, 23.2, 23.2, 23.2, 23.2, 23.2, 23.2, 23.2, 23.2, 29.9, 29.9, 29.9, 29.9, 29.9, 29.9, 29.9, 29.9, 29.9, 29.9, 29.9, 29.9, 29.9, 29.9, 29.9, 29.9, 29.9, 29.9, 29.9, 29.9, 29.9, 29.9, 29.9, 29.9, 29.9, 29.9, 29.9, 29.9, 29.9, 29.9, 29.9, 29.9, 29.9, 29.9, 29.9, 29.9, 29.9, 29.9, 29.9, 29.9, 29.9, 29.9, 29.9, 29.9, 29.9, 29.9, 29.9, 29.9, 29.9, 29.9, 29.9, 29.9, 29.9, 29.9, 29.9, 29.9, 29.9, 29.9, 29.9, 29.9, 29.9, 29.9, 29.9, 29.9, 29.9, 27.7, 27.7, 27.7, 27.7, 27.7, 27.7, 27.7, 27.7, 27.7, 27.7, 27.7, 27.7, 27.7, 27.7, 27.7, 27.7, 27.7, 27.7, 27.7, 27.7, 27.7, 27.7, 27.7, 27.7, 27.7, 27.7, 24.5, 24.5, 24.5, 24.5, 24.5, 24.5, 24.5, 24.5, 24.5, 26.6, 26.6, 26.6, 26.6, 26.6, 26.6, 26.6, 26.6, 26.6, 26.6, 26.6, 26.6, 26.6, 26.6, 26.6, 26.6, 26.6, 26.6, 26.6, 26.6, 26.6, 26.6, 26.6, 26.6, 26.6, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 23.7, 23.7, 23.7, 23.7, 23.7, 23.7, 23.7, 23.7, 23.7, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.9, 22.9, 22.9, 22.9, 22.9, 22.9, 22.9, 22.9, 22.9, 22.9, 22.9, 22.9, 22.9, 22.9, 22.9, 22.9, 22.9, 22.9, 22.9, 22.9, 22.9, 22.9, 22.9, 22.9, 22.9, 22.9, 22.9, 22.9, 22.9, 22.9, 22.9, 22.9, 22.9, 22.9, 22.9, 22.9, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764, 22.058823529411764]
shape, loc, scale = genextreme.fit(ys)
mean, var = genextreme.stats(shape, loc, scale, moments='mv')

I got the following fitted parameters (shape, location and scale respecitvely):

-2.787020488783334
22.058823529411782
5.0707584099150134e-14

Thus, the shape is negative but the documentation on https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.genextreme.html allows the shape to go negative.

However, my mean and variance are both nan.

It looks like I can fit a model, and the fitted parameters look reasonable, but why am I unable to get a mean from the fitted distribution?

Upvotes: 0

Views: 64

Answers (1)

Warren Weckesser
Warren Weckesser

Reputation: 114946

When the shape parameter is less than -1, the distribution is sufficiently "fat-tailed" that the mean and variance don't exist. This is noted in the table on the right side of the wikipedia article on the generalized extreme value distribution--but note that the sign of the shape parameter c used by genextreme is the opposite of the parameter ξ in the wikipedia article.

Upvotes: 1

Related Questions