clbustos / statsample

A suite for basic and advanced statistics on Ruby.
http://github.com/clbustos/statsample
BSD 3-Clause "New" or "Revised" License
402 stars 96 forks source link

Error when running multi variable regression from a CSV: `_check_type': NoMethodError #40

Open multimeric opened 9 years ago

multimeric commented 9 years ago

I'm not really sure what's happening here. For some reason if the y value is high precision and I try to run a regression on it, I get this error. However this only works if the high precision data is in a CSV. It won't work as a number literal so it could be an issue with the CSV module itself. I should note that I'm running on Windows (8.1, 64 bit) so this might be an implementation issue.

The simplest code I can get this issue down to is as follows:

require 'statsample'
ds = Statsample::CSV.read("input.txt")
regression = Statsample::Regression.multiple(ds,'y')

And you'll need a file "input.txt" in the same directory with the following data:

x,y
1,9.629587310436753e+127
2,1.9341543147883677e+129
3,3.88485279048245e+130

The full stack trace is:

E:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/statsample-1.4.0/lib/statsample/vector.rb
:161:in `_check_type': NoMethodError (NoMethodError)
        from E:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/statsample-1.4.0/lib/statsam
ple/vector.rb:155:in `check_type'
        from E:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/statsample-1.4.0/lib/statsam
ple/vector.rb:911:in `mean'
        from E:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/statsample-1.4.0/lib/statsam
ple/regression/multiple/rubyengine.rb:23:in `initialize'
        from E:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/statsample-1.4.0/lib/statsam
ple/regression.rb:62:in `new'
        from E:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/statsample-1.4.0/lib/statsam
ple/regression.rb:62:in `multiple'
        from script.rb:3:in `<main>'
agarie commented 9 years ago

Hi @TMiguelT, thanks for reporting this issue! We recently moved the upstream to SciRuby's organization page on GitHub, so could you post this issue there, so we can keep track of it? The repository is in the following link:

https://github.com/sciruby/statsample