Class MvnRectangle

java.lang.Object
jline.solvers.fluid.moments.MvnRectangle

public final class MvnRectangle extends Object
Rectangle probability of a multivariate normal, the cell integral behind SolverFluid.getProbAggr under the moment-closure methods. Java twin of the MATLAB fluid_mvn_rectangle and of the Python mvn_rectangle.

The integral has no closed form beyond one dimension, so it is evaluated by the separation-of-variables transformation of Genz (1992): the Cholesky factor of C turns the rectangle into an iterated integral over the unit cube whose integrand is a product of normal-CDF differences, and the first coordinate is integrated exactly. The remaining cube is integrated with a DETERMINISTIC Richtmyer lattice rule, frac(k*sqrt(p_j)) over the first primes, averaged with its antithetic reflection. Determinism is required here, not merely convenient: the MATLAB, Java and Python twins must return the same number, and a randomized rule would make them agree only in distribution.

C may be SINGULAR, which is the common case: a closed population fixes the sum of the station coordinates, so the covariance of a station holding a whole class is rank deficient. A coordinate whose CONDITIONAL variance vanishes is not integrated; it is a hard constraint, contributing 1 when the conditional mean falls inside its interval and 0 otherwise.

See Also:
  • Field Details

    • DEFAULT_POINTS

      public static final int DEFAULT_POINTS
      Lattice points per antithetic pair.
      See Also:
  • Method Details

    • probability

      public static double probability(double[] m, double[][] C, double[] a, double[] b)
      Probability that a normal vector falls in the rectangle [a,b].
      Parameters:
      m - mean vector, length d
      C - covariance matrix, d-by-d, symmetric positive semi-definite
      a - lower corner, -infinity allowed
      b - upper corner, +infinity allowed
      Returns:
      the probability in [0,1]
    • probability

      public static double probability(double[] m, double[][] C, double[] a, double[] b, int npoints)
      Probability that a normal vector falls in the rectangle [a,b].
      Parameters:
      m - mean vector, length d
      C - covariance matrix, d-by-d, symmetric positive semi-definite
      a - lower corner, -infinity allowed
      b - upper corner, +infinity allowed
      npoints - lattice points per antithetic pair
      Returns:
      the probability in [0,1]
    • logProbability

      public static double logProbability(double[] m, double[][] C, double[] a, double[] b)
      Natural logarithm of probability(double[], double[][], double[], double[]), negative infinity when the probability is zero.
      Parameters:
      m - mean vector
      C - covariance matrix
      a - lower corner
      b - upper corner
      Returns:
      log of the rectangle probability