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


Python numpy.std方法代码示例

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


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

示例1: check_num_snps

# 需要导入模块: from autograd import numpy [as 别名]
# 或者: from autograd.numpy import std [as 别名]
def check_num_snps(sampled_n_dict, demo, num_loci, mut_rate, ascertainment_pop=None, error_matrices=None):
    if error_matrices is not None or ascertainment_pop is not None:
        # TODO
        raise NotImplementedError

    #seg_sites = momi.simulate_ms(
    #    ms_path, demo, num_loci=num_loci, mut_rate=mut_rate)
    #sfs = seg_sites.sfs

    num_bases = 1000
    sfs = demo.simulate_data(
        sampled_n_dict=sampled_n_dict,
        muts_per_gen=mut_rate/num_bases,
        recoms_per_gen=0,
        length=num_bases,
        num_replicates=num_loci)._sfs

    n_sites = sfs.n_snps(vector=True)

    n_sites_mean = np.mean(n_sites)
    n_sites_sd = np.std(n_sites)

    # TODO this test isn't very useful because expected_branchlen is not used anywhere internally anymore
    n_sites_theoretical = demo.expected_branchlen(sampled_n_dict) * mut_rate
    #n_sites_theoretical = momi.expected_total_branch_len(
    #    demo, ascertainment_pop=ascertainment_pop, error_matrices=error_matrices) * mut_rate

    zscore = -np.abs(n_sites_mean - n_sites_theoretical) / n_sites_sd
    pval = scipy.stats.norm.cdf(zscore) * 2.0

    assert pval >= .05 
开发者ID:popgenmethods,项目名称:momi2,代码行数:33,代码来源:test_normalizing_constant.py

示例2: batch_normalize

# 需要导入模块: from autograd import numpy [as 别名]
# 或者: from autograd.numpy import std [as 别名]
def batch_normalize(activations):
    mbmean = np.mean(activations, axis=0, keepdims=True)
    return (activations - mbmean) / (np.std(activations, axis=0, keepdims=True) + 1) 
开发者ID:HIPS,项目名称:autograd,代码行数:5,代码来源:variational_autoencoder.py

示例3: test_std

# 需要导入模块: from autograd import numpy [as 别名]
# 或者: from autograd.numpy import std [as 别名]
def test_std():  stat_check(np.std)

# Unary ufunc tests 
开发者ID:HIPS,项目名称:autograd,代码行数:5,代码来源:test_systematic.py

示例4: test_std_ddof

# 需要导入模块: from autograd import numpy [as 别名]
# 或者: from autograd.numpy import std [as 别名]
def test_std_ddof():
    B = npr.randn(3)
    C = npr.randn(3, 4)
    D = npr.randn(1, 3)
    combo_check(np.std, (0,))([B, C, D], axis=[None], keepdims=[True, False], ddof=[0, 1])
    combo_check(np.std, (0,))([C, D], axis=[None, 1], keepdims=[True, False], ddof=[2]) 
开发者ID:HIPS,项目名称:autograd,代码行数:8,代码来源:test_numpy.py

示例5: standardize

# 需要导入模块: from autograd import numpy [as 别名]
# 或者: from autograd.numpy import std [as 别名]
def standardize(X):
    mx = np.mean(X, 0)
    stdx = np.std(X, axis=0)
    # Assume standard deviations are not 0
    Zx = old_div((X-mx),stdx)
    assert np.all(np.isfinite(Zx))
    return Zx 
开发者ID:wittawatj,项目名称:kernel-gof,代码行数:9,代码来源:util.py

示例6: __str__

# 需要导入模块: from autograd import numpy [as 别名]
# 或者: from autograd.numpy import std [as 别名]
def __str__(self):
        mean_x = np.mean(self.X, 0)
        std_x = np.std(self.X, 0) 
        prec = 4
        desc = ''
        desc += 'E[x] = %s \n'%(np.array_str(mean_x, precision=prec ) )
        desc += 'Std[x] = %s \n' %(np.array_str(std_x, precision=prec))
        return desc 
开发者ID:wittawatj,项目名称:kernel-gof,代码行数:10,代码来源:data.py

示例7: plot_runtime

# 需要导入模块: from autograd import numpy [as 别名]
# 或者: from autograd.numpy import std [as 别名]
def plot_runtime(ex, fname, func_xvalues, xlabel, func_title=None):
    results = glo.ex_load_result(ex, fname)
    value_accessor = lambda job_results: job_results['time_secs']
    vf_pval = np.vectorize(value_accessor)
    # results['job_results'] is a dictionary: 
    # {'test_result': (dict from running perform_test(te) '...':..., }
    times = vf_pval(results['job_results'])
    repeats, _, n_methods = results['job_results'].shape
    time_avg = np.mean(times, axis=0)
    time_std = np.std(times, axis=0)

    xvalues = func_xvalues(results)

    #ns = np.array(results[xkey])
    #te_proportion = 1.0 - results['tr_proportion']
    #test_sizes = ns*te_proportion
    line_styles = func_plot_fmt_map()
    method_labels = get_func2label_map()
    
    func_names = [f.__name__ for f in results['method_job_funcs'] ]
    for i in range(n_methods):    
        te_proportion = 1.0 - results['tr_proportion']
        fmt = line_styles[func_names[i]]
        #plt.errorbar(ns*te_proportion, mean_rejs[:, i], std_pvals[:, i])
        method_label = method_labels[func_names[i]]
        plt.errorbar(xvalues, time_avg[:, i], yerr=time_std[:,i], fmt=fmt,
                label=method_label)
            
    ylabel = 'Time (s)'
    plt.ylabel(ylabel)
    plt.xlabel(xlabel)
    plt.xlim([np.min(xvalues), np.max(xvalues)])
    plt.xticks( xvalues, xvalues )
    plt.legend(loc='best')
    plt.gca().set_yscale('log')
    title = '%s. %d trials. '%( results['prob_label'],
            repeats ) if func_title is None else func_title(results)
    plt.title(title)
    #plt.grid()
    return results 
开发者ID:wittawatj,项目名称:kernel-gof,代码行数:42,代码来源:plot.py


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