균일하게 분포된 난수 생성(0,1) - 페이지 19

 
AlexEro >> :

두 번째 알고리즘


 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 );
}

내가 뭘 잘못했어?

 
joo >> :

두 번째 알고리즘


내가 뭘 잘못했어?

비트 연산. 그리고 당신이 아니라 아마도 MetaQuotes 일 것입니다.

 

이 문제가 이미 다루어진 경우 사과드립니다. GOS(GPSN)에서 관심 있는 문제에 대한 별도의 주제를 열었습니다.

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