commit 060b9725ee2cfa53b5ba1dbd52355774769cbd0e
parent 9c5d99a32656e0612fd500afc7135823678eb3ad
Author: NunoSempere <nuno.semperelh@protonmail.com>
Date: Sun, 23 Jun 2024 18:18:42 -0400
extract key judgmental variables into core/main.go
Diffstat:
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/core/core.go b/core/core.go
@@ -0,0 +1,5 @@
+package core
+
+const Include_polls_within_n_days = 15 //
+const Std_additional_uncertainty = 0.0 // 4.0 / 100.0
+const Weight_polls_vs_baserate = 0.8 // 0.75
diff --git a/main.go b/main.go
@@ -3,6 +3,7 @@ package main
import (
"encoding/csv"
"fmt"
+ "git.nunosempere.com/NunoSempere/US-2024/core"
"math"
rand "math/rand/v2"
"os"
@@ -112,7 +113,7 @@ func getChanceRepublicanWinFromPollPlusUncertainty(poll Poll, state State, prett
- Increased polarization
Also note that the polls already have some error already
*/
- std_additional_uncertainty := 4.0 / 100.0
+ std_additional_uncertainty := core.Std_additional_uncertainty
if n_republican_win == 0 || n_republican_win == 6 {
// if solid states for the last 6 elections
@@ -250,7 +251,7 @@ func sampleFromState(state State) VotesForEachParty {
p_republican_win_aggregate_polls := getChanceRepublicanWinFromPollPlusUncertainty(aggregate_poll, state, false)
// p_republican_win_aggregate_polls = getChanceRepublicanWinFromPoll(aggregate_poll, false)
- weight_polls := 0.75
+ weight_polls := core.Weight_polls_vs_baserate // 0.75
p_republican_win = weight_polls*p_republican_win_aggregate_polls + (1.0-weight_polls)*p_baserate_republican_win
// p_republican_win = p_republican_win_aggregate_polls
}
@@ -442,7 +443,7 @@ func readStates() ([]State, error) {
// Filter polls by recency and by having both Biden and Trump
var recent_polls []Poll
for _, poll := range polls {
- if poll.Date.After(time.Now().AddDate(0, 0, -30)) {
+ if poll.Date.After(time.Now().AddDate(0, 0, -core.Include_polls_within_n_days)) {
recent_polls = append(recent_polls, poll)
}
}