简体   繁体   English

兰道随机数发生器

[英]landau Random number generator

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.我正在尝试生成 1000 个具有 MPV(最可能值)为 25 的兰道分布的值,但在 scipy 或 numpy 中找不到兰道随机数生成器。 I tried pylandau { pip install pylandau } but this seems to only fit landaus and not generate random numbers.我尝试了 pylandau { pip install pylandau } 但这似乎只适合兰道斯而不生成随机数。 Any way of doing this would be welcome in python or pyroot. python 或 pyroot 中欢迎任何这样做的方式。

The package pylandau is just calculating the Landau function value. package pylandau只是在计算 Landau function 值。 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:以下示例从朗道分布中创建 100 个随机值:


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())

landaupy implements a pure-Python implementation of the Landau (and Langauss) distribution and allows to generate random samples. Landaupy实现了朗道(和朗高斯)分布的纯 Python 实现,并允许生成随机样本。 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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM