ワルド・ウォルフォウィッツは、テスト実行「実行」は、あなたが「ストリーク」と呼んだものである可能候補、のようです。それは二値データを必要とするので、提案された中央値の時間のように、いくつかのしきい値に従って、各解決を「悪い」対「良い」としてラベル付けする必要があります。帰無仮説は、「良い」と「悪い」はランダムに交互に解決するというものです。あなたの直感に対応する一方的な対立仮説は、「良い」は長い縞の塊を一緒に解決するということであり、ランダムデータで予想されるよりも実行が少ないことを意味します。テスト統計は実行の数です。R:
> N <- 200 # number of solves
> DV <- round(runif(N, 15, 30), 1) # simulate some uniform data
> thresh <- median(DV) # threshold for binary classification
# do the binary classification
> DVfac <- cut(DV, breaks=c(-Inf, thresh, Inf), labels=c("good", "bad"))
> Nj <- table(DVfac) # number of "good" and "bad" solves
> n1 <- Nj[1] # number of "good" solves
> n2 <- Nj[2] # number of "bad" solves
> (runs <- rle(as.character(DVfac))) # analysis of runs
Run Length Encoding
lengths: int [1:92] 2 1 2 4 1 4 3 4 2 5 ...
values : chr [1:92] "bad" "good" "bad" "good" "bad" "good" "bad" ...
> (nRuns <- length(runs$lengths)) # test statistic: observed number of runs
[1] 92
# theoretical maximum of runs for given n1, n2
> (rMax <- ifelse(n1 == n2, N, 2*min(n1, n2) + 1))
199
観測数が少ない場合は、帰無仮説の下で実行回数ごとに正確な確率を計算できます。それ以外の場合、「実行数」の分布は標準正規分布で近似できます。
> (muR <- 1 + ((2*n1*n2) / N)) # expected value
100.99
> varR <- (2*n1*n2*(2*n1*n2 - N)) / (N^2 * (N-1)) # theoretical variance
> rZ <- (nRuns-muR) / sqrt(varR) # z-score
> (pVal <- pnorm(rZ, mean=0, sd=1)) # one-sided p-value
0.1012055
p値は、「良い」解が縞になる片側対立仮説に対するものです。