All Samples(2856) | Call(2645) | Derive(0) | Import(211)
log(x[, out])
Natural logarithm, element-wise.
The natural logarithm `log` is the inverse of the exponential function,
so that `log(exp(x)) = x`. The natural logarithm is logarithm in base `e`.
Parameters
----------
x : array_like
Input value.
Returns
-------
y : ndarray
The natural logarithm of `x`, element-wise.
See Also
--------
log10, log2, log1p, emath.log
Notes
-----
Logarithm is a multivalued function: for each `x` there is an infinite
number of `z` such that `exp(z) = x`. The convention is to return the `z`
whose imaginary part lies in `[-pi, pi]`.
For real-valued input data types, `log` always returns real output. For
each value that cannot be expressed as a real number or infinity, it
yields ``nan`` and sets the `invalid` floating point error flag.
For complex-valued input, `log` is a complex analytical function that
has a branch cut `[-inf, 0]` and is continuous from above on it. `log`
handles the floating-point negative zero as an infinitesimal negative
number, conforming to the C99 standard.
References
----------
.. [1] M. Abramowitz and I.A. Stegun, "Handbook of Mathematical Functions",
10th printing, 1964, pp. 67. http://www.math.sfu.ca/~cbm/aands/
.. [2] Wikipedia, "Logarithm". http://en.wikipedia.org/wiki/Logarithm
Examples
--------
>>> np.log([1, np.e, np.e**2, 0])
array([ 0., 1., 2., -Inf])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])
A[1,0] = sin(x[0])**2 + abs(cos(x[0]))**3.1
A[1,1] = x[0]**cos(x[1])
return log( dot(x.T, dot( inv(A), x)))
src/m/a/matplotlib-HEAD/matplotlib/examples/user_interfaces/mathtext_wx.py matplotlib(Download)
import matplotlib
matplotlib.use("WxAgg")
from numpy import arange, sin, pi, cos, log
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
from matplotlib.backends.backend_wx import NavigationToolbar2Wx
from matplotlib.figure import Figure
(r'$\sin(2 \pi x)$' , lambda x: sin(2*pi*x)),
(r'$\frac{4}{3}\pi x^3$' , lambda x: (4.0 / 3.0) * pi * x**3),
(r'$\cos(2 \pi x)$' , lambda x: cos(2*pi*x)),
(r'$\log(x)$' , lambda x: log(x))
]
class CanvasFrame(wx.Frame):
src/m/a/matplotlib-HEAD/examples/user_interfaces/mathtext_wx.py matplotlib(Download)
import matplotlib
matplotlib.use("WxAgg")
from numpy import arange, sin, pi, cos, log
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
from matplotlib.backends.backend_wx import NavigationToolbar2Wx
from matplotlib.figure import Figure
(r'$\sin(2 \pi x)$' , lambda x: sin(2*pi*x)),
(r'$\frac{4}{3}\pi x^3$' , lambda x: (4.0 / 3.0) * pi * x**3),
(r'$\cos(2 \pi x)$' , lambda x: cos(2*pi*x)),
(r'$\log(x)$' , lambda x: log(x))
]
class CanvasFrame(wx.Frame):
src/m/a/Matplotlib--JJ-s-dev-HEAD/examples/user_interfaces/mathtext_wx.py Matplotlib--JJ-s-dev(Download)
import matplotlib
matplotlib.use("WxAgg")
from numpy import arange, sin, pi, cos, log
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
from matplotlib.backends.backend_wx import NavigationToolbar2Wx
from matplotlib.figure import Figure
(r'$\sin(2 \pi x)$' , lambda x: sin(2*pi*x)),
(r'$\frac{4}{3}\pi x^3$' , lambda x: (4.0 / 3.0) * pi * x**3),
(r'$\cos(2 \pi x)$' , lambda x: cos(2*pi*x)),
(r'$\log(x)$' , lambda x: log(x))
]
class CanvasFrame(wx.Frame):
src/p/y/pymc-HEAD/pymc/examples/straightlinefit.py pymc(Download)
regression parameters. """ from pymc import stochastic, observed, deterministic, uniform_like, runiform, rnormal, Sampler, Normal, Uniform from numpy import inf, log, cos,array import pylab # ------------------------------------------------------------------------------
def theta(value=array([2.,5.])):
"""Slope and intercept parameters for a straight line.
The likelihood corresponds to the prior probability of the parameters."""
slope, intercept = value
prob_intercept = uniform_like(intercept, -10, 10)
prob_slope = log(1./cos(slope)**2)
return prob_intercept+prob_slope
src/b/i/biflib-HEAD/bal/python/examples/lyap.py biflib(Download)
def lyapunov(dynsys,pars,tstart,tend,tstep,ic):
from numpy import zeros, array, sqrt, log, reshape, eye
from numpy.linalg import qr, norm
n = len(ic)
N = n*(n+1)
x = zeros(N)
cum = zeros(n)
x[n:] = xnorm
# update running vector magnitudes
for i in range(n):
cum[i] = cum[i] + log(znorm[i])/log(2.0)
# normalize the exponents
for i in range(n):
lp[i] = cum[i]/(t-tstart)
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
src/p/y/pymc-2.1beta/pymc/examples/straightlinefit.py pymc(Download)
regression parameters. """ from pymc import stochastic, observed, deterministic, uniform_like, runiform, rnormal, Sampler, Normal, Uniform from numpy import inf, log, cos,array import pylab # ------------------------------------------------------------------------------
def theta(value=array([2.,5.])):
"""Slope and intercept parameters for a straight line.
The likelihood corresponds to the prior probability of the parameters."""
slope, intercept = value
prob_intercept = uniform_like(intercept, -10, 10)
prob_slope = log(1./cos(slope)**2)
return prob_intercept+prob_slope
src/p/a/pacal-HEAD/trunk/pacal/examples/singularities.py pacal(Download)
#! from functools import partial from numpy import log from pylab import figure, show from pacal import *
def prod_uni_pdf(n, x):
pdf = (-log(x)) ** (n-1)
for i in xrange(2, n):
pdf /= i
return pdf
figure()
demo_distr(UniformDistr(0,1) * UniformDistr(0,1) * UniformDistr(0,1) * UniformDistr(0,1) * UniformDistr(0,1) * UniformDistr(0,1), theoretical = partial(prod_uni_pdf, 6))
src/p/a/pacal-HEAD/pacal/examples/singularities.py pacal(Download)
#! from functools import partial from numpy import log from pylab import figure, show from pacal import *
def prod_uni_pdf(n, x):
pdf = (-log(x)) ** (n-1)
for i in xrange(2, n):
pdf /= i
return pdf
figure()
demo_distr(UniformDistr(0,1) * UniformDistr(0,1) * UniformDistr(0,1) * UniformDistr(0,1) * UniformDistr(0,1) * UniformDistr(0,1), theoretical = partial(prod_uni_pdf, 6))
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 Next