Package org.jquantlib.math.matrixutilities

Examples of org.jquantlib.math.matrixutilities.Matrix


    }

    @Override
    // TODO: review iterators
    public Matrix diffusion(/*@Time*/ final double t, final Array x){
        final Matrix pca = corrModel_.pseudoSqrt(t, x);
        // TODO: code review :: use of clone()
        final Array  vol = volaModel_.volatility(t, x);
        for (int i=0; i<size_; ++i) {
            pca.rangeRow(i).mulAssign(vol.get(i));
        }
        return pca;
    }
View Full Code Here


    @Override
    public Matrix covariance(/* @Time */final double t, final Array x) {
        // TODO: code review :: use of clone()
        final Array volatility = volaModel_.volatility(t, x);
        final Matrix correlation = corrModel_.correlation(t, x);

        final Matrix tmp = new Matrix(size_, size_);
        for (int i = 0; i < size_; ++i) {
            for (int j = 0; j < size_; ++j) {
                tmp.set(i, j, volatility.get(i) * correlation.get(i, j) * volatility.get(j));
            }
        }

        return tmp;
    }
View Full Code Here

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

    @Override
    public final /*@StdDev*/ Matrix stdDeviation(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
        final double v = stdDeviation(t0, x0.first(), dt);
        return new Matrix(1, 1).fill(v);
    }
View Full Code Here

    @Override
    public final /*@Covariance*/ Matrix covariance(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
        final double v = discretization1D.varianceDiscretization(this, t0, x0.first(), dt);
        return new Matrix(1, 1).fill(v);
    }
View Full Code Here

        this.lowerExtrapolation = lowerExtrapolation;
        this.upperExtrapolation = upperExtrapolation;


        this.times = new Array(dates.length+1); // TODO: verify if length is correct
        this.variances = new Matrix(strikes.size(), dates.length+1); // TODO: verify if length is correct
        this.strikes = new Array(strikes.size()+1); // TODO: verify if length is correct

        for(int i = 1; i < strikes.size()+1; i++) {
            this.strikes.set(i, strikes.get(i-1));
        }
View Full Code Here

                : (discretization_ == Discretization.Reflection)
                ? -Math.sqrt(-x1)
                        : 0.0;
                final double sigma2 = sigmav_ * vol;

                final Matrix result = new Matrix(2, 2);
                result.set(0, 0, vol);
                result.set(0, 1, 0.0);
                result.set(1, 0, rhov_ * sigma2);
                result.set(1, 1, sqrhov_ * sigma2);
                return result;
    }
View Full Code Here

    }

    @Override
    public Array drift(/* @Time */final double t, final Array x) {
        final Array f = new Array(size_);
        final Matrix covariance = lfmParam_.covariance(t, x);
        final int m = 0;//NextA
        for (int k = m; k < size_; ++k) {
            m1.set(k, accrualPeriod_.get(k) * x.get(k) / (1 + accrualPeriod_.get(k) * x.get(k)));
            final double value = m1.innerProduct(covariance.constRangeCol(k), m, k+1-m) - 0.5 * covariance.get(k, k);
            f.set(k, value);
        }
        return f;
    }
View Full Code Here

            throw new UnsupportedOperationException("work in progress");
        final int m   = 0;//nextIndexReset(t0);
        final double sdt = Math.sqrt(dt);

        final Array f = x0.clone();
        final Matrix diff       = lfmParam_.diffusion(t0, x0);
        final Matrix covariance = lfmParam_.covariance(t0, x0);

        // TODO: review iterators
        for (int k=m; k<size_; ++k) {
            final double y = accrualPeriod_.get(k)*x0.get(k);
            m1.set(k,y/(1+y));

            final double d = (m1.innerProduct(covariance.constRangeCol(k), m, k+1-m)-0.5*covariance.get(k, k)) * dt;
            final double r = diff.rangeRow(k).innerProduct(dw)*sdt;
            final double x = y*Math.exp(d + r);
            m2.set(k, x/(1+x));

            final double ip = m2.innerProduct(covariance.constRangeCol(k), m, k+1-m);
            final double value = x0.get(k) * Math.exp(0.5*(d+ip-0.5*covariance.get(k,k))*dt) + r;
            f.set(k, value);
        }

        return f;
    }
View Full Code Here

    public Matrix diffusion(/* @Time */final double t) {
        return diffusion(t, new Array());
    }

    public Matrix covariance(/* @Time */final double t, final Array x) {
        final Matrix sigma = this.diffusion(t, x);
        return sigma.mul(sigma.transpose());
    }
View Full Code Here

TOP

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

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.