Package org.jquantlib.math.matrixutilities

Examples of org.jquantlib.math.matrixutilities.Array


      } else {

        final SABRError costFunction = new SABRError(this);
        transformation_ = new SabrParametersTransformation();

        final Array guess = new Array(4);
        guess.set(0, itsCoeffs.alpha_);
        guess.set(1, itsCoeffs.beta_);
        guess.set(2, itsCoeffs.nu_);
        guess.set(3, itsCoeffs.rho_);

        final boolean[] parameterAreFixed = new boolean[4];
        parameterAreFixed[0] = itsCoeffs.alphaIsFixed_;
        parameterAreFixed[1] = itsCoeffs.betaIsFixed_;
        parameterAreFixed[2] = itsCoeffs.nuIsFixed_;
        parameterAreFixed[3] = itsCoeffs.rhoIsFixed_;

        final Array inversedTransformatedGuess = new Array(transformation_.inverse(guess));

        final ProjectedCostFunction constrainedSABRError = new ProjectedCostFunction(costFunction, inversedTransformatedGuess, parameterAreFixed);

        final Array projectedGuess = new Array(constrainedSABRError.project(inversedTransformatedGuess));

        final NoConstraint constraint = new NoConstraint();
        final Problem problem = new Problem(constrainedSABRError, constraint, projectedGuess);
        itsCoeffs.SABREndCriteria_ = optMethod_.minimize(problem, endCriteria_);
        final Array projectedResult = new Array(problem.currentValue());
        final Array transfResult = new Array(constrainedSABRError.include(projectedResult));

        final Array result = transformation_.direct(transfResult);
        itsCoeffs.alpha_ = result.get(0);
        itsCoeffs.beta_ = result.get(1);
        itsCoeffs.nu_ = result.get(2);
        itsCoeffs.rho_ = result.get(3);

      }
      itsCoeffs.error_ = interpolationError();
      itsCoeffs.maxError_ = interpolationMaxError();
View Full Code Here


      return totalError;
    }

    // calculate weighted differences
    public Array interpolationErrors(final Array not_used) {
      final Array results = new Array(vx.size());
      int ix = vx.begin();
      int iy = vy.begin();
      int iw = itsCoeffs.weights_.begin();
      int ir = results.begin();
      while (ix < vx.end()) {
        final double x = vx.get(ix);
        final double y = vy.get(iy);
        final double w = itsCoeffs.weights_.get(iw);
        results.set(ir, (op(x) - y) * Math.sqrt(w));
        ix++;
        iy++;
        iw++;
        ir++;
      }
 
View Full Code Here

    private class SabrParametersTransformation implements ParametersTransformation {
      Array y_;
      final double eps1_, eps2_;//, dilationFactor_;

      public SabrParametersTransformation() {
        y_ = new Array(4);
        eps1_ = .0000001;
        eps2_ = .9999;
        //dilationFactor_ = 0.001;
      }
View Full Code Here

        return 1;
    }

    @Override
    public final /*@Real*/ Array initialValues() {
        return new Array().fill( x0() );
    }
View Full Code Here

    }

    @Override
    public final /*@Real*/ Array drift(final /*@Time*/ double t, /*@Real*/ final Array x) {
        QL.require(x.size()==1 , ARRAY_1D_REQUIRED); // QA:[RG]::verified // TODO: message
        return new Array().fill( drift(t, x.first()) );
    }
View Full Code Here

        this.sabr_ = sabr;
      }

      @Override
            public double value(final Array x) {
        final Array y = sabr_.transformation_.direct(x);
        sabr_.itsCoeffs.alpha_ = y.get(0);
        sabr_.itsCoeffs.beta_ = y.get(1);
        sabr_.itsCoeffs.nu_ = y.get(2);
        sabr_.itsCoeffs.rho_ = y.get(3);
        return sabr_.interpolationSquaredError();
      }
View Full Code Here

    }

    @Override
    public final /*@Expectation*/ Array expectation(final /*@Time*/ double t0, final /*@Real*/ Array x0, final /*@Time*/ double dt) {
        QL.require(x0.size()==1 , ARRAY_1D_REQUIRED); // QA:[RG]::verified // TODO: message
        return new Array().fill( expectation(t0, x0.first(), dt) );
    }
View Full Code Here

    @Override
    public final Array evolve(final /*@Time*/ double t0, final /*@Real*/ Array x0, final /*@Time*/ double dt, final Array dw) {
        QL.require(x0.size()==1 , ARRAY_1D_REQUIRED); // QA:[RG]::verified // TODO: message
        QL.require(dw.size()==1 , ARRAY_1D_REQUIRED); // QA:[RG]::verified // TODO: message
        return new Array().fill( evolve(t0, x0.first(), dt, dw.first()) );
    }
View Full Code Here

    @Override
    public final /*@Real*/ Array apply(final /*@Real*/ Array x0, final Array dx) {
        QL.require(x0.size()==1 , ARRAY_1D_REQUIRED); // QA:[RG]::verified // TODO: message
        QL.require(dx.size()==1 , ARRAY_1D_REQUIRED); // QA:[RG]::verified // TODO: message
        return new Array().fill( apply(x0.first(), dx.first()) );
    }
View Full Code Here

        return sabr_.interpolationSquaredError();
      }

      @Override
            public Array values(final Array x) {
        final Array y = sabr_.transformation_.direct(x);
        sabr_.itsCoeffs.alpha_ = y.get(0);
        sabr_.itsCoeffs.beta_ = y.get(1);
        sabr_.itsCoeffs.nu_ = y.get(2);
        sabr_.itsCoeffs.rho_ = y.get(3);
        return sabr_.interpolationErrors(x);
      }
View Full Code Here

TOP

Related Classes of org.jquantlib.math.matrixutilities.Array

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.