In [1]:
def TStep(f,x,dt=.00001):
    x=[f(x)[i]*dt+x[i] for i in range(3)]
    return x

class Dynamics():

    x0=[1,1,1]
    n=10000
    dt=.0001
    params=[10.,8./3,28]
    
    def f(self,x):
        return [self.params[0]*(x[1]-x[0]),x[0]*(self.params[2]-x[2])-x[1],x[0]*x[1]-self.params[1]*x[2]]
    
    def Traj(self):
        traj=[]
        for i in range(self.n):
            self.x0=TStep(self.f,self.x0,dt=self.dt)
            traj.append(self.x0)
        return traj

In [2]:
lor=Dynamics()

In [3]:
lor.n=100000
lor.dt=.01
traj=lor.Traj()

In [12]:
lor.x0


Out[12]:
[-4.000888914540897, -7.155167572523167, 25.395242673786264]

In [16]:
import matplotlib as mpl
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
mpl.rcParams['legend.fontsize'] = 10

traj=np.array(traj)
traj=traj.transpose()
fig = plt.figure()
ax = fig.gca(projection='3d')
theta = np.linspace(-4 * np.pi, 4 * np.pi, 100)
z = np.linspace(-2, 2, 100)
r = z**2 + 1
x = r * np.sin(theta)
y = r * np.cos(theta)
ax.plot(traj[0], traj[1], traj[2], label='parametric curve')
ax.legend()

plt.show()



In [2]:
import ROOT as rt

In [3]:
mem = rt.TH1F("mem","mem",50,0,100)

In [4]:
import random

In [5]:
random.random()


Out[5]:
0.08765336312353722

In [6]:
for i in range(10000):mem.Fill(random.random()*100)

In [7]:
mem.Draw()

In [14]:
inline


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-14-b62bf4bb8c57> in <module>()
----> 1 inline

NameError: name 'inline' is not defined

In [ ]: