diff options
author | Marti Bolivar <mbolivar@leaflabs.com> | 2011-08-31 11:26:53 -0400 |
---|---|---|
committer | Marti Bolivar <mbolivar@leaflabs.com> | 2011-08-31 13:06:07 -0400 |
commit | b8545bfea262e3fcd4e3796c8d61fdf3c6f9cb70 (patch) | |
tree | 822107859f1703967c2bd2b215c83d3a8d68d848 /examples/test-usart-dma.cpp | |
parent | 796f6922f5d06b9b208a56d343266deee3940a90 (diff) | |
download | librambutan-b8545bfea262e3fcd4e3796c8d61fdf3c6f9cb70.tar.gz librambutan-b8545bfea262e3fcd4e3796c8d61fdf3c6f9cb70.zip |
test-session.cpp: Better analog noise readings.
Update measure_adc_noise() to actually use the Welford online
algorithm, instead of accumulating data in an array on the stack.
This allows us to increase the number of samples (to 1000).
Revised algorithm tested on host PC and compared (in Python) against
numpy with a list of 100 values in [0, 1) drawn using random.random().
Results (Python):
>>> r = [random.random() for i in xrange(100)]
>>> numpy.mean(r)
0.50073064742634854
>>> numpy.var(r)
0.083726090293309297
Results (C++, x86 host PC):
n: 100 mean: 0.500731 variance: 0.084572
So this algorithm for variance has some inaccuracies, but it appears
to be good to a couple of significant figures.
Diffstat (limited to 'examples/test-usart-dma.cpp')
0 files changed, 0 insertions, 0 deletions