def simple_gaussian_kernel(X): # cut off exponent at -500 to prevent overflow errors if type(X) == Numeric.ArrayType: Numeric.putmask(X, X < -500, -500) elif X < -500: X = -500 return exp(X)
def gaussian(dist, stddev): X = -dist**2 / (2 * stddev**2) # cut off exponent at -500 to prevent overflow errors if type(X) == Numeric.ArrayType: Numeric.putmask(X, X < -500, -500) elif X < -500: X = -500 return exp(X)
def leftDrag(self, event): """ Event handler for LMB drag event. @param event: A Qt mouse event. @type event: U{B{QMouseEvent}<http://doc.trolltech.com/4/qmouseevent.html>} """ dScale = .025 # This works nicely. Mark 2008-01-29. delta = self.prevY - event.y() self.prevY = event.y() factor = exp(dScale * delta) #print "y, py =", event.y(), self.prevY, ", delta =", delta, ", factor=", factor self.glpane.rescale_around_point(factor) self.glpane.gl_update() return
def f(param, t): return param[0]*exp(-param[1]/t)
def f2(param, t): return 1e13*exp(-param[0]/t)
def func(self, param, t): return self.N * param[0] * (1 / exp(param[0] * t))
def iagaussian(s,mu,sigma): """ o Purpose Generate a 2D Gaussian image. o Synopsis g = iagaussian(s,mu,sigma) o Input s: [rows columns] mu: Mean vector. 2D point (x;y). Point of maximum value. sigma: covariance matrix (square). [ Sx^2 Sxy; Syx Sy^2] o Output g: o Description A 2D Gaussian image is an image with a Gaussian distribution. It can be used to generate test patterns or Gaussian filters both for spatial and frequency domain. The integral of the gaussian function is 1.0. o Examples import Numeric f = iagaussian([8,4], [3,1], [[1,0],[0,1]]) print Numeric.array2string(f, precision=4, suppress_small=1) g = ianormalize(f, [0,255]).astype(Numeric.UnsignedInt8) print g f = iagaussian(100, 50, 10*10) g = ianormalize(f, [0,1]) g,d = iaplot(g) showfig(g) f = iagaussian([50,50], [25,10], [[10*10,0],[0,20*20]]) g = ianormalize(f, [0,255]).astype(Numeric.UnsignedInt8) iashow(g) """ from Numeric import asarray,product,arange,NewAxis,transpose,matrixmultiply,reshape,concatenate,resize,sum,zeros,Float,ravel,pi,sqrt,exp from LinearAlgebra import inverse,determinant if type(sigma).__name__ in ['int', 'float', 'complex']: sigma = [sigma] s, mu, sigma = asarray(s), asarray(mu), asarray(sigma) if (product(s) == max(s)): x = arange(product(s)) d = x - mu if len(d.shape) == 1: tmp1 = d[:,NewAxis] tmp3 = d else: tmp1 = transpose(d) tmp3 = tmp1 if len(sigma) == 1: tmp2 = 1./sigma else: tmp2 = inverse(sigma) k = matrixmultiply(tmp1, tmp2) * tmp3 else: aux = arange(product(s)) x, y = iaind2sub(s, aux) xx = reshape(concatenate((x,y)), (2, product(x.shape))) d = transpose(xx) - resize(reshape(mu,(len(mu),1)), (s[0]*s[1],len(mu))) if len(sigma) == 1: tmp = 1./sigma else: tmp = inverse(sigma) k = matrixmultiply(d, tmp) * d k = sum(transpose(k)) g = zeros(s, Float) aux = ravel(g) if len(sigma) == 1: tmp = sigma else: tmp = determinant(sigma) aux[:] = 1./(2*pi*sqrt(tmp)) * exp(-1./2 * k) return g
def func(self, param, t): return param[0] * param[1] * param[1] * t * (1 / exp(param[1] * t))
def func(self, param, t): return self.N*param[0]*param[1]*power(param[1]*t, param[0]-1)*\ (1/exp(power(param[1]*t, param[0])))
def combinations(n, k): """Returns the number of ways of choosing k items from n. """ return exp(lgam(n+1) - lgam(k+1) - lgam(n-k+1))
def f2(param, t): return 1e13 * exp(-param[0] / t)
def f(param, t): return param[0] * exp(-param[1] / t)
def f(t): s1 = sin(2 * pi * t) e1 = exp(-t) return absolute(multiply(s1, e1)) + .05
def f(t): s1 = sin(2*pi*t) e1 = exp(-t) return absolute(multiply(s1,e1))+.05