Ok, well i've come up with a function to test the uniform distribution *of sorts* (in the sense that I have no idea if it follows the standard convention or if the values even remotely correspond to the official function). I'm fairly happy with the output, but if anyone could point out how the conventional function would be designed I would appreciate it.

Code:

`/*`

Returns a score on the interval (0, 1) where 0 == worst and 1 == perfect.

Container is filled with the counts of each value where the values correspond

to the logical index of that particular element. So for example data[ 11 ]

contains a count of the value 11.

*/

template < typename Container >

double uniform_distribution( Container const& data )

{

double

result = 0,

size = double( data.size( ) ),

count = std::accumulate( data.begin( ), data.end( ) , double( 0 ) ),

expected = count / size;

if( count == 0 )

return std::numeric_limits< double >::quiet_NaN( );

for

(

typename Container::const_iterator seq = data.begin( ), fin = data.end( );

seq != fin;

++seq

)

{

double

value = *seq;

if( value )

result += value - expected;

}

return 1.0 - ( result / count );

}

EDIT:

Ok, well the function is not actually implemented correctly. I'm working on a fix right now...

EDIT #2:

Fixed (thanks to Tabstop)!