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


Python random.negative_binomial方法代码示例

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


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

示例1: get_example_data

# 需要导入模块: from numpy import random [as 别名]
# 或者: from numpy.random import negative_binomial [as 别名]
def get_example_data(*, sparse=False):
    # create test object
    adata = AnnData(np.multiply(binomial(1, 0.15, (100, 20)), negative_binomial(2, 0.25, (100, 20))))
    # adapt marker_genes for cluster (so as to have some form of reasonable input
    adata.X[0:10, 0:5] = np.multiply(binomial(1, 0.9, (10, 5)), negative_binomial(1, 0.5, (10, 5)))

    # The following construction is inefficient, but makes sure that the same data is used in the sparse case
    if sparse:
        adata.X = sp.csr_matrix(adata.X)

    # Create cluster according to groups
    adata.obs['true_groups'] = pd.Categorical(np.concatenate((
        np.zeros((10,), dtype=int),
        np.ones((90,), dtype=int),
    )))

    return adata 
开发者ID:theislab,项目名称:scanpy,代码行数:19,代码来源:test_rank_genes_groups.py

示例2: sample_binomial_frag_len

# 需要导入模块: from numpy import random [as 别名]
# 或者: from numpy.random import negative_binomial [as 别名]
def sample_binomial_frag_len(frag_mean=200, frag_variance=100):
    """
    Sample a fragment length from a binomial distribution parameterized with a
    mean and variance.

    If frag_variance > frag_mean, use a Negative-Binomial distribution.
    """
    assert(abs(frag_mean - frag_variance) > 1)  
    if frag_variance < frag_mean:
	p = 1 - (frag_variance/float(frag_mean))
	# N = mu/(1-(sigma^2/mu))
	n = float(frag_mean) / (1 - (float(frag_variance)/float(frag_mean)))
	return binomial(n, p)
    else:
	r = -1 * (power(frag_mean, 2)/float(frag_mean - frag_variance))
	p = frag_mean / float(frag_variance)
	print "Sampling frag_mean=",frag_mean, " frag_variance=", frag_variance
	print "r: ",r, "  p: ", p
	return negative_binomial(r, p) 
开发者ID:Xinglab,项目名称:rmats2sashimiplot,代码行数:21,代码来源:read_simulator.py

示例3: rvs

# 需要导入模块: from numpy import random [as 别名]
# 或者: from numpy.random import negative_binomial [as 别名]
def rvs(self, size=None):
        return random.negative_binomial(self.n, self.p, size=size) 
开发者ID:nchopin,项目名称:particles,代码行数:4,代码来源:distributions.py

示例4: simulate_BNB

# 需要导入模块: from numpy import random [as 别名]
# 或者: from numpy.random import negative_binomial [as 别名]
def simulate_BNB(mean, sigma, n):
    # sys.stderr.write("%g %g %g\n" % (mean, sigma, n))
    mean_p = np.float64(n) / (n+mean)
    sigma = (1 / sigma)**2
    a = mean_p * (sigma)+1
    b = (1 - mean_p)*sigma
    
    p = beta(a, b)
    #sys.stderr.write("%f %f\n"%(n,p))
    counts = negative_binomial(n, p)
    return counts 
开发者ID:bmvdgeijn,项目名称:WASP,代码行数:13,代码来源:simulate_counts.py


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