All Downloads are FREE. Search and download functionalities are using the official Maven repository.

smile.math.rbf.GaussianRadialBasis Maven / Gradle / Ivy

There is a newer version: 4.2.0
Show newest version
/*
 * Copyright (c) 2010-2021 Haifeng Li. All rights reserved.
 *
 * Smile is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Smile is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Smile.  If not, see .
 */

package smile.math.rbf;

import java.io.Serial;

/**
 * Gaussian RBF. φ(r) = exp(-0.5 * r2 / r02)
 * where r0 is a scale factor. The interpolation accuracy using
 * Gaussian basis functions can be very sensitive to r0, and they
 * are often avoided for this reason. However, for smooth functions and with
 * an optimal r0, very high accuracy can be achieved. The Gaussian
 * also will extrapolate any function to zero far from the data, and it gets
 * to zero quickly.
 * 

* In general, r0 should be larger than the typical separation of * points but smaller than the "outer scale" or feature size of the function * to interplate. There can be several orders of magnitude difference between * the interpolation accuracy with a good choice for r0, versus a * poor choice, so it is definitely worth some experimentation. One way to * experiment is to construct an RBF interpolator omitting one data point * at a time and measuring the interpolation error at the omitted point. * *

References

*
    *
  1. Nabil Benoudjit and Michel Verleysen. On the kernel widths in radial-basis function networks. Neural Process, 2003.
  2. *
* * @author Haifeng Li */ public class GaussianRadialBasis implements RadialBasisFunction { @Serial private static final long serialVersionUID = 1L; /** * The scale factor. */ private final double r0; /** * Constructor. The default scale is 1.0. */ public GaussianRadialBasis() { this(1.0); } /** * Constructor. * * @param scale the scale parameter. */ public GaussianRadialBasis(double scale) { r0 = scale; } @Override public double f(double r) { r /= r0; return Math.exp(-0.5 * r * r); } @Override public String toString() { return String.format("Gaussian Radial Basis (r0 = %.4f)", r0); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy