Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Define datasets | |
X = [1, 1.25, 1.8, 1.9, 2.21, 2.85] | |
Y = [1.1, 1.14, 1.8, 1.85, 2.25, 2.9] | |
print(X,Y) | |
# Let's see what this looks like | |
with plt.xkcd(): | |
plt.scatter(X, Y) | |
plt.show() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Calculate means and normalize | |
x_mean = np.mean(X) | |
X_adj = [x-x_mean for x in X] | |
y_mean = np.mean(Y) | |
Y_adj = [y - y_mean for y in Y] | |
# Caculate Covariance Matrix | |
cov = np.cov(X_adj, Y_adj) | |
print(cov) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lam, v = np.linalg.eig(cov) | |
print("Eigenvalues:") | |
print(lam) | |
print("Eigenvectors:") | |
print(v) | |
# Sort | |
eigvals, eigvects = (list(t) for t in zip(*sorted(zip(lam, v)))) | |
# And now we can see what this looks like! | |
x_s = np.linspace(np.min(X_adj), np.max(X_adj), 10) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import corner | |
import emcee | |
from google.colab import drive | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
import mplcyberpunk | |
import numpy as np | |
from sklearn.linear_model import LinearRegression | |
from sklearn.metrics import mean_squared_error | |
plt.style.use("cyberpunk") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data = pd.read_csv(DATASET_PATH, delimiter=' ') | |
data['M_BH'] = np.log10(data['M_BH']) | |
data['M_low'] = np.log10(data['M_low']) | |
data['M_high'] = np.log10(data['M_high']) | |
# Change low and high to errors | |
data['M_low'] = data['M_BH'] - data['M_low'] | |
data['M_high'] = data['M_high'] - data['M_BH'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
n = 50 # Size of spectrum | |
N = 5000 # Number of spectra | |
def gaussian(x, mu, sig): | |
return 1*np.exp(-np.power(x - mu, 2.) / (2 * np.power(sig, 2.))) | |
def conv_mat(n): | |
""" | |
Create convolution matrix that is an identity matrix with noise | |
""" | |
conv_mat = np.eye(n)+np.random.normal(0, 0.05, (n,n)) |
OlderNewer