Class: Cicada::P3DFitter

Inherits:
DistributionFitter show all
Defined in:
lib/cicada/fitting/p3d_fitter.rb

Overview

A distribution fitter that fits data to a P3D distribution.

Constant Summary collapse

REQUIRED_PARAMETERS =

parameters required by the methods in this class

[]
OPTIONAL_PARAMETERS =

parmeters used but not required in this class or only required for optional functionality

[:robust_p3d_fit_cutoff]

Instance Attribute Summary

Attributes inherited from DistributionFitter

#parameters

Instance Method Summary collapse

Methods inherited from DistributionFitter

#initialize

Constructor Details

This class inherits a constructor from Cicada::DistributionFitter

Instance Method Details

#fit(objects, diffs) ⇒ Array

Fits the P3D mean- and standard-deviation-like parameters to the data.

Parameters:

  • objects (Array<ImageObject>)

    the image objects whose distances are being fit

  • diffs (Array<Numeric>)

    the distances being fit

Returns:

  • (Array)

    a two-element array containing the mean- and standard-deviation-like parameters.



173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# File 'lib/cicada/fitting/p3d_fitter.rb', line 173

def fit(objects, diffs)
  of = P3DObjectiveFunction.new
  of.r = diffs
  tol = 1e-12
  nmm = Java::edu.stanford.cfuller.imageanalysistools.fitting.NelderMeadMinimizer.new(tol)
  initial_mean = Math.mean(diffs)
  initial_width = Math.std(diffs)
  starting_point = Java::org.apache.commons.math3.linear.ArrayRealVector.new(2, 0.0)
  starting_point.setEntry(0, initial_mean)
  starting_point.setEntry(1, initial_width)
  if @parameters[:robust_p3d_fit_cutoff] then  
    of.min_prob= @parmaeters[:robust_p3d_fit_cutoff].to_f
  end

  nmm.optimize(of, starting_point).toArray.to_a
end