Skip to content

Instantly share code, notes, and snippets.

@SergeStinckwich
Last active November 30, 2016 10:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SergeStinckwich/2a18ddb4ec0fbd020481 to your computer and use it in GitHub Desktop.
Save SergeStinckwich/2a18ddb4ec0fbd020481 to your computer and use it in GitHub Desktop.
Hubble constant approximation with PolyMath and Roassal
x := #(0.028 0.076 0.108 0.136 0.153 0.226 0.283 0.359 0.363 0.408 0.438 0.472 0.476 0.476 0.493 0.556 0.639).
y := #(2.7 4.2 10.5 14.1 10.5 13.2 19.8 28.2 20.7 29.4 31.8 44.4 32.1 37.2 33 34.5 46.5).
lr := DhbLinearRegression new.
points := (1 to: x size) collect: [:i|( (x at: i)@(y at: i))].
points do: [:i|lr add:i].
p := lr asEstimatedPolynomial.
b := RTGrapher new.
lb := RTLegendBuilder new.
lb view: b view.
lb addText: ('H=', lr slope asString).
lb build.
ds := RTData new.
ds noDot.
ds points: (0 to: 0.8 by: 0.1).
ds x: #yourself.
ds y: [:i|p value: i].
ds connectColor: (Color red).
b add: ds.
ds := RTData new.
ds points: points.
ds x: #x.
ds y: #y.
b add: ds.
b build.
b view
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment