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!