# Notation for multiplying with logical ($x_i > N$)

For a vector $$x_i$$ and numeric values $$\theta_j$$ and $$\beta_j$$, I can write this vectorized calculation in R:

y = (x > theta1) * beta1 + (x > theta2) * beta2 + (x > theta3) * beta3


In programming, x > theta1 evaluates to TRUE (1) and FALSE (0) and multiplication is straightforward. But how do I write this as a mathematical expression? This was my first hunch, but I'm not sure it would fare well:

\begin{align} y_i =& (x_i > \theta_1) \beta_1 + (x > \theta_2) \beta_2 + (x > \theta_3) \beta_3 \\ =& \sum_{j = 1}^{3} (x_i > \theta_j) \beta_j \end{align}

I would like to avoid a notation where the cumulative nature of the expression is less obvious and which quickly grows overly long. I have many more terms and comparators in actual equations.

$$y_i = \begin{cases} \beta_1 & \text{if } x_i > \theta_1 \\ \beta_1 + \beta_2 & \text{if } x_i > \theta_2 \\ \beta_1 + \beta_2 + \beta_3 & \text{if } x_i > \theta_3 \\ \end{cases}$$

$$x_i$$ and $$\theta_j$$ are monotonically increasing.

• Are we to take it that the sequence $\theta_1, \theta_2, \ldots$ is increasing? Commented Dec 10, 2019 at 15:45
• @CalumGilhooley, yes, and so too for $x_i$. I've updated the question with that clarification. Commented Dec 10, 2019 at 15:59

In any case, I feel that because the sequence $$\theta_1, \theta_2, \ldots$$ is increasing (incidentally, I don't think it is relevant that the sequence $$x_1, x_2, \ldots$$ is increasing), which results in the special form of the sums for the $$y_i$$ as shown at the end of the question, it would be clearer (although less snappy) to write something along these general lines (vary according to taste): $$\begin{gather*} N_x = \max\{j : \theta_j < x\}, \\ s(x) = \sum_{j=1}^{N_x}\beta_j, \\ y_i = s(x_i). \end{gather*}$$