Skip to content

Instantly share code, notes, and snippets.

@lokeshh
Created August 7, 2016 04:08
Show Gist options
  • Select an option

  • Save lokeshh/8fed775e53ee12c296e9fd3d39f6d8ea to your computer and use it in GitHub Desktop.

Select an option

Save lokeshh/8fed775e53ee12c296e9fd3d39f6d8ea to your computer and use it in GitHub Desktop.
require 'statsample'
require 'benchmark'
n = 10000
df = Daru::DataFrame.new({
a: Statsample::Shorthand.rnorm(n),
b: Statsample::Shorthand.rnorm(n),
c: Statsample::Shorthand.rnorm(n),
d: Statsample::Shorthand.rnorm(n),
})
df[:y] = df.a * 3 + df.b * 5 + df.c * -2 + df.d * 2
p df.head 5
p df.vectors
Benchmark.bm do |x|
x.report do
Statsample::Regression.multiple df, :y
end
x.report do
Statsample::GLM.compute df, :y, :normal, algorithm: :mle
end
end
user system total real
0.870000 0.010000 0.880000 ( 0.869864)
21.940000 0.030000 21.970000 ( 21.985580)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment