org.opensha.commons.data.function
Interface DiscretizedFunc

All Superinterfaces:
Iterable<Point2D>, Named, PlotElement, Serializable, XMLSaveable, XY_DataSet
All Known Implementing Classes:
AbstractDiscretizedFunc, ArbDiscrEmpiricalDistFunc, ArbDiscrFuncWithParams, ArbIncrementalMagFreqDist, ArbitrarilyDiscretizedFunc, EvenlyDiscretizedFunc, EvenlyDiscrFuncWithParams, GaussianMagFreqDist, GutenbergRichterMagFreqDist, HistogramFunction, IncrementalMagFreqDist, LightFixedXFunc, SingleMagFreqDist, SummedMagFreqDist, TaperedGR_MagFreqDist, UncertainArbDiscDataset, UnmodifiableDiscrFunc, YC_1985_CharMagFreqDist

public interface DiscretizedFunc
extends XY_DataSet

Title: DiscretizedFuncAPI

Description: Interface that all Discretized Functions must implement.

A Discretized Function is a collection of x and y values grouped together as the points that describe a function. A discretized form of a function is the only ways computers can represent functions. Instead of having y=x^2, you would have a sample of possible x and y values.

This functional framework is modeled after mathmatical functions such as sin(x), etc. It assumes that there are no duplicate x values, and that if two points have the same x value but different y values, they are still considered the same point. The framework also sorts the points along the x axis, so the first point contains the mimimum x-value and the last point contains the maximum value.

Since this API represents the points in a list, alot of these API functions are standard list access functions such as (paraphrasing) get(), set(), delete(). numElements(), iterator(), etc.

There are three fields along with getXXX() and setXXX() matching the field names. These javabean fields provide the basic information to describe a function. All functions have a name, information string, and a tolerance level that specifies how close two points have to be along the x axis to be considered equal.

Point2D = (x,y)

Note: This interface defines a tolerance so that you can say two x-values are the same within this tolerance limit. THERE IS NO TOLERANCE FOR THE Y-AXIS VALUES. This may be useful to add in the future.

Version:
1.0
Author:
Steven W. Rock
See Also:
DataPoint2D

Field Summary
 
Fields inherited from interface org.opensha.commons.metadata.XMLSaveable
XML_METADATA_NAME
 
Method Summary
 DiscretizedFunc deepClone()
          This function returns a new copy of this list, including copies of all the points.
 double getFirstInterpolatedX_inLogXLogYDomain(double y)
          Given the input y value, finds the two sequential x values with the closest y values, then calculates an interpolated x value for this y value, fitted to the curve.
 double getFirstInterpolatedX(double y)
          Given the imput y value, finds the two sequential x values with the closest y values, then calculates an interpolated x value for this y value, fitted to the curve.
 int getIndex(Point2D point)
          Since the x-axis is sorted and points stored in a list, they can be accessed by index.
 double getInterpolatedY_inLogXLogYDomain(double x)
          This function interpolates the Y values in the log space between x and y values.
 double getInterpolatedY_inLogYDomain(double x)
          This function interpolates the Y values in the log-Y space.
 double getInterpolatedY(double x)
          Given the input x value, finds the two sequential x values with the closest x values, then calculates an interpolated y value for this x value, fitted to the curve.
 double getTolerance()
          Returns the tolerance of this function.
 int getXIndex(double x)
          Since the x-axis is sorted and points stored in a list, they can be accessed by index.
 double getY(double x)
          returns the y-value given an x-value - within tolerance
 void scale(double scale)
          Scales (multiplies) the y-values of this function by the esupplied value.
 void setTolerance(double newTolerance)
          Sets the tolerance of this function.
 
Methods inherited from interface org.opensha.commons.data.function.XY_DataSet
areAllXValuesInteger, get, getClosestX, getClosestY, getInfo, getMaxX, getMaxY, getMetadataString, getMinX, getMinY, getNum, getX, getXAxisName, getXValuesIterator, getY, getYAxisName, getYValuesIterator, hasPoint, hasPoint, set, set, set, setInfo, setName, setXAxisName, setYAxisName, toString, toXMLMetadata, xValues, yValues
 
Methods inherited from interface org.opensha.commons.gui.plot.PlotElement
getDatasetsToPlot, getPlotNumColorList
 
Methods inherited from interface org.opensha.commons.data.Named
getName
 
Methods inherited from interface org.opensha.commons.metadata.XMLSaveable
toXMLMetadata
 
Methods inherited from interface java.lang.Iterable
iterator
 

Method Detail

setTolerance

void setTolerance(double newTolerance)
Sets the tolerance of this function.


getTolerance

double getTolerance()
Returns the tolerance of this function.


getY

double getY(double x)
returns the y-value given an x-value - within tolerance


getFirstInterpolatedX

double getFirstInterpolatedX(double y)
Given the imput y value, finds the two sequential x values with the closest y values, then calculates an interpolated x value for this y value, fitted to the curve.

Since there may be multiple y values with the same value, this function just matches the first found starting at the x-min point along the x-axis.


getInterpolatedY

double getInterpolatedY(double x)
Given the input x value, finds the two sequential x values with the closest x values, then calculates an interpolated y value for this x value, fitted to the curve.


getInterpolatedY_inLogXLogYDomain

double getInterpolatedY_inLogXLogYDomain(double x)
This function interpolates the Y values in the log space between x and y values. The Y value returned is in the linear space but the interpolation is done in the log space.

Parameters:
x - : X value in the linear space corresponding to which we are required to find the interpolated y value in log space.

getInterpolatedY_inLogYDomain

double getInterpolatedY_inLogYDomain(double x)
This function interpolates the Y values in the log-Y space. The Y value returned is in the linear space.

Parameters:
x - : X value in the linear space corresponding to which we are required to find the interpolated y value in log space.

getFirstInterpolatedX_inLogXLogYDomain

double getFirstInterpolatedX_inLogXLogYDomain(double y)
Given the input y value, finds the two sequential x values with the closest y values, then calculates an interpolated x value for this y value, fitted to the curve. The interpolated Y value returned is in the linear space but the interpolation is done in the log space. Since there may be multiple y values with the same value, this function just matches the first found starting at the x-min point along the x-axis.

Parameters:
y - : Y value in the linear space corresponding to which we are required to find the interpolated x value in the log space.

getXIndex

int getXIndex(double x)
Since the x-axis is sorted and points stored in a list, they can be accessed by index. This function returns the index of the specified x value if found within tolerance, else returns -1.


getIndex

int getIndex(Point2D point)
Since the x-axis is sorted and points stored in a list, they can be accessed by index. This function returns the index of the specified x value in the Point2D if found withing tolerance, else returns -1.


scale

void scale(double scale)
Scales (multiplies) the y-values of this function by the esupplied value.

Parameters:
scale -

deepClone

DiscretizedFunc deepClone()
Description copied from interface: XY_DataSet
This function returns a new copy of this list, including copies of all the points. A shallow clone would only create a new DiscretizedFunc instance, but would maintain a reference to the original points.

Since this is a clone, you can modify it without changing the original.

Specified by:
deepClone in interface XY_DataSet