VA: How to generate random value? 
Author Message
 VA: How to generate random value?

Hi!

I think this problem was discussed some months ago. Does someone know
how to generate random values with VisualAge 2.0? I have not found any
informations about it in the online documents. Thanks very much!

Alexander Dong

                ///                \\\
               ( ..)              (.. )
------------o00-(_)-00o--------o00-(_)-00o-------------------------------
Alexander Dong                          TH-Darmstadt
Computer science Department             Germany

http://www.*-*-*.com/ ~adong/me.html



Wed, 01 Jul 1998 03:00:00 GMT  
 VA: How to generate random value?

Quote:

>I think this problem was discussed some months ago. Does someone know
>how to generate random values with VisualAge 2.0? I have not found any
>informations about it in the online documents. Thanks very much!

Try class EsRandom (a subclass of Stream). EsRandom answers new values
each time the #next message is sent. Values are floats in the range
[0.0-1.0).

Example:

   | randy |
   randy := EsRandom new.
   10 timesRepeat: [  
      Transcript cr;
         show: randy next printString ]

If you want, say, integers in the range 0 to 10, take the value times 11
and truncate it:

   | randy |
   randy := EsRandom new.
   10 timesRepeat: [
      Transcript cr.
      10 timesRepeat: [
         Transcript show: (randy next * 11) truncated printString ] ]

(BTW, these examples hasn't been tested.)

See "IBM Smalltalk: The Language", Addison-Wesley (Benjamin/Cummings),
1995, ISBN 0-8053-0908-X, pgs. 142 and 545. (I think it's a great book,
but then I wrote it so I'm biased.)

Dave

__________________________________
David N. Smith



IBM T J Watson Research Center
Hawthorne, NY
__________________________________
Any opinions or recommendations
herein are those of the author  
and not of his employer.



Thu, 02 Jul 1998 03:00:00 GMT  
 VA: How to generate random value?

Quote:

>If this class isn't available in VA 2.0, there is a book out there by
>Josef Mittendorfer - Objektorientierte Programmierung mit Smalltak/V for
>Windows, where a class Random is discussed and available on the included
>Disk. It shouldn't be a problem to port this class to VA 2.0.  

I don't konw that particular random number generator (RNG) but one has to
be very careful about just picking up any RNG and using it. Most are
terrible. The better ones are like Yugos and there are NO Mercedes Benzes
(without special hardware). If anyone wants more info, please say so and
I'll append my standard "No! No! not that RNG" message...

Dave

__________________________________
David N. Smith



IBM T J Watson Research Center
Hawthorne, NY
__________________________________
Any opinions or recommendations
herein are those of the author  
and not of his employer.



Fri, 03 Jul 1998 03:00:00 GMT  
 VA: How to generate random value?

<I think this problem was discussed some months ago. Does someone know
<how to generate random values with VisualAge 2.0? I have not found any
<informations about it in the online documents. Thanks very much!

I only have VA 3.0 running and there you have class EsRandom as a
pseudo-random number generator available. If you create a new instance and
send <next> to it, it answers a float which is the next pseudo-random
number in the interval [0.0 1.0].

If this class isn't available in VA 2.0, there is a book out there by
Josef Mittendorfer - Objektorientierte Programmierung mit Smalltak/V for
Windows, where a class Random is discussed and available on the included
Disk. It shouldn't be a problem to port this class to VA 2.0.  

Hope this helps.

Ralf Giegerich
Nintendo of Europe
Grossostheim / Germany




Fri, 03 Jul 1998 03:00:00 GMT  
 VA: How to generate random value?

Quote:

>  See "IBM Smalltalk: The Language", ....I think it's a great book,
>  but then I wrote it so I'm biased.

I didn't write it; I'm not biased.  Its a primo book.  The sections on generating random variables are particularly valuable.

Jim



Tue, 07 Jul 1998 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. HOW TO GENERATE A RANDOM VALUE ?

2. ? generating random uniform and binomial random deviates for BIG integers

3. Generating a value from a VALUE ERROR

4. Generating Random Numbers

5. How to Generate Random Number from Clipper 5.3?

6. LOGO-L> random generated penta fractal

7. LOGO-L> generate random number in MSWLogo

8. Random Number Generating Algorithm/script

9. How to generate random numbers?

10. Newbie question: How do I generate random numbers?

11. generating random numbers

12. Random generated testdata ...

 

 
Powered by phpBB® Forum Software