Here is a program simulating malformed puzzle, it gives 1⁄3, so there is something wrong with naive Bayesian inference here
package main
import "fmt"
import "math/rand"
func main() {
countSayM := 0
countMM := 0
for i := 0; i < 100000; i++ {
//0 - MM, 1 - FM, 2 - MF, 3 FF
breed := rand.Intn(4)
answer := 0 //M
if breed == 0 {
answer = 0
} else if breed == 1 || breed == 2 {
answer = rand.Intn(2)
}
if answer == 0 {
countSayM += 1
if breed == 0 {
countMM += 1
}
}
}
fmt.Println(float64(countMM)/float64(countSayM))
}
As a maths major from different field than probabilities though, I am abit puzzled by the whole Bayesian vs Frequentist business, both approaches are derived from common formalism defining probabilities and can’t contradict each other without blowing up whole modern probability theory which is pretty solid.
The only difference is that it touches different intuitions, and in some situations one is easier to apply than the other
It has been a year since this code was posted and the user has deleted their account, but for the benefit of anyone else reading for the first time, I would like to point out that the case for breed == 3 (two girls) is unhandled; because the default answer := 0 this means that in the case of two girls, the mathematician is modeled as saying “at least one is a boy”. Incorrect code gives the incorrect result.
Here is a program simulating malformed puzzle, it gives 1⁄3, so there is something wrong with naive Bayesian inference here
As a maths major from different field than probabilities though, I am abit puzzled by the whole Bayesian vs Frequentist business, both approaches are derived from common formalism defining probabilities and can’t contradict each other without blowing up whole modern probability theory which is pretty solid.
The only difference is that it touches different intuitions, and in some situations one is easier to apply than the other
It has been a year since this code was posted and the user has deleted their account, but for the benefit of anyone else reading for the first time, I would like to point out that the case for
breed == 3
(two girls) is unhandled; because the defaultanswer := 0
this means that in the case of two girls, the mathematician is modeled as saying “at least one is a boy”. Incorrect code gives the incorrect result.