setup_rosenbrock_function

pyapprox.benchmarks.setup_rosenbrock_function(nvars)[source]

Setup the Rosenbrock function benchmark

f(z)=i=1d/2[100(z2i12z2i)2+(z2i11)2]

This benchmark can also be used to test Bayesian inference methods. Specifically this benchmarks returns the log likelihood

l(z)=f(z)

which can be used to compute the posterior distribution

πpost(z)=π(y|z)π(z)Γπ(y|z)π(z)dz

where the prior is the tensor product of d independent and identically distributed uniform variables on [2,2], i.e. π(z)=14d, and the likelihood is given by

π(y|z)=exp(l(z))
Parameters:
nvarsinteger

The number of variables of the Rosenbrock function

Returns:
benchmarkBenchmark

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 signature

jac(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 signature

hessp(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)

variableIndependentMarginalsVariable

Object containing information of the joint density of the inputs z which is the tensor product of independent and identically distributed uniform variables on [2,2].

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 signature

loglike_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)

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'])