Gaussian Function

The purpose of this project is to provide a computer based implementation including the gaussian funcion.
Recent CVS files may be found on the Sourceforge page: http://sourceforge.net/projects/gaussfunction/

Exemplary code snippet:
#include <math.h>

/*
 * Implementation of gaussian function in plain C
 */

float gaussfunction(float x, float mean, float sigma) {

  float buf;


  buf = x - mean;            // Substract mean

  buf = buf / sigma;         // Divide by sigma

  buf = buf * buf;           // Square result

  buf = (-0.5) * buf;        // Multiply with -0.5
  
  buf = exp(buf);            // Get exponential value

  buf = buf / sigma;         // Divide by sigma

  buf = buf / sqrt(2*M_PI);  // Divide by square root of 2 Pi

  return buf; 
}

SourceForge.net Logo