0
$\begingroup$

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.

$\endgroup$
2
  • $\begingroup$ What do you mean by "number of occurrences" in this context. Is there a set of points $(x,y)$ under consideration? Is there an indexed list of pairs $(x_i,y_i)$? Are $x$ and $y$ fixed but $A$ and $B$ independently can take any of a set of values? etc. The answers to these will determine how best to write things down. $\endgroup$
    – Mark S.
    Commented Nov 25, 2021 at 16:10
  • 1
    $\begingroup$ Hi @MarkS. thanks for reply. I added more details. $\endgroup$ Commented Nov 25, 2021 at 16:52

1 Answer 1

2
$\begingroup$

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.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .