ruby-gsl Sample: rnd3.rb


#!/usr/local/bin/ruby


require "GSL"
include GSL::Random

# Test random number distributions
# generate output suitable for graph(1) from GNU plotutils:
# ruby test/rnd3.rb | graph -Tps > g.ps

STDERR.puts "Running tests for RND(3)..."

x = y = 0
a = []
r = RNG.new
puts "#m=1,S=2"
printf "%g %g\n", x, y
10.times do
  a = RND::dir_2d(r)
  x += a[0]
  y += a[1]
  printf "%g %g\n", x, y
end

STDERR.puts "\ndone."


Back