Show
Ignore:
Timestamp:
08/12/08 17:42:38 (5 months ago)
Author:
rezoo
Message:

忘れないようにコメント追加。ついでにinit.pyも。

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/python/option_tools/alpha.py

    r17522 r17527  
    66 
    77def effectiveWeight_Call(S0,C0,K,T,R,V,V1,mu=None,cacheNum=10000,newtonNum=10,seed=0): 
    8         """ 
    9         対数効用関数に基づいた、無リスク資産とコールオプションの最適成長比率を求めます。 
     8        """対数効用関数に基づいた、無リスク資産とコールオプションの対数最適成長比率を求めます。 
    109         
    1110        引数: 
     
    2625        cache = [] 
    2726        random.seed(seed) 
    28         avg = -0.5*V1*V1 if not mu else mu 
     27        avg = -0.5*V1*V1 if not mu else mu #指定されなかったらマルチンゲールにする。 
    2928 
    3029        for i in range(cacheNum): 
    31                 #対数正規分布に基づいて未来のを算出 
     30                #対数正規分布に基づいて未来の価格を算出 
    3231                S = S0*random.lognormvariate(avg, V1) 
    3332                cnd = C0 / (BS_Call(S,K,T,R,V)-C0) 
     
    3938 
    4039def _newtonsMethod(num,init_alpha,cache,i=1): 
     40        """ニュートン法を用いて最適対数成長率αの値を求めます。 
     41        """ 
    4142        if i > num: 
    4243                return init_alpha 
     
    4849 
    4950def _m(alpha,cache): 
     51        """対数成長率mの値を求めます。 
     52        """ 
    5053        total = sum([math.log( (alpha/x) + 1 ) for x in cache]) 
    5154        return total / len(cache) 
    5255 
    5356def _m_alpha(alpha,cache): 
     57        """mをαで偏微分した関数です。 
     58        """ 
    5459        total = sum([1.0/(alpha + x) for x in cache]) 
    5560        return total / len(cache) 
    5661 
    5762def _m2_alpha2(alpha,cache): 
     63        """mの2階偏微分関数です。 
     64        """ 
    5865        total = sum([-1.0/((alpha + x)**2) for x in cache]) 
    5966        return total / len(cache)