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
namespace HNC4PL | |
module CouriersPage = | |
open Sutil | |
open Sutil.CoreElements | |
open HNC4PL.Model | |
open HNC4PL.FormElements | |
open HNC4PL.Maps | |
open System |
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
#r "nuget: Feliz.ViewEngine" | |
#r "nuget: Plotly.NET" | |
open Feliz.ViewEngine | |
open System | |
open System.Diagnostics | |
open System.IO | |
open Plotly.NET | |
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
#r "nuget: FSharp.FGL, 0.0.4" | |
#r "nuget: FSharp.FGL.ArrayAdjacencyGraph" | |
open FSharp.FGL | |
open FSharp.FGL.ArrayAdjacencyGraph | |
let vertices = | |
[ for i=01 to 3 do (i,i) ] | |
let edges = |
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
//http://allendowney.github.io/ThinkBayes2/chap03.html#the-dice-problem | |
#r "nuget: FSharp.Stats, 0.4.12-preview.1" | |
open FSharp.Stats | |
open FSharp.Stats.Distributions | |
let normalise (dist: Map<'a, float>) = | |
let totalProbability = dist |> Map.toSeq |> Seq.sumBy snd | |
dist |> Map.map (fun k v -> v / totalProbability) |
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
(* | |
Exercise: In Major League Baseball, most players have a batting average between .200 and .330, which means that their probability of getting a hit is between 0.2 and 0.33. | |
Suppose a player appearing in their first game gets 3 hits out of 3 attempts. What is the posterior distribution for their probability of getting a hit? | |
https://colab.research.google.com/github/AllenDowney/ThinkBayes2/blob/master/notebooks/chap04.ipynb#scrollTo=LB4DESMrA0bs | |
*) | |
#r "nuget: FSharp.Stats, 0.4.12-preview.1" | |
#r "nuget: Plotly.NET" |
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
#r "nuget: FSharp.Stats, 0.4.12-preview.1" | |
#r "nuget: fsharp.data" | |
#r "nuget: Plotly.NET" | |
open FSharp.Data | |
open FSharp.Stats | |
open FSharp.Stats.Distributions | |
open Plotly.NET | |
let normalise (dist: seq<'a * float>) = |
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
// Think Bayes - Allen B. Downey | |
//Chapter 1 - Probability | |
#r "nuget: FSharp.Stats, 0.4.12-preview.1" | |
#r "nuget: fsharp.data" | |
#r "nuget: Plotly.NET" | |
open FSharp.Data | |
open FSharp.Stats |
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
open System.Collections.Generic | |
let mutable terms = new Dictionary<int64, int>() | |
let isPower2 (x: int64) = | |
x &&& (x - 1L) = 0 | |
let addSeqToDict (t: int64 array) = | |
t | |
|> Array.rev | |
|> Array.mapi(fun i x -> terms.TryAdd(x,(i+1) )) |
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
////Helper functions//// | |
let getTrianglesAndCoPrimes n = | |
if n % 2 = 0 then (n*(n+1)/2, (n/2), (n+1)) | |
else (n*(n+1)/2,((n+1)/2), n) | |
let getDivisors n = | |
let rec loopAndCheck n i divisors = | |
if i > n/2 then divisors |> Set.ofArray | |
elif n % i = 0 then loopAndCheck n (i+1) (Array.append divisors [|i|]) | |
else loopAndCheck n (i+1) divisors |
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
#r "nuget: FSharp.Data" | |
#r "nuget: Microsoft.Data.SqlClient" | |
#r "nuget: Dapper" | |
open Microsoft.Data.SqlClient | |
open Dapper | |
open FSharp.Data | |
open System.Threading | |
open System |
NewerOlder