gpflow.expectations#
Modules#
Functions#
gpflow.expectations.expectation#
- gpflow.expectations.expectation(p, obj1, obj2=None, nghp=None)[source]#
Compute the expectation <obj1(x) obj2(x)>_p(x) Uses multiple-dispatch to select an analytical implementation, if one is available. If not, it falls back to quadrature.
- Parameters:
nghp (int) – passed to _quadrature_expectation to set the number of Gauss-Hermite points used: num_gauss_hermite_points
- Return type:
Tensor
- Returns:
a 1-D, 2-D, or 3-D tensor containing the expectation
Allowed combinations
- Psi statistics:
>>> eKdiag = expectation(p, kernel) (N) # Psi0 >>> eKxz = expectation(p, (kernel, inducing_variable)) (NxM) # Psi1 >>> exKxz = expectation(p, identity_mean, (kernel, inducing_variable)) (NxDxM) >>> eKzxKxz = expectation(p, (kernel, inducing_variable), (kernel, inducing_variable)) (NxMxM) # Psi2
- kernels and mean functions:
>>> eKzxMx = expectation(p, (kernel, inducing_variable), mean) (NxMxQ) >>> eMxKxz = expectation(p, mean, (kernel, inducing_variable)) (NxQxM)
- only mean functions:
>>> eMx = expectation(p, mean) (NxQ) >>> eM1x_M2x = expectation(p, mean1, mean2) (NxQ1xQ2) .. note:: mean(x) is 1xQ (row vector)
- different kernels. This occurs, for instance, when we are calculating Psi2 for Sum kernels:
>>> eK1zxK2xz = expectation(p, (kern1, inducing_variable), (kern2, inducing_variable)) (NxMxM)
- Parameters:
p (
Union
[ProbabilityDistribution
,Tuple
[Union
[ndarray
[Any
,Any
],Tensor
,Variable
,Parameter
],Union
[ndarray
[Any
,Any
],Tensor
,Variable
,Parameter
]]]) –obj1 (
Union
[Kernel
,MeanFunction
,None
,Tuple
[Kernel
,InducingVariables
]]) –obj2 (
Union
[Kernel
,MeanFunction
,None
,Tuple
[Kernel
,InducingVariables
]]) –nghp (
Optional
[int
]) –
gpflow.expectations.quadrature_expectation#
- gpflow.expectations.quadrature_expectation(p, obj1, obj2=None, nghp=None)[source]#
Compute the expectation <obj1(x) obj2(x)>_p(x) Uses Gauss-Hermite quadrature for approximate integration.
- Parameters:
num_gauss_hermite_points (int) – passed to _quadrature_expectation to set the number of Gauss-Hermite points used
p (
Union
[ProbabilityDistribution
,Tuple
[Union
[ndarray
[Any
,Any
],Tensor
,Variable
,Parameter
],Union
[ndarray
[Any
,Any
],Tensor
,Variable
,Parameter
]]]) –obj1 (
Union
[Kernel
,MeanFunction
,None
,Tuple
[Kernel
,InducingVariables
]]) –obj2 (
Union
[Kernel
,MeanFunction
,None
,Tuple
[Kernel
,InducingVariables
]]) –nghp (
Optional
[int
]) –
- Return type:
Tensor
- Returns:
a 1-D, 2-D, or 3-D tensor containing the expectation