Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes to GP chapter #2372

Merged
merged 4 commits into from
Aug 24, 2017
Merged

Fixes to GP chapter #2372

merged 4 commits into from
Aug 24, 2017

Conversation

rtrangucci
Copy link
Contributor

Submisison Checklist

  • Generate doc: make docs
  • Declare copyright holder and open-source license: see below

Summary

Fixes typos in GP chapter models

Intended Effect

Make code identical to example model repo's GP code.

How to Verify

Side Effects

None

Documentation

Reviewer Suggestions

@bob-carpenter

Copyright and Licensing

Please list the copyright holder for the work you are submitting (this will be you or your assignee, such as a university or company):

Rob Trangucci

By submitting this pull request, the copyright holder is agreeing to license the submitted work under the following licenses:

@rtrangucci
Copy link
Contributor Author

@seantalts I should have fixed the merge conflicts, I'll wait and see how the tests go.

@rtrangucci
Copy link
Contributor Author

@bob-carpenter finally fixed merge conflicts thanks to @seantalts and the tests are now passing, so this is ready for review when you have a chance. I'd like to get it in for the 2.17 release.

@bob-carpenter
Copy link
Member

bob-carpenter commented Aug 15, 2017 via email

@seantalts
Copy link
Member

I'm happy to review it. Going to mostly assume Rob has the math right barring any typos.

@rtrangucci
Copy link
Contributor Author

rtrangucci commented Aug 15, 2017 via email

Copy link
Member

@seantalts seantalts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Some small questions

K = cov_exp_quad(x, 1, 1);
for (i in 1:N)
K[i, i] = K[i, i] + 0.1;
matrix[N, N] K = cov_exp_quad(x, 1.0, 1.0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we prefer matrix[N, N] to cov_matrix[N] here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing it's to avoid having an issue with the cov_matrix constraint check being too strict. I think it's better behaved now. I'd rather see this declared as cov_matrix if that's computationally stable and documented if it's not (yet).

Copy link
Contributor Author

@rtrangucci rtrangucci Aug 15, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it'd be fine to use cov_matrix in the data block because the constraint checking will only get called once. I never use cov_matrix in a model because I'm usually generating the covariance matrix in the model block or in a local block in the transformed parameters block. If we were to have a covariance matrix defined in the transformed parameter I would strongly advocate against using cov_matrix because K + diag_matrix(1e-9) will be positive definite by construction and covariance matrix constraint checking is redundant and an N^3 operation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bob-carpenter where and how is the cov_matrix constraint checked?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the end of the transformed data and transformed parameter blocks, all constraints are validated. If transformed data fails, the algorithm never gets off the ground. If transformed parameters fail, it results in a rejection.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And that's a very good point about efficiency. I'll drop a note to that effect into the efficiency chapter.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, I'll leave the declaration as a matrix in. I don't want to expose readers to cov_matrix only to use matrix in all of the inference examples. Seems confusing to the user.


f2 = multi_normal_rng(f2_mu, cov_f2 + diag_delta);
}
functions{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe space between s and {?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'll change that. Thanks!

f2 = multi_normal_rng(f2_mu, cov_f2 + diag_delta);
}
functions{
vector gp_pred_rng(real[] x2,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean to add two spaces before everything here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks off, it should only be 2 spaces in every tab. I can go change that. Good catch.

@rtrangucci
Copy link
Contributor Author

Thanks for reviewing @seantalts. Think it's ready to merge if no one has any other objections.

@syclik syclik merged commit 91f52bd into develop Aug 24, 2017
@syclik syclik deleted the bugfix/issue-2371-fix-gp-typos branch August 24, 2017 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants