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

Add C++ for normal and beta, and placeholder text #51

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

fcooper8472
Copy link
Collaborator

Work towards #50

@fcooper8472 fcooper8472 requested a review from ben18785 April 4, 2019 14:04
"#include <cassert>\n",
"#include <cmath>\n",
"\n",
"class NormalDistributionPdf {\n",
Copy link
Owner

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(
Copy link
Owner

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",
Copy link
Owner

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",
Copy link
Owner

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",
Copy link
Owner

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 &lt;vector&gt;\n",
""
)
text.samples <- paste0(
Copy link
Owner

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.

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.

2 participants