创建具有左偏概率分布的随机数 [英] Create random numbers with left skewed probability distribution

查看:41
本文介绍了创建具有左偏概率分布的随机数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 1-100 之间随机选择一个数字,这样得到数字 60-100 的概率高于 1-59.

I would like to pick a number randomly between 1-100 such that the probability of getting numbers 60-100 is higher than 1-59.

我希望数字 1-100 的概率为左偏分布.也就是说,它有一个很长的尾巴和一个峰值.

I would like to have the probability to be a left-skewed distribution for numbers 1-100. That is to say, it has a long tail and a peak.

大致情况:

pers = np.arange(1,101,1)
prob = <left-skewed distribution>
number = np.random.choice(pers, 1, p=prob)

我不知道如何生成左偏离散概率函数.有任何想法吗?谢谢!

I do not know how to generate a left-skewed discrete probability function. Any ideas? Thanks!

推荐答案

就像你描述的那样,只要确保你的偏斜分布加起来等于 1.0:

Like you described, just make sure your skewed-distribution adds up to 1.0:

pers = np.arange(1,101,1)

# Make each of the last 41 elements 5x more likely
prob = [1.0]*(len(pers)-41) + [5.0]*41

# Normalising to 1.0
prob /= np.sum(prob)

number = np.random.choice(pers, 1, p=prob)

这篇关于创建具有左偏概率分布的随机数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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