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.
Asked
Active
Viewed 401 times
0

Anthony Bwembya
- 1
- 2
-
2I don't understand what you are trying to do. Can you provide us with more detail? – Jakov Gl. Apr 08 '21 at 12:15
-
Is it clearer now? – Anthony Bwembya Apr 08 '21 at 13:06
-
I think it this not exist in Python. Probably you know this paper: K.S. Kolbig and B. Schorr, A program package for the Landau distribution, Computer Phys. Comm. 31 (1984) 97–111 – len Apr 08 '21 at 22:10
2 Answers
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