How to compute (negative binomial) distribution PDF and CDF in C++?How do you declare an interface in C++?How can I profile C++ code running on Linux?Random numbers from binomial distributionGenerate random numbers with a given (numerical) distributionC++11 introduced a standardized memory model. What does it mean? And how is it going to affect C++ programming?Getting a random draw from the binomial distribution based on a sample statisticHow to calculate the cumulative density function of a sum of random variables in C++?How to random sample lognormal data in Python using the inverse CDF and specify target percentiles?How to succinctly, portably, and thoroughly seed the mt19937 PRNG?Generate random variable with known PDF expression in MATLAB
Why don't countries like Japan just print more money?
How does a blind passenger not die, if driver becomes unconscious
Ndsolve problem with Sign (friction)
Why are < or > required to use /dev/tcp
Greeting with "Ho"
What's currently blocking the construction of the wall between Mexico and the US?
Is there a way, while dragging, to "snap" to the nearest guide?
Minor traveling without parents from USA to Sweden
Helping ease my back pain when I'm studying 13 hours everyday, even weekends
Are all Ringwraiths called Nazgûl in LotR?
What can I do with a research project that is my university’s intellectual property?
Is "Busen" just the area between the breasts?
Non-flat partitions of a set
What does the hyphen "-" mean in "tar xzf -"?
Trainee keeps missing deadlines for independent learning
If plants "alternate generations" between sporophytes and gametophytes, why don't we say the same of humans?
How does the spell Remove Curse interact with a Sword of Vengeance?
Methodology: Writing unit tests for another developer
Explain why a line can never intersect a plane in exactly two points.
Does a vocal melody have any rhythmic responsibility to the underlying arrangement in pop music?
If I wouldn't want to read the story, is writing it still a good idea?
Understanding the reasoning of the woman who agreed with King Solomon to "cut the baby in half"
Do I have any obligations to my PhD supervisor's requests after I have graduated?
How would modern naval warfare have to have developed differently for battleships to still be relevant in the 21st century?
How to compute (negative binomial) distribution PDF and CDF in C++?
How do you declare an interface in C++?How can I profile C++ code running on Linux?Random numbers from binomial distributionGenerate random numbers with a given (numerical) distributionC++11 introduced a standardized memory model. What does it mean? And how is it going to affect C++ programming?Getting a random draw from the binomial distribution based on a sample statisticHow to calculate the cumulative density function of a sum of random variables in C++?How to random sample lognormal data in Python using the inverse CDF and specify target percentiles?How to succinctly, portably, and thoroughly seed the mt19937 PRNG?Generate random variable with known PDF expression in MATLAB
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
STD has many distributions, that apparently are used to generate pseudo random variables, see e.g. below code that generates and outputs some negative binomial distributed numbers.
Now this might mean that internally, there is code that computes the CDF and or PDF of the negative binomial distribution, i.e. the probability that the random variable takes on a certain value, e.g. 6. Is there a way to output that probability? If yes, how? I know I could run my own code for that, but I'd rather not do that if it there is some way to get the probabilities from std.
If possible, same question for other distributions, e.g. CDF of gamma distribution.
int main()
std::negative_binomial_distribution<int> negBin 5,0.5 ;//Negative binomial distribution
std::mt19937 RNG(260783);//Random generator
for (size_t i = 0; i < 4; i++)
std::cout << negBin(RNG) << std::endl;
return 0;
c++ random
add a comment |
STD has many distributions, that apparently are used to generate pseudo random variables, see e.g. below code that generates and outputs some negative binomial distributed numbers.
Now this might mean that internally, there is code that computes the CDF and or PDF of the negative binomial distribution, i.e. the probability that the random variable takes on a certain value, e.g. 6. Is there a way to output that probability? If yes, how? I know I could run my own code for that, but I'd rather not do that if it there is some way to get the probabilities from std.
If possible, same question for other distributions, e.g. CDF of gamma distribution.
int main()
std::negative_binomial_distribution<int> negBin 5,0.5 ;//Negative binomial distribution
std::mt19937 RNG(260783);//Random generator
for (size_t i = 0; i < 4; i++)
std::cout << negBin(RNG) << std::endl;
return 0;
c++ random
You can find the probability for standard distributions using the formula for the pmf. See this wiki page for negative binomial. And, see Inverse transform sampling to learn how one can generate samples following a given distribution. I don't know which method the std random is using.
– dhanushka
Mar 25 at 10:48
add a comment |
STD has many distributions, that apparently are used to generate pseudo random variables, see e.g. below code that generates and outputs some negative binomial distributed numbers.
Now this might mean that internally, there is code that computes the CDF and or PDF of the negative binomial distribution, i.e. the probability that the random variable takes on a certain value, e.g. 6. Is there a way to output that probability? If yes, how? I know I could run my own code for that, but I'd rather not do that if it there is some way to get the probabilities from std.
If possible, same question for other distributions, e.g. CDF of gamma distribution.
int main()
std::negative_binomial_distribution<int> negBin 5,0.5 ;//Negative binomial distribution
std::mt19937 RNG(260783);//Random generator
for (size_t i = 0; i < 4; i++)
std::cout << negBin(RNG) << std::endl;
return 0;
c++ random
STD has many distributions, that apparently are used to generate pseudo random variables, see e.g. below code that generates and outputs some negative binomial distributed numbers.
Now this might mean that internally, there is code that computes the CDF and or PDF of the negative binomial distribution, i.e. the probability that the random variable takes on a certain value, e.g. 6. Is there a way to output that probability? If yes, how? I know I could run my own code for that, but I'd rather not do that if it there is some way to get the probabilities from std.
If possible, same question for other distributions, e.g. CDF of gamma distribution.
int main()
std::negative_binomial_distribution<int> negBin 5,0.5 ;//Negative binomial distribution
std::mt19937 RNG(260783);//Random generator
for (size_t i = 0; i < 4; i++)
std::cout << negBin(RNG) << std::endl;
return 0;
c++ random
c++ random
asked Mar 25 at 8:23
willemwillem
1,27431736
1,27431736
You can find the probability for standard distributions using the formula for the pmf. See this wiki page for negative binomial. And, see Inverse transform sampling to learn how one can generate samples following a given distribution. I don't know which method the std random is using.
– dhanushka
Mar 25 at 10:48
add a comment |
You can find the probability for standard distributions using the formula for the pmf. See this wiki page for negative binomial. And, see Inverse transform sampling to learn how one can generate samples following a given distribution. I don't know which method the std random is using.
– dhanushka
Mar 25 at 10:48
You can find the probability for standard distributions using the formula for the pmf. See this wiki page for negative binomial. And, see Inverse transform sampling to learn how one can generate samples following a given distribution. I don't know which method the std random is using.
– dhanushka
Mar 25 at 10:48
You can find the probability for standard distributions using the formula for the pmf. See this wiki page for negative binomial. And, see Inverse transform sampling to learn how one can generate samples following a given distribution. I don't know which method the std random is using.
– dhanushka
Mar 25 at 10:48
add a comment |
2 Answers
2
active
oldest
votes
The standard doesn't specify how an implementation should implement the distribution, other than that sampling from it should take an amortised constant number of samples from the Generator.
None of the members provide either the CDF or PDF
add a comment |
might mean that internally, there is code that computes the CDF and or PDF of the negative binomial distribution, i.e. the probability that the random variable takes on a certain value, e.g. 6. Is there a way to output that probability?
In general, no, sampling does not require to know PDF and/or CDF, see f.e. Marsaglia method(s) to sample normally distributed RV.
I could propose to take a look at GNU Scientific Library, it has sampling methods as well as PDF and CDF for negative binomial:
https://www.gnu.org/software/gsl/manual/html_node/The-Negative-Binomial-Distribution.html
Thanks. I actually ended up using boost, which also has the desired functionaty. Btw I was well aware that sampling does not necesarily require the probs (hence "might"). But since I found on the internet that the boost library, which has similar syntax, does provide the PDF function, I thought I might just have missed something.
– willem
Mar 26 at 7:25
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55333709%2fhow-to-compute-negative-binomial-distribution-pdf-and-cdf-in-c%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
The standard doesn't specify how an implementation should implement the distribution, other than that sampling from it should take an amortised constant number of samples from the Generator.
None of the members provide either the CDF or PDF
add a comment |
The standard doesn't specify how an implementation should implement the distribution, other than that sampling from it should take an amortised constant number of samples from the Generator.
None of the members provide either the CDF or PDF
add a comment |
The standard doesn't specify how an implementation should implement the distribution, other than that sampling from it should take an amortised constant number of samples from the Generator.
None of the members provide either the CDF or PDF
The standard doesn't specify how an implementation should implement the distribution, other than that sampling from it should take an amortised constant number of samples from the Generator.
None of the members provide either the CDF or PDF
answered Mar 25 at 9:34
CalethCaleth
20.8k22344
20.8k22344
add a comment |
add a comment |
might mean that internally, there is code that computes the CDF and or PDF of the negative binomial distribution, i.e. the probability that the random variable takes on a certain value, e.g. 6. Is there a way to output that probability?
In general, no, sampling does not require to know PDF and/or CDF, see f.e. Marsaglia method(s) to sample normally distributed RV.
I could propose to take a look at GNU Scientific Library, it has sampling methods as well as PDF and CDF for negative binomial:
https://www.gnu.org/software/gsl/manual/html_node/The-Negative-Binomial-Distribution.html
Thanks. I actually ended up using boost, which also has the desired functionaty. Btw I was well aware that sampling does not necesarily require the probs (hence "might"). But since I found on the internet that the boost library, which has similar syntax, does provide the PDF function, I thought I might just have missed something.
– willem
Mar 26 at 7:25
add a comment |
might mean that internally, there is code that computes the CDF and or PDF of the negative binomial distribution, i.e. the probability that the random variable takes on a certain value, e.g. 6. Is there a way to output that probability?
In general, no, sampling does not require to know PDF and/or CDF, see f.e. Marsaglia method(s) to sample normally distributed RV.
I could propose to take a look at GNU Scientific Library, it has sampling methods as well as PDF and CDF for negative binomial:
https://www.gnu.org/software/gsl/manual/html_node/The-Negative-Binomial-Distribution.html
Thanks. I actually ended up using boost, which also has the desired functionaty. Btw I was well aware that sampling does not necesarily require the probs (hence "might"). But since I found on the internet that the boost library, which has similar syntax, does provide the PDF function, I thought I might just have missed something.
– willem
Mar 26 at 7:25
add a comment |
might mean that internally, there is code that computes the CDF and or PDF of the negative binomial distribution, i.e. the probability that the random variable takes on a certain value, e.g. 6. Is there a way to output that probability?
In general, no, sampling does not require to know PDF and/or CDF, see f.e. Marsaglia method(s) to sample normally distributed RV.
I could propose to take a look at GNU Scientific Library, it has sampling methods as well as PDF and CDF for negative binomial:
https://www.gnu.org/software/gsl/manual/html_node/The-Negative-Binomial-Distribution.html
might mean that internally, there is code that computes the CDF and or PDF of the negative binomial distribution, i.e. the probability that the random variable takes on a certain value, e.g. 6. Is there a way to output that probability?
In general, no, sampling does not require to know PDF and/or CDF, see f.e. Marsaglia method(s) to sample normally distributed RV.
I could propose to take a look at GNU Scientific Library, it has sampling methods as well as PDF and CDF for negative binomial:
https://www.gnu.org/software/gsl/manual/html_node/The-Negative-Binomial-Distribution.html
answered Mar 25 at 16:47
Severin PappadeuxSeverin Pappadeux
10.8k21535
10.8k21535
Thanks. I actually ended up using boost, which also has the desired functionaty. Btw I was well aware that sampling does not necesarily require the probs (hence "might"). But since I found on the internet that the boost library, which has similar syntax, does provide the PDF function, I thought I might just have missed something.
– willem
Mar 26 at 7:25
add a comment |
Thanks. I actually ended up using boost, which also has the desired functionaty. Btw I was well aware that sampling does not necesarily require the probs (hence "might"). But since I found on the internet that the boost library, which has similar syntax, does provide the PDF function, I thought I might just have missed something.
– willem
Mar 26 at 7:25
Thanks. I actually ended up using boost, which also has the desired functionaty. Btw I was well aware that sampling does not necesarily require the probs (hence "might"). But since I found on the internet that the boost library, which has similar syntax, does provide the PDF function, I thought I might just have missed something.
– willem
Mar 26 at 7:25
Thanks. I actually ended up using boost, which also has the desired functionaty. Btw I was well aware that sampling does not necesarily require the probs (hence "might"). But since I found on the internet that the boost library, which has similar syntax, does provide the PDF function, I thought I might just have missed something.
– willem
Mar 26 at 7:25
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55333709%2fhow-to-compute-negative-binomial-distribution-pdf-and-cdf-in-c%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You can find the probability for standard distributions using the formula for the pmf. See this wiki page for negative binomial. And, see Inverse transform sampling to learn how one can generate samples following a given distribution. I don't know which method the std random is using.
– dhanushka
Mar 25 at 10:48