Skip to content

Commit

Permalink
Added a minimum distance to compute reasonable suspiciousness in the …
Browse files Browse the repository at this point in the history
…face of different norms.
  • Loading branch information
emeryberger committed Jul 27, 2019
1 parent 82b0b60 commit 8f7f5ca
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/components/colorize.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ var Colorize = /** @class */ (function () {
};
// Compute the normalized distance from merging two ranges.
Colorize.fix_metric = function (target_norm, target, merge_with_norm, merge_with) {
console.log("fix_metric: " + target_norm + ", " + JSON.stringify(target) + ", " + merge_with_norm + ", " + JSON.stringify(merge_with));
var _a = __read(target, 2), t1 = _a[0], t2 = _a[1];
var _b = __read(merge_with, 2), m1 = _b[0], m2 = _b[1];
var n_target = rectangleutils_1.RectangleUtils.area([[t1[0], t1[1], 0], [t2[0], t2[1], 0]]);
Expand All @@ -263,6 +264,10 @@ var Colorize = /** @class */ (function () {
var norm_min = Math.min(merge_with_norm, target_norm);
var norm_max = Math.max(merge_with_norm, target_norm);
var fix_distance = Math.abs(norm_max - norm_min) / this.Multiplier;
// Ensure that the minimum fix is at least one (we need this if we don't use the L1 norm).
if (fix_distance < 1.0) {
fix_distance = 1.0;
}
var entropy_drop = this.entropydiff(n_min, n_max); // negative
var ranking = (1.0 + entropy_drop) / (fix_distance * n_min); // ENTROPY WEIGHTED BY FIX DISTANCE
ranking = -ranking; // negating to sort in reverse order.
Expand Down
7 changes: 6 additions & 1 deletion src/components/colorize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ export class Colorize {
merge_with_norm: number,
merge_with: [excelintVector, excelintVector]): number
{
console.log("fix_metric: " + target_norm + ", " + JSON.stringify(target) + ", " + merge_with_norm + ", " + JSON.stringify(merge_with));
const [t1, t2] = target;
const [m1, m2] = merge_with;
const n_target = RectangleUtils.area([[t1[0], t1[1], 0], [t2[0], t2[1], 0]]);
Expand All @@ -219,7 +220,11 @@ export class Colorize {
const n_max = Math.max(n_target, n_merge_with);
const norm_min = Math.min(merge_with_norm, target_norm);
const norm_max = Math.max(merge_with_norm, target_norm);
const fix_distance = Math.abs(norm_max - norm_min) / this.Multiplier;
let fix_distance = Math.abs(norm_max - norm_min) / this.Multiplier;
// Ensure that the minimum fix is at least one (we need this if we don't use the L1 norm).
if (fix_distance < 1.0) {
fix_distance = 1.0;
}
const entropy_drop = this.entropydiff(n_min, n_max); // negative
let ranking = (1.0 + entropy_drop) / (fix_distance * n_min); // ENTROPY WEIGHTED BY FIX DISTANCE
ranking = -ranking; // negating to sort in reverse order.
Expand Down

0 comments on commit 8f7f5ca

Please sign in to comment.