org.opensha.sha.earthquake.calc.recurInterval
Class BPT_DistCalc

java.lang.Object
  extended by org.opensha.sha.earthquake.calc.recurInterval.EqkProbDistCalc
      extended by org.opensha.sha.earthquake.calc.recurInterval.BPT_DistCalc
All Implemented Interfaces:
EventListener, ParameterChangeListener

public final class BPT_DistCalc
extends EqkProbDistCalc
implements ParameterChangeListener

Title: BPT_DistCalc.java

Description:

.

Version:
1.0
Author:
Edward Field

Field Summary
 
Fields inherited from class org.opensha.sha.earthquake.calc.recurInterval.EqkProbDistCalc
adjustableParams, aperiodicity, APERIODICITY_PARAM_INFO, APERIODICITY_PARAM_NAME, aperiodicityParam, cdf, DEFAULT_APERIODICITY_PARAM_VAL, DEFAULT_DELTAX_PARAM_VAL, DEFAULT_DURATION_PARAM_VAL, DEFAULT_MEAN_PARAM_VAL, DEFAULT_NUMPOINTS_PARAM_VAL, DELTA_X_DEFAULT, DELTA_X_PARAM_INFO, DELTA_X_PARAM_NAME, deltaX, deltaX_Param, duration, DURATION_PARAM_INFO, DURATION_PARAM_NAME, durationParam, mean, MEAN_PARAM_INFO, MEAN_PARAM_NAME, meanParam, NAME, NUM_POINTS_PARAM_INFO, NUM_POINTS_PARAM_NAME, numPoints, numPointsParam, pdf, upToDate
 
Constructor Summary
BPT_DistCalc()
           
 
Method Summary
protected  void computeDistributions()
           
static double getCondProb(double mean, double aperiodicity, double timeSinceLast, double duration)
          This computed the conditional probability using Trapezoidal integration (slightly more accurrate that the WGCEP-2002 code, which this method is modeled after).
 double getSafeCondProb(double timeSinceLast, double duration)
          This is a version of the parent method getCondProb(*) that avoids numerical artifacts at high timeSinceLast.
 double getSafeTimeSinceLastCutoff()
          The returns the maximum value of timeSinceLast (as discretized in the x-axis of the cdf) that is numerically safe (values above will return NaN from getSafeCondProb(*) due to numerical problems).
static void main(String[] args)
          Main method for running tests.
 void parameterChange(ParameterChangeEvent event)
          Set the primitive types whenever a parameter changes
 void setAll(double mean, double aperiodicity)
          For this case deltaX defaults to 0.001*mean and numPoints is aperiodicity*10/deltaX+1
 void setAll(double mean, double aperiodicity, double deltaX, int numPoints)
           
 void setAll(double mean, double aperiodicity, double deltaX, int numPoints, double duration)
           
 
Methods inherited from class org.opensha.sha.earthquake.calc.recurInterval.EqkProbDistCalc
fitToThisFunction, getAdjParams, getAperiodicity, getCDF, getCondProb, getCondProbFunc, getCondProbFunc, getHazFunc, getMean, getName, getPDF, initAdjParams
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BPT_DistCalc

public BPT_DistCalc()
Method Detail

setAll

public void setAll(double mean,
                   double aperiodicity,
                   double deltaX,
                   int numPoints)

setAll

public void setAll(double mean,
                   double aperiodicity,
                   double deltaX,
                   int numPoints,
                   double duration)
Parameters:
mean -
aperiodicity -
timeSinceLast -
duration -
deltaX -
numPoints -

setAll

public void setAll(double mean,
                   double aperiodicity)
For this case deltaX defaults to 0.001*mean and numPoints is aperiodicity*10/deltaX+1

Parameters:
mean -
aperiodicity -
timeSinceLast -
duration -

computeDistributions

protected void computeDistributions()

getCondProb

public static double getCondProb(double mean,
                                 double aperiodicity,
                                 double timeSinceLast,
                                 double duration)
This computed the conditional probability using Trapezoidal integration (slightly more accurrate that the WGCEP-2002 code, which this method is modeled after). Although this method is static (doesn't require instantiation), it is less efficient than the non-static version here (it is also very slightly less accurate because the other interpolates the cdf). Note also that if timeSinceLast/mean > aperiodicity*10, timeSinceLast is changed to equal mean*aperiodicity*10 (to avoid numerical problems at high timeSinceLast).

Parameters:
timeSinceLast - - time since last event
rate - - average rate of events
alpha - - coefficient of variation (technically corrrect??)
duration - - forecast duration
Returns:

parameterChange

public void parameterChange(ParameterChangeEvent event)
Set the primitive types whenever a parameter changes

Specified by:
parameterChange in interface ParameterChangeListener
Parameters:
event - The Event which triggered this function call

getSafeCondProb

public double getSafeCondProb(double timeSinceLast,
                              double duration)
This is a version of the parent method getCondProb(*) that avoids numerical artifacts at high timeSinceLast. If timeSinceLast is greater than safeTimeSinceLast, then the conditional probability at safeTimeSinceLast is returned (i.e., cond prob is constant above safeTimeSinceLast). The safe values have been visually verified for aperiodicity values of 0.1 to 1.0 (using the GUI).

Parameters:
timeSinceLast -
duration -
Returns:

getSafeTimeSinceLastCutoff

public double getSafeTimeSinceLastCutoff()
The returns the maximum value of timeSinceLast (as discretized in the x-axis of the cdf) that is numerically safe (values above will return NaN from getSafeCondProb(*) due to numerical problems). This returns Double.Nan is no x-axis values are safe. The safe values were found by trial and error for aperiodicity values between 0.1 and 1.0 (using the GUI).

Returns:

main

public static void main(String[] args)
Main method for running tests. Test1 compares the static getCondProb(*) method against values obtained directly from the WGCEP-2002 code; all are within 0.3%. Test2 campares the non static getCondProb(*) method against the static; all are within 0.5%. The differences is that the non-static is slightly more accurate due to interpolation of the CDF (exact same values are obtained otherwise; see commented out code). Test3 is the non-static used more efficiently (exact same values as from non-static above); this is about a factor of two faster. Test4 examines what happens if delta is changed to 0.01 in the non-static method (also about a factor of two faster).