2010/05/30

日本へ帰国

3年弱のロンドン生活が終わります。今後は東京で労働者します。住所は新宿になりそうです。

スーツを着る生活か…

 
Posted by Picasa

2010/05/10

  1. #!/usr/bin/env python  
  2.   
  3. import fileinput   
  4. import pylab  
  5. import matplotlib.pyplot as plt  
  6. from matplotlib import rc  
  7. from math import *  
  8. fig_width_pt = 246.0  # Get this from LaTeX using \showthe\columnwidth  
  9. inches_per_pt = 1.0/72.27               # Convert pt to inch  
  10. golden_mean = (sqrt(5)-1.0)/2.0         # Aesthetic ratio  
  11. fig_width = fig_width_pt*inches_per_pt  # width in inches  
  12. fig_height = fig_width*golden_mean      # height in inches  
  13. fig_size =  [fig_width,fig_height]  
  14. params = {'backend''ps',  
  15.            'axes.labelsize'20,  
  16.            'text.fontsize'20,  
  17.            'legend.fontsize'20,  
  18.            'xtick.labelsize'20,  
  19.            'ytick.labelsize'20,  
  20.            'text.usetex'True,  
  21.            'figure.figsize': fig_size}  
  22. pylab.rcParams.update(params)  
  23.   
  24. #rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})  
  25. ## for Palatino and other serif fonts use:  
  26. rc('text', usetex=True)  
  27. rc('font', family='serif')  
  28.   
  29.   
  30. time_s=[]  
  31. spot_p=[]  
  32. forward_p=[]  
  33. b_theta=[]  
  34. kappa=[]  
  35. for line in fileinput.input():  
  36.     items=line[:-1].split()  
  37.     spot_p.append(items[0])  
  38.     forward_p.append(items[1])  
  39.     b_theta.append(items[2])  
  40.     time_s.append(items[4])  
  41.     kappa.append(items[5])  
  42.     print items[0],items[1],items[2],items[3],items[4],items[5]  
  43.   
  44.   
  45. fig = pylab.figure(1, figsize=(13,10))  
  46. plt.xlabel('Time to maturity')  
  47. plt.ylabel('Prices')  
  48. plt.plot(time_s,spot_p,label='Spot price')  
  49. plt.plot(time_s,forward_p,label='Forward price')  
  50. plt.legend()  
  51. plt.xlim([01.6])  
  52. #plt.show()  
  53. plt.savefig('price_his.eps')  
  54.   
  55.   
  56. fig = pylab.figure(2,figsize=(13,10))  
  57. plt.xlabel('Time to maturity')  
  58. plt.ylabel(r'$\kappa$')  
  59. plt.plot(time_s,kappa,label=r'$\kappa$')  
  60. plt.legend()  
  61. plt.xlim([01.6])  
  62. plt.ylim([-105])  
  63. #plt.show()  
  64. plt.savefig('kappa.eps')  
  65.   
  66.   
  67. fig = pylab.figure(3,figsize=(13,10))  
  68. plt.xlabel('Time to maturity')  
  69. plt.ylabel(r'$\bar{\theta}$')  
  70. plt.plot(time_s,b_theta,label=r'$\bar{\theta}$')  
  71. plt.legend()  
  72. #plt.xlim([0, 1.6])  
  73. #plt.ylim([-10, 5])  
  74. #plt.show()  
  75. plt.savefig('b_theta.eps')  



 
Posted by Picasa

2010/05/08

ブルーベル

日本野鳥の会のメンバーで丹頂鶴を見たこともある英国人と遭遇。奇遇ですね。ブルーベルを見てきた。

Pythonでグラフを描く。
pylab.plot(xx,yy)
pylab.show()

UbuntuでPythonのモジュールをインストールする。

sudo apt-get install python-numpy python-scipy python-matplotlib python-scientific python-stats


 
Posted by Picasa

2010/05/07

matplotlib
ipython
inkscape
scipy

2010/05/01

テートブリテン

素晴らしい晴天(夕方からは雨だったけど)。テート・ブリテンへ。バスで5分乗り換えなしは魅力的な目的地。
財布を持っていくのを忘れてコーヒーも飲めなかった。

  1. #!/usr/bin/python  
  2.   
  3. #Project Euler Problem 27  
  4. #Start 01/May/2010  
  5. #End   01/May/2010  
  6.   
  7. import math  
  8.   
  9. def is_prm(i):  
  10.     if i<0:  
  11.         return 0  
  12.     else:  
  13.         sq_i=math.ceil(math.sqrt(i))  
  14.         k=2  
  15.         while k<=sq_i:  
  16.             if i%k==0:  
  17.                 return 0  
  18.             k+=1  
  19.         return 1  
  20.   
  21. def fun(a,b,n):  
  22.     return math.pow(n,2)+a*n+b  
  23.   
  24. prm=[]  
  25. prm.append(1)  
  26. for i in range(2,1000):  
  27.     k=is_prm(i)  
  28.     if k==1:  
  29.         prm.append(i)  
  30. print prm  
  31. mx=0  
  32. for a in range(-1000,1001,1):  
  33.     for b in prm:  
  34. #        print a,b  
  35.         n=0  
  36.         while 1:  
  37.             k=is_prm(fun(a,b,n))  
  38.             if k==1:  
  39.                 n+=1  
  40.             else:  
  41.                 break  
  42.         if n>mx:  
  43.             mx=n  
  44.             print a,b,n,a*b  


 
Posted by Picasa