Search Results for

    Show / Hide Table of Contents

    Class Quadrature

    Quadrature nodes and weights

    Inheritance
    Object
    Quadrature
    Inherited Members
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Object.ReferenceEquals(Object, Object)
    Object.ToString()
    Namespace: Microsoft.ML.Probabilistic.Math
    Assembly: Microsoft.ML.Probabilistic.dll
    Syntax
    public static class Quadrature

    Fields

    HermiteNodesAndWeights

    Hermite nodes and weights

    Declaration
    public static double[, ][] HermiteNodesAndWeights
    Field Value
    Type Description
    Double[,][]

    LaguerreNodesAndWeights

    Laguerre nodes and weights

    Declaration
    public static double[, ][] LaguerreNodesAndWeights
    Field Value
    Type Description
    Double[,][]

    LegendreNodesAndWeights

    Legendre nodes and weights

    Declaration
    public static double[, ][] LegendreNodesAndWeights
    Field Value
    Type Description
    Double[,][]

    Methods

    AdaptiveClenshawCurtis(Converter<Double, Double>, Double, Int32, Double)

    Integrate the function f from -Infinity to Infinity

    Declaration
    public static double AdaptiveClenshawCurtis(Converter<double, double> f, double scale, int nodeCount, double relTol)
    Parameters
    Type Name Description
    Converter<Double, Double> f

    The function to integrate

    Double scale

    A positive tuning parameter. f is assumed to be negligible outside of [-scale,scale]

    Int32 nodeCount

    The initial number of nodes. Should be at least 2 and a power of 2.

    Double relTol

    A threshold to stop subdividing

    Returns
    Type Description
    Double

    AdaptiveExpSinh(Converter<Double, Double>, Double, Double)

    Integrate the function f from 0 to +Infinity using exp-sinh quadrature.

    Declaration
    public static double AdaptiveExpSinh(Converter<double, double> f, double scale, double relTol)
    Parameters
    Type Name Description
    Converter<Double, Double> f

    The function to integrate

    Double scale

    A positive tuning parameter. f is assumed to be continuous and at least one of f(0) and cosh(arsinh(2 * ln(scale)/pi)) * scale * f(scale) to be non-zero.

    Double relTol

    A threshold to stop subdividing

    Returns
    Type Description
    Double

    AdaptivePositiveHalfAxisTrapeziumRule(Converter<Double, Double>, Double, Double, Int32)

    Integrate the function f from 0 to +Infinity

    Declaration
    public static double AdaptivePositiveHalfAxisTrapeziumRule(Converter<double, double> f, double scale, double relTol, int maxNodes)
    Parameters
    Type Name Description
    Converter<Double, Double> f

    The function to integrate. Must have at most one extremum.

    Double scale

    A positive tuning parameter. f is assumed to be continuous on (0, + Infinity) and non-negligible somewhere on (0, scale]

    Double relTol

    A threshold to stop subdividing

    Int32 maxNodes

    Another threshold to stop subdividing

    Returns
    Type Description
    Double

    GammaNodesAndWeights(Double, Double, IList<Double>, IList<Double>)

    Quadrature nodes for Gamma expectations.

    Declaration
    public static void GammaNodesAndWeights(double a, double b, IList<double> nodes, IList<double> logWeights)
    Parameters
    Type Name Description
    Double a
    Double b
    IList<Double> nodes

    A list in which to store the nodes.

    IList<Double> logWeights

    A list in which to store the weights.

    Remarks

    The nodes and weights lists are modified to have the property that for any function f with a fast-converging Taylor series, sum_i weights[i] f(nodes[i]) =approx int_{0..inf} f(x) Ga(x; a, b) dx where Ga(x; a, b) = x^aexp(-xb)b^(a+1)/Gamma(a+1). For example, to approximate E[xx] where x ~ Ga(2,3):

    Vector nodes = new Vector(3);
    Vector logWeights = new Vector(3);
    Quadrature.GammaNodesAndWeights(2,3,nodes,logWeights);
    double result = (exp(logWeights)*nodes*nodes).Sum();

    The result is mean^2 + variance = ((a+1)^2 + (a+1))/b^2 = 4/3.

    GaussianNodesAndWeights(Double, Double, IList<Double>, IList<Double>)

    Quadrature nodes for Gaussian expectations.

    Declaration
    public static void GaussianNodesAndWeights(double mean, double variance, IList<double> nodes, IList<double> weights)
    Parameters
    Type Name Description
    Double mean
    Double variance
    IList<Double> nodes

    A list in which to store the nodes.

    IList<Double> weights

    A list in which to store the weights.

    Remarks

    The nodes and weights lists are modified to have the property that for any function f with a fast-converging Taylor series, sum_i weights[i] f(nodes[i]) =approx int_{-inf..inf} f(x) N(x; m, v) dx. If f is a polynomial of order 2n-1, then the result is exact. For example, to compute E[xx] where x ~ N(2,3):

    Vector nodes = new Vector(2);
    Vector weights = new Vector(2);
    Quadrature.GaussianNodesAndWeights(2,3,nodes,weights);
    double result = (weights*nodes*nodes).Sum();

    The result is mean^2 + variance = 7.

    LaguerreGammaNodesAndWeights(Double, Double, IList<Double>, IList<Double>)

    Declaration
    public static void LaguerreGammaNodesAndWeights(double a, double b, IList<double> nodes, IList<double> weights)
    Parameters
    Type Name Description
    Double a
    Double b
    IList<Double> nodes
    IList<Double> weights

    UniformNodesAndWeights(Double, Double, IList<Double>, IList<Double>)

    Quadrature nodes for integrals on [low,high].

    Declaration
    public static void UniformNodesAndWeights(double low, double high, IList<double> nodes, IList<double> weights)
    Parameters
    Type Name Description
    Double low

    Lower limit of integration. Must be finite.

    Double high

    Upper limit of integration. Must be finite.

    IList<Double> nodes

    A list in which to store the nodes.

    IList<Double> weights

    A list in which to store the weights.

    Remarks

    The nodes and weights lists are modified to have the property that for any function f with a fast-converging Taylor series, sum_i weights[i] f(nodes[i]) =approx int_{low..high} f(x) dx. If f is a polynomial of order 2*n-1, then the result is exact. For example, to compute int_{0..1} x^3 dx:

    Vector nodes = new Vector(2);
    Vector weights = new Vector(2);
    Quadrature.UniformNodesAndWeights(0,1,nodes,weights);
    double result = (weights*nodes*nodes*nodes).Sum();

    The result is 1/4.

    In This Article
    Back to top Copyright © .NET Foundation. All rights reserved.