Class LinearStochasticLaw

  • All Implemented Interfaces:
    MathFunction, MathInversableFunction, JsonableObject

    public class LinearStochasticLaw
    extends StochasticLaw
    Law that representes a linear density.

    The linear distribution is based on f(x) = a.x+b where, if the distribution is ascendent, a>0 and f(minX) = 0, and if the distribution is descendent, a<0 and f(maxX) = 0.

    This class uses the uniform random number distribution provided by Random.

    Since:
    13.0
    Version:
    17.0 2020-01-04 14:41:41
    Author:
    Christophe BOHRHAUER
    Maven Group Id:
    org.arakhne.afc.core
    Maven Artifact Id:
    mathstochastic
    • Constructor Detail

      • LinearStochasticLaw

        public LinearStochasticLaw​(double minX,
                                   double maxX)
        Create a ascendent linear distribution.
        Parameters:
        minX - is the lower bound of the distribution
        maxX - is the upper bound of the distribution
      • LinearStochasticLaw

        public LinearStochasticLaw​(double minX,
                                   double maxX,
                                   boolean ascendent)
        Create a linear distribution.
        Parameters:
        minX - is the lower bound of the distribution
        maxX - is the upper bound of the distribution
        ascendent - indicates of the distribution function is ascendent or not
    • Method Detail

      • random

        @Pure
        public static double random​(double minX,
                                    double maxX,
                                    boolean ascendent)
                             throws MathException
        Replies a random value that respect the current stochastic law.
        Parameters:
        minX - is the lower bound of the distribution
        maxX - is the upper bound of the distribution
        ascendent - indicates of the distribution function is ascendent or not
        Returns:
        a value depending of the stochastic law parameters
        Throws:
        MathException - when error in the math definition.
      • random

        @Pure
        public static double random​(double minX,
                                    double maxX)
                             throws MathException
        Replies a random value that respect the current stochastic law.

        The used stochastic law is the ascendent linear distribution.

        Parameters:
        minX - is the lower bound of the distribution
        maxX - is the upper bound of the distribution
        Returns:
        a value depending of the stochastic law parameters
        Throws:
        MathException - when error in the math definition.
      • f

        @Pure
        public double f​(double x)
                 throws MathException
        Description copied from interface: MathFunction
        Replies the value of the function.
        Parameters:
        x - the x.
        Returns:
        the value of f(x).
        Throws:
        MathException - in case f(x) could not be computed
      • getRange

        @Pure
        public MathFunctionRange[] getRange()
        Description copied from interface: MathFunction
        Replies the range of the function.
        Returns:
        a array of ranges. It corresponds to a list of couples that defined the set of valid values.
      • inverseF

        @Pure
        public double inverseF​(double u)
                        throws MathException
        Replies the x according to the value of the distribution function.
        Specified by:
        inverseF in interface MathInversableFunction
        Specified by:
        inverseF in class StochasticLaw
        Parameters:
        u - is a value given by the uniform random variable generator U(0, 1).
        Returns:
        F<sup>-1</sup>(u)
        Throws:
        MathException - in case F<sup>-1</sup>(u) could not be computed
      • toJson

        @Pure
        public void toJson​(JsonBuffer buffer)
        Description copied from interface: JsonableObject
        Replies the Json representation of this node.
        Parameters:
        buffer - the Json buffer.