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

All Samples(6047)  |  Call(5597)  |  Derive(0)  |  Import(450)
sqrt(x[, out])

Return the positive square-root of an array, element-wise.

Parameters
----------
x : array_like
    The values whose square-roots are required.
out : ndarray, optional
    Alternate array object in which to put the result; if provided, it
    must have the same shape as `x`

Returns
-------
y : ndarray
    An array of the same shape as `x`, containing the positive
    square-root of each element in `x`.  If any element in `x` is
    complex, a complex array is returned (and the square-roots of
    negative reals are calculated).  If all of the elements in `x`
    are real, so is `y`, with negative elements returning ``nan``.
    If `out` was provided, `y` is a reference to it.

See Also
--------
lib.scimath.sqrt
    A version which returns complex numbers when given negative reals.

Notes
-----
*sqrt* has--consistent with common convention--as its branch cut the
real "interval" [`-inf`, 0), and is continuous from above on it.
(A branch cut is a curve in the complex plane across which a given
complex function fails to be continuous.)

Examples
--------
>>> np.sqrt([1,4,9])
array([ 1.,  2.,  3.])

>>> np.sqrt([4, -1, -3+4J])
array([ 2.+0.j,  0.+1.j,  1.+2.j])

>>> np.sqrt([4, -1, numpy.inf])
array([  2.,  NaN,  Inf])

src/p/y/pyfusion-HEAD/examples/test_savez.py   pyfusion(Download)
#    debug_save_compress=False;
 
global verbose
from numpy import savez, array, arange, remainder, mod, sin, pi, min, max, \
        size, diff, random, mean, unique, sort, sqrt, float32
from time import time
from pylab import plot, show
# remain is relative to unit step, need to scale back down
maxerr=max(abs(remain))*deltar
# not clear what the max expected error is - small for 12 bits, gets larger quicly
if maxerr<eps*sqrt(yspan): print("appears to be successful")
print('maximum error with %g noise = %g, =%.3g x eps' % (eps,maxerr,maxerr/eps))
 
# 

src/p/y/pyfusion-HEAD/examples/Boyds/wid_specgram.py   pyfusion(Download)
"""
from matplotlib.widgets import RadioButtons, Button
import pylab as pl
from numpy import sin, pi, ones, hanning, hamming, bartlett, kaiser, arange, blackman, cos, sqrt, log10, fft
 
import pyfusion
 
def local_wider(vec):
    """ Flat top in middle, cos at edges - meant to be narrower in f
    but not as good in the wings
    """
    N=len(vec)
    k=arange(N)
    w = sqrt(sqrt(1 - cos(2*pi*k/(N-1))))

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
 
        withinChainVariances = mean(variances, axis = 0)
        betweenChainVariances = var(means, axis = 0) * N
        varEstimate = (1 - 1.0/N) * withinChainVariances + (1.0/N) * betweenChainVariances
        self._R = sqrt(varEstimate/ withinChainVariances)
 
    @np.vectorize
    def _accept(self, last_lik,  lik):
            assert isinstance(s2, dict)
            err = []
            for k in s2.keys():
                e = np.sqrt(np.mean((s1[k]-s2[k])**2.))
                err.append(e) 
        if isinstance(s1, list):
            assert isinstance(s2, list) and len(s1) ==len(s2)
            err = [np.sqrt(np.mean((s-t)**2.)) for s, t in zip(s1, s2)]
        # initialize the temporary storage vectors
        self.currentVectors = zeros((self.nchains, self.dimensions))
        self.currentLiks = ones(self.nchains)*-inf
        self.scaling_factor = 2.38/sqrt(2*DEpairs*self.dimensions)
        self.setup_xmlrpc_plotserver()
 
    def _det_outlier_chains(self, step):
        CR = 1./self.nCR
        b = [(l[1]-l[0])/10. for l in self.parlimits]
        delta = (self.nchains-1)//2 if self.nchains >2 else 1
        gam = 2.38/sqrt(2*delta*self.dimensions)
        zis = []
        for c in xrange(self.nchains):
            o = 0

src/m/a/matplotlib-HEAD/matplotlib/examples/event_handling/poly_editor.py   matplotlib(Download)
"""
from matplotlib.artist import Artist
from matplotlib.patches import Polygon, CirclePolygon
from numpy import sqrt, nonzero, equal, array, asarray, dot, amin, cos, sin
from matplotlib.mlab import dist_point_to_segment
 
 
        xy = asarray(self.poly.xy)
        xyt = self.poly.get_transform().transform(xy)
        xt, yt = xyt[:, 0], xyt[:, 1]
        d = sqrt((xt-event.x)**2 + (yt-event.y)**2)
        indseq = nonzero(equal(d, amin(d)))[0]
        ind = indseq[0]
 

src/m/a/matplotlib-HEAD/examples/event_handling/poly_editor.py   matplotlib(Download)
"""
from matplotlib.artist import Artist
from matplotlib.patches import Polygon, CirclePolygon
from numpy import sqrt, nonzero, equal, array, asarray, dot, amin, cos, sin
from matplotlib.mlab import dist_point_to_segment
 
 
        xy = asarray(self.poly.xy)
        xyt = self.poly.get_transform().transform(xy)
        xt, yt = xyt[:, 0], xyt[:, 1]
        d = sqrt((xt-event.x)**2 + (yt-event.y)**2)
        indseq = nonzero(equal(d, amin(d)))[0]
        ind = indseq[0]
 

src/m/a/Matplotlib--JJ-s-dev-HEAD/examples/event_handling/poly_editor.py   Matplotlib--JJ-s-dev(Download)
"""
from matplotlib.artist import Artist
from matplotlib.patches import Polygon, CirclePolygon
from numpy import sqrt, nonzero, equal, array, asarray, dot, amin, cos, sin
from matplotlib.mlab import dist_point_to_segment
 
 
        xy = asarray(self.poly.xy)
        xyt = self.poly.get_transform().transform(xy)
        xt, yt = xyt[:, 0], xyt[:, 1]
        d = sqrt((xt-event.x)**2 + (yt-event.y)**2)
        indseq = nonzero(equal(d, amin(d)))[0]
        ind = indseq[0]
 

src/b/i/biflib-HEAD/bal/python/examples/lyap.py   biflib(Download)
def gsr(x):
    from numpy import zeros, dot, sqrt
    from numpy.linalg import norm
    N = len(x)
    n = int(sqrt(N))
    znorm = zeros(n)
    znorm[0] = norm(x[0:n])
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)

src/p/y/PyPWDG-HEAD/examples/2D/squarecommon.py   PyPWDG(Download)
from pypwdg import PlaneWaves
from pypwdg import setup,runParallel,gmshMesh
from pypwdg import generic_boundary_data, dirichlet
from numpy import array,sqrt
 
k = 15
direction=array([[1.0,1.0]])/sqrt(2)

src/p/y/PyPWDG-HEAD/examples/2D/soundsoft.py   PyPWDG(Download)
from pypwdg import PlaneWaves
from pypwdg import setup,runParallel,gmshMesh
from pypwdg import zero_dirichlet,generic_boundary_data 
from numpy import array,sqrt
 
k = 15
direction=array([[1.0,1.0]])/sqrt(2)

src/p/y/pymati-HEAD/pymati/samples/3d-simple.py   pymati(Download)
from numpy import linspace, sin,sqrt,pi
import pylab as p
import matplotlib.axes3d as p3
 
x=linspace(0, 7, 100)
y=x
z=sin(sqrt(x**2+y**2))

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