Skip to content

Instantly share code, notes, and snippets.

@dahtah
dahtah / float.tif
Last active February 20, 2017 09:19
problem with float-valued TIFF in CImg
@dahtah
dahtah / README.md
Last active September 30, 2017 16:47
How to get a significant correlation value by moving just one point around.

Have you ever seen these scatterplots that report a significant correlation between X and Y, but it looks like it's just the one point to the upper-right driving the correlation? Thanks to this interactive tool, you too can do this at home. Click anywhere in the picture, and the red dot will move. The sliding bar displays the resulting correlation coefficient. The grey interval are non-significant values: place the red dot right to get a significant result.

Data are generated from two standard independent gaussian (N=15). Test values are from the asymptotic Fisher transformation test that's on Wikipedia (two-sided, alpha = 5%). Code: R and d3.js.

@dahtah
dahtah / README.md
Last active October 9, 2022 15:16
Example of interactive MDS visualisation

The position of the cities are chosen so that the distances between points approximate the road distances in the dataset ("eurodist" in the R package). The location of the points is computed by Multidimensional Scaling (cmdscale in R).

For example, the road distance between Athens and Barcelona is 3313 km. Because road distances for all possible pairs cannot be represented with complete accuracy on a 2D plane, the representation given by MDS can be misleading. In this interactive graph you can hover over a city to visualise the true road distances to its neighbours. If you hover over Gibraltar you'll see that the distances are quite accurate, whereas distances from Athens to most other cities are too large compared to actual road distances.

The idea for the example comes from the documentation for the cmdscale command. The added interactive mechanisms and D3 code are by Simon Barthelme, University of Geneva, Brain and Learning Lab.