i'm using vb to generate 3 random integers ranging from 0 to 255. i write these numbers to 3 cascaded shift registers via bs2sx. the registers drive led's to observe the bit patern, i have observed that the random seed generates a very tight on/off ratio and seldom goes beyond 14:18.
supposed i wanted to introduce another variable (rate)·into the function that could significantly reduce or increase that ratio.
the only solution i could come up with on the fly is to set each bit individually; however since i cannot reference bits in vb i'd have to introduce some shifty arithmatic such as
sub flicker(rate as integer) as byte
· for cx = 0 to 7
······if rnd * 255 > rate
······· seed = seed * 2 + 1
······· seed = seed * 2
····· end if
···flicker = seed
is there a simpler algorithm that does not involve iteration?