Anonymous user
Verify distribution uniformity/Chi-squared test: Difference between revisions
Verify distribution uniformity/Chi-squared test (view source)
Revision as of 09:54, 1 June 2014
, 9 years agoUpdated D entry
(Added Ruby) |
(Updated D entry) |
||
Line 214:
<lang d>import std.stdio, std.algorithm, std.mathspecial;
real x2Dist(T)(in T[] data) pure nothrow @safe @nogc {
immutable avg = data.sum / data.length;
immutable sqs = reduce!((a, b) => a + (b - avg) ^^ 2)(0.0L, data);
Line 220:
}
real x2Prob(in real dof, in real distance)
return gammaIncompleteCompl(dof / 2, distance / 2);
}
bool x2IsUniform(T)(in T[] data, in real significance=0.05L)
return x2Prob(data.length - 1.0L, x2Dist(data)) > significance;
}
|