Computes the membership function evaluated at `x`

@param x
@return ` h \times \exp(-(x-\mu)^2/(2\sigma^2))`

where `h` is the height of the Term,
`\mu` is the mean of the Gaussian,
`\sigma` is the standard deviation of the Gaussian
519122
@Override
    public double membership(double x) {
        if (Double.isNaN(x)) {
            return Double.NaN;
        }
        return height * Math.exp((-(x - mean) * (x - mean))
                / (2.0 * standardDeviation * standardDeviation));
    }
808510
def function(self, x, y, amp, sigma_x, sigma_y, center_x=0, center_y=0):
        
        c = amp/(2*np.pi*sigma_x*sigma_y)
        delta_x = x - center_x
        delta_y = y - center_y
        exponent = -((delta_x/sigma_x)**2+(delta_y/sigma_y)**2)/2.
        return c * np.exp(exponent)
76466
public static double standardDeviation(double[] x, double mean) {
        if (x.length == 0) {
            return Double.NaN;
        }
        if (x.length == 1) {
            return 0.0;
        }
        return Math.sqrt(variance(x, mean));
    }
1084462
def funcGauss1D(x, mu, sig):
    
    arrOut = np.exp(-np.power((x - mu)/sig, 2.)/2)
    # normalize
    arrOut = arrOut/(np.sqrt(2.*np.pi)*sig)

    return arrOut
1089626
def log_normal(self, x):
        
        d = self.mu.shape[0]
        xc = x - self.mu
        if len(x.shape) == 1:
            exp_term = numpy.sum(numpy.multiply(xc, numpy.dot(self.inv, xc)))
        else:
            exp_term = numpy.sum(numpy.multiply(xc, numpy.dot(xc, self.inv)), axis=1)

        return -.5 * (d * numpy.log(2 * numpy.pi) + numpy.log(self.det) + exp_term)
699394
private static double snorm(double[] x, int itol) {
        int n = x.length;

        if (itol <= 3) {
            double ans = 0.0;
            for (int i = 0; i < n; i++) {
                ans += x[i] * x[i];
            }
            return Math.sqrt(ans);
        } else {
            int isamax = 0;
            for (int i = 0; i < n; i++) {
                if (Math.abs(x[i]) > Math.abs(x[isamax])) {
                    isamax = i;
                }
            }

            return Math.abs(x[isamax]);
        }
    }
1237663
private void calculateSCL(double[] x) {
    //System.out.println("Checking at: "+x[0]+" "+x[1]+" "+x[2]);
    value = 0.0;
    Arrays.fill(derivative, 0.0);
    double[] sums = new double[numClasses];
    double[] probs = new double[numClasses];
    double[] counts = new double[numClasses];
    Arrays.fill(counts, 0.0);
    for (int d = 0; d < data.length; d++) {
      //       if (d == testMin) {
      //         d = testMax - 1;
      //         continue;
      //       }
      int[] features = data[d];
      // activation
      Arrays.fill(sums, 0.0);
      for (int c = 0; c < numClasses; c++) {
        for (int f = 0; f < features.length; f++) {
          int i = indexOf(features[f], c);
          sums[c] += x[i];
        }
      }
      // expectation (slower routine replaced by fast way)
      // double total = Double.NEGATIVE_INFINITY;
      // for (int c=0; c<numClasses; c++) {
      //   total = SloppyMath.logAdd(total, sums[c]);
      // }
      double total = ArrayMath.logSum(sums);
      int ld = labels[d];
      for (int c = 0; c < numClasses; c++) {
        probs[c] = Math.exp(sums[c] - total);
        for (int f = 0; f < features.length; f++) {
          int i = indexOf(features[f], c);
          derivative[i] += probs[ld] * probs[c];
        }
      }
      // observed
      for (int f = 0; f < features.length; f++) {
        int i = indexOf(features[f], labels[d]);
        derivative[i] -= probs[ld];
      }
      value -= probs[ld];
    }
    // priors
    if (true) {
      for (int i = 0; i < x.length; i++) {
        double k = 1.0;
        double w = x[i];
        value += k * w * w / 2.0;
        derivative[i] += k * w;
      }
    }
  }
664730
public static double Function(double x) {
        double[] P =
                {
                        1.60119522476751861407E-4,
                        1.19135147006586384913E-3,
                        1.04213797561761569935E-2,
                        4.76367800457137231464E-2,
                        2.07448227648435975150E-1,
                        4.94214826801497100753E-1,
                        9.99999999999999996796E-1
                };
        double[] Q =
                {
                        -2.31581873324120129819E-5,
                        5.39605580493303397842E-4,
                        -4.45641913851797240494E-3,
                        1.18139785222060435552E-2,
                        3.58236398605498653373E-2,
                        -2.34591795718243348568E-1,
                        7.14304917030273074085E-2,
                        1.00000000000000000320E0
                };

        double p, z;

        double q = Math.abs(x);

        if (q > 33.0) {
            if (x < 0.0) {
                p = Math.floor(q);

                if (p == q) {
                    try {
                        throw new ArithmeticException("Overflow");
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }

                z = q - p;
                if (z > 0.5) {
                    p += 1.0;
                    z = q - p;
                }
                z = q * Math.sin(Math.PI * z);

                if (z == 0.0) {
                    try {
                        throw new ArithmeticException("Overflow");
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }

                z = Math.abs(z);
                z = Math.PI / (z * Stirling(q));

                return -z;
            } else {
                return Stirling(x);
            }
        }

        z = 1.0;
        while (x >= 3.0) {
            x -= 1.0;
            z *= x;
        }

        while (x < 0.0) {
            if (x == 0.0) {
                throw new ArithmeticException();
            } else if (x > -1.0E-9) {
                return (z / ((1.0 + 0.5772156649015329 * x) * x));
            }
            z /= x;
            x += 1.0;
        }

        while (x < 2.0) {
            if (x == 0.0) {
                throw new ArithmeticException();
            } else if (x < 1.0E-9) {
                return (z / ((1.0 + 0.5772156649015329 * x) * x));
            }

            z /= x;
            x += 1.0;
        }

        if ((x == 2.0) || (x == 3.0)) return z;

        x -= 2.0;
        p = Special.Polevl(x, P, 6);
        q = Special.Polevl(x, Q, 7);
        return z * p / q;

    }
793811
private static double getEpsilon(IntDoubleVector x, IntDoubleVector d) {
        double machineEpsilon = 2.2204460492503131e-16;
        double xInfNorm = DoubleArrays.infinityNorm(x.toNativeArray());
        double dInfNorm = DoubleArrays.infinityNorm(d.toNativeArray());
        return machineEpsilon * (1.0 + xInfNorm) / dInfNorm;
    }
1080765
@Override
    public double membership(double x) {
        double result = 0;
        List<InputVariable> inputVariables = engine.getInputVariables();
        final int numberOfVariables = inputVariables.size();
        final int numberOfCoefficients = coefficients.size();
        for (int i = 0; i < numberOfVariables; ++i) {
            if (i < numberOfCoefficients) {
                result += coefficients.get(i) * inputVariables.get(i).getValue();
            }
        }
        if (numberOfCoefficients > numberOfVariables) {
            result += coefficients.get(numberOfCoefficients - 1);
        }
        return result;
    }
229248
public static double HighAccuracyFunction(double x) {
        if (x < -8 || x > 8)
            return 0;

        double sum = x;
        double term = 0;

        double nextTerm = x;
        double pwr = x * x;
        double i = 1;

        // Iterate until adding next terms doesn't produce
        // any change within the current numerical accuracy.

        while (sum != term) {
            term = sum;

            // Next term
            nextTerm *= pwr / (i += 2);

            sum += nextTerm;
        }

        return 0.5 + sum * Math.exp(-0.5 * pwr - 0.5 * Constants.Log2PI);
    }
532680
public double Function2D(double x, double y) {
        return Math.exp(-(x * x + y * y) / (2 * sqrSigma)) / (2 * Math.PI * sqrSigma);
    }
52675
private double normPDF(double x) {
        return Math.exp(-x*x / 2) / (Math.sqrt(2 * Math.PI));
    }
966273
public double[] getStandardComponents(double[] x){
		if(x.length != originalN){
			throw new IllegalArgumentException("wrong array dimension: " + x.length);
		}
		double[] ret = new double[standardN];
		for(int i=0; i<x.length; i++){
			if (splittedVariablesList.contains(i)) {
				// this variable was splitted: x = xPlus-xMinus
				if(x[i] >= 0){
					//value for xPlus
					ret[standardS + i] = x[i];
				}else{
					int pos = -1;
					for(int k=0; k<splittedVariablesList.size(); k++){
						if(splittedVariablesList.get(k)==i){
							pos = k;
							break;
						}
					}
					//value for xMinus
					ret[standardS + x.length + pos] = -x[i];
				}
			}else{
				ret[standardS + i] = x[i];
			}
		}
		if(standardS>0){
			DoubleMatrix1D residuals = ColtUtils.zMult(standardA, F1.make(ret), standardB, -1);
			for(int i=0; i<standardS; i++){
				ret[i] = -residuals.get(i) + ret[i];
			}
		}
		return ret;
	}
1231112
public double[] presolve(double[] x){
		if(x.length != originalN){
			throw new IllegalArgumentException("wrong array dimension: " + x.length);
		}
		double[] presolvedX = Arrays.copyOf(x, x.length);
		for(int i=0; i<presolvingStack.size(); i++){
			presolvingStack.get(i).preSolve(presolvedX);
		}
		double[] ret = new double[presolvedN];
		int cntPosition = 0;
		for(int i=0; i<presolvedX.length; i++){
			if(indipendentVariables[i]){
				ret[cntPosition] = presolvedX[i];
				cntPosition++;
			}
		}
		if(this.T != null){
			//rescaling has been done: x = T.x1
			for(int i=0; i<ret.length; i++){
				ret[i] = ret[i] / T.getQuick(i);
			}
		}
		return ret;
	}
908967
def evaluate(x, amplitude, mean, stddev):
        
        return 1.0 - Gaussian1D.evaluate(x, amplitude, mean, stddev)
923780
public static double gaussian() {
    // use the polar form of the Box-Muller transform
    double r, x, y;
    do {
      x = uniform(-1.0, 1.0);
      y = uniform(-1.0, 1.0);
      r = x * x + y * y;
    }
    while (r >= 1 || r == 0);
    return x * Math.sqrt(-2 * Math.log(r) / r);

    // Remark: y * Math.sqrt(-2 * Math.log(r) / r)
    // is an independent random gaussian
  }