• Facebook
  • Twitter
  • Reddit
  • StumbleUpon
  • Digg
  • email

All Samples(3337)  |  Call(2990)  |  Derive(0)  |  Import(347)
exp(x[, out])

Calculate the exponential of all elements in the input array.

Parameters
----------
x : array_like
    Input values.

Returns
-------
out : ndarray
    Output array, element-wise exponential of `x`.

See Also
--------
expm1 : Calculate ``exp(x) - 1`` for all elements in the array.
exp2  : Calculate ``2**x`` for all elements in the array.

Notes
-----
The irrational number ``e`` is also known as Euler's number.  It is
approximately 2.718281, and is the base of the natural logarithm,
``ln`` (this means that, if :math:`x = \ln y = \log_e y`,
then :math:`e^x = y`. For real input, ``exp(x)`` is always positive.

For complex arguments, ``x = a + ib``, we can write
:math:`e^x = e^a e^{ib}`.  The first term, :math:`e^a`, is already
known (it is the real argument, described above).  The second term,
:math:`e^{ib}`, is :math:`\cos b + i \sin b`, a function with magnitude
1 and a periodic phase.

References
----------
.. [1] Wikipedia, "Exponential function",
       http://en.wikipedia.org/wiki/Exponential_function
.. [2] M. Abramovitz and I. A. Stegun, "Handbook of Mathematical Functions
       with Formulas, Graphs, and Mathematical Tables," Dover, 1964, p. 69,
       http://www.math.sfu.ca/~cbm/aands/page_69.htm

Examples
--------
Plot the magnitude and phase of ``exp(x)`` in the complex plane:

>>> import matplotlib.pyplot as plt

>>> x = np.linspace(-2*np.pi, 2*np.pi, 100)
>>> xx = x + 1j * x[:, np.newaxis] # a + ib over complex plane
>>> out = np.exp(xx)

>>> plt.subplot(121)
>>> plt.imshow(np.abs(out),
...            extent=[-2*np.pi, 2*np.pi, -2*np.pi, 2*np.pi])
>>> plt.title('Magnitude of exp(x)')

>>> plt.subplot(122)
>>> plt.imshow(np.angle(out),
...            extent=[-2*np.pi, 2*np.pi, -2*np.pi, 2*np.pi])
>>> plt.title('Phase (angle) of exp(x)')
>>> plt.show()

src/a/u/aureservoir-HEAD/python/examples/filtering.py   aureservoir(Download)
	# Efficient Implementation of the Patterson-Holdsworth Cochlear
	# Filter Bank."
	cf = N.arange(numChannels) + 1
	cf = -(EarQ*minBW) + N.exp( cf * (-N.log(fs/2. + EarQ*minBW) + \
	     N.log(lowFreq + EarQ*minBW) ) / numChannels ) \
	     *(fs/2. + EarQ*minBW)
 
	ERB = ((cf/EarQ)**order + minBW**order)**(1/order)
	B = 1.019*2*N.pi*ERB
 
	# calculate gain factor
	gain = abs( (-2*N.exp(4*1j*cf*N.pi*T)*T + \
	       2*N.exp(-(B*T) + 2*1j*cf*N.pi*T) * T * \
	gain = abs( (-2*N.exp(4*1j*cf*N.pi*T)*T + \
	       2*N.exp(-(B*T) + 2*1j*cf*N.pi*T) * T * \
	       (N.cos(2*cf*N.pi*T) - N.sqrt(3. - 2**(3./2.)) * \
	       N.sin(2*cf*N.pi*T))) * (-2*N.exp(4*1j*cf*N.pi*T)*T + \
	       2*N.exp(-(B*T) + 2*1j*cf*N.pi*T) * T * \
	       (N.cos(2*cf*N.pi*T) + N.sqrt(3. - 2**(3./2.)) * \
	       N.sin(2*cf*N.pi*T))) * (-2*N.exp(4*1j*cf*N.pi*T)*T + \
	       2*N.exp(-(B*T) + 2*1j*cf*N.pi*T) * T * (N.cos(2*cf*N.pi*T) - \
	       N.sqrt(3. + 2**(3./2.)) * N.sin(2*cf*N.pi*T))) * \
	       (-2*N.exp(4*1j*cf*N.pi*T)*T + 2*N.exp(-(B*T) + \
	       2*1j*cf*N.pi*T) * T * (N.cos(2*cf*N.pi*T) + \
	       N.sqrt(3. + 2**(3./2.)) * N.sin(2*cf*N.pi*T))) / \
	       (-2. / N.exp(2*B*T) - 2*N.exp(4*1j*cf*N.pi*T) + \
	       2.*(1. + N.exp(4*1j*cf*N.pi*T)) / N.exp(B*T)) ** 4)
	Afilt = N.zeros((len(cf),9))  # feedback path
	Bfilt = N.zeros((len(cf),5))  # forward path
	Bfilt[:,0] = T**4 / gain
	Bfilt[:,1] = -4*T**4*N.cos(2*cf*N.pi*T) / N.exp(B*T) / gain
	Bfilt[:,2] = 6*T**4*N.cos(4*cf*N.pi*T) / N.exp(2*B*T) / gain
	Bfilt[:,3] = -4*T**4*N.cos(6*cf*N.pi*T) / N.exp(3*B*T) / gain
	Bfilt[:,4] =  T**4*N.cos(8*cf*N.pi*T) / N.exp(4*B*T) / gain
	Afilt[:,0] = 1.
	Afilt[:,1] = -8*N.cos(2*cf*N.pi*T) / N.exp(B*T)
	Afilt[:,2] = 4*(4 + 3*N.cos(4*cf*N.pi*T)) / N.exp(2*B*T)
	Afilt[:,3] = -8*(6*N.cos(2*cf*N.pi*T) + N.cos(6*cf*N.pi*T)) / N.exp(3*B*T)
	Afilt[:,4] = 2*(18 + 16*N.cos(4*cf*N.pi*T)+N.cos(8*cf*N.pi*T)) / N.exp(4*B*T)
	Afilt[:,5] = -8*(6*N.cos(2*cf*N.pi*T) + N.cos(6*cf*N.pi*T)) / N.exp(5*B*T)
	Afilt[:,6] = 4*(4 + 3*N.cos(4*cf*N.pi*T)) / N.exp(6*B*T)
	Afilt[:,4] = 2*(18 + 16*N.cos(4*cf*N.pi*T)+N.cos(8*cf*N.pi*T)) / N.exp(4*B*T)
	Afilt[:,5] = -8*(6*N.cos(2*cf*N.pi*T) + N.cos(6*cf*N.pi*T)) / N.exp(5*B*T)
	Afilt[:,6] = 4*(4 + 3*N.cos(4*cf*N.pi*T)) / N.exp(6*B*T)
	Afilt[:,7] = -8*N.cos(2*cf*N.pi*T) / N.exp(7*B*T)
	Afilt[:,8] = N.exp(-8*B*T)
 
	return Bfilt,Afilt
	# Efficient Implementation of the Patterson-Holdsworth Cochlear
	# Filter Bank."
	cf = N.arange(numChannels) + 1
	cf = -(EarQ*minBW) + N.exp( cf * (-N.log(fs/2. + EarQ*minBW) + \
	     N.log(lowFreq + EarQ*minBW) ) / numChannels ) \
	     *(fs/2. + EarQ*minBW)
 
	ERB = ((cf/EarQ)**order + minBW**order)**(1/order)
	B = 1.019*2*N.pi*ERB
 
	# calculate gain factor
	gain = abs( (-2*N.exp(4*1j*cf*N.pi*T)*T + \
	       2*N.exp(-(B*T) + 2*1j*cf*N.pi*T) * T * \
	gain = abs( (-2*N.exp(4*1j*cf*N.pi*T)*T + \
	       2*N.exp(-(B*T) + 2*1j*cf*N.pi*T) * T * \
	       (N.cos(2*cf*N.pi*T) - N.sqrt(3. - 2**(3./2.)) * \
	       N.sin(2*cf*N.pi*T))) * (-2*N.exp(4*1j*cf*N.pi*T)*T + \
	       2*N.exp(-(B*T) + 2*1j*cf*N.pi*T) * T * \
	       (N.cos(2*cf*N.pi*T) + N.sqrt(3. - 2**(3./2.)) * \
	       N.sin(2*cf*N.pi*T))) * (-2*N.exp(4*1j*cf*N.pi*T)*T + \
	       2*N.exp(-(B*T) + 2*1j*cf*N.pi*T) * T * (N.cos(2*cf*N.pi*T) - \
	       N.sqrt(3. + 2**(3./2.)) * N.sin(2*cf*N.pi*T))) * \
	       (-2*N.exp(4*1j*cf*N.pi*T)*T + 2*N.exp(-(B*T) + \
	       2*1j*cf*N.pi*T) * T * (N.cos(2*cf*N.pi*T) + \
	       N.sqrt(3. + 2**(3./2.)) * N.sin(2*cf*N.pi*T))) / \
	       (-2. / N.exp(2*B*T) - 2*N.exp(4*1j*cf*N.pi*T) + \
	       2.*(1. + N.exp(4*1j*cf*N.pi*T)) / N.exp(B*T)) ** 4)
	# init all 4 biquads
	for n in range(4):
		Afilt[:,n,0] = 1.
		Afilt[:,n,1] = -2 * N.cos(2*cf*N.pi*T) / N.exp(B*T)
		Afilt[:,n,2] = N.exp(-2*B*T)
		Bfilt[:,n,0] = T
		Bfilt[:,n,2] = 0.
 
	# init the rest
	tmp = 2*T*N.cos(2*cf*N.pi*T) / N.exp(B*T)
	Bfilt[:,0,1] = -(tmp+2*N.sqrt(3.+2**1.5)*T*N.sin(2*cf*N.pi*T)/N.exp(B*T))/2.
	Bfilt[:,1,1] = -(tmp-2*N.sqrt(3.+2**1.5)*T*N.sin(2*cf*N.pi*T)/N.exp(B*T))/2.
	Bfilt[:,2,1] = -(tmp+2*N.sqrt(3.-2**1.5)*T*N.sin(2*cf*N.pi*T)/N.exp(B*T))/2.
	Bfilt[:,3,1] = -(tmp-2*N.sqrt(3.-2**1.5)*T*N.sin(2*cf*N.pi*T)/N.exp(B*T))/2.
	# Efficient Implementation of the Patterson-Holdsworth Cochlear
	# Filter Bank."
	cf = N.arange(numChannels) + 1
	cf = -(EarQ*minBW) + N.exp( cf * (-N.log(fs/2. + EarQ*minBW) + \
	     N.log(lowFreq + EarQ*minBW) ) / numChannels ) \
	     *(fs/2. + EarQ*minBW)
 

src/n/i/nipy-HEAD/nipy/neurospin/group/spatial_relaxation_onesample.py   nipy(Download)
                    A = np.inf
                else:
                    A += ((U - Uc) * (U + Uc - 2 * proposal_mean) / proposal_std**2).sum()
        self.R[i, b] = np.random.uniform() > np.exp(0.5 * A)
        if self.R[i, b] == 0 and not reject_override:
            self.D.U[:, i, b] = U
            self.D.V[:, i, block] = V
    def update_labels(self):
        N, r = self.labels_prior.shape
        I = self.labels_prior_mask
        m_mean = self.m_mean[self.label_values]
        m_var = self.m_var[self.label_values]
        L = (self.m[I].reshape(1, r) - m_mean)**2 / m_var
        P = self.labels_prior * np.exp(-0.5 * L) / np.sqrt(m_var)
            f = np.zeros(1)
            fc = np.zeros(1)
        A = (f - fc).sum() + 0.5 * (Uc**2 - U**2).sum() / self.std**2
        self.R[i, b] = np.random.uniform() > np.exp(A / T)
        if self.R[i, b] == 0 and not reject_override:
            self.D.U[:, i, b] = U
            self.D.V[:, i, block] = V

src/n/i/NiPy-OLD-HEAD/nipy/neurospin/group/spatial_relaxation_onesample.py   NiPy-OLD(Download)
                    A = np.inf
                else:
                    A += ((U - Uc) * (U + Uc - 2 * proposal_mean) / proposal_std**2).sum()
        self.R[i, b] = np.random.uniform() > np.exp(0.5 * A)
        if self.R[i, b] == 0 and not reject_override:
            self.D.U[:, i, b] = U
            self.D.V[:, i, block] = V
    def update_labels(self):
        N, r = self.labels_prior.shape
        I = self.labels_prior_mask
        m_mean = self.m_mean[self.label_values]
        m_var = self.m_var[self.label_values]
        L = (self.m[I].reshape(1, r) - m_mean)**2 / m_var
        P = self.labels_prior * np.exp(-0.5 * L) / np.sqrt(m_var)
            f = np.zeros(1)
            fc = np.zeros(1)
        A = (f - fc).sum() + 0.5 * (Uc**2 - U**2).sum() / self.std**2
        self.R[i, b] = np.random.uniform() > np.exp(A / T)
        if self.R[i, b] == 0 and not reject_override:
            self.D.U[:, i, b] = U
            self.D.V[:, i, block] = V

src/m/a/matplotlib-HEAD/matplotlib/examples/pylab_examples/vline_demo.py   matplotlib(Download)
#!/usr/bin/env python
from matplotlib.pyplot import *
from numpy import sin, exp,  absolute, pi, arange
from numpy.random import normal
 
def f(t):
    s1 = sin(2*pi*t)
    e1 = exp(-t)

src/m/a/matplotlib-HEAD/examples/pylab_examples/vline_demo.py   matplotlib(Download)
#!/usr/bin/env python
from matplotlib.pyplot import *
from numpy import sin, exp,  absolute, pi, arange
from numpy.random import normal
 
def f(t):
    s1 = sin(2*pi*t)
    e1 = exp(-t)

src/m/a/matplotlib-HEAD/matplotlib/examples/pylab_examples/finance_work2.py   matplotlib(Download)
    if type=='simple':
        weights = np.ones(n)
    else:
        weights = np.exp(np.linspace(-1., 0., n))
 
    weights /= weights.sum()
 

src/a/l/algopy-HEAD/documentation/sphinx/examples/first_order_forward.py   algopy(Download)
 
 
 
import numpy; from numpy import log, exp, sin, cos, abs
import algopy; from algopy import UTPM, dot, inv, zeros
 
def f(x):
    A = zeros((2,2),dtype=x)
    A[0,0] = numpy.log(x[0]*x[1])
    A[0,1] = numpy.log(x[1]) + exp(x[0])

src/m/a/matplotlib-HEAD/examples/pylab_examples/finance_work2.py   matplotlib(Download)
    if type=='simple':
        weights = np.ones(n)
    else:
        weights = np.exp(np.linspace(-1., 0., n))
 
    weights /= weights.sum()
 

src/m/a/matplotlib-HEAD/py4science/examples/fitting.py   matplotlib(Download)
#!/usr/bin/env python
"""Simple data fitting and smoothing example"""
 
from numpy import exp,arange,array,linspace
from numpy.random import normal
 
from scipy.optimize import leastsq
def func(pars):
    a, alpha, k = pars
    return a*exp(alpha*x_vals) + k
 
def errfunc(pars):
    """Return the error between the function func() evaluated""" 
    return y_noisy - func(pars)  #return the error

src/m/a/Matplotlib--JJ-s-dev-HEAD/examples/pylab_examples/vline_demo.py   Matplotlib--JJ-s-dev(Download)
#!/usr/bin/env python
from matplotlib.pyplot import *
from numpy import sin, exp,  absolute, pi, arange
from numpy.random import normal
 
def f(t):
    s1 = sin(2*pi*t)
    e1 = exp(-t)

  1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9  Next