I'm triying to test wheter Excel's random generator is really random, that's why I'm using Wald's test
By so doing this I have obtained a p-value of 0 thus I have not to accept null hypotesis i.e the sample is not random.
My question is:
1) Am I making some mistake either coding or interpreting?
Code:
'By Julio Jesús Luna moreno
'jlqmoreno@gmail.com
Option Base 1
Sub WALDTEST()
Dim x, r(), i, n, mu, sigma, plus(), minus(), k, h, f, mediana As Variant
Dim w As Double
n = 1000: k = 0: h = 0
Set f = Application.WorksheetFunction
ReDim r(n)
For i = 1 To n
Randomize
x = Rnd()
r(i) = IIf(x >= 0.5, 1, 0)
If r(i) = 1 Then
h = h + 1
ReDim Preserve plus(h)
plus(h) = r(i)
Else
k = k + 1
ReDim Preserve minus(k)
minus(k) = r(i)
End If
Debug.Print r(i)
Next i
Debug.Print f.Count(plus)
Debug.Print f.Count(minus)
mu = ((2 * f.Count(plus) + f.Count(minus)) / n) + 1
sigma = (mu - 1) * (mu - 2) / (n + 1)
w = f.Norm_Dist(n, mu, sigma, False)
Debug.Print w
End Sub
Thanks in advance!
Aucun commentaire:
Enregistrer un commentaire