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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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  }
Note: See TracChangeset for help on using the changeset viewer.