Пример #1
0
def concatmap(fs, kern):
	fshape = fs.shape
	kshape = kern.shape
	newshape = util.tupleop(lambda x, y: x * y, fshape, kshape)
	newkern = numpy.zeros(newshape)
	for i in numpy.ndindex(kshape):
		x = kern[i]
		result = map(lambda f: f(x), fs)
		for j in numpy.ndindex(fshape):
			newi = util.tupleop(lambda ii, ij, fs: ij + ii * fs, i, j, fshape)
			newkern[newi] = result
	return newkern
Пример #2
0
def gaussian(mu, sigma, *v):
	A = 1 / (sigma * math.sqrt(2 * math.pi))
	tau = (2 * (sigma ** 2))
	shift = util.tupleop(lambda x, m: x - m, v, mu)
	t = sum(util.tupleop(lambda s: s * s.conjugate(), shift))
	return A * math.exp(- t / tau)