0
$\begingroup$

I have the following algorithm which needs to be expressed more concisely using mathematical symbols and I need help for that.

The algorithm accepts a square matrix and a related set of integers (ids) and returns a real number.

(1) I have a square matrix S of size N x N.

(2) Each row of the matrix has two integers associated with it. $Id_{true}$ and $Id_{obs}$.

(3) V consecutive rows have the same $Id_{true}$. Rows with the same $Id_{true}$ may or may not have same $Id_{obs}$. Thus each $Id_{true}$ is related to V number of $Id_{obs}$.

(4) Let the most frequently occurring id in $\{Id_{obs}\}$ be $Id_f$. Tie is not acceptable. The frequency with which $Id_f$ occurs must be greater than all other Ids frequency.

(5) If $Id_{true}$ == $Id_{f}$, success else failure.

(6) At the end of processing all rows of S, the no of successes is counted and returned as a percentage.

  • 0
    @TsuyoshiIto yes - you are right. That is because I did not explain how the ids are related to the rows...which I thought is irrelevant to mention here.2011-11-19

1 Answers 1

1

I take it your algorithm is something like

count:=0;

for i from 1 to N do if Id_true = Id_obs then count:=count + 1 fi;

return 100 count / N.

As for a mathematical formula, how about ${100\over N}\sum_{i=1}^N1_{Id_{true}(i)=Id_{obs}(i)}$ where $1_P$ is the notation for the quantity that is 1 if $P$ is true and 0 if $P$ is false.

  • 0
    I was asking for a concise mathematical representation. I have already implemented the above algorithm.2011-11-20