There should be an explanation at https://docs.moodle.org/dev/Quiz_statistics_calculations, but currently equation rendering is broken there, which makes the page not very helpful. (MDLSITE-8046).
The code that computes the statistics is spread over various classes, but if you want to look, https://github.com/moodle/moodle/blob/3e73c33f9920fbb066f2c554fb998af46d4706d8/question/classes/statistics/questions/calculator.php#L37 is probably a reasonable place to start. (And, how that is called from mod/quiz/report/statistics code.)
The code that computes the statistics is spread over various classes, but if you want to look, https://github.com/moodle/moodle/blob/3e73c33f9920fbb066f2c554fb998af46d4706d8/question/classes/statistics/questions/calculator.php#L37 is probably a reasonable place to start. (And, how that is called from mod/quiz/report/statistics code.)