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
def get_probability(self, d, y, x, n, c): | |
""" | |
This gets the probability of drop / pickup for any given Datum, d | |
:param d: the datum | |
:param x: the x location of the datum / ant carrying datum | |
:param y: the y location of the datum / ant carrying datum | |
:param n: the size of the neighbourhood function | |
:param c: constant for convergence control | |
:return: the probability of | |
""" |
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
library(devtools) | |
devtools::install_github(repo="stuartgordonreid/emh") |
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
results <- emh::is_random(my.zoo.object) | |
emh::plot_results(results) | |
View(results) |
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 os | |
import math | |
import time | |
import numpy | |
import pandas | |
import random | |
import matplotlib | |
import numpy.random as nrand | |
import matplotlib.pylab as plt | |
from sklearn.preprocessing import normalize |
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
bettingStrategyProof <- function(t = (252 * 7), w = 5, sd = 0.02, sims = 30) { | |
# Store market and strategy returns. | |
markets <- NULL | |
strats <- NULL | |
for (i in 1:sims) { | |
# Generate an underlying signal. | |
signal <- sin(seq(1, t)) / 50 | |
signal <- signal - mean(signal) | |
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
testRobustness <- function(t = (252 * 7)) { | |
# Generate an underlying signal. | |
signal <- sin(seq(1, t)) / 50 | |
signal <- signal - mean(signal) | |
# For different noise levels | |
sds <- seq(0.0, 0.020, 0.0005) | |
cratios <- c() | |
for (s in sds) { | |
# Generate a noisy signal |
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
compressionTest <- function(code, years = 7, algo = "g") { | |
# The generic Quandl API key for TuringFinance. | |
Quandl.api_key("t6Rn1d5N1W6Qt4jJq_zC") | |
# Download the raw price data. | |
data <- Quandl(code, rows = -1, type = "xts") | |
# Extract the variable we are interested in. | |
ix.ac <- which(colnames(data) == "Adjusted Close") | |
if (length(ix.ac) == 0) |
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
def random_excursions(self, bin_data): | |
""" | |
Note that this description is taken from the NIST documentation [1] | |
[1] http://csrc.nist.gov/publications/nistpubs/800-22-rev1a/SP800-22rev1a.pdf | |
The focus of this test is the number of cycles having exactly K visits in a cumulative sum random walk. The | |
cumulative sum random walk is derived from partial sums after the (0,1) sequence is transferred to the | |
appropriate (-1, +1) sequence. A cycle of a random walk consists of a sequence of steps of unit length taken at | |
random that begin at and return to the origin. The purpose of this test is to determine if the number of visits | |
to a particular state within a cycle deviates from what one would expect for a random sequence. This test is |
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
def cumulative_sums(self, bin_data: str, method="forward"): | |
""" | |
Note that this description is taken from the NIST documentation [1] | |
[1] http://csrc.nist.gov/publications/nistpubs/800-22-rev1a/SP800-22rev1a.pdf | |
The focus of this test is the maximal excursion (from zero) of the random walk defined by the cumulative sum of | |
adjusted (-1, +1) digits in the sequence. The purpose of the test is to determine whether the cumulative sum of | |
the partial sequences occurring in the tested sequence is too large or too small relative to the expected | |
behavior of that cumulative sum for random sequences. This cumulative sum may be considered as a random walk. | |
For a random sequence, the excursions of the random walk should be near zero. For certain types of non-random |
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
def universal(self, bin_data: str): | |
""" | |
Note that this description is taken from the NIST documentation [1] | |
[1] http://csrc.nist.gov/publications/nistpubs/800-22-rev1a/SP800-22rev1a.pdf | |
The focus of this test is the number of bits between matching patterns (a measure that is related to the | |
length of a compressed sequence). The purpose of the test is to detect whether or not the sequence can be | |
significantly compressed without loss of information. A significantly compressible sequence is considered | |
to be non-random. **This test is always skipped because the requirements on the lengths of the binary | |
strings are too high i.e. there have not been enough trading days to meet the requirements. |
OlderNewer