integrate pretty parser, move number of samples to 1M

This commit is contained in:
NunoSempere 2024-06-30 09:30:55 -04:00
parent 079535ce6b
commit 860e63b4be
2 changed files with 7 additions and 8 deletions

13
f.go
View File

@ -9,7 +9,6 @@ import (
"math"
"os"
"sort"
"strconv"
"strings"
)
@ -89,7 +88,7 @@ const HELP_MSG = " Operation | Variable assignment | Special\n" +
" exit\n"
const NORMAL90CONFIDENCE = 1.6448536269514727
const INIT_DIST Scalar = Scalar(1)
const N_SAMPLES = 100_000
const N_SAMPLES = 1_000_000
/* Printers */
func prettyPrintDist(dist Dist) {
@ -305,7 +304,7 @@ func parseWordsIntoOpAndDist(words []string, vars map[string]Dist) (string, Dist
return parseWordsErr("Operator must have operand; can't operate on nothing")
case 1:
var_word, var_word_exists := vars[words[0]]
single_float, err1 := strconv.ParseFloat(words[0], 64) // abstract this away to search for K/M/B/T/etc.
single_float, err1 := pretty.ParseFloat(words[0]) // abstract this away to search for K/M/B/T/etc.
switch {
case var_word_exists:
dist = var_word
@ -315,16 +314,16 @@ func parseWordsIntoOpAndDist(words []string, vars map[string]Dist) (string, Dist
return parseWordsErr("Trying to operate on a scalar, but scalar is neither a float nor an assigned variable")
}
case 2:
new_low, err1 := strconv.ParseFloat(words[0], 64)
new_high, err2 := strconv.ParseFloat(words[1], 64)
new_low, err1 := pretty.ParseFloat(words[0])
new_high, err2 := pretty.ParseFloat(words[1])
if err1 != nil || err2 != nil {
return parseWordsErr("Trying to operate by a distribution, but distribution is not specified as two floats")
}
dist = Lognormal{low: new_low, high: new_high}
case 3:
if words[0] == "beta" || words[0] == "b" {
a, err1 := strconv.ParseFloat(words[1], 64)
b, err2 := strconv.ParseFloat(words[2], 64)
a, err1 := pretty.ParseFloat(words[1])
b, err2 := pretty.ParseFloat(words[2])
if err1 != nil || err2 != nil {
return parseWordsErr("Trying to specify a beta distribution? Try beta 1 2")
}

View File

@ -60,7 +60,7 @@ func multiplyOrPassThroughError(a float64, b float64, err error) (float64, error
}
}
func parseFloat(word string) (float64, error) {
func ParseFloat(word string) (float64, error) {
// l = len(word) // assuming no UTF stuff
switch len(word) {