@Override public double getLogFraction( KeyType key) { final double total = this.getTotal(); return (total != 0.0) ? (Math.log(this.get(key)) - Math.log(total)) : Double.NEGATIVE_INFINITY; }
@Override public double getLogFraction( KeyType key) { final double total = this.getTotal(); return (total != 0.0) ? (Math.log(this.get(key)) - Math.log(total)) : Double.NEGATIVE_INFINITY; }
@Override public double getLogFraction( KeyType key) { final double total = this.getTotal(); return (total != 0.0) ? (Math.log(this.get(key)) - Math.log(total)) : Double.NEGATIVE_INFINITY; }
@Override public KeyType sample( final Random random) { double w = random.nextDouble() * this.getTotal(); for (ScalarMap.Entry<KeyType> entry : this.entrySet()) { w -= entry.getValue(); if (w <= 0.0) { return entry.getKey(); } } return null; }
@Override public KeyType sample( final Random random) { double w = random.nextDouble() * this.getTotal(); for (ScalarMap.Entry<KeyType> entry : this.entrySet()) { w -= entry.getValue(); if (w <= 0.0) { return entry.getKey(); } } return null; }
@Override public KeyType sample( final Random random) { double w = random.nextDouble() * this.getTotal(); for (ScalarMap.Entry<KeyType> entry : this.entrySet()) { w -= entry.getValue(); if (w <= 0.0) { return entry.getKey(); } } return null; }
@Override public double getEntropy() { double entropy = 0.0; final double total = this.getTotal(); final double denom = (total != 0.0) ? total : 1.0; for (ScalarMap.Entry<KeyType> entry : this.entrySet()) { double p = entry.getValue() / denom; if (p != 0.0) { entropy -= p * MathUtil.log2(p); } } return entropy; }
@Override public double getEntropy() { double entropy = 0.0; final double total = this.getTotal(); final double denom = (total != 0.0) ? total : 1.0; for (ScalarMap.Entry<KeyType> entry : this.entrySet()) { double p = entry.getValue() / denom; if (p != 0.0) { entropy -= p * MathUtil.log2(p); } } return entropy; }
@Override public double getEntropy() { double entropy = 0.0; final double total = this.getTotal(); final double denom = (total != 0.0) ? total : 1.0; for (ScalarMap.Entry<KeyType> entry : this.entrySet()) { double p = entry.getValue() / denom; if (p != 0.0) { entropy -= p * MathUtil.log2(p); } } return entropy; }