2
我嘗試在perl中完成我在R中成功完成的任務,但很難與我的下游需求相結合。perl中的隨機二項式分佈式數據集
R中我做了以下
library("MASS")
d <- rnegbin(100000, mu = 250, theta = 2)
hist(d, breaks=1000, xlim=c(0,1000))
產生很好的圖形,我需要有一個峯值一輪180-200和尾部右側。
有人能幫助我的代碼中使用數學::隨機
我試過,但沒有得到正確的形狀perl的等效
use Math::Random qw(random_negative_binomial);
# random_negative_binomial($n, $ne, $p)
# When called in an array context, returns an array of $n outcomes
# generated from the negative binomial distribution with number of
# events $ne and probability of an event in each trial $p.
# When called in a scalar context, generates and returns only one
# such outcome as a scalar, regardless of the value of $n.
# Argument restrictions: $ne is rounded using int(), the result must be positive.
# $p must be between 0 and 1 exclusive.
# I tried different variable values but never got the right shape
my @dist = random_negative_binomial($n, $ne, $p);
什麼樣的價值觀,我需要模仿R結果? 我需要在同一範圍內的X和總體形狀相同
感謝您的幫助值,我沒有找到那個包的說明例子
斯特凡