I would like to populate a NumPy array with "accumulated" results from a custom function.
Currently, my code is:
import numpy as np
def f(x, mu):
    return mu * x * (1 - x)
def populate(x0, mu, n):
    s = np.zeros(n)
    x = x0
    for i in range(n):
        s[i], x = x, f(x, mu)
    return s
It does not take advantage of the vectorization performance of NumPy.
Is there any way to improve the speed of creating arrays like this?
s[0] == x0. \$\endgroup\$