Package org.arakhne.afc.math.stochastic
Class UniformStochasticLaw
- java.lang.Object
-
- org.arakhne.afc.math.stochastic.StochasticLaw
-
- org.arakhne.afc.math.stochastic.UniformStochasticLaw
-
- All Implemented Interfaces:
MathFunction
,MathInversableFunction
,JsonableObject
public class UniformStochasticLaw extends StochasticLaw
Law that representes an uniform density.The uniform law is described by:
U(minX, maxX) = 1/abs(maxX-minY) iff maxY<>minY
U(minX, maxX) = 1 iff maxY=minY
Reference: Uniform Distribution.
This class uses the uniform random number distribution provided by
Random
. This class replies a random number equivalent to the value replied by(maxX-minX)*Math.random()+minX
.- 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
-
-
Field Summary
-
Fields inherited from class org.arakhne.afc.math.stochastic.StochasticLaw
NAME_NAME
-
-
Constructor Summary
Constructors Constructor Description UniformStochasticLaw(double minX1, double maxX1)
Create a uniform stochastic law.UniformStochasticLaw(Map<String,String> parameters)
Construct a law with the following parameters.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description double
f(double x)
Replies the value of the function.MathFunctionRange[]
getRange()
Replies the range of the function.double
inverseF(double u)
Replies the x according to the value of the distribution function.static double
random(double minX, double maxX)
Replies a random value that respect the current stochastic law.void
toJson(JsonBuffer buffer)
Replies the Json representation of this node.-
Methods inherited from class org.arakhne.afc.math.stochastic.StochasticLaw
generateRandomValue, getLawName, inverseF, paramBoolean, paramDouble, toString
-
-
-
-
Constructor Detail
-
UniformStochasticLaw
public UniformStochasticLaw(Map<String,String> parameters) throws LawParameterNotFoundException
Construct a law with the following parameters.minX
maxX
- Parameters:
parameters
- is the set of accepted parameters.- Throws:
LawParameterNotFoundException
- if the list of parameters does not permits to create the law.
-
UniformStochasticLaw
public UniformStochasticLaw(double minX1, double maxX1)
Create a uniform stochastic law.- Parameters:
minX1
- is the lower boundmaxX1
- is the upper bound
-
-
Method Detail
-
random
@Pure public static double random(double minX, double maxX) throws MathException
Replies a random value that respect the current stochastic law.- Parameters:
minX
- is the lower boundmaxX
- is the upper bound- Returns:
- a value depending of the stochastic law parameters
- Throws:
MathException
- when math definition error.
-
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 casef(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 interfaceMathInversableFunction
- Specified by:
inverseF
in classStochasticLaw
- Parameters:
u
- is a value given by the uniform random variable generatorU(0, 1)
.- Returns:
F<sup>-1</sup>(u)
- Throws:
MathException
- in caseF<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.
-
-