当前位置: 首页>>代码示例>>Python>>正文


Python RandomArray.normal方法代码示例

本文整理汇总了Python中RandomArray.normal方法的典型用法代码示例。如果您正苦于以下问题:Python RandomArray.normal方法的具体用法?Python RandomArray.normal怎么用?Python RandomArray.normal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RandomArray的用法示例。


在下文中一共展示了RandomArray.normal方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: compare

# 需要导入模块: import RandomArray [as 别名]
# 或者: from RandomArray import normal [as 别名]
def compare(m, Nobs, Ncodes, Nfeatures):
    obs = RandomArray.normal(0., 1., (Nobs, Nfeatures))
    codes = RandomArray.normal(0., 1., (Ncodes, Nfeatures))
    import scipy.cluster.vq
    scipy.cluster.vq
    print 'vq with %d observation, %d features and %d codes for %d iterations' % \
           (Nobs,Nfeatures,Ncodes,m)
    t1 = time.time()
    for i in range(m):
        code, dist = scipy.cluster.vq.py_vq(obs, codes)
    t2 = time.time()
    py = (t2 - t1)
    print ' speed in python:', (t2 - t1) / m
    print code[:2], dist[:2]

    t1 = time.time()
    for i in range(m):
        code, dist = scipy.cluster.vq.vq(obs, codes)
    t2 = time.time()
    print ' speed in standard c:', (t2 - t1) / m
    print code[:2], dist[:2]
    print ' speed up: %3.2f' % (py / (t2 - t1))

    # load into cache
    b = vq(obs, codes)
    t1 = time.time()
    for i in range(m):
        code, dist = vq(obs, codes)
    t2 = time.time()
    print ' speed inline/blitz:', (t2 - t1) / m
    print code[:2], dist[:2]
    print ' speed up: %3.2f' % (py / (t2 - t1))

    # load into cache
    b = vq2(obs, codes)
    t1 = time.time()
    for i in range(m):
        code, dist = vq2(obs, codes)
    t2 = time.time()
    print ' speed inline/blitz2:', (t2 - t1) / m
    print code[:2], dist[:2]
    print ' speed up: %3.2f' % (py / (t2 - t1))

    # load into cache
    b = vq3(obs, codes)
    t1 = time.time()
    for i in range(m):
        code, dist = vq3(obs, codes)
    t2 = time.time()
    print ' speed using C arrays:', (t2 - t1) / m
    print code[:2], dist[:2]
    print ' speed up: %3.2f' % (py / (t2 - t1))
开发者ID:kamirow,项目名称:Slicer4,代码行数:54,代码来源:vq.py

示例2: statistics

# 需要导入模块: import RandomArray [as 别名]
# 或者: from RandomArray import normal [as 别名]
def statistics():
    pd = stats.norm(loc=1, scale=0.5)  # normal distribution N(1,0.5)
    n=10000
    r = pd.rvs(n) # random variates
    import RandomArray
    r = RandomArray.normal(1, 0.1, n)
    s = stats.stats
    print pd.stats()
    print 'mean=%g stdev=%g skewness=%g kurtosis=%g' % \
          (s.mean(r), s.variation(r), s.skew(r), s.kurtosis(r))
    bin_counts, bin_min, min_width, noutside = s.histogram(r, numbins=50)
开发者ID:eddienko,项目名称:SamPy,代码行数:13,代码来源:SciPy.py

示例3: dot

# 需要导入模块: import RandomArray [as 别名]
# 或者: from RandomArray import normal [as 别名]
from Numeric import dot,sum 
import sys,numeric_version 
import RandomArray 
import LinearAlgebra 

print sys.version 
print "Numeric version:",numeric_version.version 

RandomArray.seed(123,456) 
a = RandomArray.normal(0,1,(100,10)) 
f = RandomArray.normal(0,1,(10,30)) 
e = RandomArray.normal(0,0.1,(100,30)) 
print "Got to seed:",RandomArray.get_seed() 

b = dot(a,f)+e 

(x,res,rank,s)=LinearAlgebra.linear_least_squares(a,b) 

f_res = sum((b-dot(a,f))**2) 
x_res = sum((b-dot(a,x))**2) 

print "'Planted' residues, upper bound for optimal residues:" 
print f_res 
print "Claimed residues:" 
print res 
print "Actual residues:" 
print x_res 
print "Ratio between actual and claimed (shoudl be 1):" 
print x_res/res 
print "Ratio between actual and planted (should be <1):" 
print x_res/f_res 
开发者ID:mikeswamp,项目名称:numeric_copy,代码行数:33,代码来源:llstest.py

示例4: xrange

# 需要导入模块: import RandomArray [as 别名]
# 或者: from RandomArray import normal [as 别名]
sampleRate = 44100.

c = 300. # meters per second
spectralRange = sampleRate / 2

import numpy
import math
import RandomArray
import stats


T=r/c


spectrum = numpy.zeros( nBins-1, numpy.complex)
for x in RandomArray.normal(0,standardMicrophoneDeviation,(nSpeakers,)) :
	t1root = 1+x
	t2root = 1-x
	print t1root, t2root
	spectrum += numpy.array([
		complex(1, t1root*w*T) * math.e**complex(math.cos(w*T*t1root), math.sin(w*T*t1root)) /x / w / w / T / T -
		complex(1, t2root*w*T) * math.e**complex(math.cos(w*T*t2root), math.sin(w*T*t2root)) /x / w / w / T / T 
		for w in [ math.pi*2*normfreq*spectralRange/nBins 
			for normfreq in xrange(1,nBins) ] ])


import Gnuplot
gp=Gnuplot.Gnuplot(persist=1)
gp('set data style lines')
gp.plot(abs(spectrum), [bin.real for bin in spectrum], [bin.imag for bin in spectrum], numpy.zeros(nBins))
gp.hardcopy(filename="IncoherenceSimulation.png",terminal="png") 
开发者ID:rolodub,项目名称:thesis,代码行数:33,代码来源:simulateMicMissplacement.py

示例5: min

# 需要导入模块: import RandomArray [as 别名]
# 或者: from RandomArray import normal [as 别名]
import RandomArray
import numpy
from numpy.random import normal
import sys
import fcs
import pylab
sys.path.append('../')
import flow

if __name__ == '__main__':
    data = numpy.concatenate((RandomArray.normal(5, 1, (2000, 2)),
                              RandomArray.normal(7, 1, (2000, 2)),
                              RandomArray.normal(9, 1, (3000, 2)),
                              RandomArray.normal(11, 1, (2000, 2)),
                              RandomArray.normal(13, 1, (1000, 2))), axis=0)

    #     f = fcs.FCSReader("../data/3FITC-4PE.004.fcs")
    #     print f.data.keys()
    #     m = 10000
    #     x1 = numpy.array((f.data['FSC-H'])[:m], 'd')
    #     x2 = numpy.array((f.data['SSC-H'])[:m], 'd')
    #     x3 = numpy.array((f.data['FL1-H'])[:m], 'd')
    #     x4 = numpy.array((f.data['FL2-H'])[:m], 'd')
    
    #     print min(x1), max(x1)
    #     print min(x2), max(x2)
    #     print min(x3), max(x3)
    #     print min(x4), max(x4)

    #     data_unscaled = numpy.transpose([x1, x2, x3, x4])
    #     #data = numpy.transpose([(x1-min(x1))/max(x1), (x2-min(x2))/max(x2), (x3-min(x3))/max(x3), (x4-min(x4))/max(x4)])
开发者ID:cliburn,项目名称:flow,代码行数:33,代码来源:test_flow.py

示例6: Histogram

# 需要导入模块: import RandomArray [as 别名]
# 或者: from RandomArray import normal [as 别名]
        nbins = self.array.shape[0]
        histo = N.add.reduce(weights*N.equal(N.arange(nbins)[:,N.NewAxis],
                                             data), -1)
        histo[-1] = histo[-1] + N.add.reduce(N.repeat(weights,
                                                      N.equal(nbins, data)))
        self.array[:, 1] =  self.array[:, 1] + histo


if __name__ == '__main__':
    if N.package == 'Numeric':
        import RandomArray as random
    elif N.package == 'NumPy':
        from numpy import random
    nsamples = 1000
    random.seed(12,13)
    data = random.normal(1.0, 0.5, nsamples)
    h = Histogram(data, 50)  # use 50 bins between min & max samples
    h.normalizeArea()        # make probabilities in histogram
    x = h.getBinIndices()
    y = h.getBinCounts()

    # add many more samples:
    nsamples2 = nsamples*100
    data = random.normal(1.0, 0.5, nsamples2)
    h.addData(data)
    h.normalizeArea()
    x2 = h.getBinIndices()
    y2 = h.getBinCounts()

    # and more:
    nsamples3 = nsamples*1000
开发者ID:davem22101,项目名称:semanticscience,代码行数:33,代码来源:Histogram.py


注:本文中的RandomArray.normal方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。