This repository has been archived by the owner on Apr 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgenerador_congruencial_mixto.html
58 lines (58 loc) · 1.83 KB
/
generador_congruencial_mixto.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<html>
<head>
<title>
numeros pseudoaleatorios
</title>
</head>
<body>
<script type="text/javascript">
var x,a , c, m, date, numero, valor, valor_usado;
alert("Generar numeros pseudoaleatorios");
//Aqui se obtienen los valores iniciales del generador basandose en la fecha del sistema
date = new Date();
x =date.getMonth();
a =date.getDate();
if (a%2==0)
{
a = date.getMinutes();
}
c =date.getDay();
if (c%8!=5)
{
c =date.getMinutes();
if (a==c)
{
c = date.getSeconds();
}
}
m =date.getHours();
document.write("x " , x, "\n", "a " , a, "\n", "c " ,c, "\n", "m " ,m, "\n");
//Esta es la formula inicial del generador|
numero = (((a*x+c)%m)/m);
for(i=0;i<10000;i++)
{
//Se generan los numeros con la condicion que sean menor que 10 y mayor que 0
numero = ((a*numero+c)%m);
valor = numero/m;
if(valor<10 && valor!=0)
{
//Se multiplica por 10 el numero para que quede mayor que 1, si sigue siendo menor se multiplica de nuevo por 10 para obtener flotantes mayores a 1 que luego se redondean
valor=valor*10;
if(valor<1)
{
valor=valor*10;
if(valor<1)
{
valor=valor*10;
}
}
}
valor_usado= Math.round(valor);
if(valor_usado<10 && valor_usado !=0)
{
document.write( valor_usado, "\n");
}
}
</script>
</body>
</html>