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;








6















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;










share|improve this question






















  • 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

















6















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;










share|improve this question






















  • 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













6












6








6








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;










share|improve this question














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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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

















  • 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












2 Answers
2






active

oldest

votes


















1














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






share|improve this answer






























    0















    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






    share|improve this answer























    • 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













    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
    );



    );













    draft saved

    draft discarded


















    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









    1














    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






    share|improve this answer



























      1














      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






      share|improve this answer

























        1












        1








        1







        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






        share|improve this answer













        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







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 25 at 9:34









        CalethCaleth

        20.8k22344




        20.8k22344























            0















            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






            share|improve this answer























            • 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















            0















            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






            share|improve this answer























            • 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













            0












            0








            0








            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






            share|improve this answer














            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







            share|improve this answer












            share|improve this answer



            share|improve this answer










            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

















            • 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

















            draft saved

            draft discarded
















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

            용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

            155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해