random.vonmisesvariate

Full name
random.vonmisesvariate
Library
random
Syntax

random.vonmisesvariate(mu, kappa)

Description

The random.vonmisesvariate function returns a random number drawn from a von Mises distribution, also known as a circular normal distribution or Tikhonov distribution.

Parameters
  • mu: Mean angle expressed in radians between 0 and 2π.
  • kappa: Concentration parameter. It must be greater than or equal to 0.
Result

The random.vonmisesvariate function returns a real number.

Examples

We can generate a random number extracted from a von Mises distribution with a mean angle equal to 5 and with a concentration parameter equal to 1 with the following code:

random.vonmisesvariate(5, 1)
2.4304091598728492

To confirm the distribution from which the random numbers are extracted, we can generate one hundred thousand random numbers from a von Mises distribution with a mean angle equal to 5 and with a concentration parameter equal to 1 and show its histogram:

import matplotlib.pyplot as plt
plt.figure(figsize = (8, 4))
plt.hist([random.vonmisesvariate(5, 1) for i in range(100000)], bins = 100)
plt.grid()
plt.show()
random.vonmisesvariate
Submitted by admin on Thu, 03/18/2021 - 09:02