Düzgün dağılmış rasgele sayılar (0,1) oluşturma - sayfa 19

 
AlexEro >> :

2. algoritma


 void OnStart ()
  {
//---
   MathSrand (( int ) TimeLocal ());

   for ( int i= 0 ;i< 10000 ;i++)
   {
   Print (DRNG_Tausworthe());
   }

  }
//+------------------------------------------------------------------+

// Tausworthe is a nice option. It gives 2^88 non-repetitive numbers.
// A handful of primitive operations, and extremely good randomness;
static long s1 = 1423667 , s2 = 2234 , s3 = 34567 ; // any non-zero numbers
long RNG_Tausworthe ()
{       long b ;
        b = ( (s1 << 13 ) ^ s1) >> 19 ;
        s1 = ( (s1 & 4294967294 ) << 12 ) ^ b;
        b = ( (s2 << 2 ) ^ s2) >> 25 ;
        s2 = ( (s2 & 4294967288 ) << 4 ) ^ b ;
        b = ( (s3 << 3 ) ^ s3) >> 11 ;
        s3 = ( (s3 & 4294967280 ) << 17 ) ^ b ;
         return (s1 ^ s2 ^ s3);
}
// Or, simply:
// s1=((s1&4294967294)<<12)^(((s1<<13)^s1)>>19) ;
// s2=((s2&4294967288)<<4)^(((s2<<2)^s2)>>25) ;
// s3=((s3&4294967280)<<17)^(((s3<<3)^s3)>>11) ;
// return (s1^s2^s3) ;

//............................./ DRNG_Tausworthe \.................................
double DRNG_Tausworthe ( void )
{       return ( ( double ) RNG_Tausworthe () * 2.3283064365 e- 10 );
}

Neyi yanlış yaptım?

 
joo >> :

2. algoritma


Neyi yanlış yaptım?

Bit işlemleri. Ve sen değil, muhtemelen MetaQuotes.

 

Bu konuya daha önce değinildiyse özür dilerim, GOS'ta (GPSN) beni ilgilendiren konuyla ilgili ayrı bir konu açtım:

https://forum.mql4.com/ru/31779