|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.opensha.sra.riskmaps.func.DiscreteFunction
org.opensha.sra.riskmaps.func.DiscreteInterpExterpFunc
public class DiscreteInterpExterpFunc
This class behaves much like the DiscreteFunction class, however
it allows for values between the discrete domain values to be interpolated,
and values outside the domain altogether to be extrapolated. This
interpolation/extrapolation can be done in different arithmetic spaces to
allow for a “best fit” regression curve. Extrapolation follows
one of four different approaches for each side of the curve. See the
predefined constants for a list of options and their meanings.
-=* CHANGE LOG *=- 07/07/08 -- EMM: Original implementation.
| Field Summary | |
|---|---|
static int |
EXTRAP_EXTEND
Extrapolation should continue a linear regression of the final points. |
static int |
EXTRAP_FLATTEN
Extrapolation should assume the constant value of the endpoint. |
static int |
EXTRAP_INFINITY
Extrapolation should jump to +/- infinity (slope dependent). |
static int |
EXTRAP_ZERO
Extrapolation should just drop values to zero. |
protected int |
extrapAbove
|
protected int |
extrapBelow
|
protected int |
interpType
|
static int |
LINEAR_LINEAR
Identifies interpolation in linear-x, linear-y domains. |
static int |
LINEAR_LOG
Identifies interpolation in linear-x, logarithmic-y domains. |
static int |
LOG_LINEAR
Identifies interpolation in logarithmic-x, linear-y domains. |
static int |
LOG_LOG
Identifies interpolation in logarithmic-x, logarithmic-y domains. |
| Fields inherited from class org.opensha.sra.riskmaps.func.DiscreteFunction |
|---|
xvals, yvals |
| Constructor Summary | |
|---|---|
DiscreteInterpExterpFunc(double[] xvals,
double[] yvals)
Creates a discrete function with interpolation and extrapolation methods based on the given xvals and yvals. |
|
DiscreteInterpExterpFunc(double[] xvals,
double[] yvals,
String name)
Creates a discrete function with interpolation and extrapolation methods based on the given xvals, yvals and
name. |
|
DiscreteInterpExterpFunc(double[] xvals,
double[] yvals,
String name,
int interpType,
int extrapBelow,
int extrapAbove)
Creates a discrete function with interpolation and extrapolation methods based on the given xvals, yvals and
name. |
|
| Method Summary | |
|---|---|
static DiscreteInterpExterpFunc |
fromArbDistFunc(ArbitrarilyDiscretizedFunc func)
|
int |
getExtrapAbove()
|
int |
getExtrapBelow()
|
int |
getInterp()
|
void |
setExtrapMethod(int extrapAbove,
int extrapBelow)
Attempts to set the extrapolation methods used for this discrete function. |
void |
setInterpMethod(int interpType)
Attempts to set the interpolataion method used for this discrete function. |
double |
valueOf(double x)
For the given value x returns the function value
f(x) for this function. |
double[] |
valueOf(double[] x)
For the given array of x values, a corresponding array of
f(x) values is created and returned according to the
computation methods described in valueOf(double x). |
| Methods inherited from class org.opensha.sra.riskmaps.func.DiscreteFunction |
|---|
equals, getDomain, getName, getRange, getXVals, getYVals, toString |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int LINEAR_LINEAR
public static final int LINEAR_LOG
public static final int LOG_LINEAR
public static final int LOG_LOG
public static final int EXTRAP_ZERO
public static final int EXTRAP_FLATTEN
public static final int EXTRAP_EXTEND
public static final int EXTRAP_INFINITY
protected int interpType
protected int extrapBelow
protected int extrapAbove
| Constructor Detail |
|---|
public DiscreteInterpExterpFunc(double[] xvals,
double[] yvals)
xvals and yvals. The name of
this function will be the default name, and the interpolation and
extrapoltion methods will be the defaults as well.
xvals - The x-values of this discrete function.yvals - The y-values of this descrete function.
public DiscreteInterpExterpFunc(double[] xvals,
double[] yvals,
String name)
xvals, yvals and
name. The interpolation and extrapolation methods will be the
defaults.
xvals - The x-values of this discrete function.yvals - The y-values of this discrete function.name - The name of this discrete function.
public DiscreteInterpExterpFunc(double[] xvals,
double[] yvals,
String name,
int interpType,
int extrapBelow,
int extrapAbove)
xvals, yvals and
name. Assuming the interpType,
extrapBelow and/or extrapAbove correspond to a
well-known method, they will be used as the respective
interpolation/extrapolation methods. Otherwise the defaults will be used.
xvals - The x-values of this discrete function.yvals - The y-values of this discrete function.name - The name of this discrete function.interpType - The arithmetic space in which to interpolate.extrapBelow - The method of extrapolation for values below the lower
bound of the function domain.extrapAbove - The method of extrapolation for the values above the
upper bound of the function domain.| Method Detail |
|---|
public void setInterpMethod(int interpType)
interpType does not correspond to a known
interpolation type, then nothing is done.
interpType - The new interpolation type to use.
public void setExtrapMethod(int extrapAbove,
int extrapBelow)
extrapBelow or extrapAbove does not
correspond to a known extrapolation method, then the respective value is
not set.
extrapBelow - The extrapolation method used for values below the
lower bound of the domain of this discrete function.extrapAbove - The extrapolation method used for values above the
upper bound of the domain of this discrete function.public int getInterp()
public int getExtrapBelow()
public int getExtrapAbove()
public double valueOf(double x)
x returns the function value
f(x) for this function. If x is one of the
discrete defining values of this function, its corresponding discrete
y-value is returned. If x is somehwere within the bounds of
the domain of this discrete function, then an interpolation is performed
according to the current interpolation type and that interpolated value is
returned. If x is above or below the upper or lower bounds of
this discrete function's domain (respectively), then the funcntion value
of x is extrapolated according to the current extrapolation
method for values above/below the domain (respectively).
valueOf in interface FunctionAPIvalueOf in class DiscreteFunctionx - The value for which we want to know f(x).
f(x), interpolated or extrapolated
as needed.public double[] valueOf(double[] x)
x values, a corresponding array of
f(x) values is created and returned according to the
computation methods described in valueOf(double x).
x - The array of x-values for which you want to know y-values.
x.public static DiscreteInterpExterpFunc fromArbDistFunc(ArbitrarilyDiscretizedFunc func)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||