I’m randomly selecting nodes from a Binary Tree and I have to build a black-box test that proves all nodes have the nearly the same probability of being selected.
I’m adapting the Chi-Square test algorithm based on this article http://en.wikibooks.org/wiki/Algorithm_Implementation/Pseudorandom_Numbers/Chi-Square_Test
but I’m a bit confused about what ‘r’ should be.
Just as a side question, do you think this is an appropriate algorithm to prove randomness in a set of results?
Thank you,
Diogo
The answer is right there in the citation. Scroll down to the javadocs:
It sounds to me like
rought to be the number of nodes in the tree. Do you agree?I don’t understand this. Do you? It seems less a test of the tree data structure and more about the random algorithm you use to choose a node to be selected. What does this outcome prove?
Walk me through what you’re doing, please. Here’s what I’m imagining:
If there are
rnodes in your tree, each one should have 1/r probability of being selected. It’s a multi-dimensional, r-sided coin or die. Right?The tree could bring another element into the mix: the probabilities are changed if the chances of being selected depend on where you are in the tree and whether or not you’re allowed to backtrack. If that’s the case, the chances of being selected are different at each node. Starting at the root means you can get to all child nodes. Being on the first level and not being able to backtrack eliminates the root and all other first level nodes from consideration, and so on.
Which problem are you trying to solve?