How to write down formally number(s) of occurence?

I am trying to see how to have more than one condition using Iverson bracket notion. Basically, I am trying to represent this if statement formally.

Count number of occurence when [ (A<x) and (B<y)] is true.

I am aware of the following question.

My first guess was:

$$C(x) = \sum_{i=1}^n [A < x][B < y]$$

which I am not sure if true.

x and y are arbitrary numbers, while A and B values are attributes of each element in a set where the size of the set is n. The pseudocode for the above statement is:

for i in n:
     if i.A < x and i.B < y:
           count++

where count is the total number of time the condition was true.


Solution 1:

Going off of your pseudo-code, there are a couple of problems with your guess.

First of all, while you use i.A and i.B in your code, there is no connection between $A$, $B$ and $i$ in your formula. Now, in math, “objects” that have properties you can access are not a normal way of setting things up, so you wouldn’t normally see $i{.}A$ or $i_A$ or $i(A)$. Instead, it’s more common to arrange the A-values and B-values into sequences, i.e. to write $A_i$ and $B_i$ (or $A(i)$ and $B(i)$, if you prefer). You can index your A-values and B-values by integers, but other indexing sets might work, too.

Your loop then becomes $$ \sum_{i = 1}^n [A_i < x] [B_i < y]. $$ I included the transformation from $[\text{$A_i < x$ and $B_i < y$}]$ to $[A_i < x] [B_i < y]$ that you did in your post. Either version is fine.

Last, it is a bit strange that you used $C(x)$ even though the value depends on both $x$ and $y$. (I would have expected $C(x,y)$.) But this might be fine, if $y$ is generally fixed whereas $x$ varies.