Java Utililty Methods Gauss

List of utility methods to do Gauss

Description

The list of methods to do Gauss are organized into topic(s).

Method

double[]gaussian(double[] d, double sigma, double mean)
gaussian
double[] ret = new double[d.length];
for (int i = 0; i < d.length; i++) {
    ret[i] = gaussian(d[i], sigma, mean);
return ret;
double[]gaussian(double[][] A, double[] b)
GaussianElimination
int N = b.length;
for (int p = 0; p < N; p++) {
    int max = p;
    for (int i = p + 1; i < N; i++) {
        if (Math.abs(A[i][p]) > Math.abs(A[max][p])) {
            max = i;
    double[] temp = A[p];
    A[p] = A[max];
    A[max] = temp;
    double t = b[p];
    b[p] = b[max];
    b[max] = t;
    for (int i = p + 1; i < N; i++) {
        double alpha = A[i][p] / A[p][p];
        b[i] -= alpha * b[p];
        for (int j = p; j < N; j++) {
            A[i][j] -= alpha * A[p][j];
double[] x = new double[N];
for (int i = N - 1; i >= 0; i--) {
    double sum = 0.0;
    for (int j = i + 1; j < N; j++) {
        sum += A[i][j] * x[j];
    x[i] = (b[i] - sum) / A[i][i];
return x;
floatgaussian(float x, float mean, float sd)
gaussian
float mu = mean;
float sigma = sd;
float k1 = (float) ((float) 1 / (sigma * (Math.sqrt(2 * Math.PI))));
float k2 = -1 / (2 * (sigma * sigma));
return (float) (k1 * Math.exp((x - mu) * (x - mu) * k2));
float[]gaussian(int size, double sigma)
gaussian
final float[] g = new float[size];
final int s2 = size / 2;
float sum = 0;
for (int i = 0; i < size; i++) {
    final double x = (double) (i - s2) / (double) s2;
    final float v = (float) Math.exp(-(x * x) / (2.0 * sigma * sigma));
    sum += v;
    g[i] = v;
...
voidgaussianBlur(int[][] pixels, float sigma)
gaussian Blur
int kernelSize = (int) Math.ceil(6 * sigma);
if (kernelSize % 2 == 0) {
    ++kernelSize;
if (kernelSize < 3) {
    kernelSize = 3;
float[][] kernel = new float[kernelSize][kernelSize];
...
doublegaussianDensity(double x, double mean, double standardDeviation)
This function evaluates the 1-dimensional gaussian density function with specified mean and standard deviation.
return (gaussianDensity((x - mean) / standardDeviation) / standardDeviation);
doublegaussianDerivative(double x)
gaussian Derivative
return -x * gaussian(x);
float[]gaussianFilter(float[] weights, float sigma)
Gaussian smoothing of the elements of the array "weights"
float meanFiltered[] = new float[weights.length];
int center = (int) Math.floor(sigma * 1.5) + 1;
float kernel[] = new float[(int) Math.ceil(center * 2 + 1)];
float kernelSum = 0;
for (int j = 0; j < (center * 2) + 1; j++) {
    kernel[j] = (float) (Math.exp(-0.5 * Math.pow((center - j) / sigma, 2)) / sigma
            / Math.sqrt(2 * Math.PI));
    kernelSum += kernel[j];
...
doublegaussianIntegral(double x)
gaussian Integral
if (x < -8.)
    return -.5;
if (x > 8.)
    return .5;
double xx = x * x;
double sum = 0.0, term = x;
for (int i = 3;; i += 2) {
    double next = sum + term;
...
doublegaussianPDF(double mean, double variance, double x)
gaussian PDF
double twoVariance = 2 * variance;
double probability = 1 / Math.sqrt(Math.PI * twoVariance);
probability = probability * Math.exp(-Math.pow((x - mean), 2) / twoVariance);
return probability;