15.12.2012 Views

scipy tutorial - Baustatik-Info-Server

scipy tutorial - Baustatik-Info-Server

scipy tutorial - Baustatik-Info-Server

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

SciPy Reference Guide, Release 0.8.dev<br />

bigmodel.estimate() This function approximates both the feature expectation vector<br />

bigmodel.logpdf(fx[, Returns the log of the estimated density p(x) = p_theta(x) at the point x.<br />

log_prior_x])<br />

bigmodel.pdf(fx) Returns the estimated density p_theta(x) at the point x with feature statistic<br />

fx = f(x).<br />

bigmodel.pdf_function() Returns the estimated density p_theta(x) as a function p(f) taking a vector f<br />

= f(x) of feature statistics at any point x.<br />

bigmodel.resample() (Re)samples the matrix F of sample features.<br />

bigmodel.setsampleFgen(sampler[, Initializes the Monte Carlo sampler to use the supplied<br />

staticsample])<br />

bigmodel.settestsamples(F_list, Requests that the model be tested every ‘testevery’ iterations<br />

logprob_list)<br />

bigmodel.stochapprox(K) Tries to fit the model to the feature expectations K using<br />

bigmodel.test() Estimate the dual and gradient on the external samples, keeping track of the<br />

parameters that yield the minimum such dual.<br />

estimate()<br />

This function approximates both the feature expectation vector E_p f(X) and the log of the normalization term<br />

Z with importance sampling.<br />

It also computes the sample variance of the component estimates of the feature expectations as: varE = var(E_1,<br />

..., E_T) where T is self.matrixtrials and E_t is the estimate of E_p f(X) approximated using the ‘t’th auxiliary<br />

feature matrix.<br />

It doesn’t return anything, but stores the member variables logZapprox, mu and varE. (This is done because<br />

some optimization algorithms retrieve the dual fn and gradient fn in separate function calls, but we can compute<br />

them more efficiently together.)<br />

It uses a supplied generator sampleFgen whose .next() method returns features of random observations s_j<br />

generated according to an auxiliary distribution aux_dist. It uses these either in a matrix (with multiple runs)<br />

or with a sequential procedure, with more updating overhead but potentially stopping earlier (needing fewer<br />

samples). In the matrix case, the features F={f_i(s_j)} and vector [log_aux_dist(s_j)] of log probabilities are<br />

generated by calling resample().<br />

We use [Rosenfeld01Wholesentence]’s estimate of E_p[f_i] as:<br />

{sum_j p(s_j)/aux_dist(s_j) f_i(s_j) }<br />

/ {sum_j p(s_j) / aux_dist(s_j)}.<br />

Note that this is consistent but biased.<br />

This equals:<br />

{sum_j p_dot(s_j)/aux_dist(s_j) f_i(s_j) }<br />

/ {sum_j p_dot(s_j) / aux_dist(s_j)}<br />

Compute the estimator E_p f_i(X) in log space as:<br />

num_i / denom,<br />

where<br />

and<br />

num_i = exp(logsumexp(theta.f(s_j) - log aux_dist(s_j)<br />

• log f_i(s_j)))<br />

denom = [n * Zapprox]<br />

254 Chapter 3. Reference

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!