NEWS: Total Picture Views: 147066 | Total Article Views: 155641 | Top 5 Most Popular Article: 1. Am I Stuck Algorithm with Becker Robot | 2. How to read a JSON and work with it | 3. PickUpThings with Becker Robot | 4. Encrypted Data GUI (Download .Zip) | 5. Create Wall and Things with Becker

Normal Distribution Formula Java

Description:

In this example I'll show you how to incorportate the normal distribution.

Code:

public class NormalDistribution {
	public static double PDF(double x) //returns the probability density function, PDF(x)
	{ 
		double PDFtemp = (1/Math.sqrt(2*Math.PI)) * Math.exp(-(x*x)/2); 
		return PDFtemp;
	} 

	public static double AREA(double x)//returns the area under PDF(x) from 0 to x
	{ 
		double AREAtemp = 0; //initial area under PDF(x)=0 double dx = x/1000000; //width dx
		for (double i=0; i< x; i+=dx) //for steps of size dx
		{
			AREAtemp += dx * PDF(i+dx/2);
		} //add width*height to the area under the PDF(x) } 
		return AREAtemp;
	{ //show outputs for x=1.00, x=1.645, x=1.96, and x=2.33 
	System.out.println(AREA(1)); 
	System.out.println(AREA(1.645)); 
	System.out.println(AREA(1.96)); 
	System.out.println(AREA(2.33));
}
Attachments: None

Tags: PDF For loop Normal Distribution

Total Views: 1063

My name is Jean-Mathieu

I created this website so other people could enjoy finding useful stuff easier. If you have any question do not hesitate to contact me.

jean8mathieuCreated on 04/23/15


affiliate_link

Disclosure: We are a website that needs compensation to operate like any other website on the internet.
We may receive consideration for our reviews but we are totally unbiased and do not accept paid reviews or fake reviews claiming to be something they are not.