Skip to content

Instantly share code, notes, and snippets.

View romanmichaelpaolucci's full-sized avatar
:octocat:
Studying

Roman Paolucci romanmichaelpaolucci

:octocat:
Studying
View GitHub Profile
import numpy as np
def HHH(p):
return 1/p + 1/(p**2) + 1/(p**3)
tosses = []
for i in range(10000):
chain = []
while True:
chain.append(np.random.choice([0, 1], p=[.5, .5]))
import numpy as np
import random
# Define the state space and number of days
state_space = range(101)
num_days = 365*20
# Generate fake daily data for the Markov chain
# For simplicity, we'll use a random choice for transitions between states
daily_data = [random.choice(state_space) for _ in range(num_days)]
import numpy as np
# transition matrix
P = np.array([[.5, .5, 0, 0],
[.5, 0, .5, 0],
[.5, 0, 0, .5],
[.5, 0, 0, .5]])
# Simulation
hits = []
import numpy as np
N = 10
P0 = np.array([[.5, .5, 0, 0], [.5, 0, .5, .0],
[.5, 0, 0, .5], [.5, 0, 0, .5]])
P1 = np.array([[.5, .5, 0, 0], [.5, 0, .5, .0],
[.5, 0, 0, .5], [0, 0, 0, 1]])
import numpy as np
P = np.array([[.7, .3],[.6, .4]])
P26 = np.linalg.matrix_power(P, 26)
print(P26[1][0]*.5 + P26[0][0]*.5)
day27 = []
import numpy as np
day2 = []
for i in range(10000):
# Randomly select coin 1 or 2 on day 1
X = np.random.randint(0, 2)
# Flip either coin and append the outcome to day2 vector
import matplotlib.pyplot as plt
import numpy as np
# Assuming df is your DataFrame and it has 'salary' and 'stock_return' columns
# df = pd.read_csv('your_data.csv') # Replace with your data source
# Creating the scatter plot
plt.figure(figsize=(10, 6))
plt.scatter(fr, np.log(stock_comp), color='blue', edgecolor='black', s=50)
def get_latest_highest(stock, comp, year):
return get_exec_comp(stock)[get_exec_comp(stock)['year'] == year].drop_duplicates("nameAndPosition").sort_values(by=comp, ascending=False).iloc[0]
fr = []
p = []
stock_comp = []
total_comp = []
for ticker in r_2021['Adj Close'].reset_index()['index'].values:
fr.append(r_2021['Adj Close'][ticker])
p.append(p_2021['Adj Close'][ticker])
import yfinance as yf
import pandas as pd
# Define the stock symbols
# Define the time period
start_date = '2021-01-01'
end_date = '2022-01-01'
# Download the stock data
plt.figure(figsize=(10, 6))
plt.hist(get_exec_comp("TSLA").drop_duplicates('nameAndPosition')['total']/1000000, bins=30, color='skyblue', edgecolor='black')
# Enhancing the plot
plt.title('TSLA Salary Distribution (millions)', fontsize=15)
plt.xlabel('Salary', fontsize=12)
plt.ylabel('Frequency', fontsize=12)
plt.grid(True, linestyle='--', alpha=0.7)
plt.tight_layout()