Ejemplo n.º 1
0
def generate_gaussian_line(err=1.0, h=10.0):
  xx = R.random.randn(1000)*err
  ii = R.random.randint(2, 997)
  print ii
  xc = R.arange(1000)
  eterm = -((xc-ii)**2)/(2.0*(2.5**2))
  eterm = R.clip(eterm, -10.0, 0.0)
  xx += R.exp(eterm)*h
  return xx
Ejemplo n.º 2
0
def gauss(x, sigma):
  # Do all the derivatives at the same time
  eterm = -(x**2)/(2.0*sigma**2)
  eterm = R.clip(eterm, -10.0, 0.0) # Avoid nastiness

  invs2pi = 1./R.sqrt(2.0*R.pi)
  norm = invs2pi * (1./sigma)
  d0 = R.exp(eterm)*norm
  d1 = -x * d0/sigma**2
  
  return (d0, d1)