RandomProcess¶
- class probnum.randprocs.RandomProcess(input_dim, output_dim, dtype)¶
Bases:
Generic
[probnum.randprocs._random_process.InputType
,probnum.randprocs._random_process.OutputType
],abc.ABC
Random processes represent uncertainty about a function.
Random processes generalize functions by encoding uncertainty over function values in their covariance function. They can be used to model (deterministic) functions which are not fully known or to define functions with stochastic output.
- Parameters
input_dim (
Union
[int
,Integral
,integer
]) – Input dimension of the random process.output_dim (
Union
[int
,Integral
,integer
,None
]) – Output dimension of the random process.dtype (
Union
[dtype
[Any
],None
,Type
[Any
],_SupportsDType
[dtype
[Any
]],str
,Tuple
[Any
,int
],Tuple
[Any
,Union
[SupportsIndex
,Sequence
[SupportsIndex
]]],List
[Any
],_DTypeDict
,Tuple
[Any
,Any
]]) – Data type of the random process evaluated at an input. Ifobject
will be converted tonumpy.dtype
.
See also
RandomVariable
Random variables.
GaussianProcess
Gaussian processes.
MarkovProcess
Random processes with the Markov property.
Notes
Random processes are assumed to have an (un-/countably) infinite domain. Random processes with a finite index set are represented by
RandomVariable
.Attributes Summary
Data type of (elements of) the random process evaluated at an input.
Shape of inputs to the random process.
Shape of the random process evaluated at an input.
Methods Summary
__call__
(args)Evaluate the random process at a set of input arguments.
cov
(args0[, args1])Covariance function or kernel.
covmatrix
(args0[, args1])A convenience function for the covariance matrix of two sets of inputs.
marginal
(args)Batch of random variables defining the marginal distributions at the inputs.
mean
(args)Mean function.
push_forward
(args, base_measure, sample)Transform samples from a base measure into samples from the random process.
sample
(rng[, args, size])Sample paths from the random process.
std
(args)Standard deviation function.
var
(args)Variance function.
Attributes Documentation
Methods Documentation
- abstract __call__(args)[source]¶
Evaluate the random process at a set of input arguments.
- Parameters
args (~InputType) – shape=(input_dim,) or (n, input_dim) – Input(s) to evaluate random process at.
- Returns
shape=(), (output_dim,) or (n, output_dim) – Random process evaluated at the inputs.
- Return type
- abstract cov(args0, args1=None)[source]¶
Covariance function or kernel.
Returns the covariance function \(\operatorname{Cov}(f(x_0), f(x_1)) = \mathbb{E}[(f(x_0) - \mathbb{E}[f(x_0)])(f(x_0) - \mathbb{E}[f( x_0)])^\top]\) of the process evaluated at \(x_0\) and \(x_1\). If only
args0
is given the covariance among the components of the random process at the inputs defined byargs0
is computed.- Parameters
args0 (~InputType) – shape=(input_dim,) or (n0, input_dim) – First input to the covariance function.
args1 (
Optional
[~InputType]) – shape=(input_dim,) or (n1, input_dim) – Second input to the covariance function.
- Returns
shape=(), (output_dim, output_dim), (n0, n1) or (n0, n1, output_dim, output_dim) – Covariance of the process at
args0
andargs1
. If onlyargs0
is given the kernel matrix \(K=k(x_0, x_0)\) is computed.- Return type
_OutputType
- covmatrix(args0, args1=None)[source]¶
A convenience function for the covariance matrix of two sets of inputs.
This is syntactic sugar for
proc.cov(x0[:, None, :], x1[None, :, :])
. Hence, it computes the matrix of pairwise covariances between two sets of input points.- Parameters
x0 (array-like) – First set of inputs to the covariance function as an array of shape
(M, D)
, whereD
is either 1 orinput_dim
.x1 (array-like) – Optional second set of inputs to the covariance function as an array of shape
(N, D)
, whereD
is either 1 orinput_dim
. Ifx1
is not specified, the function behaves as ifx1 = x0
.
- Returns
kernmat – The matrix / stack of matrices containing the pairwise evaluations of the covariance function(s) on
x0
andx1
as an array of shape(M, N)
ifshape
is()
or(S[l - 1], ..., S[1], S[0], M, N)
, whereS
isshape
ifshape
is non-empty.- Return type
- Raises
ValueError – If the shapes of the inputs don’t match the specification.
See also
RandomProcess.cov
Evaluate the kernel more flexibly.
Examples
See documentation of class
Kernel
.
- marginal(args)[source]¶
Batch of random variables defining the marginal distributions at the inputs.
- Parameters
args (~InputType) – shape=(input_dim,) or (n, input_dim) – Input(s) to evaluate random process at.
- Return type
- abstract mean(args)[source]¶
Mean function.
Returns the mean function evaluated at the given input(s).
- Parameters
args (~InputType) – shape=(input_dim,) or (n, input_dim) – Input(s) where the mean function is evaluated.
- Returns
shape=(), (output_dim, ) or (n, output_dim) – Mean function of the process evaluated at inputs
x
.- Return type
_OutputType
- abstract push_forward(args, base_measure, sample)[source]¶
Transform samples from a base measure into samples from the random process.
This function can be used to control sampling from the random process by explicitly passing samples from a base measure evaluated at the input arguments.
- Parameters
args (~InputType) – Input arguments.
base_measure (
Type
[RandomVariable
]) – Base measure. Given as a type of random variable.sample (
ndarray
) – shape=(sample_size, output_dim) – Sample(s) from a base measure evaluated at the input arguments.
- Return type
- sample(rng, args=None, size=())[source]¶
Sample paths from the random process.
If no inputs are provided this function returns sample paths which are callables, otherwise random variables corresponding to the input locations are returned.
- Parameters
rng (
Generator
) – Random number generator.args (
Optional
[~InputType]) – shape=(input_dim,) or (n, input_dim) – Evaluation input(s) of the sample paths of the process. IfNone
, sample paths, i.e. callables are returned.size (
Union
[int
,Integral
,integer
,Iterable
[Union
[int
,Integral
,integer
]]]) – Size of the sample.
- Return type
- std(args)[source]¶
Standard deviation function.
- Parameters
args (~InputType) – shape=(input_dim,) or (n, input_dim) – Input(s) to the standard deviation function.
- Returns
shape=(), (output_dim,) or (n, output_dim) – Standard deviation of the process at
args
.- Return type
_OutputType
- var(args)[source]¶
Variance function.
Returns the variance function which is the value of the covariance or kernel evaluated elementwise at
args
for each output dimension separately.- Parameters
args (~InputType) – shape=(input_dim,) or (n, input_dim) – Input(s) to the variance function.
- Returns
shape=(), (output_dim,) or (n, output_dim) – Variance of the process at
args
.- Return type
_OutputType