setup_rosenbrock_function
- pyapprox.benchmarks.setup_rosenbrock_function(nvars)[source]
Setup the Rosenbrock function benchmark
This benchmark can also be used to test Bayesian inference methods. Specifically this benchmarks returns the log likelihood
which can be used to compute the posterior distribution
where the prior is the tensor product of
independent and identically distributed uniform variables on , i.e. , and the likelihood is given by- Parameters:
- nvarsinteger
The number of variables of the Rosenbrock function
- Returns:
- benchmark
Benchmark
Object containing the benchmark attributes documented below
- funcallable
The rosenbrock function with signature
fun(z) -> np.ndarray
where
z
is a 2D np.ndarray with shape (nvars,nsamples) and the output is a 2D np.ndarray with shape (nsamples,1)- jaccallable
The jacobian of
fun
with signaturejac(z) -> np.ndarray
where
z
is a 2D np.ndarray with shape (nvars,nsamples) and the output is a 2D np.ndarray with shape (nvars,1)- hesspcallable
Hessian of
fun
times an arbitrary vector p with signaturehessp(z, p) -> ndarray shape (nvars,1)
where
z
is a 2D np.ndarray with shape (nvars,nsamples) and p is an arbitraty vector with shape (nvars,1)- variable
IndependentMarginalsVariable
Object containing information of the joint density of the inputs z which is the tensor product of independent and identically distributed uniform variables on
.- meanfloat
The mean of the rosenbrock function with respect to the pdf of variable.
- loglikecallable
The log likelihood of the Bayesian inference problem for inferring z given the uniform prior specified by variable and the negative log likelihood given by the Rosenbrock function. loglike has the signature
loglike(z) -> np.ndarray
where
z
is a 2D np.ndarray with shape (nvars,nsamples) and the output is a 2D np.ndarray with shape (nsamples,1)- loglike_gradcallable
The gradient of the
loglike
with the signatureloglike_grad(z) -> np.ndarray
where
z
is a 2D np.ndarray with shape (nvars,nsamples) and the output is a 2D np.ndarray with shape (nsamples,1)
- benchmark
References
Examples
>>> from pyapprox.benchmarks.benchmarks import setup_benchmark >>> benchmark=setup_benchmark('rosenbrock',nvars=2) >>> print(benchmark.keys()) dict_keys(['fun', 'jac', 'hessp', 'variable', 'mean', 'loglike', 'loglike_grad'])