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

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/n/i/nipy-HEAD/nipy/neurospin/group/spatial_relaxation_onesample.py   nipy(Download)
def log_gammainv_pdf(x, a, b):
    """
    log density of the inverse gamma distribution with shape a and scale b,
    at point x, using Stirling's approximation for a > 100
    """
    return a * np.log(b) - sp.gammaln(a) - (a + 1) * np.log(x) - b / x
 
def log_gaussian_pdf(x, m, v):
    """
    log density of the gaussian distribution with mean m and variance v at point x
    """
    return -0.5 * (np.log(2 * np.pi * v) + (x - m)**2 / v)
                i, b, 1.0, proposal_std,
                verbose=False, reject_override=True)
        mean_acceptance = np.exp(A_values).clip(0,1).mean()
        L -= np.log(mean_acceptance)
        for i in range(n)[::-1]:
            for b in range(B)[::-1]:
                n_ib = n * B - i * B - b
                    (np.exp(A_values).clip(0,1) * \
                        np.exp( -0.5 * SS_values / proposal_std**2) \
                        / (np.sqrt(2 * np.pi) * proposal_std)**3).mean()
                L += np.log(mean_kernel) - np.log(mean_acceptance)*(i>0 or b>0)
        if not change_U:
            # Restore initial displacement value
            self.proposal = 'fixed'
                IJ)
            fc = self.log_voxel_likelihood[J]
            f = - 0.5 * (\
                    N * np.log(2 * np.pi) + \
                    np.log(1 + self.m_var[self.labels[J]] * SS1) \
                    + SS2 + SS3 - SS4**2 / \
                    (1 / self.m_var[self.labels[J]] + SS1))
                    Vk[xrange(nk), xrange(nk)] = v_j + m_var_j
                else:
                    Vk[xrange(nk), xrange(nk)] = vark + m_var_j
                log_region_likelihood[j] += np.log(np.linalg.det(Vk)) + datak.transpose() * np.linalg.inv(Vk) * datak
            if self.std == None:
                nj = n * len(L)
            else:
                nj = self.N[L].sum()
            log_region_likelihood[j] += nj * np.log(2 * np.pi)
                add_lines(np.log(tot_var[i]).reshape(p, 1), SS2.reshape(p, 1), Ii)
                add_lines((Z[i]**2 / tot_var[i]).reshape(p, 1), SS3.reshape(p, 1), Ii)
                add_lines((Z[i] / tot_var[i]).reshape(p, 1), SS4.reshape(p, 1), Ii)
        LL = - 0.5 * (N * np.log(2 * np.pi) + np.log(1 + m_var[self.labels] * SS1) \
                + SS2 + SS3 - SS4**2 / (1 / m_var[self.labels] + SS1))
        if return_SS:
            return LL, Z, tot_var, SS1, SS2, SS3, SS4
            return max_log_conditional + ll_ratio.mean(axis=0)
        elif not update_spatial:
            return max_log_conditional \
                 + np.log(np.exp(ll_ratio).sum(axis=0)) \
                 - np.log(nsimu)
        else:
            return max_log_conditional.sum() \
                +  np.log(np.exp(ll_ratio.sum(axis=1)).sum()) \
                - np.log(nsimu)
                U = self.D.U
            log_displacements_prior = \
                - 0.5 * np.square(U).sum() / std**2 \
                - self.D.U.size * np.log(std)
            log_displacements_posterior = \
                self.compute_log_conditional_displacements_posterior(\
                    U, 

src/n/i/NiPy-OLD-HEAD/nipy/neurospin/group/spatial_relaxation_onesample.py   NiPy-OLD(Download)
def log_gammainv_pdf(x, a, b):
    """
    log density of the inverse gamma distribution with shape a and scale b,
    at point x, using Stirling's approximation for a > 100
    """
    return a * np.log(b) - sp.gammaln(a) - (a + 1) * np.log(x) - b / x
 
def log_gaussian_pdf(x, m, v):
    """
    log density of the gaussian distribution with mean m and variance v at point x
    """
    return -0.5 * (np.log(2 * np.pi * v) + (x - m)**2 / v)
                i, b, 1.0, proposal_std,
                verbose=False, reject_override=True)
        mean_acceptance = np.exp(A_values).clip(0,1).mean()
        L -= np.log(mean_acceptance)
        for i in range(n)[::-1]:
            for b in range(B)[::-1]:
                n_ib = n * B - i * B - b
                    (np.exp(A_values).clip(0,1) * \
                        np.exp( -0.5 * SS_values / proposal_std**2) \
                        / (np.sqrt(2 * np.pi) * proposal_std)**3).mean()
                L += np.log(mean_kernel) - np.log(mean_acceptance)*(i>0 or b>0)
        if not change_U:
            # Restore initial displacement value
            self.proposal = 'fixed'
                IJ)
            fc = self.log_voxel_likelihood[J]
            f = - 0.5 * (\
                    N * np.log(2 * np.pi) + \
                    np.log(1 + self.m_var[self.labels[J]] * SS1) \
                    + SS2 + SS3 - SS4**2 / \
                    (1 / self.m_var[self.labels[J]] + SS1))
                    Vk[xrange(nk), xrange(nk)] = v_j + m_var_j
                else:
                    Vk[xrange(nk), xrange(nk)] = vark + m_var_j
                log_region_likelihood[j] += np.log(np.linalg.det(Vk)) + datak.transpose() * np.linalg.inv(Vk) * datak
            if self.std == None:
                nj = n * len(L)
            else:
                nj = self.N[L].sum()
            log_region_likelihood[j] += nj * np.log(2 * np.pi)
                add_lines(np.log(tot_var[i]).reshape(p, 1), SS2.reshape(p, 1), Ii)
                add_lines((Z[i]**2 / tot_var[i]).reshape(p, 1), SS3.reshape(p, 1), Ii)
                add_lines((Z[i] / tot_var[i]).reshape(p, 1), SS4.reshape(p, 1), Ii)
        LL = - 0.5 * (N * np.log(2 * np.pi) + np.log(1 + m_var[self.labels] * SS1) \
                + SS2 + SS3 - SS4**2 / (1 / m_var[self.labels] + SS1))
        if return_SS:
            return LL, Z, tot_var, SS1, SS2, SS3, SS4
            return max_log_conditional + ll_ratio.mean(axis=0)
        elif not update_spatial:
            return max_log_conditional \
                 + np.log(np.exp(ll_ratio).sum(axis=0)) \
                 - np.log(nsimu)
        else:
            return max_log_conditional.sum() \
                +  np.log(np.exp(ll_ratio.sum(axis=1)).sum()) \
                - np.log(nsimu)
                U = self.D.U
            log_displacements_prior = \
                - 0.5 * np.square(U).sum() / std**2 \
                - self.D.U.size * np.log(std)
            log_displacements_posterior = \
                self.compute_log_conditional_displacements_posterior(\
                    U, 

src/c/u/CUV-HEAD/examples/rbm/datasets.py   CUV(Download)
    def logtransform(self):
        """ adds one to (test) data and applies log """
        self.ensure_float32()
        self.data += 1
        np.log(self.data,self.data)
        if "test_data" in self.__dict__:
            self.test_data += 1
            np.log(self.test_data, self.test_data)

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/a/u/aureservoir-HEAD/python/examples/filtering.py   aureservoir(Download)
	w0 = 2 * N.pi * f0 / Fs
	if( BW != None ):
		#print BW
		alpha = N.sin(w0)*N.sinh( N.log(2)/2 * BW * w0/N.sin(w0) )
		#Q = ( 2*N.sinh(N.log(2)/2*BW*w0/N.sin(w0)) )**(-1)
		#print Q
	else:
	# 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)
 
	# 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)
 
	# 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/m/a/matplotlib-HEAD/matplotlib/examples/api/custom_scale_example.py   matplotlib(Download)
            if masked.mask.any():
                return ma.log(np.abs(ma.tan(masked) + 1.0 / ma.cos(masked)))
            else:
                return np.log(np.abs(np.tan(a) + 1.0 / np.cos(a)))
 
        def inverted(self):
            """

src/m/a/matplotlib-HEAD/matplotlib/examples/api/hinton_demo.py   matplotlib(Download)
        ax = fig.add_subplot(1, 1, 1)
 
    if not maxWeight:
        maxWeight = 2**np.ceil(np.log(np.abs(W).max())/np.log(2))
 
    ax.patch.set_facecolor('gray')
    ax.set_aspect('equal', 'box')

src/m/a/matplotlib-HEAD/examples/api/custom_scale_example.py   matplotlib(Download)
            if masked.mask.any():
                return ma.log(np.abs(ma.tan(masked) + 1.0 / ma.cos(masked)))
            else:
                return np.log(np.abs(np.tan(a) + 1.0 / np.cos(a)))
 
        def inverted(self):
            """

src/m/a/matplotlib-HEAD/examples/api/hinton_demo.py   matplotlib(Download)
        ax = fig.add_subplot(1, 1, 1)
 
    if not maxWeight:
        maxWeight = 2**np.ceil(np.log(np.abs(W).max())/np.log(2))
 
    ax.patch.set_facecolor('gray')
    ax.set_aspect('equal', 'box')

src/m/a/Matplotlib--JJ-s-dev-HEAD/examples/api/custom_scale_example.py   Matplotlib--JJ-s-dev(Download)
            if masked.mask.any():
                return ma.log(np.abs(ma.tan(masked) + 1.0 / ma.cos(masked)))
            else:
                return np.log(np.abs(np.tan(a) + 1.0 / np.cos(a)))
 
        def inverted(self):
            """

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