This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import numpy as np | |
from numba import jit | |
def calc_hurst(series: pd.Series, n_wins: int = 300): | |
changes = series.diff().dropna().astype(np.float32).values | |
max_w = changes.shape[0] - 1 | |
win_sizes = np.linspace(np.log10(10), np.log10(max_w), num=n_wins) | |
win_sizes = np.unique(np.power(10, win_sizes).astype(np.int16)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
import time | |
from scipy.stats import kendalltau | |
def kendall(x, y): | |
n = x.shape[0] | |
def sub_pairs(x): | |
return x.expand(n,n).T.sub(x).sign_() | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local words = torch.load(opt.words) -- it's a tds.Hash | |
local word2vec = torch.FloatTensor(opt.vocabsz, opt.dim) | |
local buffsz = 2^13 -- == 8k | |
local f = io.input(opt.input) | |
local done = 0 | |
local unk | |
-- read huge word2vec file with 2,196,017 lines | |
while true do | |
local lines, leftover = f:read(buffsz, '*line') |