19 const double kADMin32 = 0.202;
20 const double kADMax32 = 3.89;
23 SkTQSort<double>(p, p + 32);
27 for(
int k = 0; k < 32; k++) {
28 double v = p[k]*(1.0 - p[31-k]);
32 s += (2.0*(k+1)-1.0)*log(v);
34 double a2 = -32.0 - 0.03125*
s;
36 return (kADMin32 < a2 && a2 < kADMax32);
41 const double kChiSqMin256 = 206.3179;
42 const double kChiSqMax256 = 311.5603;
46 for (
int j = 0; j < 256; ++j) {
47 double delta = bins[j] - e;
48 chi2 += delta*delta/e;
51 return (kChiSqMin256 < chi2 && chi2 < kChiSqMax256);
57 double t = ((-0.0004406*z*z* + 0.0418198)*z*z + 0.9)*z;
59 double p = 1.0/(1.0 + exp(t));
66 memset(bins, 0,
sizeof(
int)*256);
69 for (
int i = 0; i < 256*10000; ++i) {
70 bins[(rand.
nextU() >> shift) & 0xff]++;
78 memset(bins, 0,
sizeof(
int)*256);
81 for (
int i = 0; i < 256*10000; ++i) {
82 float f = rand.
nextF();
84 bins[(
int)(f*256.f)]++;
89 for (
int j = 0; j < 32; ++j) {
90 float f = rand.
nextF();
108 const int kWordWidth = 16;
109 const double kMean = 24108.0;
110 const double kStandardDeviation = 127.0;
111 const int kN = (1 << kWordWidth);
112 const int kNumEntries = kN >> 5;
113 unsigned int entries[kNumEntries];
116 memset(entries, 0,
sizeof(
unsigned int)*kNumEntries);
119 for (
int i = 0; i < kWordWidth-1; ++i) {
121 unsigned int rnd = rand.
nextU();
122 value |= ((rnd >> shift) & 0x1);
126 for (
int i = 0; i < kN; ++i) {
128 unsigned int rnd = rand.
nextU();
129 value |= ((rnd >> shift) & 0x1);
131 int index =
value & (kNumEntries-1);
133 int entry_shift = (
value >> (kWordWidth-5)) & 0x1f;
134 entries[index] |= (0x1 << entry_shift);
139 for (
int i = 0; i < kNumEntries; ++i) {
140 unsigned int entry = entries[i];
142 total += (entry & 0x1);
148 double z = ((kN-total)-kMean)/kStandardDeviation;
160 for (
int bit_position = 0; bit_position < 32; ++bit_position) {
175 memset(bins, 0,
sizeof(
int)*256);
176 for (
int i = 0; i < 256*10000; ++i) {
static double normal_cdf(double z)
static double test_single_gorilla(skiatest::Reporter *reporter, int shift)
static void test_random_byte(skiatest::Reporter *reporter, int shift)
static void test_random_float(skiatest::Reporter *reporter)
static bool chi_square_test(int bins[256], int e)
static bool anderson_darling_test(double p[32])
static void test_range(skiatest::Reporter *reporter)
static void test_gorilla(skiatest::Reporter *reporter)
static constexpr int32_t SkLeftShift(int32_t value, int32_t shift)
#define DEF_TEST(name, reporter)
#define REPORTER_ASSERT(r, cond,...)
Type::kYUV Type::kRGBA() int(0.7 *637)
uint32_t nextRangeU(uint32_t min, uint32_t max)