| ▲ | progval 11 hours ago | ||||||||||||||||||||||||||||||||||||||||
The pure Python code in the last example is more verbose than it needs to be.
can be rewritten as:
and
as: | |||||||||||||||||||||||||||||||||||||||||
| ▲ | roadside_picnic 8 hours ago | parent | next [-] | ||||||||||||||||||||||||||||||||||||||||
> (n - 1) It's also funny that one would write their own standard deviation function and include Bessel's correction. Usually if I'm manually re-implementing a standard deviation function it's because I'm afraid the implementors blindly applied the correction without considering whether or not it's actually meaningful for the given analysis. At the very least, the correct name for what's implemented there should really be `sample_std_dev`. | |||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||
| ▲ | ashdev 10 hours ago | parent | prev [-] | ||||||||||||||||||||||||||||||||||||||||
Disagree. In the first instance, the original code is readable and tells me exactly what's what. In your example, you're sacrificing readability for being clever. Clear code(even if verbose) is better than being clever. | |||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||