{"id":40883683,"date":"2021-11-27T12:21:03","date_gmt":"2021-11-27T06:51:03","guid":{"rendered":"https:\/\/stockviz.biz\/index.php\/?p=40883683"},"modified":"2021-11-27T12:21:09","modified_gmt":"2021-11-27T06:51:09","slug":"hamming-distance","status":"publish","type":"post","link":"https:\/\/stockviz.biz\/index.php\/2021\/11\/27\/hamming-distance\/","title":{"rendered":"Hamming Distance"},"content":{"rendered":"\n<p><a rel=\"noreferrer noopener\" href=\"https:\/\/stockviz.biz\/index.php\/2021\/11\/19\/direction-vs-magnitude\/\" target=\"_blank\">Previously<\/a>, we discussed how <em>removing<\/em> information from data can be useful. And our discussion on using  <a rel=\"noreferrer noopener\" href=\"https:\/\/stockviz.biz\/2020\/11\/17\/euclidean-distance-for-pattern-matching\/\" target=\"_blank\">Euclidean Distance for Pattern Matching<\/a> showed how you can use a rolling window to identify matching segments within a time-series. What if we mix the two ideas together?<\/p>\n\n\n\n<p>If you transform a time-series of returns to 0-1, then we can use Hamming distance, a measure the minimum number of substitutions required to change one string into the other (<a rel=\"noreferrer noopener\" href=\"https:\/\/en.wikipedia.org\/wiki\/Hamming_distance\" target=\"_blank\">Wikipedia<\/a>,) as a measure of similarity. <\/p>\n\n\n\n<p>For example, take the most recent 20-day VIX time-series and \u201cmatch\u201d it with a rolling window of historical 20-day VIX segments and sort it by its Hamming Distance.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/raw.githubusercontent.com\/stockviz\/blog\/master\/volatility\/vix-match\/closest-hamming.png\" alt=\"\" \/><figcaption>Here, on the second row, we see that by just flipping two bits, the 20-day sequence ending on 2020-05-18 matches with the 20-day sequence ending 2021-11-16.<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/raw.githubusercontent.com\/stockviz\/blog\/master\/volatility\/vix-match\/closest-match-hamming.png\" alt=\"\" \/><figcaption>If you are looking for a rough up\/down days match, then this is a blistering fast way to compute it.<\/figcaption><\/figure>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Previously, we discussed how removing information from data can be useful. And our discussion on using Euclidean Distance for Pattern Matching showed how you can use a rolling window to identify matching segments within a time-series. What if we mix the two ideas together? If you transform a time-series of returns to 0-1, then we &hellip; <\/p>\n","protected":false},"author":2,"featured_media":2106273,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3471],"tags":[2761,3221],"class_list":["post-40883683","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-investing-insight","tag-quant","tag-vix","entry"],"_links":{"self":[{"href":"https:\/\/stockviz.biz\/index.php\/wp-json\/wp\/v2\/posts\/40883683","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/stockviz.biz\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/stockviz.biz\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/stockviz.biz\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/stockviz.biz\/index.php\/wp-json\/wp\/v2\/comments?post=40883683"}],"version-history":[{"count":0,"href":"https:\/\/stockviz.biz\/index.php\/wp-json\/wp\/v2\/posts\/40883683\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/stockviz.biz\/index.php\/wp-json\/wp\/v2\/media\/2106273"}],"wp:attachment":[{"href":"https:\/\/stockviz.biz\/index.php\/wp-json\/wp\/v2\/media?parent=40883683"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/stockviz.biz\/index.php\/wp-json\/wp\/v2\/categories?post=40883683"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/stockviz.biz\/index.php\/wp-json\/wp\/v2\/tags?post=40883683"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}