# How would you generate this type of wave form?

I'm trying to generate a wave form that looks like this:

It looks to me like a square wave that has a large transitional section between going from "low" to "high" and back.

Any idea how to generate such a wave mathematically (and/or via some Python library)?

Note also that there is a higher-frequency carrier wave.

• To me it is more like sum of two sines(?), can you provide a more clear image? Oct 29 '16 at 17:30

Try a suitably parameterized function of form:

$$f(t) = \operatorname{clip}\big(a_0\sin(f_0 t) + a_1\sin(f_1 t)\big),$$

where $t$ is time, $f_0$ and $f_1$ are the frequencies and $a_0$ and $a_1$ the amplitudes of two sine waves, and:

$$\operatorname{clip}(x) = \left\{\begin{array}{ll}-1 &\text{if } x < -1\\x &\text{if }-1 \le x \le 1 \\1 &\text{if } x > 1.\end{array}\right.$$

You don't show the scale of the data so the bounds $-1$ and $1$ might be of wrong absolute value. I assumed that the data is zero-centered so there is no zero frequency (bias) term and the bounds look symmetrical in your graph.

• In your $\mathrm{clip}(x)$, $0$ in the second line should be $x$. Apart from that, the bounds are not necessarily $1$ and $-1$, but $\gamma_1$ and $\gamma_2$, or at least $\gamma$ and $-\gamma$.
– msm
Oct 30 '16 at 8:25