Git Product home page Git Product logo

distribution's People

Contributors

agarie avatar agisga avatar clbustos avatar cschwartz avatar dacohen avatar dennyabraham avatar dmitrykorolev-stripe avatar envp avatar mwptrsn avatar ozydingo avatar ppawlikmb avatar rdlugosz avatar reactive-relations avatar translunar avatar v0dro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

distribution's Issues

The gem changes the behavior of integer division

When including the gem, division of two integers returns a rational, whereas normally it would return another integer. Is there a way to turn this off? I would like to use the gem for statistics, but it's clashing with other parts of the code.

ruby-1.8.7-p352 :001 > require 'rubygems'
=> true
ruby-1.8.7-p352 :002 > 3/2
=> 1
ruby-1.8.7-p352 :003 > require 'distribution'
=> true
ruby-1.8.7-p352 :004 > 3/2
=> 3/2
ruby-1.8.7-p352 :005 > (3/2).class
=> Rational

T.cdf on ruby engine doesn't work right

Report:
Seems to give incorrect value. For example:

a=[0,0,0,1,1,1,2,2,2].to_scale
b=[2,2,2,3,3,3,4,4,4].to_scale
t_2 = Statsample::Test::T::TwoSamplesIndependent.new(a,b)
t_2.probability_not_equal_variance

this gives the result: => 0.03333672278567579

However, the result should be: 0.00016053418045947065

Which actually is the value of t_2.probability_equal_variance

The issue seems to be with Distribution::T.cdf which treats df different if its a Fixnum vs a Float.

For the two vectors, where the variance actually is the same, the t statistic and the df should be the same for the equal_variance case and the not_equal_variance case.

But Distribution::T.cdf(-4.8990,16) doesn't give the same result as Distribution::T.cdf(-4.8990,16.0)

I only just started using statsample today, so I don't know if this is a new issue or a long-standing one.

Which gem/repository to use?

Dear @clbustos,

Thanks for your work on the awesome gem distribution!

I'd like to use the gem for some projects but I'm a bit confused about the future: This repository, the original clbustos/distribution, references the SciRuby-Fork as its homepage (See here in the gemspec). Also, the SciRuby-Fork, (sciruby/distribution) contains some constructive work that is not contained in the original, and, confusingly, vice versa, the original contains some work (from 2019) that is not in the Sciruby-fork.

So, of course I completely understand how we may run into this, but I'm asking myself: Shall we invest some work to bring these two forks together again? If yes, what should be the "common" place to continue development? As you are also member of SciRuby: Should it be the original repository, this one or should it be where the SciRuby-fork lives? So, would it be good
to investing work to move the work contained in sciruby/distribution into this one, or would it be good trying to get the work of clbustos/distribution into Sciruby?

Thanks in advance!

other failing tests

Hi again,

After adding the requirement for weibull, I have now two more tests failing:

Failures:

  1) Distribution::Exponential rng should default to Kernel#rand if no :random is given
     Failure/Error: Random.should_receive(:rand).and_return(0.5)
       (Random (class)).rand(*(any args))
           expected: 1 time with any arguments
           received: 0 times with any arguments
     # ./spec/exponential_spec.rb:82:in `block (3 levels) in <top (required)>'

  2) Distribution::Exponential rng should use a given rng if one is passed during construction
     Failure/Error: rng = Distribution::Exponential::rng 1.0, :random => random
     ArgumentError:
       wrong number of arguments (2 for 1)
     # ./spec/exponential_spec.rb:90:in `block (3 levels) in <top (required)>

getting a 'Normal is not a module (TypeError)' when using derailed_benchmarks gem

when trying to run bundle exec derailed bundle:mem

/distribution-0.7.3/lib/distribution/normal/ruby.rb:2:in `<module:Distribution>': Normal is not a module (TypeError)

block at top of said file:

module Distribution
  module Normal
    module Ruby_
      class << self

I've had to add require: false to the Gem, just to get passed this and for the commands to finally work.

Normal distribution CDF gives wrong values for |x| > 38

Distribution::Normal.cdf(-36)
=> 0.0
Distribution::Normal.cdf(-37)
=> 0.0
Distribution::Normal.cdf(-38)
=> 0.0
Distribution::Normal.cdf(-39)
=> 0.5
Distribution::Normal.cdf(38)
=> 1.0
Distribution::Normal.cdf(39)
=> 0.5

Since I just discovered that the Ruby Math library has an erf function, I switched to just using

0.5*(1.0+Math.erf(x.to_f/Math.sqrt(2.0)))

Maybe fixing this bug could help others, though.

Chi-square q_chi2 range violation

2.1.6 :112 > Distribution::ChiSquare.q_chi2(4000, 1487)
=> 1.1715358426793223
2.1.6 :113 > Distribution::ChiSquare.q_chi2(4000, 1488)
=> 1.287980205519492
2.1.6 :114 > Distribution::ChiSquare.q_chi2(4000, 1489)
=> 1.0610471112556463
2.1.6 :115 > Distribution::ChiSquare.q_chi2(4000, 1490)
=> 1.7505434400435371
2.1.6 :116 > Distribution::ChiSquare.q_chi2(4000, 1491)
=> 0.0
2.1.6 :117 > Distribution::ChiSquare.q_chi2(4000, 1492)
=> 0.0

it is expected Distribution::ChiSquare.q_chi2 to be within [0..1] range

not enough 'require' to run correctly spec/weibull_spec.rb

Hi,

Currently, when I run rspec, I get the following error:

/home/boutil/src/ruby/distribution/distribution/spec/weibull_spec.rb:5:in `<top (required)>': uninitialized constant Distribution::Weibull (NameError)
        from /usr/lib/ruby/vendor_ruby/rspec/core/configuration.rb:1327:in `load'
        from /usr/lib/ruby/vendor_ruby/rspec/core/configuration.rb:1327:in `block in load_spec_files'
        from /usr/lib/ruby/vendor_ruby/rspec/core/configuration.rb:1325:in `each'
        from /usr/lib/ruby/vendor_ruby/rspec/core/configuration.rb:1325:in `load_spec_files'
        from /usr/lib/ruby/vendor_ruby/rspec/core/runner.rb:103:in `setup'
        from /usr/lib/ruby/vendor_ruby/rspec/core/runner.rb:89:in `run'
        from /usr/lib/ruby/vendor_ruby/rspec/core/runner.rb:74:in `run'
        from /usr/lib/ruby/vendor_ruby/rspec/core/runner.rb:42:in `invoke'
        from /usr/bin/rspec:4:in `<main>'

For some strange reason, when loading the spec_helper, distribution/weibull.rb is not loaded, whereas distribution.rb is. Adding require "distribution/weibull" to spec/weibull_spec.rb does the trick, but it is just a workaround.

Cannot reproduce `Distribution::Normal::rng` sampling sequence with fixed seed

Passing a fixed seed is necessary to allow debugging of functions using Distribution sampling.

Distribution::Normal.rng(0, 1, 1) == Distribution::Normal.rng(0, 1, 1)
# => false

Should return true instead.

Version info:

p Distribution::Normal.rng(0, 1, 1)
# => #<Proc:0x000000013533f0@/home/user/.rvm/gems/ruby-2.2.1/gems/distribution-0.7.3/lib/distribution/normal/ruby.rb:17 (lambda)>

Notably, you seem to have a test set up in spec/normal_spec.rb:27, but I can't get it executed.

# cd to gem folder
rspec spec/normal_spec.rb:27 2>&1 | grep 'seed'
# => no output
rspec spec/normal_spec.rb 2>&1 | grep 'seed'
# => no output
rspec spec/ 2>&1 | grep 'seed'
# => no output
rspec 2>&1 | grep 'seed'
# => no output

Documentation: README is not using markdown

I find the README quite hard to read because it seems to be in plain text but perhaps formatted for some sort of conversion that github doesn't recognise perhaps?

Anyway, assuming the other version is not needed somewhere else. I have changed the README to README.md and reformatted accordingly for github to make the document more palatable.

The result can be viewed on my own branch which is forked from this repo. I will make a pull request for this change if you agree with what I did there.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.