[Numpy-discussion] Creating a sine wave with exponential decay

Ram Rachum ram at rachum.com
Tue Jul 23 10:28:03 EDT 2019


Hi everyone! Total Numpy newbie here.

I'd like to create an array with a million numbers, that has a sine wave
with exponential decay on the amplitude.

In other words, I want the value of each cell n to be sin(n) * 2 ** (-n *
factor).

What would be the most efficient way to do that?

Someone suggested I do something like this:

y = np.sin(x) * np.exp(newfactor * x)

But this would create 2 arrays, wouldn't it? Isn't that wasteful? Does
Numpy provide
an efficient way of doing that without creating a redundant array?


Thanks for your help,

Ram Rachum.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20190723/4b29510d/attachment.html>


More information about the NumPy-Discussion mailing list