Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to 'checksum' an array of noisy floating point numbers?
    primarykey
    data
    text
    <p>What is a quick and easy way to 'checksum' an array of floating point numbers, while allowing for a specified small amount of inaccuracy?</p> <p>e.g. I have two algorithms which should (in theory, with infinite precision) output the same array. But they work differently, and so floating point errors will accumulate differently, though the array lengths should be exactly the same. I'd like a quick and easy way to test if the arrays seem to be the same. I could of course compare the numbers pairwise, and report the maximum error; but one algorithm is in C++ and the other is in Mathematica and I don't want the bother of writing out the numbers to a file or pasting them from one system to another. That's why I want a simple checksum.</p> <p>I could simply add up all the numbers in the array. If the array length is N, and I can tolerate an error of 0.0001 in each number, then I would check if <code>abs(sum1-sum2)&lt;0.0001*N</code>. But this simplistic 'checksum' is not robust, e.g. to an error of +10 in one entry and -10 in another. (And anyway, probability theory says that the error probably grows like sqrt(N), not like N.) Of course, any checksum is a low-dimensional summary of a chunk of data so it will miss <em>some</em> errors, if not most... but simple checksums are nonetheless useful for finding non-malicious bug-type errors.</p> <p>Or I could create a two-dimensional checksum, <code>[sum(x[n]), sum(abs(x[n]))]</code>. But is the best I can do, i.e. is there a different function I might use that would be "more orthogonal" to the <code>sum(x[n])</code>? And if I used some arbitrary functions, e.g. <code>[sum(f1(x[n])), sum(f2(x[n]))]</code>, then how should my 'raw error tolerance' translate into 'checksum error tolerance'?</p> <p>I'm programming in C++, but I'm happy to see answers in any language.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload