Java programming implements two-item distribution sampling or sample instance code, java two-item

Source: Internet
Author: User

Java programming implements two-item distribution sampling or sample instance code, java two-item

This article focuses on the sampling or sampling of two distributions implemented by Java programming. The following is the specific implementation code.

The following procedures sample n = 100, p = 0.9 of the two distributions, a total of 10000 samples

Package function; import org. apache. commons. math3.distribution. betaDistribution; import org. apache. commons. math3.distribution. binomialDistribution; import org. apache. commons. math3.special. gamma; public class dergamma {// sample 1000 times public static void main (String [] args) {for (int I = 0; I <1000; I ++) {System. out. println (binomialsampler (100, 0.9) ;}// two-item distributed sampling public static double binomialsampler (int trials, double p) {partition binomial = new BinomialDistribution (trials, p); return binomial. sample ();}}

Shows the result of each sampling:

The following figure shows the distribution:

Summary

The above is the full content of sample or sample instance code for implementing two distributions in Java programming. I hope it will be helpful to you. If you are interested, you can continue to refer to other related topics on this site. If you have any shortcomings, please leave a message. Thank you for your support!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.