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 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
//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() |
This file contains 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
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 file contains 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
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 |