## A metric for comparing two heatmaps

Say I have two heatmaps: Each pixel of the heatmap represents a certain probability.

One heatmap is derived from empirical data, and the other heatmap is generated by an algorithm that is designed to simulate the natural process that underlies the empirical data.

I wish to tune the algorithm to make the generated heatmap match up as closely to the empirical heatmap as possible, but this is difficult without a proper metric to actually make a comparison. Thus, I wish to implement a metric that can return a value from 0 to 1 to make this comparison.

I am currently considering vector distance, mutual information, and KL-divergence. I am curious if anyone has experience or advice regarding this. --Thanks!

-
 the choice of metric depends on how you will use the approximation. If you want the simulated heatmap to be able to discriminate between high and low values in the empirical, then correlation between the empirical and simulated seems like the way to go. if you intend to use the value of the simulations, a square error metric might be more appropriate. – Steven Pav May 19 2010 at 2:23

If this is a high-stake computation, on which you're willing to spend some comp. effort, you could use a $h_{-1}$-Sobolev norm - in effect, compute Fourier coefficients of the difference of the heatmaps, and discount them by the wavenumber, before summing them up. I'm writing this from memory, so please check literature.

$$d( A, B )^2 = \sum_{k} \frac{ \mathcal{F}(A - B)^2_k }{ 1 + (2\pi \vert k \vert)^2 }$$

Where $A,B$ are the heatmaps, $\mathcal{F}(A - B)_k$ is the Fourier coefficient associated with the wavevector $k=(k_x, k_y)$, $\vert k \vert^2 = k_x^2 + k_y^2$.

This will have a "low-pass-filter" effect on the difference, so instead of just taking a plain $l_2$ norm, which assigns equal weight to variations on large scale (coarse details), the above norm ( $h_{-1}$-Sobolev norm) will discount variations in small-scale details and emphasize alignment of heat maps on the large scale level first. Due to the nature of your heatmaps, one computational, and the other being empirical, I believe you are bound to have small scale variations that you don't care about.

-
 Oh, I forgot to mention that the above distance doesn't go up to 1, but you can always achieve that by using $\tilde d(A,b) = \frac{d(A,B)}{1 + d(A,B)}$ instead. – Marko Budisic May 19 2010 at 23:28

Some ideas I got from my excursion into image processing, which might be a good place to research.

First, compare the histograms of each row and column, this will give you a better idea of how far off you are especially if you're concerned about gradient changes, multiply by 256 and you've got a greyscale image.

Secondly, if you're interested in particularly "interesting" segments, you might hit it with a Sobel transform (convolving with a certain matrix) to do edge detection and compare each segment.

You might also work with genetic algorithms and change the fitness functions so that you find the correct way to change to get "closer" to the empirical data.

-
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 1, "mathjax_display_tex": 1, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.5661975145339966, "perplexity": 456.90605608166317}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2013-20/segments/1368701063060/warc/CC-MAIN-20130516104423-00055-ip-10-60-113-184.ec2.internal.warc.gz"}