|
WebCab Portfolio Demo v4.2 (J2EE Edition) |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
Within this class we offer methods by which the Efficient Frontier can be constructed from a finite set of known points. In particular, we offer methods based around the cubic interpolation (recommended approach) and polynomial interpolation procedures. This Enterprise JavaBean contains several methods for constructing continuous functions from discrete data points. Such methods are generally referred to as Interpolation and Extrapolation methods.
Functionality Offered
With this Enterprise JavaBean we offer the following functionality:
interpolateExtrapolatePolynomial - returns the value and an error
estimate of an interpolation point where the interpolation function is a polynomial
of a given order.
coefficientsInterpolatingPolynomialStable - this method is similar to
the approach given above except that here we have a higher level of stability which
we pay for with lower efficiency.
coefficientsInterpolatingPolynomial - this methods evaluates the
coefficients of the interpolation polynomial.
cubicSplinePointwisePreEvaluation - Evaluates the value of the cubic
spline at a given point.
cubicSpline2ndDifferential - Allow the 2nd derivatives of the cubic
spline to be evaluated so that they can be consumed within cubicSplinePointwisePreEvaluation
cubicSplinePointwise - Evaluates the cubic spline interpolation constructed from a given
set of points. When applying this method you will need to give the values of the derivatives at the end
points. A reasonable estimate could be provided by directed evaluation of the slope between either the
first or last two known points of the Efficient Frontier.
How to construct the Efficient Frontier using Interpolation
As mentioned above the main aim of these interpolation procedures is to provide the means
by which the Efficient Frontier can be constructed from a finite set of points on which it
can be evaluated by using the method: calculateEfficientFrontier from Markowitz Enterprise JavaBean.
The expected return and risk coordinate components of these points can then be read off by using
the methods expectedReturnEfficientFrontier and
portfolioRisksEfficientFrontier from Markowitz Enterprise JavaBean.
Once the interpolation points are known we are able to construct the interpolation around
these points and then in the case of cubic spline interpolation evaluate the Efficient Frontier
at an arbitrary value points by using one of the methods: cubicSplinePointwise,
cubicSplinePointwisePreEvaluation.
| Method Summary | |
double[] |
coefficientsInterpolatingPolynomial(double[] tabulatedValues,
double[] polynomialValues)
Evaluates the coefficients of the interpolating polynomial when the tabulation points are known. |
double[] |
coefficientsInterpolatingPolynomialStable(double[] tabulatedValues,
double[] polynomialValues)
Evaluates the coefficients of the interpolating polynomial when the tabulation points are known. |
double[] |
cubicSpline2ndDifferential(double[] tabulationPointsInX,
double[] functionValuesAtTabulationPoints,
double derivativeInterpolationAt0,
double derivativeInterpolationAtn_1)
Evaluates the second derivatives of the cubic spline interpolation polynomial at the given functions tabulation points when the first derivative at the boundary (equivalently the end points) is known. |
double |
cubicSplinePointwise(double[] tabulationPointsInX,
double[] functionValuesAtTabulationPoints,
double derivativeInterpolationAt0,
double derivativeInterpolationAtn_1,
double interpolationPoint)
Returns the value of the cubic spline interpolation at a given point. |
double |
cubicSplinePointwisePreEvaluation(double[] tabulationPointsInX,
double[] functionValuesAtTabulationPoints,
double[] secondDifferential,
double interpolationPoint)
Returns the cubic spline interpolation of a function at a point. |
double[] |
interpolateExtrapolatePolynomial(double[] tabulationPointsInX,
double[] polynomialValues,
double interpolationPoint)
This method interpolates (or extrapolates) a given polynomial in one variable. |
| Methods inherited from interface javax.ejb.EJBObject |
getEJBHome, getHandle, getPrimaryKey, isIdentical, remove |
| Method Detail |
public double[] interpolateExtrapolatePolynomial(double[] tabulationPointsInX,
double[] polynomialValues,
double interpolationPoint)
throws InterpolationException,
InterpolationDemoException,
RemoteException
If P(x) is the polynomial of degree `n-1' such that P(xCoordinates[i])
= yCoordinates[i]; i=0,...,n-1; then if the desired point at which the interpolation
functions value is required is `interpolationPoint'. Then the returned value will
be some double value y, where y = P(interpolationPoint).
The `tabulationPointsInX' array and the `polynomialValues' array should each contain at least one element. If these arrays have different lengths the shorter one will be chosen as reference.
tabulationPointsInX - an array of doubles for which at member we know the corresponding value of the given polynomial. Note, that the corresponding values of the polynomial at these points given by the member of the array yCoordinates which lie in the corresponding position.polynomialValues - an array of doubles which corresponds to the value of the polynomial at the points tabulationPointsInX. The first point of this array is the value of the given polynomial evaluated at the point tabulationPointsInX[0], th second point of the array is the value of the given polynomial at the point tabulationPointsInX[1].interpolationPoint - the value of the point at which the interpolation function is evaluated and a corresponding error estimate is given.
InterpolationException - Thrown when the input values do not meet the requirements mentioned above.
InterpolationDemoException
RemoteException
public double[] coefficientsInterpolatingPolynomialStable(double[] tabulatedValues,
double[] polynomialValues)
throws InterpolationException,
InterpolationDemoException,
RemoteException
Further Explanation
If we are given a set of n points on which the
interpolation function is known then this method evaluates the n coefficients
c_i of the interpolation function c_0 + (c_1 * x) + (c_2 * x * x)+ ....
More explicitly, given a set of tabulation points x = {x[i]: i=0,...,n-1}
and y = {y[i]:i=0,...,n-1}
which defines a function by y[i] = f(x[i]). This method returns an array of
doubles which are the coefficients of the interpolating polynomial where the first term
of the array corresponds to the 0th order term, the second term corresponds to the 1st order
term (i.e. x's coefficient) and so on.
Comparison with coefficientsInterpolatingPolynomial
The method coefficientsInterpolatingPolynomial
differs slightly from this method which is less direct and slower by a
power of the number of tabulation points used. However, we have found this
approach to be more stable. The essential idea in this approach is that it
uses the interpolateExtrapolatePolynomial method with iterative reduction
to arrive at the interpolation polynomial.
Remark: If the two arrays have different lengths the shorter one will be used as reference.
tabulatedValues - an array of doubles which represent the values at which the interpolation polynomial is tabulated. That is, is `f' is the interpolating polynomial then we have f(tabulatedValues[i]) = polynomialValues[i]; where `polynomialValues[i]' is the value of the interpolating polynomial at the `tabulatedValues[i]'.polynomialValues - an array of doubles where the first element `polynomialValues[0]', corresponds to the value of the interpolating polynomial at the first tabulation point `tabulatedValues[0]', and the second values `polynomialValues[1]' corresponds to the value of the interpolating polynomial at the second tabulated point `tabulatedValues[1]', and so on...
InterpolationException - Thrown when any of the two parameters are null.
InterpolationDemoException
RemoteExceptioncoefficientsInterpolatingPolynomial
,
interpolateExtrapolatePolynomial
public double[] coefficientsInterpolatingPolynomial(double[] tabulatedValues,
double[] polynomialValues)
throws InterpolationException,
InterpolationDemoException,
RemoteException
Further Explanation
If we are given a set of n points on which the
interpolation function is known then this method evaluates the n coefficients
c_i of the interpolation function c_0 + (c_1 * x) + (c_2 * x * x)+ ....
More explicitly, given a set of tabulation points x = {x[i]: i=0,...,n-1}
and y = {y[i]:i=0,...,n-1}
which defines a function by y[i] = f(x[i]). This method returns an array of
doubles which are the coefficients of the interpolating polynomial where the first term
of the array corresponds to the 0th order term, the second term corresponds to the 1st order
term (i.e. x's coefficient) and so on.
Comparison with coefficientsInterpolatingPolynomialStable
The method coefficientsInterpolatingPolynomialStable differs slightly
from this method which is more direct, and faster by a power of the number of tabulation
points used. However, we have found this approach to be less stable.
Remark: If the two arrays have different lengths the shorter one will be used as reference.
tabulatedValues - an array of doubles which represent the values at which the interpolation polynomial is tabulated. That is, if `f' is the interpolation polynomial then we have f(tabulatedValues[i]) = polynomialValues[i]; where `polynomialValues[i]' is the value of the interpolation polynomial at the `tabulated values`tabulatedValues[i]'.polynomialValues - an array of double where the first element `polynomialValues[0]', corresponds to the value of the interpolating polynomial at the first tabulation point `tabulatedValues[0]', and the second values `polynomialValues[1]' corresponds to the value of the interpolating polynomial at the second tabulated point `tabulatedValues[1]', and so on...
InterpolationException - Thrown when either of the two parameters is null.
InterpolationDemoException
RemoteException
public double[] cubicSpline2ndDifferential(double[] tabulationPointsInX,
double[] functionValuesAtTabulationPoints,
double derivativeInterpolationAt0,
double derivativeInterpolationAtn_1)
throws InterpolationException,
InterpolationDemoException,
RemoteException
Description of the parameters
Given arrays tabulationPointsInX[0..n-1] and
tabulationPointsInY[0..n-1] containing a tabulated function,
i.e. tabulationPointsInY[i] = f(tabulationPointsInY[i]), with
tabulationPointsInX[0] < tabulationPointsInX[1] < ... < tabulationPointsInX[n-1],
and given values derivativeInterpolationAt0 and derivativeInterpolationAtn_1
for the first derivative of the interpolating function at the points tabulationPointsInX[0]
and tabulationPointsInX[n-1], respectively. This method returns an array
of length n, that contains the second derivatives of the interpolation
function at the tabulation points tabulationPointsInX[i]. If
derivativeInterpolationAt0 and/or derivativeInterpolationAtn_1
are equal to 1030 or larger, then the method sets
the second derivative at the boundary to be zero.
Remark: If the two arrays have different lengths, the shorter one will be used as reference. The two arrays should be at least 2 elements long.
tabulationPointsInX - an array of doubles which are the values at which the function is tabulated, i.e. functionValuesAtTabulationPoints[i] = f(tabulationPointsInX[i])functionValuesAtTabulationPoints - an array of doubles which are the values of the function evaluated at the interpolation points, i.e. functionValuesAtTabulationPoints[i] = f(tabulationPointsInX[i])derivativeInterpolationAt0 - the first derivative of the interpolation function at the point tabulationPointsInX[0]derivativeInterpolationAtn_1 - the first derivative of the interpolation function at the point tabulatedPointInX[n-1]
InterpolationException - Thrown when the input values do not meet the requirements mentioned above.
InterpolationDemoException
RemoteException
public double cubicSplinePointwisePreEvaluation(double[] tabulationPointsInX,
double[] functionValuesAtTabulationPoints,
double[] secondDifferential,
double interpolationPoint)
throws InterpolationException,
InterpolationDemoException,
RemoteException
cubicSpline2ndDifferential.
General Description of Parameters
Given the arrays tabulationPointsInX[0..n-1] and functionValuesAtTabulationPoints[0..n-1],
which tabulate a function where the tabulationPointsInX is an array where the elements are monotonically
increasing. Moreover, given the array secondDifferenttial[0..n-1], which is the output of the method
cubicSpline2ndDifferential, and given a value of the interpolation points interpolationPoint,
this method returns the value of the function at interpolationPoint according to the cubic-spline interpolation
method.
Description of the Parameters in terms of the Efficient Frontier
With direct regards to the Efficient Frontier the points tabulationPointsInX[0..n-1],
will refer to the risk of the portfolios on the Efficient Frontier and be evaluated using
portfolioRisksEfficientFrontier of the Markowitz Enterprise JavaBean.
The values functionValuesAtTabulationPoints[0..n-1]
will refer to the expected returns of the known portfolios on the Efficient Frontier and can be evaluated using
expectedReturnEfficientFrontier of the Markowitz Enterprise JavaBean.
The 2nd derivatives can be thought of as the rate of change of the increase in the expected return for taken
on more risk. That is, the second derivatives express a qualitative property of the Efficient Frontier.
The point at which the cubic spline in interpolated namely, interpolationPoint, will refer to the
value of the portfolio risk for which the value of corresponding expected return will be returned.
Remarks:
cubicSpline2ndDifferential
is used in the evaluation of the 2nd derivatives then all the parameters in both methods
are applied in a consistent fashion.
tabulationPointsInX - the array containing the values at which the function is tabulated, i.e. functionValuesAtTabulationPoints[i] = f(tabulationPointsInX[i])functionValuesAtTabulationPoints - an array of doubles of the values of the function evaluated at the interpolation points, i.e. functionValuesAtTabulationPoints[i] = f(tabulationPointsInX[i])secondDifferential - an array containing the 2nd differential of the cubic spline at the tabulation points. These 2nd differentials can be evaluated using the method cubicSpline2ndDifferential.interpolationPoint - the point at which the interpolation function is evaluated and returned. Note that this is the point at which we wished to find the value of the given function which we only knew at the tabulation points
InterpolationException - Thrown when the input values do not meet the requirements
mentioned above.
InterpolationDemoException
RemoteExceptioncubicSplinePointwise - this is an alternative means by which the value of the cubic spline
can be evaluated at a point. Here rather than providing the 2nd differentials we are required
to provide the values of the differentials at the end points.
,
cubicSpline2ndDifferential - use this method in order to evaluate the 2nd differentials at
the tabulation points which most be provided to this method a parameter.
public double cubicSplinePointwise(double[] tabulationPointsInX,
double[] functionValuesAtTabulationPoints,
double derivativeInterpolationAt0,
double derivativeInterpolationAtn_1,
double interpolationPoint)
throws InterpolationException,
InterpolationDemoException,
RemoteException
General Description of Parameters
Given a function which is tabulated at the points tabulationPointsInX[0..n-1]
which has elements was are monotonically increasing and takes the values
functionValuesAtTabulationPoints[0..n-1] at those points, this methods returns
the values of the cubic spline interpolation function evaluated at the
given point interpolationPoint.
Description of the Parameters in terms of the Efficient Frontier
With direct regards to the Efficient Frontier the points tabulationPointsInX[0..n-1],
will refer to the risk of the portfolios on the Efficient Frontier and be evaluated using
portfolioRisksEfficientFrontier of the Markowitz Enterprise JavaBean.
The values functionValuesAtTabulationPoints[0..n-1]
will refer to the expected returns of the known portfolios on the Efficient Frontier and be evaluated using
expectedReturnEfficientFrontier of the Markowitz Enterprise JavaBean.
The point at which the cubic spline in interpolated namely, interpolationPoint, will refer
to the value of the portfolio risk for which the value of corresponding expected return will be returned.
Notes on Estimating the Derivatives
When applying this method you will need to provide values of the derivative of the interpolation function at the end points. A reasonable estimate with regard to approximating the Efficient Frontier could be provided by directed evaluating the slope between either the first or last two known points of the Efficient Frontier.
Remark: If the two arrays have different lengths, the shorter one will be used as reference. The two arrays should be at least 2 elements long.
tabulationPointsInX - the array containing the values at which the function is tabulated, i.e. functionValuesAtTabulationPoints[i] = f(tabulationPointsInX[i])functionValuesAtTabulationPoints - an array of double of the values of the function evaluated at the interpolation points, i.e. functionValuesAtTabulationPoints[i] = f(tabulationPointsInX[i]), where f is the function being consideredderivativeInterpolationAt0 - the first derivative of the interpolation function at the point tabulationPointsInX[0]derivativeInterpolationAtn_1 - the first derivative of the interpolation function at the point tabulatedPointInX[n-1]interpolationPoint - The value of the `x-coordinate' at which the value of the cubic spline interpolation function is evaluated. Note, that in the case of the Efficient Frontier this will refer to the risk of the portfolio.
InterpolationException - Thrown when the input values do not meet the requirements mentioned above.
InterpolationDemoException
RemoteExceptioncubicSplinePointwisePreEvaluation
|
WebCab Portfolio Demo v4.2 (J2EE Edition) |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||