• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python math.log1p函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中math.log1p函数的典型用法代码示例。如果您正苦于以下问题:Python log1p函数的具体用法?Python log1p怎么用?Python log1p使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: test_log1p

    def test_log1p(self):
        import math

        self.ftest(math.log1p(1 / math.e - 1), -1)
        self.ftest(math.log1p(0), 0)
        self.ftest(math.log1p(math.e - 1), 1)
        self.ftest(math.log1p(1), math.log(2))
开发者ID:GaussDing,项目名称:pypy,代码行数:7,代码来源:test_math.py


示例2: logadd

	def logadd(self, alpha):
		x = alpha[0]
		y = alpha[1]
		if y <= x:
			return x + math.log1p(math.exp(y-x))
		else:
			return y + math.log1p(math.exp(x-y))
开发者ID:cedrichu,项目名称:trigramHMM,代码行数:7,代码来源:hmm_trigram.py


示例3: testing

def testing(test_list, vocabulary, P1, P2, pp, np):
	result_value = []
	for test in test_list:
		test = test.split()
		
#		print test
		
		sum_of_pprob = 0
		sum_of_nprob = 0
		for word in test:
			if vocabulary.count(word):
				index = vocabulary.index(word)
				sum_of_pprob += math.log1p(pp[index])
				sum_of_nprob += math.log1p(np[index])

		positiveProbability = sum_of_pprob + math.log1p(P1)
		negativeProbability = sum_of_nprob + math.log1p(P2)
		
#		print positiveProbability
#		print negativeProbability
#		input('probability')

		if positiveProbability >= negativeProbability:
			result_value.append('+')
		else:
			result_value.append('-')
	return result_value
开发者ID:Mahe94,项目名称:NLP_Project,代码行数:27,代码来源:stage5.py


示例4: transition

def transition(dist, a, f, logspace=0):
    """
    Compute transition probabilities for a HMM. 
    
    to compute transition probabilities between hidden-states,
    when moving from time t to t+1,
    the genetic distance (cM) between the two markers are required.
    
    Assuming known parameters a and f.
    lf logspace = 1, calculations are log-transformed.
    
    Key in dictionary: 0 = not-IBD, 1 = IBD.
    """
    if logspace == 0:
        qk = exp(-a*dist)

        T = { # 0 = not-IBD, 1 = IBD
            1: {1: (1-qk)*f + qk, 0: (1-qk)*(1-f)},
            0: {1: (1-qk)*f, 0: (1-qk)*(1-f) + qk}
            }
        
    else:
        if dist == 0:
            dist = 1e-06

        ff = 1-f
        ad = a*dist
        A = expm1(ad)
        AA = -expm1(-ad)
        T = { # 0 = not-IBD, 1 = IBD
            1: {1: log1p(A*f)-ad, 0: log(AA*ff)},
            0: {1: log(AA*f), 0: log1p(A*ff)-ad}}
    return T
开发者ID:magnusdv,项目名称:filtus,代码行数:33,代码来源:AutEx.py


示例5: __log_add

 def __log_add(self, left, right):
     if (right < left):
         return left + math.log1p(math.exp(right - left))
     elif (right > left):
         return right + math.log1p(math.exp(left - right))
     else:
         return left + self.M_LN2
开发者ID:yrjie,项目名称:genomeBackup,代码行数:7,代码来源:hmm_gamma.py


示例6: log_sum

def log_sum(left,right):
	if right < left:
		return left + log1p(exp(right - left))
	elif left < right:
		return right + log1p(exp(left - right));
	else:
		return left + log1p(1)
开发者ID:adityamarella,项目名称:hiddenmarkovmodel,代码行数:7,代码来源:hmm.py


示例7: log_add

def log_add(left, right):
    if (right < left):
        return left + math.log1p(math.exp(right - left))
    elif (right > left):
        return right + math.log1p(math.exp(left - right))
    else:
        return left + M_LN2
开发者ID:Tell1,项目名称:ml-impl,代码行数:7,代码来源:test.py


示例8: my_features

def my_features(u, t):
    vector = []
    #vector += [float(edits_num(u, t, p)) for p in periods]
    vector += [math.log1p(user_lastedit[(u,t)]-user_frstedit[(u,t)])]
    vector += [math.log1p(numpy.reciprocal(numpy.mean(user_edit_freq[u])))] 
    #vector += [float(artis_num(u, t, p)) for p in periods]
    return vector
开发者ID:aniketalshi,项目名称:wikipediaprediciton,代码行数:7,代码来源:predictor.py


示例9: B

def B(x):
    y=None
    if math.sin(x/(x**2+2))+math.exp(math.log1p(x)+1)==0 or x==0:
        y='Neopredelen'
    else:
         y=(1/(math.sin(x/(x**2+2))+math.exp(math.log1p(x)+1)))-1
    return y
开发者ID:Brattelnik,项目名称:Borodulin,代码行数:7,代码来源:Math1.py


示例10: mandelbrot

def mandelbrot(n):
	z = complex(0,0)
	for i in range(max_iter):
		z = complex.add(complex.multiply(z,z),n)
		if cabs(z) >= escape_radius:
			smooth = i + 1 - int(math.log1p(math.log1p(cabs(z)))/math.log1p(escape_radius))
			return int(smooth)
	return True
开发者ID:Kerorogunso,项目名称:Mandelbrot,代码行数:8,代码来源:Mandelbrot.py


示例11: drift

def drift(active_editors_test, grouped_edits, time_train, time_test):
    """Calculate drift
    """
    average_train = sum([math.log1p(count_edits(grouped_edits[editor], time_train, 5))
                         for editor in active_editors_test])/len(active_editors_test)
    average_test = sum([math.log1p(count_edits(grouped_edits[editor], time_test, 5))
                        for editor in active_editors_test])/len(active_editors_test)
    return average_test - average_train
开发者ID:879229395,项目名称:wikichallenge,代码行数:8,代码来源:driver.py


示例12: test_log1p

 def test_log1p(self):
     import math
     self.ftest(math.log1p(1/math.e-1), -1)
     self.ftest(math.log1p(0), 0)
     self.ftest(math.log1p(math.e-1), 1)
     self.ftest(math.log1p(1), math.log(2))
     raises(ValueError, math.log1p, -1)
     raises(ValueError, math.log1p, -100)
开发者ID:Qointum,项目名称:pypy,代码行数:8,代码来源:test_math.py


示例13: logadd

def logadd(x, y):
    if y == 0:
        return x
    if x == 0:
        return y
    if y <= x:
        return x + math.log1p(math.exp(y - x))
    else:
        return y + math.log1p(math.exp(x - y))
开发者ID:asrivat1,项目名称:PartOfSpeechTagger,代码行数:9,代码来源:vtagem.py


示例14: geometric

def geometric(data, p):
    denom = math.log1p(-p)
    data.start_example(GEOMETRIC_LABEL)
    while True:
        probe = fractional_float(data)
        if probe < 1.0:
            result = int(math.log1p(-probe) / denom)
            assert result >= 0, (probe, p, result)
            data.stop_example()
            return result
开发者ID:Wilfred,项目名称:hypothesis-python,代码行数:10,代码来源:utils.py


示例15: __call__

 def __call__(self, response, a, result):
     text = get_text_from_html(a)
     this_features = defaultdict(float)
     norm = 0.0
     for token in parse_string(text, self.default_language):
         this_features[self.prefix + "__" + token] += 1.0
         norm += 1
     norm = log1p(norm)
     result.features.update((t, log1p(c) / norm) for t, c in this_features.viewitems())
     return result
开发者ID:windj007,项目名称:lcrawl,代码行数:10,代码来源:html.py


示例16: compute_scale_for_cesium

def compute_scale_for_cesium(coordmin, coordmax):
    '''
    Cesium quantized positions need to be in uint16
    This function computes the best scale to apply to coordinates
    to fit the range [0, 65535]
    '''
    max_int = np.iinfo(np.uint16).max
    delta = abs(coordmax - coordmin)
    scale = 10 ** -(math.floor(math.log1p(max_int / delta) / math.log1p(10)))
    return scale
开发者ID:LI3DS,项目名称:lopocs,代码行数:10,代码来源:utils.py


示例17: next_temp

def next_temp(initial_temp, iteration, max_iteration, current_temp, slope=None, standard_deviation=None):
    if Config.SA_AnnealingSchedule == 'Linear':
        temp = (float(max_iteration-iteration)/max_iteration)*initial_temp
        print ("\033[36m* COOLING::\033[0m CURRENT TEMP: "+str(temp))
#   ----------------------------------------------------------------
    elif Config.SA_AnnealingSchedule == 'Exponential':
        temp = current_temp * Config.SA_Alpha
        print ("\033[36m* COOLING::\033[0m CURRENT TEMP: "+str(temp))
#   ----------------------------------------------------------------
    elif Config.SA_AnnealingSchedule == 'Logarithmic':
        # this is based on "A comparison of simulated annealing cooling strategies"
        # by Yaghout Nourani and Bjarne Andresen
        temp = Config.LogCoolingConstant * (1.0/log10(1+(iteration+1)))     # iteration should be > 1 so I added 1
        print ("\033[36m* COOLING::\033[0m CURRENT TEMP: "+str(temp))
#   ----------------------------------------------------------------
    elif Config.SA_AnnealingSchedule == 'Adaptive':
        temp = current_temp
        if iteration > Config.CostMonitorQueSize:
            if 0 < slope < Config.SlopeRangeForCooling:
                temp = current_temp * Config.SA_Alpha
                print ("\033[36m* COOLING::\033[0m CURRENT TEMP: "+str(temp))
#   ----------------------------------------------------------------
    elif Config.SA_AnnealingSchedule == 'Markov':
        temp = initial_temp - (iteration/Config.MarkovNum)*Config.MarkovTempStep
        if temp < current_temp:
            print ("\033[36m* COOLING::\033[0m CURRENT TEMP: "+str(temp))
        if temp <= 0:
            temp = current_temp
#   ----------------------------------------------------------------
    elif Config.SA_AnnealingSchedule == 'Aart':
        # This is coming from the following paper:
        # Job Shop Scheduling by Simulated Annealing Author(s): Peter J. M. van Laarhoven,
        # Emile H. L. Aarts, Jan Karel Lenstra
        if iteration % Config.CostMonitorQueSize == 0 and standard_deviation is not None and standard_deviation != 0:
            temp = float(current_temp)/(1+(current_temp*(log1p(Config.Delta)/standard_deviation)))
            print ("\033[36m* COOLING::\033[0m CURRENT TEMP: "+str(temp))
        elif standard_deviation == 0:
            temp = float(current_temp)*Config.SA_Alpha
            print ("\033[36m* COOLING::\033[0m CURRENT TEMP: "+str(temp))
        else:
            temp = current_temp
#   ----------------------------------------------------------------
    elif Config.SA_AnnealingSchedule == 'Huang':
        if standard_deviation is not None and standard_deviation != 0:
            temp = float(current_temp)/(1+(current_temp*(log1p(Config.Delta)/standard_deviation)))
            print ("\033[36m* COOLING::\033[0m CURRENT TEMP: "+str(temp))
        elif standard_deviation == 0:
            temp = float(current_temp)*Config.SA_Alpha
            print ("\033[36m* COOLING::\033[0m CURRENT TEMP: "+str(temp))
        else:
            temp = current_temp
#   ----------------------------------------------------------------
    else:
        raise ValueError('Invalid Cooling Method for SA...')
    return temp
开发者ID:siavooshpayandehazad,项目名称:SoCDep2,代码行数:55,代码来源:SimulatedAnnealing.py


示例18: _get_thruput

 def _get_thruput(_ce_endpoint):
     if _ce_endpoint not in worker_ce_backend_throughput_dict:
         q_good_init = 0.
         q_good_fin = 0.
     else:
         q_good_init = float(sum(worker_ce_backend_throughput_dict[_ce_endpoint][_st]
                                 for _st in ('submitted', 'running', 'finished')))
         q_good_fin = float(sum(worker_ce_backend_throughput_dict[_ce_endpoint][_st]
                                 for _st in ('submitted',)))
     thruput = (log1p(q_good_init) - log1p(q_good_fin))
     return thruput
开发者ID:PanDAWMS,项目名称:panda-harvester,代码行数:11,代码来源:htcondor_submitter.py


示例19: get_stream_rating

def get_stream_rating(broadcast_id):
    periscope_api = PeriscopeAPI()
    users = periscope_api.getBroadcastUsers(broadcast_id)

    rating = 0
    for user in users['live']:
        rating += log1p(user['n_followers']) * (1 + 0.05 * user['n_hearts_given'])
    for user in users['replay']:
        rating += log1p(user['n_followers']) * (1 + 0.05 * user['n_hearts_given']) * 0.6
    rating += 0.1 * users['n_web_watched']
    return round(rating)
开发者ID:aikiselev,项目名称:Podsloosha,代码行数:11,代码来源:periscope_streams.py


示例20: get_ir_distances

    def get_ir_distances(self):
        """Converts the IR distance readings into a distance in meters"""
        
        ir_distances = [ \
            max( min( (log1p(3960) - log1p(reading))/30 + 
                       self.robot.ir_sensors.rmin,
                      self.robot.ir_sensors.rmax),
                 self.robot.ir_sensors.rmin)
            for reading in self.robot.ir_sensors.readings ]

        return ir_distances
开发者ID:Muminisko,项目名称:pysimiam,代码行数:11,代码来源:khepera3.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python math.log2函数代码示例发布时间:2022-05-27
下一篇:
Python math.log10函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap