I've been working to learn about the Gaussian Function, Probability Density Functions, and Cumulative Distribution Functions.
https://en.wikipedia.org/wiki/Gaussian_function
https://en.wikipedia.org/wiki/Probability_density_function
https://en.wikipedia.org/wiki/Cumulative_distribution_function
From my understanding you have the Gaussian function:
and the integral of the Gaussian function is only equal to 1 when
a = 1/(c * sqrt(2pi))
In this case, it can be used as a probability density function with normally distributed values. (This form is used for statistical analysis)
b = mu (mean)
c^2 = sigma^2 (standard deviation squared or the variance)
The above is the relation of the variables of the regular Gaussian function to that of the Normal Distribution (as it's used in statistics).
I've never taken a statistics class, so forgive me if I'm wrong on something. Most of the information here is from the wiki page or other resources I was reading to learn from.
My goal is to write a function which utilizes the normalized Gaussian function to make a method that returns a random Gaussian number. By doing so it would return numbers closer to the mean more often than those that are farther away.
What I tried to do was write a function for the standard Gaussian function, another function for the normalized Gaussian function and then a function that returns a random Gaussian number:
/**
*
* @param a - Absolute maximum
* @param b - Mean or center point
* @param c - Standard deviation or width
* @param x - x-value along the gaussian function
* @return corresponding y-value along the gaussian function
*/
public static double gaussian(double a, double b, double c, double x) {
return a * Math.exp( -Math.pow(x-b, 2) / (2 * Math.pow(c, 2)) );
}
/**
*
* @param mu - Mean or center point
* @param sigma - Standard deviation or width
* @param x - x-value along the gaussian function
* @return corresponding y-value along the gaussian function
*/
public static double gaussianNormalized(double mu, double sigma, double x) {
return gaussian( 1 / (sigma * Math.sqrt(2 * Math.PI)), mu, sigma, x);
}
My issue is that the numbers it provides will always be distributed in an equal fashion to that of the Java Random class which is not what I'm looking for.
How can I go about returning numbers that conform to a normalized Gaussian function distribution? am I going about this in the wrong way?