convert javascript to python
Anonymous User
140
var totalprob = 0;
    for(var quad in stat) {
        var prob = Math.log(stat[quad] ? stat[quad]/totalsum : 0.01/totalsum)/Math.log(10);
        totalprob += stat[quad] > 1 ? prob : 0;
        stat[quad] = prob;
    }
    var totaltoppersprob = 0;
    for(var quad in toppers) {
        var prob = Math.log(toppers[quad]/totaltoppers)/Math.log(10);
        totaltoppersprob += prob;
    }
    stat.normalized = totaltoppersprob/totaltopperscount;
    return stat;

How to convert this code from javascript to python?

Comments (0)