Someone attempted to reproduce BDM, had problems and posted on CodeReview StackExchange asking for insight. The dummies there criticized the white space and variable names in his code. I found someone’s blog post with a correct answer and posted it. Sanctimonious and clueless lifers on the site deleted the information. The rules of StackExchange pretty much guarantee that narrow-minded lifers, similar to Wikipedia edit patrollers, will defend StackExchange against any useful content. Oh well. Here’s my answer:
OP is trying to write a Python program to reproduce a claimed calculation result of Bueno De Mesquita (BDM). There is another attempt to reproduce this calculation, in Python, by David Masad, “Replicating a replication of BDM“. Masad provided Python code, and also showed an approximately 20% divergence in the median score, starting from the same example and same inputs and same references. Jeremy McKibben-Sanders then replicated the model, with results matching BDM. Masad added a new post to discuss the coding issues which led him awry. Reading those posts and their code and comparing with above code will lead to correct diagnosis for above code.