Skip to content

Commit e335f08

Browse files
committed
lecture 3
1 parent ded1727 commit e335f08

File tree

3 files changed

+61
-0
lines changed

3 files changed

+61
-0
lines changed

comp_np_vs_std.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
import numpy as np
3+
import random
4+
import time
5+
6+
t0 = time.time()
7+
8+
n = 1000000
9+
r = []
10+
for i in range(n):
11+
r.append(random.normalvariate(0,1))
12+
13+
t1 = time.time()
14+
15+
nr = np.random.randn(n)
16+
17+
t2 = time.time()
18+
19+
print(t1-t0)
20+
print(t2-t1)
21+
22+
23+

lec3.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# -*- coding: utf-8 -*-
2+
import datetime
3+
import bondpricing
4+
from bondpricing import bondprice
5+
6+
today = datetime.datetime.today()
7+
issuedate = datetime.datetime(2016,2,15)
8+
matdate = datetime.datetime(2026,2,15)
9+
ytm = 0.03
10+
freq = 4
11+
couponrate = 0.04
12+
temp = bondprice(today, issuedate, matdate, freq, couponrate, ytm)
13+
print(temp)

rotate_axes3d_demo.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
'''
2+
==================
3+
Rotating a 3D plot
4+
==================
5+
6+
A very simple animation of a rotating 3D plot.
7+
8+
See wire3d_animation_demo for another simple example of animating a 3D plot.
9+
'''
10+
11+
from mpl_toolkits.mplot3d import axes3d
12+
import matplotlib.pyplot as plt
13+
14+
fig = plt.figure()
15+
ax = fig.add_subplot(111, projection='3d')
16+
17+
# load some test data for demonstration and plot a wireframe
18+
X, Y, Z = axes3d.get_test_data(0.1)
19+
ax.plot_wireframe(X, Y, Z, rstride=5, cstride=5)
20+
21+
# rotate the axes and update
22+
for angle in range(0, 360):
23+
ax.view_init(30, angle)
24+
plt.draw()
25+
plt.pause(.001)

0 commit comments

Comments
 (0)