Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function losBinC($bit=8){
- $losBinC="";
- for ($bit=0;$bit<8;$bit++){
- $losBinC .= rand(0,1);
- //echo $losBinC."<br>";
- }
- return $losBinC;
- }
- //echo substr(str_shuffle("0000000011111111"),8);
- //echo bindec("1010");
- function losBinS($bit=8) {
- $losBinS="";
- for($bit=0;$bit<8;$bit++)
- $losBinS .="01";
- $losBinS = substr(str_shuffle($losBinS),$bit);
- return $losBinS;
- }
- echo losBinS();
- for($i=0;$i<=255;$i++) {
- $StatC[$i]=0;
- $StatS[$i]=0;
- }
- $ileLosow=50000;
- for ($losowanko=0;$losowanko<$ileLosow;$losowanko++)
- {
- $StatC[bindec(losBinC())]++;
- $StatS[bindec(losBinS())]++;
- }
- $AvgC = 0; $AvgS = 0;
- for ($i=0;$i<=255;$i++) {
- $AvgC+=$StatC[$i]*$i;
- $AvgS+=$StatS[$i]*$i;
- }
- $AvgC /=$ileLosow;
- $AvgS /=$ileLosow;
- echo "<p>Średnia z classic: $AvgC.<p>";
- echo "<p>Średnia z stringowania: $AvgS.<p>";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement