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

[WIP] Feature/math guide #192

Closed
wants to merge 6 commits into from
Closed

[WIP] Feature/math guide #192

wants to merge 6 commits into from

Conversation

bbbales2
Copy link
Member

@bbbales2 bbbales2 commented Feb 1, 2021

My first attempt was to write intro docs for all the new stuff in Stan. That started getting long and I was barely making it anywhere so I gave up. Rendered attempt is here

Then I tried to write a cheat sheet for all the new stuff in Stan. The idea being that things only needed roughly documented examples and a few words. It's still crazy long, not sure it will fit on a cheat sheet. Rendered cheat sheet is here

Now I am thinking that my best chance of finishing something is an "anatomy of a Stan function" document. For this, the goal would be to take an existing function and explain the file structure, tests, and add verbal descriptions of all the little different things inside it (and leave the technical description to the doxygen and examples to other functions).

Anyway putting this stuff up to share, not looking for merge.

Copy link

@t4c1 t4c1 left a comment

Choose a reason for hiding this comment

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

This looks great! I bet it will help any new developers a lot.

knitr/math-guide/math_cheat_sheet.Rmd Outdated Show resolved Hide resolved

The arena does not call destructors for objects stored in arena.

## Autodiff memory
Copy link

Choose a reason for hiding this comment

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

This section seems a bit incomplete. I would also expect info on when to put a vari on certain stack.

knitr/math-guide/math_cheat_sheet.Rmd Show resolved Hide resolved
Comment on lines +252 to +253
Substitution Failure Is Not An Error is the preferred way to define
function implementations in Stan.
Copy link

Choose a reason for hiding this comment

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

Suggested change
Substitution Failure Is Not An Error is the preferred way to define
function implementations in Stan.
Overloads using "Substitution Failure Is Not An Error" are the preferred way to define
different function implementations for different input types in Stan Math.

function implementations in Stan.

Function argument lists are fully templated, and then template meta-programs
are used to define which definitions are visible at argument lookup.
Copy link

Choose a reason for hiding this comment

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

Suggested change
are used to define which definitions are visible at argument lookup.
are used to define which overloads can be specialized for particular argument types.

knitr/math-guide/math_guide.Rmd Show resolved Hide resolved
knitr/math-guide/math_guide.Rmd Show resolved Hide resolved
versions. This can happen when multiplying the values/adjoints of an AOS
autodiff type against other matrices.

It is not safe to use `.noalias()` with the AOS value/adjoint expressions.
Copy link

Choose a reason for hiding this comment

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

Why not?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure, but I believe it exploded when I did it before. When @SteveBronder did this he added some if statements so the noalias code only ran for SOA. I forget where it was though (I thought multiply but when I looked it wasn't there).


### Multiple argument scalar types

Pretend for a minute that
Copy link

Choose a reason for hiding this comment

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

This looks unfinished.

As an aside, in order to get the actual vector result, Eigen defines the
`.eval()` operator, so `c.eval()` would return an actual `Eigen::VectorXd`.
Similarly, Math defines the `eval` function which will evaluate an Eigen
expression and forward anything that is not an Eigen expression.
Copy link

Choose a reason for hiding this comment

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

This seems to be in wrong section.

Co-authored-by: Tadej Ciglarič <tadej.c@gmail.com>
@bbbales2
Copy link
Member Author

bbbales2 commented Feb 2, 2021

Judging from your comments @t4c1 you like the longer document? So it's fair to count that as a vote to just finish the longer thing instead of a cheat-sheet style doc?

@t4c1
Copy link

t4c1 commented Feb 2, 2021

Well the longer one will be more useful for new devs. Also it looks like 90% finished to me.

@SteveBronder SteveBronder self-requested a review February 2, 2021 19:13

The title contans "Current State" to emphasize that if any information here is
out of date or any advice does not work, it should be reported as a bug (the
[example-models](https://github.com/stan-dev/example-models)).

Choose a reason for hiding this comment

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

[todo] move this over to the math site.

@bbbales2 bbbales2 mentioned this pull request Feb 3, 2021
13 tasks
@SteveBronder
Copy link

fyi working on writing some stuff up based on this as well

@bbbales2
Copy link
Member Author

bbbales2 commented Feb 3, 2021

@SteveBronder feel free to edit here or move this to where you want to work on it.

Based on what Tadej said, I'm thinking ditch the cheat sheet (but I'll just leave it in for copy-pasting convenience)

@bob-carpenter
Copy link
Contributor

Sounds great. @seantalts and I went through a whole lecture at StanCon Helsinki on how to add a function to the math library. And we didn't even cover all the doc we had written then. So this is a big problem. I also want to say that as long as what's there is correct, it doesn't matter if it's not 100% complete---it'll be an improvement on what we have.

@bbbales2
Copy link
Member Author

bbbales2 commented Feb 5, 2021

The new place to work on this is stan-dev/math#2350.

I merged the comments from this thread into that.

@bbbales2 bbbales2 closed this Feb 5, 2021
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.

None yet

5 participants