Skip to content

Instantly share code, notes, and snippets.

View TheTexasDev's full-sized avatar

Texan TheTexasDev

  • Neverland
View GitHub Profile
@TheTexasDev
TheTexasDev / montehallproof.py
Created March 11, 2024 18:41
Proof of the Monte Hall problem which I personally disagree with. Picks a random door and decides whether to switch or stay. Logs the wins and percentages at the end
from random import randint
switching_wins = 1
staying_wins = 1
switching_count = 1
staying_count = 1
total_runs = 0
stop_at = randint(10000,100000) # Set to how many instances you wanna try. Bigger the sample size the less room for error
when_to_swap = round(stop_at/2) # The point where to stop switching from the initally picked door. By default it will equally switch and stay. Can be set to anything less than stop_at
switch_randomly = False # If set to true, instead of switching at a set number the program will randomly decide to switch or not every time
@TheTexasDev
TheTexasDev / randomness.js
Last active October 13, 2020 20:07
Has a Pseudo Random number generator, input keys with numerical values as an object into the function and get a uneven random output
function RandomGen(min,max){ // random number
return Math.round(Math.random()*max-min)+min;
}
function PRandomGen(obj){ // pseudo random number
// {"thing": 2, "otherthing": 6} // 'otherthing' will be 3x more likely to be returned since 6 is three times 2
var toReturn, sortable = [], total = 0;
for(var x in obj){ // loops through all values in the object