Commit f84c8737 authored by LANORE Vincent's avatar LANORE Vincent
Browse files

generate_pairs: added toggle for distance type.

parent 76a56a0b
......@@ -43,6 +43,8 @@ Options:
-b, --bins <spec> bin specification in the form of a list of intervals
[default: [0.01,0.4],[0.4,0.6],[0.6,2]]
-s, --bin-size <size> number of pairs per bin [default: 100]
-e, --euclid use euclidien distance (instead of Jensen-Shannon
distance) [default: False]
-p, --plot show plot of pair distributions, otherwise it will
be written to a png file [default: False]"""
......@@ -61,6 +63,8 @@ binspec = args["--bins"][0]
MESSAGE("Bin specification is " + param(binspec))
binsize = int(args["--bin-size"][0])
MESSAGE("Bin size is " + param(binsize))
disttype = "euclidian" if args["--euclid"] else "Jensen-Shannon"
MESSAGE("Distance to use is " + param(disttype))
showplot = args["--plot"]
MESSAGE("Showing distance histogram is set to " + param(showplot == 1))
......@@ -150,9 +154,13 @@ while min(map(lambda b: b.shape[0], pair_bins)) < binsize:
nb_it += 1
p1 = pick(profiles)
p2 = pick(profiles)
if disttype == "Jensen-Shannon":
dist = jensen_shannon_distance(p1, p2)
# dist = jensen_shannon_divergence(p1, p2)
# dist = euclidian_distance(p1, p2)
elif disttype == "euclidian":
dist = euclidian_distance(p1, p2)
else:
FAILURE("Unknown distance type " + data(disttype))
for i in range(nb_bins):
if in_bin(dist, i) and pair_bins[i].shape[0] < binsize:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment