[#4341] DRY and embedded docs. — Hugh Sasse Staff Elec Eng <hgs@...>
If I have a here document in some ruby program:
[#4347] Re: DATA and rewind. — ts <decoux@...>
>>>>> "H" == Hugh Sasse Staff Elec Eng <hgs@dmu.ac.uk> writes:
[#4350] Re: Thirty-seven Reasons [Hal Fulton] Love[s] Ruby — "David Douthitt" <DDouthitt@...>
[#4396] Re: New Require (was: RAA development ideas (was: RE: Looking for inp ut on a 'links' page)) — Hugh Sasse Staff Elec Eng <hgs@...>
On 9 Aug 2000, Dave Thomas wrote:
[#4411] Re: RAA development ideas (was: RE: Lookin g for inp ut on a 'links' page) — Aleksi Niemel<aleksi.niemela@...>
Me:
On Thu, 10 Aug 2000, [iso-8859-1] Aleksi Niemelwrote:
[#4465] More RubyUnit questions. — Hugh Sasse Staff Elec Eng <hgs@...>
I am beginning to get a feel for this, but I still have a few more
[#4478] Re: RubyUnit. Warnings to be expected? — ts <decoux@...>
>>>>> "H" == Hugh Sasse Staff Elec Eng <hgs@dmu.ac.uk> writes:
[#4481] Invoking an extension after compilation — Dave Thomas <Dave@...>
Hi,
[#4501] What's the biggest Ruby development? — Dave Thomas <Dave@...>
[#4502] methods w/ ! giving nil — Hugh Sasse Staff Elec Eng <hgs@...>
I have got used to the idea that methods that end in '!' return nil if
[#4503] RubyUnit and encapsulation. — Hugh Sasse Staff Elec Eng <hgs@...>
My_class's instance variables are not all "attr :<name>" type variables,
[#4537] Process.wait bug + fix — Brian Fundakowski Feldman <green@...>
If your system uses the rb_waitpid() codepath of rb_f_wait(),
[#4567] Re: What's the biggest Ruby development? — Aleksi Niemel<aleksi.niemela@...>
Dave said:
Robert Feldt <feldt@ce.chalmers.se> writes:
On Sat, 26 Aug 2000, Dave Thomas wrote:
Robert Feldt <feldt@ce.chalmers.se> writes:
On Mon, 28 Aug 2000, Dave Thomas wrote:
Robert Feldt <feldt@ce.chalmers.se> writes:
[#4591] Can't get Tcl/Tk working — Stephen White <steve@...>
I can't get any of the samples in the ext/tk/sample directory working. All
I'm sure looking forwards to buying the book. :)
Stephen White <steve@deaf.org> writes:
On Sun, 27 Aug 2000, Dave Thomas wrote:
Stephen White <steve@deaf.org> writes:
[#4608] Class methods — Mark Slagell <ms@...>
Reading the thread about regexp matches made me wonder about this:
[#4611] mod_ruby 0.1.19 — shreeve@...2s.org (Steve Shreeve)
Shugo (and others),
[#4633] Printing tables — DaVinci <bombadil@...>
Hi.
[#4647] Function argument lists in parentheses? — Toby Hutton <thutton@...>
Hello,
[#4652] Andy and Dave's European Tour 2000 — Dave Thomas <Dave@...>
Hi,
[#4672] calling super from c — Robert Feldt <feldt@...>
[#4699] Double parenthesis — Klaus Spreckelsen <ks@...1.ruhr-uni-bochum.de>
Why is the first line ok, but the second line is not?
[ruby-talk:4530] RFC: Ruby extension for Random numbers
Hi all,
It turns out that both Aleksi and I have developed Ruby extensions for
random number generators. They are needed since the rng's in the OS:es are
typically not very good (ie. random) or fast and you want to be able to
create stream of rn's that are not affected by calls from other threads /
programs.
We will merge our efforts and intend to submit a working copy to RAA in a
couple of days. Below you'll find a proposed structure for the extension.
If you have any comments, additions, code or ideas that relate to this
effort then please mail them to us as quickly as possible (and we'll try
to include them...).
We especially request comments on the naming of classes and methods. We
want them to adhere to the "principle-of-least-surprise" for as many of
you as possible!
Thanks in advance,
Robert
Ps. Initial testing show that the implementation of the MersenneTwister
RNG is actually 80% faster than using rand()! And this for a very good RNG
(with a period of 2**19937-1!).
Design of Ruby Random extension
-------------------------------
module Math::Random
class RandomNumberGenerator
include Marshal
initialize(seed = nil)
if seed == nil then use Time.now.usec
rand(n)
call rand_float if n = 0, call rand_integer otherwise
rand_integer(n)
returns Fixnum or Bignum (Bignum if n is Bignum)
rand_fixnum(n)
rand_bignum(n)
rand_float
returns Float in [0.0, 1.0) (ie. including 0.0 but NOT 1.0)
alias_mehod :randint, :rand_integer
alias_mehod :randfloat, :rand_float
rand_interval(min, max)
return a Fixnum in the interval [min, max] (inclusive)
seed=(newSeed)
set new (fixnum) seed
seed
returns the current seed
stream_position
returns the current position in the RNG stream ie. the number of rn's
taken from the stream since the last seeding
inspect
Prints name of RNG algorithm, seed and position.
to_s
calls inspect
_dump(aDepth)
dump internal state to string
RandomNumberGenerator._load(aString)
create object with state from string
end
class MersenneTwister19937 < RandomNumberGenerator
# Fast implementation of the Mersenne Twister RNG algorithm
end
class RubyRng < RandomNumberGenerator
# Wrapper for Ruby rand() and srand() for testing purposes.
# WARNING! Will not give a unique stream since external rand/srand calls
# will alter the nums from the stream.
end
class RngTester
initialize(aRng)
average_float(iterations)
performance(iterations)
end
class RandomGauss
initialize(aRng = nil, mean = 0.0, stdDev = 1.0)
attr_accessor :mean, :std_deviation
sample(mean = 0.0, stdDev = 1.0)
Get a random number sampled from a Gaussian(mean, stdDev) distribution
end
end
Todo
----
* Add more RNG's: R250 (faster than MT but shorter period), taus...
* Basic testing in RubyUnit/Rubicon
* Random strings? RandomString.sample("CCcc!nc") could give "RShi$5w"...
* Add more non-uniform distributions: binomial, cauchy, ...
* Wrap the built-ins?! Global singleton object that rand/srand delegates
to?
* Cryptographic RNG's: ISAAC and/or Yarrow
* RngTester
chi2_uniformity
kolomogorov_smirnov_uniformity