| ??? 12/30/03 07:52 Read: times |
#61556 - RE: Random number from 1 to 8 Responding to: ???'s previous message |
Mahmood:
I think you have the correct view point about the "randomness" factor. It only really has to be "good enough". I do think as Kai pointed out that the bursts of 3 in a row could be problematic. I messed around with Keil C51 using the debugger in the simulator and created the following small program:
#include <stdlib.h>
unsigned char xdata array[300];
void main(void)
{
int r;
unsigned char rr;
int i;
for(i=0; i<300; i++)
{
r = rand();
rr = ((r / 7) % 8) + 1;
array[i] = rr;
}
while(1)
{
}
}
I then exported the data out of the µVision2 Watch Window for the array[] variable into Excel and created a chart similar to yours as shown below:
Is this more "random"? Good question. Does it have a "pattern"? Maybe. Is it "good enough"? I think so!! Michael Karas |



