I hereby claim:
- I am cpfiffer on github.
- I am cpfiffer (https://keybase.io/cpfiffer) on keybase.
- I have a public key ASBuOyV4zsOUIxWVtBtAh0aRwqkKu25BwWPjUIxgfL8R4go
To claim this, I am signing this object:
| #The riddle can be found at https://fivethirtyeight.com/features/how-long-will-it-take-to-blow-out-the-birthday-candles/ | |
| tests = 10000000 | |
| blows <- rep(0,tests) | |
| i = 1 | |
| while (i <=tests) { | |
| candles = 30 | |
| while (candles > 0) { |
| # Cameron Pfiffer | |
| # July 31st, 2017 | |
| # Julia Does Numbers 2: The Mathening | |
| # See the link below for information about the challenge. | |
| # https://fivethirtyeight.com/features/pick-a-number-any-number/ | |
| #= | |
| From Itay Bavly, a chain-link number problem: |
| # Misc functions for conservation biology stats in R. | |
| shannon <- function (x) { | |
| proportion_x = x/sum(x) | |
| print(proportion_x) | |
| print(log(proportion_x)) | |
| print(proportion_x * log(proportion_x)) | |
| print(sum(proportion_x * log(proportion_x))) | |
| return(-sum(proportion_x*log(proportion_x))) | |
| } |
| # From Keith Wynroe, a battle for the tokens: | |
| # | |
| # You have one token, and I have two tokens. Naturally, we both crave more tokens, so we play a game of skill that unfolds over a number of rounds in which the winner of each round gets to steal one token from the loser. The game itself ends when one of us is out of tokens — that person loses. Suppose that you’re better than me at this game and that you win each round two-thirds of the time and lose one-third of the time. | |
| # | |
| # What is your probability of winning the game? | |
| @everywhere function play_game() | |
| p1 = 2 | |
| p2 = 1 | |
| play = true |
I hereby claim:
To claim this, I am signing this object:
| module P21 (properDivisors, sumDivisors, sumAmicable, isAmicable, amicableList) where | |
| properDivisors :: Int -> [Int] | |
| properDivisors x = [xs | xs <- [1..x-1], x `mod` xs == 0] | |
| sumDivisors :: Int -> Int | |
| sumDivisors x = sum $ properDivisors x |
| using CmdStan, DynamicHMC | |
| using StatsPlots, Random, MCMCDiagnostics | |
| using Revise | |
| using Turing, AdvancedHMC; const AHMC = AdvancedHMC | |
| Random.seed!(1239911) | |
| ProjDir = @__DIR__ | |
| cd(ProjDir) | |
| Nsamples = 2000 |
| using CmdStan, StatsPlots, Random, MCMCDiagnostics | |
| Random.seed!(12395391) | |
| ProjDir = @__DIR__ | |
| cd(ProjDir) | |
| berstanmodel = " | |
| data { | |
| int<lower=0> N; |
| using MCMCChains | |
| function sim(nsamples) | |
| cnt = 0 | |
| for i in 1:1000 | |
| chn = Chains(randn(nsamples,1,1)) | |
| ess = describe(chn)[1].df[:ess][1] | |
| ess > nsamples ? cnt+=1 : nothing | |
| end | |
| return cnt |
| using Turing | |
| using CSVFiles | |
| using DataFrames | |
| using Dates | |
| using StatsPlots | |
| # The TV syntax allows sampling to be type-stable. | |
| @model garch(r, ::Type{TV}=Vector{Float64}) where {TV} = begin | |
| T = length(r) |