package examples.extractor;

public class RankExtractorFeature_20240530 {

    public static Double calDiv(double a, double b){
        if (a == 0 || b == 0){
            return 0D;
        }
        return a / b;
    }
    public static Double calLog(double a){
        if (a <= 0){
            return 0D;
        }
        return Math.log(a + 1.0);
    }

    public static Double divSmooth1(double a, double b, double zscore) {
        // division with wilson smoothing
        // for confidence level 0.95, zscore should be 1.96
        if (a == 0 || b == 0) {
            return 0D;
        }
        double zscore2 = zscore * zscore;
        double p = a / b;
        double numerator = p + zscore2 / (2 * b) - zscore * Math.sqrt((p * (1 - p) + zscore2 / (4 * b)) / b);
        double denominator = 1 + zscore2 / b;
        return numerator / denominator;
    }

    public static double divSmooth2(double a, double b, double beta) {
        if (a == 0 || b == 0) {
            return 0d;
        }
        return a / (b + beta);
    }

    public static void main(String[] args) {
        System.out.println(Math.log(10));
        System.out.println(Math.log(100));
        System.out.println(Math.log(1000));
        System.out.println(Math.log(10000));
        System.out.println(Math.log(100000));

        System.out.println(Math.log10(10));
        System.out.println(Math.log10(100));
        System.out.println(Math.log10(1000));
        System.out.println(Math.log10(10000));
        System.out.println(Math.log10(100000));
    }
}


