Pull Request Proposal: Alias average & avg -> mean
First off, thank you for working on mathjs and making it available to everybody. We really love it, and I'm extremely impressed.
Our users are smart but not math-focused. We're using mathjs' excellent parser to provide math answers in response to a text search box, similar to how macOS Spotlight support math. I've already done some work to format answers how I'd like, i.e. 10,000 instead of 10000, etc. and have found mathjs to be very extensible.
It'd be awesome if mathjs made avg and average aliases for mean. Then my users could type "average(1, 2, 3)" in the search and get an answer back. I realize there's a proper mean function, and tha mean is the BEST name, but with my use case, we have smart, but not math-focused people typing in free form math. The parser is doing an excellent job handling this use case, but it'd be even better if avg and average were aliases for mean.
Would you support a pull request that adds this? It's a low-risk, pragmatic change that adds very little cruft to support the human element in mathjs' parser!
Related: https://github.com/josdejong/mathjs/issues/1181
I'd also add clear documentation that math.avg and math.average are just aliases for math.mean, and that for most programatic use cases you should call math.mean directly.
My suggestion would be to extend the library with your own average function.
Here is an example: https://jsfiddle.net/ph4e08j7/
Thanks for your suggestion Ben. It can indeed be frustrating to find the function you're looking for if it is named differently than you expect. On the other hand, if there are multiple functions doing the same it also gets confusing (at some places you see avg being used, in others mean... is it the same or is there a different implementation behind it? Hard to figure out).
How about creating a solution which gives you an error but with a meaningful suggestion? Like 'Error: Function "avg" not found. Did you mean "mean"?' Such a suggestion can also be helpful when you make a typo in a function name.
I'd love to have that assigned to me if this feature interests mathjs.
Thanks for your offer kevin. Yes, it would be neath to implement a hinting system that can give you useful hints.
This boiled down to the same basic idea as #3045, so closing this one in favor of that. Please continue discsussion there. Thanks.