spell check

This commit is contained in:
NunoSempere 2024-12-29 00:53:42 +01:00
parent b645f6648a
commit 3a734f180c
2 changed files with 17 additions and 15 deletions

View File

@ -1,6 +1,6 @@
# A calculator for distributions, for Fermi estimation
This project is a minimalist, calculator-style DSL for fermi estimation. It can multiply, divide, add and substract scalars, lognormals and beta distributions, and supports variables.
This project is a minimalist, calculator-style DSL for fermi estimation. It can multiply, divide, add and subtract scalars, lognormals and beta distributions, and supports variables.
## Motivation
@ -62,7 +62,6 @@ $ fermi
beta: beta alpha beta
Variable assignment: =: variable_name
Variable assignment and clear stack: =. variable_name
Suffixes: %, K, M, B, T
Special commands:
Comment: # this is a comment
Summary stats: stats
@ -79,7 +78,7 @@ $ fermi
+ 1 10
* beta 1 10
1 10 (multiplication taken as default operation)
=: x
=: x
.
1 100
+ x
@ -89,16 +88,20 @@ $ fermi
1 10
+ beta 1 100
)
=. y
mx x 1 y 2.33
+ mx x 30% y 70%
exit
Command flags:
2. Command flags:
-echo
Specifies whether inputs should be echoed back. Useful if reading from a file
. -f string
Specifies a file with a model to run. Sets the echo command to true by default.
Specifies a file with a model to run
-n int
Specifies the number of samples to draw when using samples (default 100000)
-h Shows help message
```
You can see real life examples [here](https://x.com/NunoSempere/status/1831106442721452312), [here](https://x.com/NunoSempere/status/1829525844169248912), [here](https://x.com/NunoSempere/status/1818810770932568308), [here](https://x.com/NunoSempere/status/1816605190415401100), [here](https://x.com/NunoSempere/status/1816604386703081894), [here](https://x.com/NunoSempere/status/1815169781907042504)
@ -106,7 +109,7 @@ You can see real life examples [here](https://x.com/NunoSempere/status/183110644
## Tips & tricks
- It's conceptually clearer to have all the multiplications first and then all the divisions
- For things between 0 and 1, consider using a beta distribution
- For distributions between 0 and 1, consider using a beta distribution
### Command line options
@ -123,9 +126,9 @@ You also run a file with the -f option
$ fermi -f more/piano-tuners.fermi
```
### Integrations with linux utilities
### Integrations with Linux utilities
Because the model reads from standard input, you can a model to it:
Because the model reads from standard input, you can pipe a model to it:
```
$ cat more/piano-tuners.fermi | fermi
@ -134,7 +137,6 @@ $ cat more/piano-tuners.fermi | fermi
In that case, you will probably want to use the echo flag as well
```
$ cat more/piano-tuners-commented.fermi | fermi -echo
```
@ -152,9 +154,9 @@ fermi | tee -a fermi.log
## Different levels of complexity
The top level f.go file (420 lines) has a bunch of complexity: variables, parenthesis, samples, beta distributions, number of samples, etc. In the simple/ folder:
The mainline code has a bunch of complexity: variables, parenthesis, samples, beta distributions, number of samples, mixtures etc. In the simple/ folder:
- f_simple.go (370 lines) strips variables and parenthesis, but keeps beta distributions, samples, and addition and substraction
- f_simple.go (370 lines) strips variables and parenthesis, but keeps beta distributions, samples, and addition and subtraction
- f_minimal.go (140 lines) strips everything that isn't lognormal and scalar multiplication and addition, plus a few debug options.
## Roadmap
@ -173,7 +175,7 @@ Done:
- [x] Think how to integrate with squiggle.c to draw samples
- [x] Copy the time to botec go code
- [x] Define samplers
- [x] Call those samplers when operating on distributions that can't be operted on algebraically
- [x] Call those samplers when operating on distributions that can't be operated on algebraically
- [x] Display output more nicely, with K/M/B/T
- [x] Consider the following: make this into a stack-based DSL, with:
- [x] Variables that can be saved to and then displayed
@ -194,6 +196,7 @@ Done:
- [x] Add flag to repeat input lines (useful when reading from files)
- [x] Add percentages
- [x] Consider adding an understanding of percentages
- [x] Improve and rationalize error messages a bit
To (possibly) do:
@ -201,7 +204,7 @@ To (possibly) do:
- [ ] Document mixture distributions
- [ ] Fix lognormal multiplication and division by 0 or < 0
- [ ] With the -f command line option, the program doesn't read from stdin after finishing reading the file
- [ ] Add functions. Now easier to do with an explicit representation of the stakc
- [ ] Add functions. Now easier to do with an explicit representation of the stack
- [ ] Think about how to draw a histogram from samples
- [ ] Dump samples to file
- [ ] Represent samples/statistics in some other way

View File

@ -105,7 +105,7 @@ const HELP_MSG = "1. Grammar:\n" +
" Specifies a file with a model to run\n" +
" -n int\n" +
" Specifies the number of samples to draw when using samples (default 100000)\n" +
" -h Shows help message"
" -h Shows help message\n"
const NORMAL90CONFIDENCE = 1.6448536269514727
const INIT_DIST Scalar = Scalar(1)
@ -367,7 +367,6 @@ func parseWordsIntoOpAndDist(words []string, vars map[string]Dist) (string, Dist
/* Combine old dist and new line */
// We want this as a function (rather than just be in main)
// to be able to have parenthesis/recusion, possibly functions
func runRepl(stack Stack, reader *bufio.Reader, echo_flag *bool) Stack {
replForLoop:
for {