Skip to content

Instantly share code, notes, and snippets.

View JefClaes's full-sized avatar

Jef Claes JefClaes

View GitHub Profile
@JefClaes
JefClaes / gist:295b611e30f6c79e2fb6
Last active August 29, 2015 14:13
Averages are not good enough (2)
let (|Even|Odd|) x =
if x % 2 = 0 then Even
else Odd
let median input =
let sortedInput = input |> Seq.sort
let length = input |> Seq.length
match length with
| 0 -> raise <| new ArgumentException("Input sequence is empty")
| 1 -> input |> Seq.nth 0
@JefClaes
JefClaes / gist:a5464518bbabb1e0b5eb
Last active August 29, 2015 14:13
Averages are not good enough (1)
let average input =
let length = input |> Seq.length
match length with
| 0 -> raise <| new ArgumentException("Input sequence is empty")
| _ -> (input |> Seq.sum) / float length
// Average = 45.625
// (18 + 21 + 41 + 42 + 48 + 50 + 55 + 90) / 8
@JefClaes
JefClaes / gist:9af1d2be7727ec22429e
Last active August 29, 2015 14:13
Averages are not good enough (0)
let responseTimes = [ 18.0; 21.0; 41.0; 42.0; 48.0; 50.0; 55.0; 90.0; ]
A First Course in Probability
http://www.amazon.com/First-Course-Probability-9th-Edition/dp/032179477X
Probability Theory: The Logic of Science
http://www.amazon.com/Probability-Theory-The-Logic-Science/dp/0521592712
Probability for Statistics and Machine Learning: Fundamentals and Advanced Topics
http://www.amazon.com/Probability-Statistics-Machine-Learning-Fundamentals/dp/B00E6TK8P8/ref=sr_1_2?s=books&ie=UTF8&qid=1420291747&sr=1-2&keywords=Probability+for+Statistics+and+Machine+Learning%3A+Fundamentals+and+Advanced+Topics
@JefClaes
JefClaes / gist:865778a8dad9c9cdc44d
Created December 17, 2014 09:54
CommandProjection
new CommandProjection("CasinoClerkReferralsProjection", _bus)
.FromEvents((eventId) => _store.GetEvents(eventId))
.When<CashUserRegisteredInCasino>(e => new AwardReferralFee(x, y, z))
.Run();
@JefClaes
JefClaes / gist:74d5c34d5abc0fb38b7a
Created December 13, 2014 11:14
Spinning the wheel: clustering and near misses (2)
Results seq [(Miss3, 37501); (Miss2, 49901); (Win, 12598)]
@JefClaes
JefClaes / gist:6b4784286189dc16b0b7
Created December 13, 2014 11:13
Spinning the wheel: clustering and near misses (1)
let physicalWheel = [Miss1; Miss2; Win; Miss3] |> Seq.ofList
let virtualWheel = [1; 1; 1; 1; 2; 3; 3; 3] |> Seq.ofList
@JefClaes
JefClaes / gist:a4354cdb01be916024d0
Created December 13, 2014 11:10
Spinning the wheel: clustering and near misses (0)
type WheelSpaceLabel =
| Miss1
| Miss2
| Miss3
| Win
@JefClaes
JefClaes / gist:e48f7bcff251efe9e007
Created December 7, 2014 20:04
Spinning the wheel in F#: manipulating the odds (3)
seq [(Miss, 856903); (Win, 143097)]
@JefClaes
JefClaes / gist:3da63f8b74fae5031b5f
Created December 7, 2014 20:03
Spinning the wheel in F#: manipulating the odds (2)
let rng = new Random()
let random (rng : Random) virtualIndexes =
virtualIndexes |> Seq.nth (rng.Next(0, virtualIndexes |> Seq.length))
let spin physicalWheel virtualIndexes rng =
physicalWheel |> Seq.nth (random rng virtualIndexes)