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


Python random.standard_normal方法代码示例

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


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

示例1: step

# 需要导入模块: from numpy import random [as 别名]
# 或者: from numpy.random import standard_normal [as 别名]
def step(self, th, z):
        s = self.stepsize
        randstep = npr.standard_normal(th.shape)
        th_new = th + 0.5*s**2*self.D_prob(th,z) + randstep*s
        # bonus for probability difference. Using cache-friendly order
        diff_probs = -self.prob(th, z)+self.prob(th_new, z)
        # penalty for having asymmetric proposals:
        randstep_back = (th - (th_new + 0.5*s**2*self.D_prob(th_new,z)))/s
        diff_proposal = 0.5*np.sum(randstep_back**2) - 0.5*np.sum(randstep**2)
        # M-H accept/reject:
        if np.log(npr.rand()) < diff_probs - diff_proposal:
            self.num_rejects = 0
            return th_new
        else:
            self.num_rejects = 1
            return th 
开发者ID:HIPS,项目名称:firefly-monte-carlo,代码行数:18,代码来源:step_algorithms.py

示例2: initialise

# 需要导入模块: from numpy import random [as 别名]
# 或者: from numpy.random import standard_normal [as 别名]
def initialise(self, context):
        
        self.r0 = 0.05 # current UK funding rate
        self.theta = 0.10 # 1 % long term interest rate
        self.k = 0.3
        self.beta = 0.03
         
        ## simulate short rate paths
        self.n = 1000    # MC simulation trials
        self.T = 24.    # total time
        self.m = 100   # subintervals
        self.dt = self.T/self.m  # difference in time each subinterval
        self.r = np.zeros(shape=(self.n, self.m), dtype=float) # matrix to hold short rate paths
        
        # Tell the engine where to associate the data to security.        
        context['My Simple Model'] = Simulation(self.n, self.m, standard_normal)
    
        self.fig = plt.figure()
        self.ax = self.fig.add_subplot(111)
        self.ax.autoscale_view(True,True,True) 
开发者ID:ActiveState,项目名称:code,代码行数:22,代码来源:recipe-578867.py

示例3: setup_class

# 需要导入模块: from numpy import random [as 别名]
# 或者: from numpy.random import standard_normal [as 别名]
def setup_class(cls):
        R.seed(54321)
        cls.X = R.standard_normal((40,10)) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:5,代码来源:test_contrast.py

示例4: setup_class

# 需要导入模块: from numpy import random [as 别名]
# 或者: from numpy.random import standard_normal [as 别名]
def setup_class(cls):
        np.random.seed(54321)
        cls.X = standard_normal((40,10)) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:5,代码来源:test_scale.py

示例5: setup

# 需要导入模块: from numpy import random [as 别名]
# 或者: from numpy.random import standard_normal [as 别名]
def setup(self):
        self.X = R.standard_normal((40,10))
        self.namespace = {}
        self.terms = []
        for i in range(10):
            name = '%s' % string.ascii_uppercase[i]
            self.namespace[name] = self.X[:,i]
            self.terms.append(formula.Term(name))

        self.formula = self.terms[0]
        for i in range(1, 10):
            self.formula += self.terms[i]
        self.formula.namespace = self.namespace 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:15,代码来源:test_formula.py

示例6: test_contrast3

# 需要导入模块: from numpy import random [as 别名]
# 或者: from numpy.random import standard_normal [as 别名]
def test_contrast3(self):
        X = self.formula.design()
        P = np.dot(X, L.pinv(X))

        dummy = formula.Term('noise')
        resid = np.identity(40) - P
        self.namespace['noise'] = np.transpose(np.dot(resid, R.standard_normal((40,5))))
        terms = dummy + self.terms[2]
        terms.namespace = self.formula.namespace
        c = contrast.Contrast(terms, self.formula)
        assert_equal(c.matrix.shape, (10,)) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:13,代码来源:test_formula.py

示例7: test_extendedpinv

# 需要导入模块: from numpy import random [as 别名]
# 或者: from numpy.random import standard_normal [as 别名]
def test_extendedpinv(self):
        X = standard_normal((40, 10))
        np_inv = np.linalg.pinv(X)
        np_sing_vals = np.linalg.svd(X, 0, 0)
        sm_inv, sing_vals = pinv_extended(X)
        assert_almost_equal(np_inv, sm_inv)
        assert_almost_equal(np_sing_vals, sing_vals) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:9,代码来源:test_tools.py

示例8: test_extendedpinv_singular

# 需要导入模块: from numpy import random [as 别名]
# 或者: from numpy.random import standard_normal [as 别名]
def test_extendedpinv_singular(self):
        X = standard_normal((40, 10))
        X[:, 5] = X[:, 1] + X[:, 3]
        np_inv = np.linalg.pinv(X)
        np_sing_vals = np.linalg.svd(X, 0, 0)
        sm_inv, sing_vals = pinv_extended(X)
        assert_almost_equal(np_inv, sm_inv)
        assert_almost_equal(np_sing_vals, sing_vals) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:10,代码来源:test_tools.py

示例9: test_fullrank

# 需要导入模块: from numpy import random [as 别名]
# 或者: from numpy.random import standard_normal [as 别名]
def test_fullrank(self):
        import warnings
        with warnings.catch_warnings():
            warnings.simplefilter("ignore")
            X = standard_normal((40,10))
            X[:,0] = X[:,1] + X[:,2]

            Y = tools.fullrank(X)
            assert_equal(Y.shape, (40,9))

            X[:,5] = X[:,3] + X[:,4]
            Y = tools.fullrank(X)
            assert_equal(Y.shape, (40,8))
            warnings.simplefilter("ignore") 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:16,代码来源:test_tools.py

示例10: setUp

# 需要导入模块: from numpy import random [as 别名]
# 或者: from numpy.random import standard_normal [as 别名]
def setUp(self):
        rnd.seed(1234567)
        self.xd1 = rnd.standard_normal(128)
        self.xf1 = self.xd1.astype(np.float32)
        self.xz1 = rnd.standard_normal((128,2)).view(dtype=np.complex128).squeeze()
        self.xc1 = self.xz1.astype(np.complex64) 
开发者ID:IntelPython,项目名称:mkl_fft,代码行数:8,代码来源:test_fft1d.py


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