The exponential function is e^x where e is a mathematical constant called Euler's number, approximately 2.718281. This value has a close mathematical relationship with pi and the slope of the curve e^x is equal to its value at every point. np.exp() calculates e^x for each value of x in your input array.
Videos
The exponential function is e^x where e is a mathematical constant called Euler's number, approximately 2.718281. This value has a close mathematical relationship with pi and the slope of the curve e^x is equal to its value at every point. np.exp() calculates e^x for each value of x in your input array.
It calculates ex for each x in your list where e is Euler's number (approximately 2.718). In other words, np.exp(range(5)) is similar to [math.e**x for x in range(5)].
I came across this code example:
import plotly.graph_objects as go import numpy as np np.random.seed(42) # Simulate data returns = np.random.normal(0.01, 0.2, 100) price = 100 * np.exp(returns.cumsum()) time = np.arange(100)
I read up on the use of the natural logarithm and Euler's number here: https://lucaslouca.com/Why-Use-Logarithmic-Returns-In-Time-Series-Modelling/
I'm not quite sure why it's good to use Euler's number here.
My thinking so far is this:
multiplying with 100 simply makes the data start at index 100 instead of at index 1.
I see that using the exp function allows a simple summation of the returns. But on the other hand, if we see the returns as percentage based (0.1 meaning 10 %) then using this method will distort the data - since exp(0.1) = 1.10517
Curious if anyone can explain this.
I realize it's as much math and economics as its programming, but I've seen it used before and in this particular example there were no comments in the relevant section of the code.
after a lot of searching i couldn't find any answer that makes sense.