PHP 0 ve 1'leri Hesaplama

0 Cevap

PHP Frekans (Monobits) testi hesaplamak istiyorum:

Description: The focus of the test is the proportion of zeroes and ones for the entire sequence. The purpose of this test is to determine whether that number of ones and zeros in a sequence are approximately the same as would be expected for a truly random sequence. The test assesses the closeness of the fraction of ones to ½, that is, the number of ones and zeroes in a sequence should be about the same.

Ben gerçekten 0 ve 1 adlı (bit) veya yeterli aşağıdaki hesaplamak gerekiyor ki merak ediyorum:

$value = 0;

// Loop through all the bytes and sum them up.
for ($a = 0, $length = strlen((binary) $data); $a < $length; $a++)
    $value += ord($data[$a]);

// The average should be 127.5.
return (float) $value/$length;

Yukarıdaki aynı değilse, o zaman nasıl ben tam olarak 0 ve 1 adlı hesaplanır?

0 Cevap