3 ms·
The terrible irony of this post is that they use a completely wrong definition of expected value. They write down an integral...but then implement something tot
by jointpdf 5y ago
The terrible irony of this post is that they use a completely wrong definition of expected value. They write down an integral...but then implement something totally different.
You cannot calculate the EV of a random variable X by taking the mean of random samples drawn from the distribution of X (e.g. try it with the Cauchy distribution—see if you get something approaching the actual EV). The only thing they accomplished is building up a very convoluted way of calculating a sample mean—which is already trivial with Numpy or just standard Python. Why do this? I’m perplexed.
This is the issue with software engineers writing scientific code—they often flagrantly misunderstand basic mathematical definitions, and then obfuscate this misunderstanding with their “pure” and “robust” code.
Sorry for the harsh criticism, but I’m tired of seeing this kind of thing.
- vitorsr 5y agoThe uncomfortable truth is that merely subscribing to the tenets of current software development “best practices” does not compensate for limitations in knowledge of applied mathematical sciences.
- tgb 5y agoWell the integral doesn’t work for a Cauchy distribution either so that seems a little unfair for criticism. And this kind of procedure is not unusual for more complex distributions that have no well-understood density function to integrate, like the results a physics simulation, aren’t they?
- ww_wpg 5y ago> You cannot calculate the EV of a random variable X by taking the mean of random samples drawn from the distribution of X My understanding of statistics is rudimentary so forgive me but doesn't the sample mean of a normally distributed variable tend towards the expected value for the population?
- mturmon 5y agoThe sample mean of a Normal RV does tend towards the population expected value, sure. The GP comment is talking about a Cauchy RV, which has heavy tails. So it has enough probability mass at large values that the expected value is infinite. Discarding constant scale factors, in this case: E[X] = Int{0..infty} x * p(x) dx = Int{0..infty} x * (1/x^2) dx = Int{0..infty} (1/x) dx = +infty So, the sample mean of Cauchy random variates will not converge to any real number.
- hrzn 5y agoNote that the actual EV of a Cauchy random variable is undefined...