0

I am working on designing a new sensor, and so I have a vector of measured values and a vector of truth values. To represent error, it's simply measured - truth. Since there's a lot of variation in the truth, I would like to represent the normalized error. My initial thought would be error./truth to get percent error, but there are many cases where my truth value is zero! Can anyone think of a better way to represent the normalized data while avoiding the divide-by-zero? I'm working in Matlab, though the question is a bit language-agnostic as well.

PS, feel free to push this to another stackexchange if you think it's better suited

David K
  • 1,296
  • 18
  • 39

2 Answers2

0

Try error = (measured-truth)/norm2(truth) for each vector.

Where norm2() is the forbenious norm.

norm2(x) =SQRT( SUM( x[i]^2, i=1..N ) )

This can only fail is all the values of truth are zero. You can mitigate this by adding a small positive number like 1e-12 to the norm, or to avoid the division when the norm is less than a threshold number.

John Alexiou
  • 28,472
  • 11
  • 77
  • 133
  • All this really does is scale all of my values by the same number. I want to somehow scale each measured point by it's corresponding truth point. – David K Apr 26 '13 at 15:24
  • Well, if your truth point can be `0`, you can't always get what you want. So, try and spend some time rethinking what you actually need... – comingstorm Apr 27 '13 at 00:30
  • @DavidK - Do not do that. It will be far to unstable and the error estimates will be way off. It is best to normalize the differences against a standard value (either typical, or norm2() or a max(), or arbitrary). – John Alexiou Apr 27 '13 at 13:04
0

I'd suggest you to separate results with zero (or smaller than 10e-6 for example) truth vector and non-zero truth vector. You can't treat it by the same means (since you can't normalize truth vector) and you should define what to do in that case.
I can't suggest you something specific because I don't know the problem statement, but you should define it by yourself how to deal with it. Or if you post your problem here I hope we can help you.

Chechulin
  • 2,426
  • 7
  • 28
  • 35