Sha256: 3010403d440530b92e13a72de5624c8b33a9bb9c2618362b71a99d6988947e38

Contents?: true

Size: 612 Bytes

Versions: 8

Compression:

Stored size: 612 Bytes

Contents

require 'spec_helper'
require 'bioinform/support/inverf'

describe 'Math#inverf' do
  it 'should be erf(inverf(x)) == x' do
    rng = (-0.9..0.9).step(0.1)
    arr = rng.to_a
    arr2 = rng.map{|x| Math.inverf(x)}.map{|x| Math.erf(x)}
    delta = arr.each_index.map{|i| (arr[i] - arr2[i]).abs }
    delta.each{|el| el.should <= 0.001}
  end
  it 'should be erf(inverf(x)) == x' do
    rng = (-5..5).step(1)
    arr = rng.to_a
    arr2 = rng.map{|x| Math.erf(x)}.map{|x| Math.inverf(x)}
    delta = arr.each_index.map{|i| (arr[i] - arr2[i]).abs }
    delta.each{|el| el.should <= 0.01}
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
bioinform-0.1.7 spec/support/inverf_spec.rb
bioinform-0.1.6 spec/support/inverf_spec.rb
bioinform-0.1.5 spec/support/inverf_spec.rb
bioinform-0.1.4 spec/support/inverf_spec.rb
bioinform-0.1.3 spec/support/inverf_spec.rb
bioinform-0.1.2 spec/support/inverf_spec.rb
bioinform-0.1.1 spec/support/inverf_spec.rb
bioinform-0.1.0 spec/support/inverf_spec.rb