import numpy as np import matplotlib.pyplot as plt A = np.array([[[0.,0.],[0.,0.16]], [[0.85,0.04],[-0.04,0.85]], [[0.20,-0.26],[0.23,0.22]], [[-0.15,0.28],[0.26,0.24]]]) B = np.array([[0.,0.], [0.,1.60], [0.,1.60], [0.,0.44]]) ntrials = 40000 pos = np.zeros((ntrials,2)) for n in range(1,ntrials): type = np.random.choice(range(4),p=[0.01,0.85,0.07,0.07]) pos[n] = A[type].dot(pos[n-1])+B[type] plt.figure(figsize=(8, 12), dpi=80) plt.scatter(pos[:,0],pos[:,1],c=pos[:,1]*0.5,alpha=0.5,s=10,marker='.') plt.show()