-
Notifications
You must be signed in to change notification settings - Fork 12
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
Add C++ for normal and beta, and placeholder text #51
base: master
Are you sure you want to change the base?
Conversation
"#include <cassert>\n", | ||
"#include <cmath>\n", | ||
"\n", | ||
"class NormalDistributionPdf {\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd call the class NormalDistribution
rather than NormalDistributionPdf
maybe since you can all PDF or LogPDF from it.
"pdf.LogPdf(0.5);\n", | ||
"" | ||
) | ||
text.samples.dep <- paste0( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the two box layout, I would add the random sampling to the class NormalDistribution
. I think following the Mathematica way of doing things where you define a distribution then do whatever you want from it makes a lot of sense.
text.pdf <- paste0( | ||
"const double mean = ", eval(parse(text=input$normal_mu)), ";\n", | ||
"const double std_dev = ", eval(parse(text=input$normal_sigma)), ";\n", | ||
"NormalDistributionPdf pdf{mean, std_dev};\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd call it dist
rather thanPdf
since the class can do more than just evaluate the pdf.
" double mBm1;\n", | ||
"\n", | ||
"public:\n", | ||
" explicit BetaDistributionPdf(double alpha = 1.0, double beta = 1.0)\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like this a lot! Really nice.
text.pdf <- paste0( | ||
"const double alpha = ", eval(parse(text=input$beta_a)), ";\n", | ||
"const double beta = ", eval(parse(text=input$beta_b)), ";\n", | ||
"BetaDistributionPdf pdf{alpha, beta};\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again would rename the class to BetaDistribution
and call the instantiation of it dist
.
"#include <vector>\n", | ||
"" | ||
) | ||
text.samples <- paste0( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As for normal would make this part of the class.
Work towards #50