org.opensourcephysics.cabrillo.tracker

## Class BounceModel

• java.lang.Object
• org.opensourcephysics.cabrillo.tracker.BounceModel

• public class BounceModel
extends java.lang.Object
A LinearModelWithStep maps a parameter vector to a series of data points at equally spaced time intervals. For handling 2D data, the parameters are a num_params x 2 Matrix. This class requires the JAMA matrix package from http://math.nist.gov/javanumerics/jama Mon Oct 31 14:02:07 PDT 2011 Kevin Karplus
Author:
Kevin Karplus
• ### Constructor Summary

Constructors
Constructor and Description
BounceModel(int num_data, int deg, double when_step)
constructor for n data points using polynomial of degree d plus a Dirac delta in the acceleration (step in velocity) at time s That is, data[t] will be fitted to sum_i<=d param[i]*t**i for t=num_data-1, then it is not possible to fit an extra parameter, so it is omitted from the model, and a pure polynomial is used sum_i<=d param[i]*t**i If the time of the step is Double.NaN, then the step time is unknown and two extra parameters are needed to estimate s, which is assumed to be in range (0.5*num_data-1, 0.5*num_data).
• ### Method Summary

Methods
Modifier and Type Method and Description
double[] first_deriv(BounceMatrix model_param, double t)
return first derivatives at time t The dimensionality of the returned array of doubles is the same as the number of columns in the model_param Matrix (that would be 2 for model_param returned by fit_xy()).
BounceParameters fit_xy(double[] xData, double[] yData, int start, int index_step)
fit parameters for model to a window of (x,y) points Returned result: fitted paramters returns null if fitting is not possible, which can happen if start, start+index_step, ..., start+(num_data-1)*index_step goes out of range for either data array or xdata or ydata is Double.NaN for one of the specified points Time t=0 corresponds to subscript "start" Time t=1 to start+time_step
BounceParameters fit_xy(double[] xData, double[] yData, int start, int index_step, double initial_step_at, double[] initial_step_size)
fit parameters for model to a window of (x,y) points, with a specified step to be removed before fitting Returned result: fitted parameters, with record of extra step returns null if fitting is not possible, which can happen if start, start+index_step, ..., start+(num_data-1)*index_step goes out of range for either data array or xdata or ydata is Double.NaN for one of the specified points Time t=0 corresponds to subscript "start" Time t=1 to start+time_step
double getStepAt()
where is there a step?
double getStepAt(BounceMatrix model_param)
where is there a step? If there is a step in a model which estimates time as well as size of step, we need the model parameters to say where the step was fitted.
double[] getStepSize(BounceMatrix model_param)
return step size The dimensionality of the returned array of doubles is the same as the number of columns in the model_param Matrix (that would be 2 for model_param returned by fit_xy()).
double[] second_deriv(BounceMatrix model_param, double t)
return second derivatives at time t The dimensionality of the returned array of doubles is the same as the number of columns in the model_param Matrix (that would be 2 for model_param returned by fit_xy()).
boolean usesStep()
return use_step
• ### Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
• ### Constructor Detail

• #### BounceModel

public BounceModel(int num_data,
int deg,
double when_step)
constructor for n data points using polynomial of degree d plus a Dirac delta in the acceleration (step in velocity) at time s That is, data[t] will be fitted to sum_i<=d param[i]*t**i for t=num_data-1, then it is not possible to fit an extra parameter, so it is omitted from the model, and a pure polynomial is used sum_i<=d param[i]*t**i If the time of the step is Double.NaN, then the step time is unknown and two extra parameters are needed to estimate s, which is assumed to be in range (0.5*num_data-1, 0.5*num_data). Other than 0 to turn it off, the step should not be located at an integer.
Parameters:
num_data -
deg -
when_step - when step in velocity happens
• ### Method Detail

• #### getStepAt

public double getStepAt()
where is there a step?
Returns:
time of step in velocity
• #### getStepAt

public double getStepAt(BounceMatrix model_param)
where is there a step? If there is a step in a model which estimates time as well as size of step, we need the model parameters to say where the step was fitted.
Parameters:
model_param - parameters from fit
Returns:
time of step in velocity
• #### fit_xy

public BounceParameters fit_xy(double[] xData,
double[] yData,
int start,
int index_step)
fit parameters for model to a window of (x,y) points Returned result: fitted paramters returns null if fitting is not possible, which can happen if start, start+index_step, ..., start+(num_data-1)*index_step goes out of range for either data array or xdata or ydata is Double.NaN for one of the specified points Time t=0 corresponds to subscript "start" Time t=1 to start+time_step
Parameters:
xData - array of x values
yData - array of y values
start - subscript of first (x,y) pair for window
index_step - increment between subscripts for subsequent data points
Returns:
LinearModelParams containing parameters and residual square error
• #### fit_xy

public BounceParameters fit_xy(double[] xData,
double[] yData,
int start,
int index_step,
double initial_step_at,
double[] initial_step_size)
fit parameters for model to a window of (x,y) points, with a specified step to be removed before fitting Returned result: fitted parameters, with record of extra step returns null if fitting is not possible, which can happen if start, start+index_step, ..., start+(num_data-1)*index_step goes out of range for either data array or xdata or ydata is Double.NaN for one of the specified points Time t=0 corresponds to subscript "start" Time t=1 to start+time_step
Parameters:
xData - array of x values
yData - array of y values
start - subscript of first (x,y) pair for window
index_step - increment between subscripts for subsequent data points
initial_step_at - what time the predefined step happens 0<=t
initial_step_size -
Returns:
LinearModelParams containing parameters and residual square error
• #### first_deriv

public double[] first_deriv(BounceMatrix model_param,
double t)
return first derivatives at time t The dimensionality of the returned array of doubles is the same as the number of columns in the model_param Matrix (that would be 2 for model_param returned by fit_xy()). Time t=0 corresponds to subscript "start" in the fit_xy call Time t=1 to start+time_step in the fit_xy call
Parameters:
model_param - parameter matrix as returned by a fit_xy call
t - what time
Returns:
first derivates of x and y at time t
• #### second_deriv

public double[] second_deriv(BounceMatrix model_param,
double t)
return second derivatives at time t The dimensionality of the returned array of doubles is the same as the number of columns in the model_param Matrix (that would be 2 for model_param returned by fit_xy()). The Dirac delta causes some difficulty in expressing the acceleration, and it is replaced in the acceleration output (but not the velocity or data fitting) by a pulse in the interval (s-0.5, s+.5]
Parameters:
model_param - parameter matrix as returned by a fit_xy call
t - what time step (t=0 corresponds to subscript "start" in the fit_xy call
Returns:
second derivates of x and y at time t
• #### usesStep

public boolean usesStep()
return use_step
Returns:
true if model uses as step, false if pure polynomial model
• #### getStepSize

public double[] getStepSize(BounceMatrix model_param)
return step size The dimensionality of the returned array of doubles is the same as the number of columns in the model_param Matrix (that would be 2 for model_param returned by fit_xy()).
Parameters:
model_param - parameter matrix as returned by a fit_xy call
Returns:
step size (0 if no step)