/* SCCS - @(#)NslGaussian.java 1.3 - 09/01/99 - 00:18:21 */ // Copyright: Copyright (c) 1997 University of Southern California Brain Project. // Copyright: This software may be freely copied provided the toplevel // Copyright: COPYRIGHT file is included with each such copy. // Copyright: Email nsl@java.usc.edu. //////////////////////////////////////////////////////////// // // Gaussian routines // // /** Gaussian routines. There are two basic format for the evaluation method in this routine: 1, eval(a) -> c a is the input parameter to pass the threshold function: (1/sqrt(2*PI*pow(sig,2)))*exp(-pow(x-mean,2)/(2*pow(sig,2))) 2. eval(dest, a) -> c a is the parameter of the threshold function and dest is the temporary space to hold the result. The method returns the reference to dest. */ //////////////////////////////////////////////////////////////////////////////// // step functions package nslj.src.math; import nslj.src.lang.*; public final class NslGaussian { // doubles private static double value(double x, double sig, double mean) { double temp=2.0*Math.pow(sig,2.0); return (1/Math.sqrt(Math.PI*temp))*Math.exp(-Math.pow(x-mean,2.0)/temp); } public static double eval(double a) { return eval(a,1,0); } public static double[] eval(double[] a) { return eval(a,1,0); } public static double[][] eval(double[][] a) { return eval(a,1,0); } public static double[][][] eval(double[][][] a) { return eval(a,1,0); } public static double[][][][] eval(double[][][][] a) { return eval(a,1,0); } public static double[] eval(double[] dest, double[] a) { return eval(dest,a,1,0); } public static double[][] eval(double[][] dest, double[][] a) { return eval(dest,a,1,0); } public static double[][][] eval(double[][][] dest, double[][][] a) { return eval(dest,a,1,0); } public static double[][][][] eval(double[][][][] dest, double[][][][] a) { return eval(dest,a,1,0); } public static double eval(double a, double sig, double mean) { return value(a, sig, mean); } public static double[] eval (double[] a, double sig, double mean) { double[] dest = new double[a.length]; return eval(dest, sig, mean); } public static double[] eval (double[] dest, double[] a, double sig, double mean) { int i; if (dest.length!=a.length) { dest = new double[a.length]; } for (i=0; i