Skip to content

Instantly share code, notes, and snippets.

View samueleverett01's full-sized avatar
🤡

Samuel Everett samueleverett01

🤡
View GitHub Profile
@samueleverett01
samueleverett01 / Pi.py
Created September 9, 2017 21:12
Find the value of pi using Monte Carlo sampling
from random import random
from math import pow, sqrt
#set the number of trials that will be run to calculate pi
trial=10000000
hits=0.0
throws=0.0
# Monte Carlo step
@samueleverett01
samueleverett01 / Chip-Game.py
Created September 9, 2017 21:19
Monte Carlo simulation that calculates probability of winning a die-rolling game. Start with 1 chip, roll a 1, 2, 3, and you lose a chip, roll a 4 or 5, you gain a chip, roll a 6, you gain 2 chips. If you have no chips you lose, 4+ chips you win.
from random import choice
from tqdm import tqdm
trials = 10000000 # number of times the game is played (10,000,000)
lose = 0
win = 0
for game in tqdm(range(1, trials)):
options = [1, 2, 3, 4, 5, 6] # can roll any of these numbers
chips = 1 # starting point for each game
//This program implements a simple game of craps using some random number functions
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
int rollDice();
int main()
@samueleverett01
samueleverett01 / SKL-KNN.ipynb
Created March 28, 2018 22:12
K-NN model in Scikit-Learn
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@samueleverett01
samueleverett01 / COS-KNN.ipynb
Last active June 23, 2020 15:02
A K-NN model that outperforms standard Scikit-Learn K-NN classifiers.
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.