-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGaussian.py
More file actions
23 lines (21 loc) · 854 Bytes
/
Gaussian.py
File metadata and controls
23 lines (21 loc) · 854 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Jun 6 14:05:59 2019
@author: vaeahc
"""
import numpy as np
import matplotlib.pyplot as plt
sigmax = 1
sigmay = 2
rou = -0.4 #0.4, 0.9, 0, -0.4, -0.9
sigma = np.array([[sigmax ** 2, rou * sigmax * sigmay], [rou * sigmax * sigmay, sigmay ** 2]])
sigma_det = np.abs(sigmax ** 2 * sigmay ** 2 - rou ** 2 * sigmax ** 2 * sigmay ** 2)
sigma_inv = 1 / sigma_det * np.array([[sigmay ** 2, -rou * sigmax * sigmay], [-rou * sigmax * sigmay, sigmax ** 2]])
x = np.linspace(-5, 5, 100)
y = np.linspace(-5, 5, 100)
x, y = np.meshgrid(x, y)
g = 1 / (2 * np.pi * np.sqrt(1 - rou ** 2) * sigmax * sigmay) * np.exp(-(x ** 2 * sigmax **2 + y ** 2 * sigmay ** 2 - 2 * rou * x * y * sigmax * sigmay) / (2 * (1 - rou ** 2) * sigmax ** 2 * sigmay ** 2))
plt.contourf(x, y, g)
plt.contour(x, y, g)
plt.show()