Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » sci.math.* » sci.math

Topic: Help with algorithm for adjusting RGB colors
Replies: 1   Last Post: Jan 5, 2013 9:04 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View  
James Waldby

Posts: 358
Registered: 1/27/11
Re: Help with algorithm for adjusting RGB colors
Posted: Jan 5, 2013 9:04 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

On Sat, 05 Jan 2013 20:51:17 +0000, Richard Tobin wrote:
> David C. Ullrich <ullrich@math.okstate.edu> wrote:
>> On Fri, 04 Jan 2013 15:08:19 -0800, Jennifer Murphy wrote:
>>> Sub MyRandCharColors()
>>> Dim oChr As Range
>>> Dim sngR As Single, sngG As Single, sngB As Single
>>> Randomize

>
>>It's a common thing, people calling Randomize, or the
>>equivalent in another language, in the body of a
>>function like this, thinking that the more calls to
>>Randomize the better.

>
> There are other reasons why the function might call Randomize.
> In particular, it might be considered a library function and
> not want to assume that the calling program will call it.
>

>>You think calling Randomize over and over is
>>making things more random, but it actually
>>makes things _less_ random. The story:
>>Randomize sets some "seed" based on the
>>system clock. Once that seed is set, repeated
>>calls to Rnd return a sequence of quasi-random
>>numbers, starting with the seed.

>
> I hope not. It would make more sense for it to combine something
> based on the clock with the current random state.


If VBA's Randomize is given a parameter it uses its value to
determinately initialize the random number generator. With no
parameter, it reads a millisecond timer and (according to link
given below) combines it with one state byte to initialize the
random number generator. Info at the link implies that if you
call Randomize more than 256 times in the same millisecond, you
will get repeated sequences of random numbers.
<http://stackoverflow.com/a/13690685/837847>

--
jiw



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.