Sha256: b7576142c3c3a3aba295c706cb8b5d19c127ea72fe7f11b27a0c2aa7f47c33a7

Contents?: true

Size: 792 Bytes

Versions: 4

Compression:

Stored size: 792 Bytes

Contents

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

Statsample::Analysis.store(Statsample::Test::ChiSquare) do
  # Collect the two vectors with the categorical data (raw number of occurences) into one matrix. Here
  #--------------------------------------------
  #| category | observation 1 | observation 2 |
  #|------------------------------------------|
  #|    A     |      100      |      20       |
  #|    B     |      50       |      70       |
  #|    C     |      30       |      100      |
  #|------------------------------------------|
  #
  m=Matrix[[100, 50, 30],[20, 70, 100]]
  x_2=Statsample::Test.chi_square(m)
  # after the test is done, look at the p-value.
  puts x_2.probability
end

if __FILE__==$0
  Statsample::Analysis.run_batch
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
statsample-ekatena-2.0.2.1 examples/chisquare_test.rb
statsample-ekatena-2.0.2 examples/chisquare_test.rb
statsample-2.1.0 examples/chisquare_test.rb
statsample-2.0.2 examples/chisquare_test.rb