i tried the algorithm with a very simple C program and this is the
output i got ,
from my visual  inspection , there was no repetition for the first 98
values after which the cycle started again, this is my output
followed by a simple implementation.

Hope this helps

pdhan...@hansolo:/afs/ece.cmu.edu/usr/pdhanapa> ./a.out
Enter seed X0 5
Enter  multiplier a 2
Enter c and m - relatively prime to each other0
199
 10
 20
 40
 80
 160
 121
 43
 86
 172
 145
 91
 182
 165
 131
 63
 126
 53
 106
 13
 26
 52
 104
 9
 18
 36
 72
 144
 89
 178
 157
 115
 31
 62
 124
 49
 98
 196
 193
 187
 175
 151
 103
 7
 14
 28
 56
 112
 25
 50
 100
 1
 2
 4
 8
 16
 32
 64
 128
 57
 114
 29
 58
 116
 33
 66
 132
 65
 130
 61
 122
 45
 90
 180
 161
 123
 47
 94
 188
 177
 155
 111
 23
 46
 92
 184
 169
 139
 79
 158
 117
 35
 70
 140
 81
 162
 125
 51
 102
 5
 10
 20

// naive Code :P

#include<stdlib.h>
#include<stdio.h>
int main()
{
int x0,a,c,m,i,x1;
printf("Enter seed X0 ");
scanf("%d",&x0);
printf("Enter  multiplier a ");
scanf("%d",&a);
printf("Enter c and m - relatively prime to each other");
scanf("%d %d",&c,&m);
for(i=0;i<=100;i++)
{
x1=( ( (a*x0) + c)% m) ;
printf(" %d \n",x1);
x0=x1;
}
}




On 10/5/09, Prabhu Hari Dhanapal <[email protected]> wrote:
> hi ,
>
> I think the Linear Congruential Generator is believed to be the most
> simple of all PRNGs.
>
> The sequence can be generated using the following,
> X(n+1) = (a* Xn +c ) mod m
>
> In the above , your first step would be
> X1 = (a*X0 +c ) mod m
>
> X0 is the seed value that you need to feed to the algorithm and it has
> no restrictions as such.
>  a is a multiplier
> c is the  increment and choose some value for m
>
> note that c and m should be relatively prime to each other - (such
> that they do no have any common factor except for 1 )
>
>  This perfectly fits you application because, LCGs are generally not
> advisable to be used in Cryptographic algorithms - where randomness is
> critical.
>
>
>
> On 10/3/09, Brandon <[email protected]> wrote:
>>
>> Hi.
>>
>> I need a computationally simple algorithm to generate a random series
>> of discrete values, i.e., I want to get a string of integers where
>> each integer is in the range from 1 to N where N is fairly small (less
>> than 100 for sure).  Has to be simple enough to run on a
>> microcontroller unit.  Doesn't need to be extremely good, the sequence
>> could probably repeat after only 1000 values and sitll be okay.  I
>> just don't want to someone looking at the sequence to notice any
>> obvious patterns.
>>
>> Thanks
>>
>> >>
>>
>
>
> --
> Hari
>


-- 
Hari

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~----------~----~----~----~------~----~------~--~---

Reply via email to