Beispiel #1
0
def OrnsteinUhlenbeck(x, mu, sigma, tau):
    '''
    An Ornstein-Uhlenbeck process.
    mu = mean
    sigma = standard deviation
    tau = time constant
    x = name of the variable
    Returns an Equations() object
    '''
    return Equations('dx/dt=(mu-x)*invtau+sigma*((2.*invtau)**.5)*xi : unit', \
                     x=x, mu=mu, sigma=sigma, invtau=1. / tau, unit=get_unit(mu))
Beispiel #2
0
def OrnsteinUhlenbeck(x, mu, sigma, tau):
    '''
    An Ornstein-Uhlenbeck process.
    mu = mean
    sigma = standard deviation
    tau = time constant
    x = name of the variable
    Returns an Equations() object
    '''
    return Equations('dx/dt=(mu-x)*invtau+sigma*((2.*invtau)**.5)*xi : unit', \
                     x=x, mu=mu, sigma=sigma, invtau=1. / tau, unit=get_unit(mu))
Beispiel #3
0
 def __init__(self, f, xmin, xmax, n):
     self.xmin = xmin
     self.xmax = xmax
     self.dx = (xmax - xmin) / float(n)
     self.invdx = 1 / self.dx
     self.unit = get_unit(f(xmin))
     # Tabulation at midpoints
     x = xmin + (.5 + arange(n)) * self.dx
     try:
         self.f = f(x)
     except:
         # If it fails we try passing the values one by one
         self.f = zeros(n) * f(xmin) # for the unit
         for i in xrange(n):
             self.f[i] = f(x[i])
Beispiel #4
0
 def __init__(self, f, xmin, xmax, n):
     self.xmin = xmin
     self.xmax = xmax
     self.dx = (xmax - xmin) / float(n)
     self.invdx = 1 / self.dx
     self.unit = get_unit(f(xmin))
     # Tabulation at midpoints
     x = xmin + (.5 + arange(n)) * self.dx
     try:
         self.f = f(x)
     except:
         # If it fails we try passing the values one by one
         self.f = zeros(n) * f(xmin)  # for the unit
         for i in xrange(n):
             self.f[i] = f(x[i])
Beispiel #5
0
 def __init__(self, f, xmin, xmax, n):
     self.xmin = xmin
     self.xmax = xmax
     self.dx = (xmax - xmin) / float(n - 1)
     self.invdx = 1 / self.dx
     # Not at midpoints here
     x = xmin + arange(n) * self.dx
     self.unit = get_unit(f(xmin))
     try:
         self.f = f(x)
     except:
         # If it fails we try passing the values one by one
         self.f = zeros(n) * f(xmin) # for the unit
         for i in xrange(n):
             self.f[i] = f(x[i])
     self.f = array(self.f)
     self.df = (self.f[range(1, n)] - self.f[range(n - 1)]) * float(self.invdx)
Beispiel #6
0
 def __init__(self, f, xmin, xmax, n):
     self.xmin = xmin
     self.xmax = xmax
     self.dx = (xmax - xmin) / float(n - 1)
     self.invdx = 1 / self.dx
     # Not at midpoints here
     x = xmin + arange(n) * self.dx
     self.unit = get_unit(f(xmin))
     try:
         self.f = f(x)
     except:
         # If it fails we try passing the values one by one
         self.f = zeros(n) * f(xmin)  # for the unit
         for i in xrange(n):
             self.f[i] = f(x[i])
     self.f = array(self.f)
     self.df = (self.f[range(1, n)] - self.f[range(n - 1)]) * float(
         self.invdx)