Vectorizing a sequence \$x_{i+1} = f(x_i)\$ with NumPy 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?
You can't vectorize this. Repeated application of \$x_i = \mu x_{i-1} (1-x_{i-1})\$ is chaotic.