Skip to content

The docstring of np.random.pareto (Version 1.8.0) contains multiple critical errors #4181

@ckuehne

Description

@ckuehne

The docstring of np.random.pareto (Version 1.8.0) contains multiple errors. In a nutshell np.random.pareto does not draw samples from the Pareto distribution shown under 'Notes' in the docstring. Instead it draws samples from a Lomax distribution (also stated in the docstring). However, the description in the docstring of how to convert those Lomax random variates to a Pareto distribution is wrong. Further, the examples are faulty.

More detailed:
The function np.random.pareto draws random variates from a Lomax distribution with shape a and location m'=1. To convert
those samples to a classical Pareto distribution with shape a and
location m you have to add 1 and multiply by m, instead of adding m as
stated in the docstring.

More specifically, the docstring says:
"The Lomax or Pareto II distribution is a shifted Pareto distribution. The
classical Pareto distribution can be obtained from the Lomax distribution
by adding the location parameter m, see below."

Instead, it should read "[..] by adding 1 and multiplying my m, see below."

The example at the bottom therefore should read:

a, m = 3., 1. # shape and mode
s = (np.random.pareto(a, 1000) + 1) * m

Maybe an example with m=10 makes it clearer

a, m = 3., 10. # shape and mode
s = (np.random.pareto(a, 1000) + 1) * m

Additionally, calling m the location parameter could be misleading.
For simple Pareto (Type I) distributions it is usually referred to as
the x_min or the scale parameter of the distribution. When discussing
generalized Pareto distributions m is also called the scale
parameter (a constant factor) while mu is the location (an additive
term) [1]. I assume the misleading naming could have caused some
confusion and lead to the errors described above.

Last but not least I think it might also cause confusion to call
a function 'random.pareto' while its meaning is 'shifted by -1 pareto'. :)

[1] http://en.wikipedia.org/wiki/Generalized_Pareto_distribution

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions