-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprml_2_19.py
More file actions
35 lines (27 loc) · 730 Bytes
/
prml_2_19.py
File metadata and controls
35 lines (27 loc) · 730 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Dec 23 16:47:57 2016
@author: Narifumi
"""
import matplotlib.pyplot as plt
import numpy as np
from mpl_toolkits.mplot3d import Axes3D
def von_mises(theta, theta0, m):
dx = 0.001
x = np.arange(0, 2 * np.pi, dx)
I0 = (np.exp(m * np.cos(x)) * dx).sum() / (np.pi * 2)
ret = 1 / (I0 * 2 * np.pi) * np.exp(m * np.cos(theta - theta0))
return ret
theta0 = np.pi / 2
theta = np.arange(0, 2 * np.pi, 0.01)
m = 1
x = np.cos(theta)
y = np.sin(theta)
z = von_mises(theta, theta0, m)
fig = plt.figure()
ax1 = fig.add_subplot(121)
ax2 = fig.add_subplot(122,projection="3d")
ax1.plot(theta, von_mises(theta, theta0, m))
ax2.scatter(x, y, z)
plt.show()