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


Python Storage.mu方法代码示例

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


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

示例1: current_option

# 需要导入模块: from storage import Storage [as 别名]
# 或者: from storage.Storage import mu [as 别名]
        return params.option(history,params)*exp(-r_free*T) 

#   Our custom option for stock XXX.
def current_option(history,params):
    #   If within the 60 first days price has gone over $105 we return 3.
    for i in range(60):
        if(history[i]>105): return 3
    #   If the stock at expiration is between $101 and $105 we return 1.
    if 105>=history[-1]>=101: return 1
    #   If the stock at expiration is over $105 we return 2.
    elif history[-1]>105: return 2
    else: return 0

#   Variables are initialized here.
params=Storage()
params.mu = 0.03/300 # avg daily return.
params.sigma = 0.2/sqrt(300) # avg daily volatility.
params.S = 100.0 # today's stock price.
params.option=current_option
params.T = 120 # time to expiration.
params.r_free = 0.04/300 # avg daily risk free rate.

params.dt = 1.0 # simulation step.

#   StockSimulator Object is initialized.
s = StockSimulator(params)

# Plotting is disabled for the purpose of this program.
#plot(dict(data=[x for x in enumerate(r)]))

#  Simulating to get the price for different volatility values or absolute precision.
开发者ID:athosprv,项目名称:Monte-Carlo-HA,代码行数:33,代码来源:my_option.py

示例2: range

# 需要导入模块: from storage import Storage [as 别名]
# 或者: from storage.Storage import mu [as 别名]
            for i in range(drivers):
                claim_chance = randint(1,3650)                
                if claim_chance==1:                
                    balance -= lognormvariate(mu,sigma)
                    self.num_claims+=1
                    drivers_claimed+=1
            drivers-=drivers_claimed
        
        #print total_balance
        #self.num_claims = 0
        self.u.append(balance);
       
        return balance

params=Storage()
params.mu = 5
params.sigma = 2.1
params.T = 365 # time to expiration.
params.dt = 1.0 # simulation step.
params.num_drivers = 10000 # Number of total drivers.
params.total_balance = params.num_drivers*150 # Value of the total Premiums.


h = HealthInsuranceSim(params)

print 'Problem 1: Average Total Annual profit', 1500000 - exp(5.0 + ((2.1)*(2.1))/2)*1000
print 'Problem 2:', h.simulate_many(absolute_precision = 0.1 , max_iterations= 2)
print 'Claims: ', h.num_claims

print 'Problem X: Better Average Total Annual profit', 1500000*2 - exp(5.0 + ((2.1)*(2.1))/2)*h.num_claims
开发者ID:athosprv,项目名称:Monte-Carlo-HA,代码行数:32,代码来源:fp.py


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