Part 1 of my question was answered by Michael. What about the second part? Well, I just had a look at it. What I did is:
- extract the full series of hash codes, from block 1 to the latest (VERY LONG).
- extract the numbers contained in such hash codes (i.e. remove letters).
- analyse the "randomness" of this series of numbers with purposely designed tests.
The tests suggest that the randomness hypothesis cannot be rejected at the 5%. Interestingly, the distribution of numbers is very skewed. If anything, one might expect it to be somewhat resembling a uniform distribution (noticing that the contrary is not true, i.e. uniform distribution does not imply randomness). I'm still pounding on this, but a first look suggest that the series might be random.
The R code to reproduce the above analysis is below:
# Initialise stuff
remove(list = ls())
options(timeout = 1000000) # in case request times-out
library(jsonlite)
library(ggplot2)
library(randtests)
# Get maximum number of blocks
last_block <- fromJSON("https://api6.tzscan.io//v3/head")
N <- last_block$level
blocks <- seq(1,N,by = 1)
hashs <- vector(mode="character", length = N)
# Download all hash codes (timer and print included, for analysis) VERY LONG
start <- proc.time()
for (i in 1:N) {
url <- paste0("https://api6.tzscan.io//v3/block_hash_level/",i)
hashs[i] <- fromJSON(url)
print(i)
}
finish <- proc.time() - start
# Remove letters
n_hashs <- as.numeric(gsub("\\D+","", hashs, perl = TRUE))
df <- data.frame(value=n_hashs)
names(df)[names(df) == "df.value....." ] <- "value"
# Plot (definitively not a uniform distribution, for any level of zooming in)
ggplot(df, aes(x=value)) + geom_histogram()
# Randomness tests (indicating the number sequence is not random)
bartels.rank.test(df$value)
cox.stuart.test(df$value)
difference.sign.test(df$value)
rank.test(df$value)
runs.test(df$value)
turning.point.test(df$value)