Package org.apache.commons.math.linear

Examples of org.apache.commons.math.linear.RealMatrix


    return w.done();
  }
 
  public IValue PearsonsCorrelationStandardErrors(IList dataValues){
    make(dataValues);
    RealMatrix errors = new org.apache.commons.math.stat.correlation.PearsonsCorrelation(xyvalues).getCorrelationStandardErrors();
    return RealMatrix2List(errors);
  }
View Full Code Here


    return RealMatrix2List(errors);
  }
 
  public IValue PearsonsCorrelationPValues(IList dataValues){
    make(dataValues);
    RealMatrix errors;
    try {
      errors = new org.apache.commons.math.stat.correlation.PearsonsCorrelation(xyvalues).getCorrelationPValues();
      return RealMatrix2List(errors);
    } catch (MathException e) {
      // TODO Auto-generated catch block
View Full Code Here

    double sideVectX = line.sideVectX;
    double sideVectY = line.sideVectY;

    Vector2d direction = rm.getNewDirectionVector();
    direction.normalize();
    RealMatrix coefficients = new Array2DRowRealMatrix(new double[][] { { direction.getX(), -(sideVectX) },
        { direction.getY(), -(sideVectY) } }, false);
    DecompositionSolver solver = new LUDecompositionImpl(coefficients).getSolver();
    RealVector constants = new ArrayRealVector(new double[] { sideX - roboter1.getX(), sideY - roboter1.getY() }, false);
    RealVector solution = solver.solve(constants);
View Full Code Here

  @Test
  public void testLeastSquares1()
  throws FunctionEvaluationException, ConvergenceException {

      final RealMatrix factors =
          new Array2DRowRealMatrix(new double[][] {
              { 1.0, 0.0 },
              { 0.0, 1.0 }
          }, false);
      LeastSquaresConverter ls = new LeastSquaresConverter(new MultivariateVectorialFunction() {
          public double[] value(double[] variables) {
              return factors.operate(variables);
          }
      }, new double[] { 2.0, -3.0 });
      NelderMead optimizer = new NelderMead();
      optimizer.setConvergenceChecker(new SimpleScalarValueChecker(-1.0, 1.0e-6));
      optimizer.setMaxIterations(200);
View Full Code Here

  @Test
  public void testLeastSquares2()
  throws FunctionEvaluationException, ConvergenceException {

      final RealMatrix factors =
          new Array2DRowRealMatrix(new double[][] {
              { 1.0, 0.0 },
              { 0.0, 1.0 }
          }, false);
      LeastSquaresConverter ls = new LeastSquaresConverter(new MultivariateVectorialFunction() {
          public double[] value(double[] variables) {
              return factors.operate(variables);
          }
      }, new double[] { 2.0, -3.0 }, new double[] { 10.0, 0.1 });
      NelderMead optimizer = new NelderMead();
      optimizer.setConvergenceChecker(new SimpleScalarValueChecker(-1.0, 1.0e-6));
      optimizer.setMaxIterations(200);
View Full Code Here

  @Test
  public void testLeastSquares3()
  throws FunctionEvaluationException, ConvergenceException {

      final RealMatrix factors =
          new Array2DRowRealMatrix(new double[][] {
              { 1.0, 0.0 },
              { 0.0, 1.0 }
          }, false);
      LeastSquaresConverter ls = new LeastSquaresConverter(new MultivariateVectorialFunction() {
          public double[] value(double[] variables) {
              return factors.operate(variables);
          }
      }, new double[] { 2.0, -3.0 }, new Array2DRowRealMatrix(new double [][] {
          { 1.0, 1.2 }, { 1.2, 2.0 }
      }));
      NelderMead optimizer = new NelderMead();
View Full Code Here

            messageBuffer.append("\nexpected " + expected.getRowDimension() +
                    " x " + expected.getColumnDimension());
            Assert.fail(messageBuffer.toString());
        }

        RealMatrix delta = expected.subtract(observed);
        if (delta.getNorm() >= tolerance) {
            StringBuffer messageBuffer = new StringBuffer(msg);
            messageBuffer.append("\nExpected: " + expected);
            messageBuffer.append("\nObserved: " + observed);
            messageBuffer.append("\nexpected - observed: " + delta);
            Assert.fail(messageBuffer.toString());
View Full Code Here

                { 1, 3, 2, 6 },
                { 3, 13, 16, 2 },
                { 2, 16, 38, -1 },
                { 6, 2, -1, 197 }
        };
        RealMatrix covRM = MatrixUtils.createRealMatrix(cov);
        JDKRandomGenerator jg = new JDKRandomGenerator();
        jg.setSeed(5322145245211l);
        NormalizedRandomGenerator rg = new GaussianRandomGenerator(jg);
        CorrelatedRandomVectorGenerator sg =
            new CorrelatedRandomVectorGenerator(mean, covRM, 0.00001, rg);
View Full Code Here

        }

    }

    public void testRootMatrix() {
        RealMatrix b = generator.getRootMatrix();
        RealMatrix bbt = b.multiply(b.transpose());
        for (int i = 0; i < covariance.getRowDimension(); ++i) {
            for (int j = 0; j < covariance.getColumnDimension(); ++j) {
                assertEquals(covariance.getEntry(i, j), bbt.getEntry(i, j), 1.0e-12);
            }
        }
    }
View Full Code Here

            meanStat.increment(v);
            covStat.increment(v);
        }

        double[] estimatedMean = meanStat.getResult();
        RealMatrix estimatedCovariance = covStat.getResult();
        for (int i = 0; i < estimatedMean.length; ++i) {
            assertEquals(mean[i], estimatedMean[i], 0.07);
            for (int j = 0; j <= i; ++j) {
                assertEquals(covariance.getEntry(i, j),
                        estimatedCovariance.getEntry(i, j),
                        0.1 * (1.0 + Math.abs(mean[i])) * (1.0 + Math.abs(mean[j])));
            }
        }

    }
View Full Code Here

TOP

Related Classes of org.apache.commons.math.linear.RealMatrix

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.