Package org.jquantlib.math.matrixutilities

Examples of org.jquantlib.math.matrixutilities.Matrix$RangeRow


            this.j_ = j;
            this.param_ = param;
        }

        public double op(final double t) {
            final Matrix m = param_.diffusion(t);
            return m.constRangeRow(i_).innerProduct(m.constRangeRow(j_));
        }
View Full Code Here


     */
    @Override
    public Matrix covarianceDiscretization(
                final StochasticProcess sp,
                /* @Time */final double t0, /* @Real */ final Array x0, /* @Time */final double dt) {
        final Matrix sigma = sp.diffusion(t0, x0);
        return sigma.mul(sigma.transpose()).mulAssign(dt);
    }
View Full Code Here

        final Array drift = process.drift(process.time(date18.clone()), new Array(1).fill(5.6));
        System.out.println("The drift of the process after time = 18th day from today with value of the stock as specified from the quote");

        //Calculating the diffusion of the process after time = 18th day from today with value of the stock as specified from the quote
        //The diffusion = volatiltiy of the stochastic process
        final Matrix diffusion = process.diffusion(process.time(date18.clone()), new Array(1).fill(5.6));
        System.out.println("The diffusion of the process after time = 18th day from today with value of the stock as specified from the quote");

        //Calulating the standard deviation of the process after time = 18th day from today with value of the stock as specified from the quote
        //The standard deviation = volatility*sqrt(dt)
        final Matrix stdDeviation = process.stdDeviation(process.time(date18.clone()), new Array(1).fill(5.6), 0.01);
        System.out.println("The stdDeviation of the process after time = 18th day from today with value of the stock as specified from the quote");

        //Calulating the expected value of the stock quote after time = 18th day from today with the current value of the stock as specified from the quote
        //The expectedValue = intialValue*exp(drift*dt)-----can be obtained by integrating----->dx/x= drift*dt
        final Array expectation = process.expectation(process.time(date18.clone()), new Array(1).fill(5.6), 0.01);
        System.out.println("Expected value = "+expectation.first());

        //Calulating the exact value of the stock quote after time = 18th day from today with the current value of the stock as specified from the quote
        //The exact value = intialValue*exp(drift*dt)*exp(volatility*sqrt(dt))-----can be obtained by integrating----->dx/x= drift*dt+volatility*sqrt(dt)
        final Array evolve = process.evolve(process.time(date18.clone()), new Array(1).fill(6.7), .001, new Array(1).fill(new NormalDistribution().op(Math.random()) ));
        System.out.println("Exact value = "+evolve.first());

        //Calculating covariance of the process
        final Matrix covariance = process.covariance(process.time(date18.clone())new Array(1).fill(5.6), 0.01);
        System.out.println("Covariance = "+covariance.get(0, 0));

        clock.stopClock();
        clock.log();
    }
View Full Code Here

    }

    @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

        if (System.getProperty("EXPERIMENTAL") == null) {
            throw new UnsupportedOperationException("Work in progress");
        }

        corrMatrix_ = new Matrix(size, size);
        factors = factors != 0 ? 0 : size;
        arguments_.set(0, new ConstantParameter(rho, new BoundaryConstraint(-1.0, 1.0)));
        arguments_.set(1, new ConstantParameter(beta, new PositiveConstraint()));
        generateArguments();
    }
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

        final Date[] datesAxis = {date10.clone(), date15.clone(), date20.clone(), date25.clone(), date30.clone(), date40.clone() };

        final Array strikeAxis = new Array(new double[] {10,20,35,40,56,60});

        //Following is the volatility surface on which interpolations will be done
        final Matrix volatilityMatrix = new Matrix(new double[][] {
                {0.01,0.02,0.03,0.04,0.05,0.06},
                {0.02,0.03,0.04,0.05,0.06,0.07},
                {0.03,0.04,0.05,0.06,0.07,0.08},
                {0.3,0.5,0.6,0.7,0.8,0.9},
                {0.1,0.4,0.6,0.7,0.8,0.9},
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); // 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); // TODO: message
        final double v = stdDeviation(t0, x0.first(), dt);
        return new Matrix(1, 1).fill(v);
    }
View Full Code Here

TOP

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

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.