• 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/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/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/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)

src/m/a/matplotlib-HEAD/py4science/examples/skel/fitting_skel.py   matplotlib(Download)
#!/usr/bin/env python
"""Simple data fitting and smoothing example"""
 
XXX = None # placeholder for missing pieces
 
from numpy import exp,arange,array,linspace
from numpy.random import normal
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/b/i/BIP-0.5.2/BIP/Bayes/Samplers/MCMC.py   BIP(Download)
 
import numpy as np
from liveplots.xmlrpcserver import rpc_plot
from numpy import array, mean,isnan,  nan_to_num, var, sqrt, inf, exp, greater, less, identity, ones, zeros, floor, log, recarray, nan
from numpy.random import random,  multivariate_normal,  multinomial,  rand
from scipy.stats import cov,  uniform, norm, scoreatpercentile
 
        if lik == -inf:#0:
            return 0
        if last_lik >-inf:#0:
            alpha = min( exp(lik-last_lik), 1)
            #alpha = min(lik-last_lik, 1)
        elif last_lik == -inf:#0:
            alpha = 1
        if p2 == None: p2 = -inf
        # ps are log probabilities
        if p2 >-inf:#np.exp(p2)>0
            alpha = min( exp(p1-p2), 1)
        elif p2 == -inf:#np.exp(p2)==0
            alpha = 1
        else:

src/p/l/playdoh-0.2/examples/distopt_example3.py   playdoh(Download)
arguments.
"""
 
from numpy import exp
class myclass(object):
    def __init__(self, shared_data, local_data):
        self.sigma = shared_data['sigma']
        try:
            self.a0 = local_data['a0']
            self.b0 = local_data['b0']
        except:
            self.a0 = self.b0 = 0
    def __call__(self, a, b):
        return exp(-((a-self.a0)**2+(b-self.b0)**2)/(2*self.sigma*2))

src/p/l/playdoh-0.2/examples/distopt_example2.py   playdoh(Download)
`sigma`, and `local_data` to store the center of the Gaussian.
We could also use a global variable for sigma. 
"""
from numpy import exp
def fun(a, b, shared_data, local_data):
    try:
        a0 = local_data['a0']
        b0 = local_data['b0']
    except:
        a0 = b0 = 0
    sigma = shared_data['sigma']
    return exp(-((a-a0)**2+(b-b0)**2)/(2*sigma*2))

src/g/m/gmes-HEAD/trunk/examples/pmltest2d03.py   gmes(Download)
new_path = os.path.abspath('../')
sys.path.append(new_path)
 
from numpy import array, exp, arange
from sys import stdout
from gmes import *
from pmltest2d01 import *
    def update(self, ez, hy, hx, dt, dx, dy):
        """Update Ez values according to time sequence."""
 
        i, j, k = self.idx
        j_src = -2 * ((self.t - self.t0) / self.tw) * exp(-((self.t - self.t0) / self.tw) ** 2)
        ez[self.idx] += dt / self.epsilon * ((hy[i+1,j,k+1] - hy[i,j,k+1]) / dx - (hx[i,j+1,k+1] - hx[i,j,k+1]) / dy - j_src)
        self.t += dt

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