Sha256: 746727cc7a5da453220618f20daf6d91071c7808d17bac7f0cead8e0e9f57b2d

Contents?: true

Size: 840 Bytes

Versions: 4

Compression:

Stored size: 840 Bytes

Contents

#!/usr/bin/ruby
$:.unshift(File.dirname(__FILE__)+'/../lib/')

require 'statsample'
require 'benchmark'
samples=1000
a=samples.times.collect {rand}.to_scale
b=samples.times.collect {rand}.to_scale
c=samples.times.collect {rand}.to_scale
d=samples.times.collect {rand}.to_scale

ds={'a'=>a,'b'=>b,'c'=>c,'d'=>d}.to_dataset
ds['y']=ds.collect{|row| row['a']*5+row['b']*3+row['c']*2+row['d']*1+rand()}

Benchmark.bm(7) do |x|


rb=ReportBuilder.new(:name=>"Multiple Regression Engines")

if Statsample.has_gsl?
  x.report("GSL:") {
  lr=Statsample::Regression::Multiple::GslEngine.new(ds,'y',:name=>"Multiple Regression using GSL")
  rb.add(lr.summary)
  }
end


  x.report("Ruby:") {
  lr=Statsample::Regression::Multiple::RubyEngine.new(ds,'y',:name=>"Multiple Regression using RubyEngine")
  rb.add(lr.summary)
  }
  puts rb.to_text
end



Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
statsample-0.9.0 examples/multiple_regression.rb
statsample-0.8.2 examples/multiple_regression.rb
statsample-0.8.1 examples/multiple_regression.rb
statsample-0.8.0 examples/multiple_regression.rb