-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
tanjent
committed
Mar 1, 2012
1 parent
332f01d
commit 8687042
Showing
42 changed files
with
9,164 additions
and
8,318 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,56 @@ | ||
#include "AvalancheTest.h" | ||
|
||
//----------------------------------------------------------------------------- | ||
|
||
void PrintAvalancheDiagram ( int x, int y, int reps, double scale, int * bins ) | ||
{ | ||
const char * symbols = ".123456789X"; | ||
|
||
for(int i = 0; i < y; i++) | ||
{ | ||
printf("["); | ||
for(int j = 0; j < x; j++) | ||
{ | ||
int k = (y - i) -1; | ||
|
||
int bin = bins[k + (j*y)]; | ||
|
||
double b = double(bin) / double(reps); | ||
b = fabs(b*2 - 1); | ||
|
||
b *= scale; | ||
|
||
int s = (int)floor(b*10); | ||
|
||
if(s > 10) s = 10; | ||
if(s < 0) s = 0; | ||
|
||
printf("%c",symbols[s]); | ||
} | ||
|
||
printf("]\n"); | ||
} | ||
} | ||
|
||
//---------------------------------------------------------------------------- | ||
|
||
double maxBias ( std::vector<int> & counts, int reps ) | ||
{ | ||
double worst = 0; | ||
|
||
for(int i = 0; i < (int)counts.size(); i++) | ||
{ | ||
double c = double(counts[i]) / double(reps); | ||
|
||
double d = fabs(c * 2 - 1); | ||
|
||
if(d > worst) | ||
{ | ||
worst = d; | ||
} | ||
} | ||
|
||
return worst; | ||
} | ||
|
||
//----------------------------------------------------------------------------- | ||
#include "AvalancheTest.h" | ||
|
||
//----------------------------------------------------------------------------- | ||
|
||
void PrintAvalancheDiagram ( int x, int y, int reps, double scale, int * bins ) | ||
{ | ||
const char * symbols = ".123456789X"; | ||
|
||
for(int i = 0; i < y; i++) | ||
{ | ||
printf("["); | ||
for(int j = 0; j < x; j++) | ||
{ | ||
int k = (y - i) -1; | ||
|
||
int bin = bins[k + (j*y)]; | ||
|
||
double b = double(bin) / double(reps); | ||
b = fabs(b*2 - 1); | ||
|
||
b *= scale; | ||
|
||
int s = (int)floor(b*10); | ||
|
||
if(s > 10) s = 10; | ||
if(s < 0) s = 0; | ||
|
||
printf("%c",symbols[s]); | ||
} | ||
|
||
printf("]\n"); | ||
} | ||
} | ||
|
||
//---------------------------------------------------------------------------- | ||
|
||
double maxBias ( std::vector<int> & counts, int reps ) | ||
{ | ||
double worst = 0; | ||
|
||
for(int i = 0; i < (int)counts.size(); i++) | ||
{ | ||
double c = double(counts[i]) / double(reps); | ||
|
||
double d = fabs(c * 2 - 1); | ||
|
||
if(d > worst) | ||
{ | ||
worst = d; | ||
} | ||
} | ||
|
||
return worst; | ||
} | ||
|
||
//----------------------------------------------------------------------------- |
Oops, something went wrong.