Model this relationship linearly $V_i = 1$ if$ P_i > 0$, else $0$

20 Views Asked by At

Given a vector $P$ with entries between $0$ and $1$.

I want to do some linear transformation to output a vector $V$ where : $V_i = 1$ if $P_i \gt 0$, else $V_i=0$.

One of the solutions is to divide with $max(P_i, eps)$, but it is not continuous.

Is there a way to do it with using only linear transformations?

1

There are 1 best solutions below

0
On BEST ANSWER

You are essentially applying the Heaviside step function to each component of the vector, and this is inherently non-linear. With a linear function, scaling the input scales the output by a similar factor, but if your function is only taking values of $0$ and $1$ then there's no way to scale anything.

As the Wikipedia article mentions, there are plenty of smooth approximations to the step function, for example

$$H(x) \approx \frac{1}{1 + e^{-2kx}}$$

will give decent results for large (positive and negative) values of $x$, and depending on how large $k$ is the approximation will work well for smaller values of $x$ as well (although requiring a continuous function means you'll always have an interval where values are hovering around $\frac{1}{2}$, and most of the common approximations will probably have that happen at $x = 0$).