Class PowerLawFitter

java.lang.Object
edu.cnu.mdi.splot.fit.ALeastSquaresFitter
edu.cnu.mdi.splot.fit.PowerLawFitter
All Implemented Interfaces:
IFitStringGetter, IFitter

public final class PowerLawFitter extends ALeastSquaresFitter
Nonlinear least-squares fitter for a power law with a constant offset:
 y(x) = A * x^n + C
 

Parameter ordering

  • params[0] = A — amplitude
  • params[1] = n — exponent (real-valued, unconstrained)
  • params[2] = C — baseline offset

Typical applications

Log-log scaling laws, stellar flux vs distance, turbulence spectra, fractal relationships, and any data that appears linear on a log-log plot.

Important: domain restriction

The model A * x^n is only defined for x > 0. Any data point with x <= 0 will cause the fit to fail. If your data includes non-positive x values, shift or truncate before fitting.

Initial guess strategy

The baseline C is estimated from the smallest-y points. The offset-subtracted data is log-log linearised: fitting a line to log(y − C) vs log(x) gives n as the slope and log(A) as the intercept.

Author:
heddle
  • Field Details

    • IDX_A

      public static final int IDX_A
      Index of amplitude parameter A.
      See Also:
    • IDX_N

      public static final int IDX_N
      Index of exponent parameter n.
      See Also:
    • IDX_C

      public static final int IDX_C
      Index of baseline-offset parameter C.
      See Also:
    • PARAM_NAMES

      public static final String[] PARAM_NAMES
      Display names used in legend strings and fit summaries.
  • Constructor Details

    • PowerLawFitter

      public PowerLawFitter()
      Creates a fitter with the default Levenberg-Marquardt optimizer.
    • PowerLawFitter

      public PowerLawFitter(org.apache.commons.math3.fitting.leastsquares.LeastSquaresOptimizer optimizer)
      Creates a fitter with a custom optimizer.
      Parameters:
      optimizer - the least-squares optimizer to use (non-null)
  • Method Details