conjuring
conjuring

Reputation: 131

Adding location parameter in paretovariate() function

Currently I'm looking forward to generate random values of the pareto distribution using Paretovariate() function of the random module which by default accepts just one parameter i.e for the shape of the distribution (alpha),but assumes the location parameter(Xm) as 1.

How shall the python implementation be if I wanna consider some other value of Xm?

Upvotes: 1

Views: 316

Answers (1)

Severin Pappadeux
Severin Pappadeux

Reputation: 20130

Basically, do something like

import random

def my_paretovariate(alpha, xm = 1.0):
    """
    Sample Pareto variate with arbitrary xm
    """
    return xm * random.paretovariate(alpha)

Upvotes: 1

Related Questions