Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/24/17 13:17:43 (7 years ago)
Author:
bwerth
Message:

#2699 checked and reformulated gradient functions for kernels

Location:
branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/KernelFunctions
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/KernelFunctions/CicularKernel.cs

    r14872 r14883  
    4747
    4848    protected override double Get(double norm) {
    49       if (norm >= Beta || Math.Abs(Beta) < double.Epsilon) return 0;
     49      if (Math.Abs(Beta) < double.Epsilon) return double.NaN;
     50      if (norm >= Beta) return 0;
    5051      var d = norm / Beta;
    5152      return Math.Acos(-d) - d * Math.Sqrt(1 - d * d) - Math.PI / 2;
     
    5354
    5455    protected override double GetGradient(double norm) {
    55       if (Beta <= 0) return double.NaN;
     56      if (Math.Abs(Beta) < double.Epsilon) return double.NaN;
    5657      if (Beta < norm) return 0;
    57       return 2 * norm * Math.Sqrt(Beta * Beta - norm * norm) / (Beta * Beta * Beta);
     58      return -2*Math.Pow(norm,3)/(Math.Pow(Beta,4)*Math.Sqrt(1-norm*norm/(Beta*Beta)));
    5859    }
    5960  }
  • branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/KernelFunctions/GaussianKernel.cs

    r14872 r14883  
    4747
    4848    protected override double Get(double norm) {
    49       if (Math.Abs(Beta) < double.Epsilon) return 0;
    50       return Math.Abs(norm) < double.Epsilon ? 1 : Math.Exp(-norm * norm / (Beta * Beta));
     49      if (Math.Abs(Beta) < double.Epsilon) return double.NaN;
     50      return Math.Exp(-norm * norm / (Beta * Beta));
    5151    }
    5252
    5353    protected override double GetGradient(double norm) {
    5454      if (Math.Abs(Beta) < double.Epsilon) return double.NaN;
    55       norm *= norm;
    56       return 2 * norm * Math.Exp(-norm / (Beta * Beta)) / (Beta * Beta * Beta);
     55      return 2 * norm * norm / Math.Pow(Beta, 3) * Math.Exp(-norm * norm / (Beta * Beta));
    5756    }
    5857  }
  • branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/KernelFunctions/InverseMultiquadraticKernel.cs

    r14872 r14883  
    4646
    4747    protected override double Get(double norm) {
    48       if (Math.Abs(Beta) < double.Epsilon) return 0;
     48      if (Math.Abs(Beta) < double.Epsilon) return double.NaN;
    4949      return 1 / Math.Sqrt(1 + norm * norm / Beta);
    5050    }
     
    5252    protected override double GetGradient(double norm) {
    5353      if (Math.Abs(Beta) < double.Epsilon) return double.NaN;
    54       norm *= norm;
    55       return norm / (2 * Beta * Beta * Math.Pow((norm + Beta) / Beta, 1.5));
     54      return norm * norm / (2 * Beta * Beta * Math.Pow((norm * norm + Beta) / Beta, 1.5));
    5655    }
    5756  }
  • branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/KernelFunctions/LaplacianKernel.cs

    r14872 r14883  
    4444
    4545    protected override double Get(double norm) {
    46       return Math.Abs(Beta) < double.Epsilon ? 0 : Math.Exp(-norm / Beta);
     46      if (Math.Abs(Beta) < double.Epsilon) return double.NaN;
     47      return Math.Exp(-norm / Beta);
    4748    }
    4849
  • branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/KernelFunctions/MultiquadraticKernel.cs

    r14872 r14883  
    4848    #endregion
    4949    protected override double Get(double norm) {
    50       return Math.Abs(Beta) < double.Epsilon ? 0 : Math.Sqrt(1 + norm * norm / Beta);
     50      if (Math.Abs(Beta) < double.Epsilon) return double.NaN;
     51      return Math.Sqrt(1 + norm * norm / Beta);
    5152    }
    5253
    5354    protected override double GetGradient(double norm) {
    5455      if (Math.Abs(Beta) < double.Epsilon) return double.NaN;
    55       norm *= norm;
    56       return -norm / (2 * Beta * Beta * Math.Sqrt((norm + Beta) / Beta));
     56      var dividend = 2 * Beta * Beta * Math.Sqrt((Beta + norm * norm) / Beta);
     57      return -norm * norm / dividend;
    5758    }
    5859  }
  • branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/KernelFunctions/PolysplineKernel.cs

    r14872 r14883  
    5252
    5353    protected override double GetGradient(double norm) {
    54       return Math.Pow(norm, Beta) * Math.Log(Beta);
     54      return Math.Pow(norm, Beta) * Math.Log(norm);
    5555    }
    5656  }
  • branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/KernelFunctions/ThinPlatePolysplineKernel.cs

    r14872 r14883  
    4646
    4747    protected override double Get(double norm) {
    48       if (Math.Pow(norm, Beta) <= 0) return 0;
    49       return Math.Pow(norm, Beta * 2) * Math.Log(1 + Math.Pow(norm, Beta));
     48      if (Math.Pow(norm, Beta) <= 0) return double.NaN;
     49      return Math.Pow(norm, 2 * Beta) * Math.Log(1 + Math.Pow(norm, Beta));
    5050    }
    5151
    5252    protected override double GetGradient(double norm) {
    5353      if (Math.Pow(norm, Beta) <= 0) return double.NaN;
    54       var ax = Math.Pow(norm, Beta);
    55       var a2x = ax * ax;
    56       var a3x = a2x * ax;
    57       var loga = Math.Log(norm);
    58       return 2 * a2x * loga * Math.Log(ax + 1) + a3x * loga / (ax + 1);
     54      return 2 * Math.Log(norm) * Math.Pow(norm, 2 * Beta) * Math.Log(1 + Math.Pow(norm, Beta)) + Math.Pow(norm, 3 * Beta) * Math.Log(norm) / (Math.Pow(norm, Beta) + 1);
    5955    }
    6056  }
Note: See TracChangeset for help on using the changeset viewer.