Beispiel #1
0
 /**
  * Computes the ouput of a RBF
  *
  * @param _input Input vector
  * @return The ouput of a RBF
  */
 public double evaluationRbf(double[] _input) {
   double aux;
   aux = RBFUtils.euclidean(_input, centre);
   aux *= aux;
   aux /= (2.0 * radius * radius);
   return (Math.exp(-aux));
 }
Beispiel #2
0
 /**
  * Chi square distribution
  *
  * @param x Chi^2 value
  * @param n Degrees of freedom
  * @return P-value associated
  */
 private static double ChiSq(double x, int n) {
   if (n == 1 & x > 1000) {
     return 0;
   }
   if (x > 1000 | n > 1000) {
     double q = ChiSq((x - n) * (x - n) / (2 * n), 1) / 2;
     if (x > n) {
       return q;
     }
     {
       return 1 - q;
     }
   }
   double p = Math.exp(-0.5 * x);
   if ((n % 2) == 1) {
     p = p * Math.sqrt(2 * x / Math.PI);
   }
   double k = n;
   while (k >= 2) {
     p = p * x / k;
     k = k - 2;
   }
   double t = p;
   double a = n;
   while (t > 0.0000000001 * p) {
     a = a + 2;
     t = t * x / a;
     p = p + t;
   }
   return 1 - p;
 }
Beispiel #3
0
  /**
   * It calculate the matching degree between the antecedent of the rule and a given example
   *
   * @param indiv Individual The individual representing a fuzzy rule
   * @param ejemplo double [] A given example
   * @return double The matching degree between the example and the antecedent of the rule
   */
  double Matching_degree(Individual indiv, double[] ejemplo) {
    int i, sig;
    double result, suma, numerador, denominador, sigma, ancho_intervalo;

    suma = 0.0;
    for (i = 0; i < entradas; i++) {
      ancho_intervalo = train.getMax(i) - train.getMin(i);

      sigma = -1.0;
      sig = indiv.antecedente[i].sigma;
      switch (sig) {
        case 1:
          sigma = 0.3;
          break;
        case 2:
          sigma = 0.4;
          break;
        case 3:
          sigma = 0.5;
          break;
        case 4:
          sigma = 0.6;
          break;
      }

      sigma *= ancho_intervalo;

      numerador = Math.pow((ejemplo[i] - indiv.antecedente[i].m), 2.0);
      denominador = Math.pow(sigma, 2.0);
      suma += (numerador / denominador);
    }

    suma *= -1.0;
    result = Math.exp(suma);

    return (result);
  }