00001 #include <vcl_cmath.h> 00002 #include <vifa/vifa_gaussian.h> 00003 00004 float vifa_gaussian::pdf(float x) 00005 { 00006 if (sigma_ < StatEPSILON) 00007 { 00008 // Degenerate distribution: 00009 // The variance is zero, so the pdf is a unit impulse at the mean. 00010 // Return 1.0 if x == mean, and 0.0 otherwise. 00011 00012 return vcl_fabs(x - mu_) < StatEPSILON ? 1.0f : 0.0f; 00013 } 00014 else 00015 { 00016 float xp = (x - mu_) / sigma_; 00017 return norm_dens(xp) / sigma_; 00018 } 00019 } 00020 00021 00022 float vifa_gaussian::norm_dens(float x) 00023 { 00024 // Check to see if the magnitude of x is large enough to 00025 // warrant clipping the pdf to 0.0 00026 return x < -EXPLIMIT || x > EXPLIMIT ? 0.0f : 00027 float(I_SQRT_2PI * vcl_exp(-0.5 * x * x)); 00028 }
1.4.4