考虑累计频率的随机数函数 [英] Random number function that factors into account Cumulative Frequency

查看:125
本文介绍了考虑累计频率的随机数函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

姓氏人口普查数据集和名字出现会提供cumulative frequencyfrequency.我该如何获得一个随机名称,并选择其在现实世界中出现的可能性?

The census dataset for last name and first name occurrences provides cumulative frequency and frequency. How do I go about getting a random name with the likelyhood of it being chosen that of the occurrence in the real world?

推荐答案

只需生成0-100范围内的随机实数,然后在累积频率数据集中查找相应的条目即可.

Just generate a random real number in the 0-100 range and look for the corresponding entry in the cumulative frequency dataset.

例如,假设您的随机数为x = 19.41.查看表(按累积频率排序),找到第一个值大于或等于x

Example, say your random number gives x = 19.41. Look into the table (sorted by cumulative frequencies) and locate the first one that has a value greater or equal than x

WALLACE        0.081 19.315    106
WOODS          0.080 19.395    107
COLE           0.080 19.476    108
WEST           0.080 19.555    109
JORDAN         0.078 19.634    110

在此示例中,您获得"COLE"

in this example, you obtain 'COLE'

这篇关于考虑累计频率的随机数函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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