Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Qs on randSizeBiasedNegativeBinomial() #3

Open
t-pollington opened this issue Jan 21, 2021 · 0 comments
Open

Qs on randSizeBiasedNegativeBinomial() #3

t-pollington opened this issue Jan 21, 2021 · 0 comments

Comments

@t-pollington
Copy link
Contributor

Questions for @LloydChapman added as comments

function randSizeBiasedNegativeBinomial(r,p,n)
    @argcheck isa(r, Int) & (r ≥ 1)
    @argcheck (p ≤ 1) & (p ≥ 0)
    @argcheck isa(n, Int) & (n ≥ 1)
    u = rand(MersenneTwister(),n,1)
    mu = r*(1-p)/p + 1 # why is +1 necessary? Because the support starts from 0?
    M = repeat(transpose(1:100),n,1) # why is size(M,2) set at 100?
    x = sum(cumsum((1 .- cdf.(NegativeBinomial(r,p),M.-2)),dims=2)/mu .<= repeat(u,1,size(M,2)), dims=2) .+ 1 # why M.-2 and why .+ 1 
    return x
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant