Skip to content

Commit

Permalink
Bayesian linear regression with arbitrary x array
Browse files Browse the repository at this point in the history
  • Loading branch information
ccshan committed Sep 28, 2017
1 parent ff95452 commit 7fe716c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions examples/blr_xs.hk
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
fn x array(real):
a <~ normal(2,3)
b <~ normal(4,5)
y <~ plate i of size(x): normal(a*x[i]+b,1)
return (y,(a,b))

6 comments on commit 7fe716c

@JacquesCarette
Copy link
Contributor

Choose a reason for hiding this comment

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

I am puzzled by the specificity of the priors on a and b. Any reason for that?

@ccshan
Copy link
Member Author

@ccshan ccshan commented on 7fe716c Sep 28, 2017

Choose a reason for hiding this comment

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

Here there's no reason. In https://github.com/hakaru-dev/hakaru/blob/master/examples/icfp2017/linearRegression.hk the numbers came from examples/LinearRegression.cs in r2-0.0.1.zip (https://www.microsoft.com/en-us/download/details.aspx?id=52372).

@JacquesCarette
Copy link
Contributor

Choose a reason for hiding this comment

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

As far as I can tell, the weird number in that latter example is sqrt(10)/sqrt(3) [or sqrt(10/3) if you prefer`. I believe that if you put that in instead, the simplifier will behave radically differently. Pun intended.

@ccshan
Copy link
Member Author

@ccshan ccshan commented on 7fe716c Sep 28, 2017

Choose a reason for hiding this comment

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

Done, and nice pun, and the simplification result is shorter, but identical in structure.

@JacquesCarette
Copy link
Contributor

Choose a reason for hiding this comment

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

Intriguing. Should you check in the new _simp ? I didn't see that in the previous commit.

@ccshan
Copy link
Member Author

@ccshan ccshan commented on 7fe716c Sep 29, 2017 via email

Choose a reason for hiding this comment

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

Please sign in to comment.