add real life examples + simplify multiply code.

This commit is contained in:
NunoSempere 2024-09-15 16:33:56 -04:00
parent 88d37f174e
commit 6686e4f919
2 changed files with 4 additions and 9 deletions

View File

@ -90,6 +90,8 @@ help
exit exit
``` ```
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)
## Tips & tricks ## Tips & tricks
- It's conceptually clearer to have all the multiplications first and then all the divisions - It's conceptually clearer to have all the multiplications first and then all the divisions

View File

@ -73,7 +73,7 @@ const HELP_MSG = " Operation | Variable assignment | Special\n" +
" beta: beta alpha beta\n" + " beta: beta alpha beta\n" +
" Variable assignment: =: variable_name\n" + " Variable assignment: =: variable_name\n" +
" Variable assignment and clear stack: =. variable_name\n" + " Variable assignment and clear stack: =. variable_name\n" +
" Special: \n" + " Special commands: \n" +
" Comment: # this is a comment\n" + " Comment: # this is a comment\n" +
" Clear stack: clear | c | .\n" + " Clear stack: clear | c | .\n" +
" Print debug info: debug | d\n" + " Print debug info: debug | d\n" +
@ -209,8 +209,6 @@ func multiplyDists(old_dist Dist, new_dist Dist) (Dist, error) {
return multiplyLogDists(o, n), nil return multiplyLogDists(o, n), nil
case Scalar: case Scalar:
return multiplyLogDists(o, Lognormal{low: float64(n), high: float64(n)}), nil return multiplyLogDists(o, Lognormal{low: float64(n), high: float64(n)}), nil
default:
return operateDistsAsSamples(old_dist, new_dist, "*")
} }
} }
case Scalar: case Scalar:
@ -223,20 +221,15 @@ func multiplyDists(old_dist Dist, new_dist Dist) (Dist, error) {
return multiplyLogDists(Lognormal{low: float64(o), high: float64(o)}, n), nil return multiplyLogDists(Lognormal{low: float64(o), high: float64(o)}, n), nil
case Scalar: case Scalar:
return Scalar(float64(o) * float64(n)), nil return Scalar(float64(o) * float64(n)), nil
default:
return operateDistsAsSamples(old_dist, new_dist, "*")
} }
} }
case Beta: case Beta:
switch n := new_dist.(type) { switch n := new_dist.(type) {
case Beta: case Beta:
return multiplyBetaDists(o, n), nil return multiplyBetaDists(o, n), nil
default:
return operateDistsAsSamples(old_dist, new_dist, "*")
} }
default:
return operateDistsAsSamples(old_dist, new_dist, "*")
} }
return operateDistsAsSamples(old_dist, new_dist, "*")
} }
func divideDists(old_dist Dist, new_dist Dist) (Dist, error) { func divideDists(old_dist Dist, new_dist Dist) (Dist, error) {