2010/05/30

日本へ帰国

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

スーツを着る生活か…

 
Posted by Picasa

2010/05/10


#!/usr/bin/env python

import fileinput
import pylab
import matplotlib.pyplot as plt
from matplotlib import rc
from math import *
fig_width_pt = 246.0 # Get this from LaTeX using \showthe\columnwidth
inches_per_pt = 1.0/72.27 # Convert pt to inch
golden_mean = (sqrt(5)-1.0)/2.0 # Aesthetic ratio
fig_width = fig_width_pt*inches_per_pt # width in inches
fig_height = fig_width*golden_mean # height in inches
fig_size = [fig_width,fig_height]
params = {'backend': 'ps',
'axes.labelsize': 20,
'text.fontsize': 20,
'legend.fontsize': 20,
'xtick.labelsize': 20,
'ytick.labelsize': 20,
'text.usetex': True,
'figure.figsize': fig_size}
pylab.rcParams.update(params)

#rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})
## for Palatino and other serif fonts use:
rc('text', usetex=True)
rc('font', family='serif')


time_s=[]
spot_p=[]
forward_p=[]
b_theta=[]
kappa=[]
for line in fileinput.input():
items=line[:-1].split()
spot_p.append(items[0])
forward_p.append(items[1])
b_theta.append(items[2])
time_s.append(items[4])
kappa.append(items[5])
print items[0],items[1],items[2],items[3],items[4],items[5]


fig = pylab.figure(1, figsize=(13,10))
plt.xlabel('Time to maturity')
plt.ylabel('Prices')
plt.plot(time_s,spot_p,label='Spot price')
plt.plot(time_s,forward_p,label='Forward price')
plt.legend()
plt.xlim([0, 1.6])
#plt.show()
plt.savefig('price_his.eps')


fig = pylab.figure(2,figsize=(13,10))
plt.xlabel('Time to maturity')
plt.ylabel(r'$\kappa$')
plt.plot(time_s,kappa,label=r'$\kappa$')
plt.legend()
plt.xlim([0, 1.6])
plt.ylim([-10, 5])
#plt.show()
plt.savefig('kappa.eps')


fig = pylab.figure(3,figsize=(13,10))
plt.xlabel('Time to maturity')
plt.ylabel(r'$\bar{\theta}$')
plt.plot(time_s,b_theta,label=r'$\bar{\theta}$')
plt.legend()
#plt.xlim([0, 1.6])
#plt.ylim([-10, 5])
#plt.show()
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分乗り換えなしは魅力的な目的地。
財布を持っていくのを忘れてコーヒーも飲めなかった。


#!/usr/bin/python

#Project Euler Problem 27
#Start 01/May/2010
#End 01/May/2010

import math

def is_prm(i):
if i<0:
return 0
else:
sq_i=math.ceil(math.sqrt(i))
k=2
while k<=sq_i:
if i%k==0:
return 0
k+=1
return 1

def fun(a,b,n):
return math.pow(n,2)+a*n+b

prm=[]
prm.append(1)
for i in range(2,1000):
k=is_prm(i)
if k==1:
prm.append(i)
print prm
mx=0
for a in range(-1000,1001,1):
for b in prm:
# print a,b
n=0
while 1:
k=is_prm(fun(a,b,n))
if k==1:
n+=1
else:
break
if n>mx:
mx=n
print a,b,n,a*b



 
Posted by Picasa