Skip to content

Commit 7d87970

Browse files
authored
Minor correction to FA algorithm (#614)
1 parent 7e32466 commit 7d87970

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

analysis/markov/src/Linleios/Probability.lean

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,19 @@ deriving Repr
1919
Fait Accompli sortition.
2020
-/
2121
def faSortition (nPools n : Nat) : List Sortition :=
22-
let S (i : Nat) := ((nPools - i + 1).toFloat / nPools.toFloat)^10 - ((nPools - i).toFloat / nPools.toFloat)^10
23-
let ρ (i : Nat) := 1 - ((nPools - i).toFloat / nPools.toFloat)^10
24-
let test (n i : Nat) : Bool := (1 - S i / ρ i)^2 < (n - i).toFloat / (n - i + 1).toFloat
22+
let ρ (i : Nat) := ((nPools - i + 1).toFloat / nPools.toFloat)^10
23+
let S (i : Nat) := ρ i - ((nPools - i).toFloat / nPools.toFloat)^10
24+
let test (i : Nat) : Bool := (1 - S i / ρ i)^2 < (n - i).toFloat / (n - i + 1).toFloat
2525
let i := (List.range nPools).map $ Add.add 1
26-
let ⟨ persistent , nonpersistent ⟩ := i.partition $ test n
27-
let ρStar := ρ $ persistent.length + 1
26+
let ⟨ persistent , nonpersistent ⟩ := i.partition test
27+
let n₁ := persistent.length
28+
let n₂ := n - n₁
29+
let ρStar := ρ $ n₁ + 1
2830
let persistent' := persistent.map $ fun i ↦ {stake := S i, probability := 1}
2931
let nonpersistent' :=
3032
nonpersistent.map $ fun i ↦
3133
let Si := S i
32-
{stake := Si, probability := Si / ρStar}
34+
{stake := Si, probability := 1 - Float.exp (- n₂.toFloat * Si / ρStar)}
3335
persistent' ++ nonpersistent'
3436

3537
/--

analysis/markov/src/LinleiosTest.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ private def outcomeNearUnity (os : Outcomes) : Bool :=
131131
)
132132
$ group "Quorum" (
133133
check "All voters vote and all votes are received" (
134-
∀ τ : RangedFloat 0.51 0.76,
135-
∀ committeeSize : RangedNat 700 1000,
134+
∀ τ : RangedFloat 0.50 0.90,
135+
∀ committeeSize : RangedNat 600 1000,
136136
nearUnity $ pQuorum 1 committeeSize.value.toFloat τ.value
137137
)
138138
)

0 commit comments

Comments
 (0)