如何在python中随机采样2参数的weibull分布 [英] How to random sample a 2-parameter weibull distribution in python

查看:330
本文介绍了如何在python中随机采样2参数的weibull分布的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何在python中生成带有2参数(lambda,k)的随机weibull分布.我知道numpy具有 numpy. random.weibull ,但仅接受 a 参数作为分布形状.

I was wondering how to generate a random weibull distribution with 2-parameter (lambda, k) in python. I know that numpy has a numpy.random.weibull, but it only accepts the a parameter as the shape of the distribution.

推荐答案

Severin Pappadeux的答案可能是包括scale参数的最简单方法.一种替代方法是使用 scipy.stats.weibull_min . weibull_min具有三个参数:形状,位置和比例.您只需要形状和比例,因此可以将位置设置为0.

Severin Pappadeux's answer is probably the simplest way to include the scale parameter. An alternative is to use scipy.stats.weibull_min. weibull_min has three parameters: shape, location and scale. You only want the shape and scale, so you would set the location to 0.

from scipy.stats import weibull_min

n = 100     # number of samples
k = 2.4     # shape
lam = 5.5   # scale

x = weibull_min.rvs(k, loc=0, scale=lam, size=n)

这篇关于如何在python中随机采样2参数的weibull分布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆