Convert plot offset along the y-axis to a sign function [-1;1]

13 Views Asked by At

I’m not sure that I clearly enough reflected the essence of a small problem in the title of the topic, but I’ll try to reveal its essence in the question itself.

https://www.wolframalpha.com/input/...

enter image description here

We have two functions.

If the function is shifted more to the positive region (up along the $y-axis$), then we "mentally associate the $+1$ sign with it, if it is negative (down the $y-axis$), then we" mentally associate the $-1$ sign with it".

If both the positive and negative regions are approximately the same, then we must switch between $-1$ and $+1$. Is there a continuous function that implements this operation, including in real time mode and those cases when the analytical description of the function is unknown?

EDIT: Let me be more specific: I need a function that extracts a constant component of the signal proportional to the displacement along the y-axis. The signal continuously changes in time, therefore, it is necessary to extract the DC component in real time. For example, from this functions:

https://www.wolframalpha.com/input...