Package org.jquantlib.math.functions

Examples of org.jquantlib.math.functions.Identity


        }
    }

    private void testSeveral(final Integrator I) {
        testSingle(I, "f(x) = 1",      new Constant(1.0),               0.0, 1.0, 1.0);
        testSingle(I, "f(x) = x",      new Identity(),                  0.0, 1.0, 0.5);
        testSingle(I, "f(x) = x^2",    new Square(),                    0.0, 1.0, 1.0/3.0);
        testSingle(I, "f(x) = sin(x)", new Sin(),                       0.0, Constants.M_PI, 2.0);
        testSingle(I, "f(x) = cos(x)", new Cos(),                       0.0, Constants.M_PI, 0.0);
        testSingle(I, "f(x) = Gaussian(x)", new NormalDistribution(), -10.0, 10.0, 1.0);
View Full Code Here


    \f[ \langle x \rangle = \frac{\sum w_i x_i}{\sum w_i}. \f]
     */
    public final double mean() {
        final int size = getSampleSize();
        QL.require(size > 0 , empty_sample_set); // QA:[RG]::verified
        return expectationValue(new Identity(), new TruePredicate()).getFirst();
    }
View Full Code Here

            return (deltaPlus - deltaMinus) / (grid.get(jmid) - grid.get(jmid - 1));
        }
    }

    public void regrid(final Array newGrid) {
        regrid(newGrid, new Identity());
    }
View Full Code Here

            //throw new IllegalArgumentException(empty_sample_set);
        }
        final double target = -valueAtRisk(centile);

        final Ops.DoublePredicate less = new Bind2ndPredicate(new LessThanPredicate(), target);
        final Pair<Double, Integer> result = statistics.expectationValue(new Identity(), less);

        final double x = result.getFirst();
        final Integer N = result.getSecond();

        if(N.intValue() ==  0.0)
View Full Code Here

    public /*@Real*/ double mean() /*@ReadOnly*/ {
        /*@Size*/ final int N = samples();
        QL.require(N != 0, "empty sample set");
        // eat our own dog food
        return expectationValue(new Identity(), new Everywhere()).first();
    }
View Full Code Here

    QL.ensure(samples() != 0, EMPTY_SAMPLE_SET);
   
    final double target = -valueAtRisk(centile);

    final Ops.DoublePredicate less = new Bind2ndPredicate(new LessThanPredicate(), target);
    final Pair<Double, Integer> result = expectationValue(new Identity(), less);

    final double x = result.first();
    final Integer N = result.second();

    QL.ensure(N != 0, NO_DATA_BELOW_THE_TARGET);
View Full Code Here

            return (deltaPlus - deltaMinus) / (grid.get(jmid) - grid.get(jmid - 1));
        }
    }

    public void regrid(final Array newGrid) {
        regrid(newGrid, new Identity());
    }
View Full Code Here

        }
    }

    private void testSeveral(final Integrator I) {
        testSingle(I, "f(x) = 1",      new Constant(1.0),               0.0, 1.0, 1.0);
        testSingle(I, "f(x) = x",      new Identity(),                  0.0, 1.0, 0.5);
        testSingle(I, "f(x) = x^2",    new Square(),                    0.0, 1.0, 1.0/3.0);
        testSingle(I, "f(x) = sin(x)", new Sin(),                       0.0, Constants.M_PI, 2.0);
        testSingle(I, "f(x) = cos(x)", new Cos(),                       0.0, Constants.M_PI, 0.0);
        testSingle(I, "f(x) = Gaussian(x)", new NormalDistribution(), -10.0, 10.0, 1.0);
View Full Code Here

  }

  @Test
  public void testPolynomials() {
    checkSingleTabulated(new Constant(1.0), "f(x)=1", 2.0, 1.0e-13);
    checkSingleTabulated(new Identity(), "f(x)=x", 0.0, 1.0e-13);
    checkSingleTabulated(new Square(), "f(x)=x^2", 2.0/3.0, 1.0e-13);
    checkSingleTabulated(new Cube(), "f(x)=x^3", 0.0, 1.0e-13);
    checkSingleTabulated(new Fourth(), "f(x)=x^4", 2.0/5.0, 1.0e-13);
  }
View Full Code Here

  }

  @Test
  public void testPolynomials() {
    checkSingleTabulated(new Constant(1.0), "f(x)=1",   2.0,     1.0e-13);
    checkSingleTabulated(new Identity(),    "f(x)=x",   0.0,     1.0e-13);
    checkSingleTabulated(new Square(),         "f(x)=x^2", 2.0/3.0, 1.0e-13);
    checkSingleTabulated(new Cube(),        "f(x)=x^3", 0.0,     1.0e-13);
    checkSingleTabulated(new Fourth(),      "f(x)=x^4", 2.0/5.0, 1.0e-13);
  }
View Full Code Here

TOP

Related Classes of org.jquantlib.math.functions.Identity

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.