Friday, 17 November 2017

Java Program to Generate Random Numbers Using Probability Distribution Function


Code:

import java.util.Random;

public class Probability_distribution_Function_Random_Numbers 
{
    static int N = 10;
    public static void main(String args[])
    {
        Random random = new Random();
        int p=0;
        for(int i=0; i
        {
            p = random.nextInt(400);
            if(p > 360)
                System.out.println(1 + " ");
            else if(p < 0)
                System.out.println(0 + " ");
            else
                System.out.println(p*0.1/360 + " ");
        }
    }
}

Output:

The random numbers are:
0.08527777777777779 
0.07361111111111111 
0.007222222222222223 
0.08694444444444445 


0.05527777777777779 
0.0952777777777778 
0.04888888888888889 
0.016944444444444446


More Java Programs:















100+ Best Home Decoration Ideas For Christmas Day 2019 To Make Home Beautiful

Best gifts for Christmas Day | Greeting cards for Christmas Day | Gift your children a new gift on Christmas day This Christmas d...