I have to describe a code I have written using formal mathematical notation, but I don't know how to define an operation that depends on the number of elements.
Here's an example pseudocode:
example_function(vector):
relevant_values = 0
positive_values = 0
for each element of vector:
if element > 0.7:
relevant_values += 1
positive_values += 1
if element < 0.3:
relevant_values += 1
return positive_values/relevant_values
Given the example pseudocode above I need to describe it as a function something like:
\begin{equation} f(\mathbf{v}) = \text{something} \end{equation}
I want to know if this is even possible, and any directions on where I can possibly find the answer will be good as well.
Guide:
There are a few ways.
we can use the cardinality of a set , $A$, using notation $|A|$. Hence you just have to describe the set.
Alternatively, we can also use indicator variable. $\mathbb{1}_p$ to take value $1$ if condition $p$ holds and $0$ otherwise and then sum it up. For example, if we want to check whether the first element is more than $0.7$, we can write $\mathbb{1}_{v_1>0.7}$. If we want to check how many elements in the vector satisfy that condition, just use an index and sum it up, $\sum_{i=1}^{n} \mathbb{1}_{v_i>0.7}$.
Do give it a try, edit your post, and discuss further if you need further help.