Skip to content

Instantly share code, notes, and snippets.

View romanmichaelpaolucci's full-sized avatar
🔨
Building

Roman Paolucci romanmichaelpaolucci

🔨
Building
View GitHub Profile
import matplotlib.pyplot as plt
import numpy as np
payouts = []
for i in range(10000):
n = np.random.geometric(0.5)
payouts.append(2 ** n)
plt.title("Payout distribution")
import random
total = 0
num_rolls = 10000
for _ in range(num_rolls):
roll = random.randint(1, 6)
total += roll
average_naive = total / num_rolls
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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)