1
votes

I would like to get the error rate of 2 vectors?

like

                # incorrect numbers           6
error rate  = ______________________    =    ____ 
               # total numbers(size)          15

here are 15 numbers, 9 are correct x is the true answer (the reference), and y is vector with answers I would like to compare them and get error rate:

x= [1 ,1,1, 1,1, 1,1,1,1,1, 1,-1,-1,-1,-1] 
y= [-1,1,1,-1,1,-1,1,1,1,1,-1, 1,-1, 1,-1]   
  • Also is it corret what I am doing? Ok I was wrong about the formula I updated it.
2
Ok, so what have you tried already?Oliver Charlesworth
I have tried substracting them, but like x-y, and if the result is 0 they are equal, but do not how to code in MATLAB size(x-y < 0); but don't get correct answeredgarmtze
Ok, so, we need another substractring right?edgarmtze

2 Answers

3
votes

If you want the error rate, then you want the number of incorrect values divided by the total number of values. You can do this using the relational operator ~= and the function MEAN:

errorRate = mean(x ~= y);
1
votes

Another version that works:

length(find(x~=y))/length(y)