0

I am trying to generate 1000 values with landau distribution with an MPV(most probable value) of 25, can't find a landau random number generator in scipy or numpy. I tried pylandau {pip install pylandau} but this seems to only fit landaus and not generate random numbers. Any way of doing this would be welcome in python or pyroot.

2 Answers2

0

The package pylandau is just calculating the Landau function value. It can be used for fitting, random number generation, etc. It seems like you would like to know how to generate random numbers from a distribution, as answered in another question here. The following example creates 100 random values from the Landau distribution:


import numpy as np
import pylandau

x = np.arange(-1, 1, 0.01)
y = pylandau.landau(x)
random_values = np.random.choice(x, size=100, p=y / y.sum())
DavidLP
  • 11
  • 4
0

landaupy implements a pure-Python implementation of the Landau (and Langauss) distribution and allows to generate random samples. The code would be

from landaupy import landau

samples = landau.sample(x_mpv=25, xi=1, n_samples=1000)

You can install this with

pip install git+https://github.com/SengerM/landaupy
user171780
  • 2,243
  • 1
  • 20
  • 43