-
-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Infinite action chains biased towards small sizes #515
Comments
Since all actions are added without weight, all get the same weight. Thus, end of chain has a probability of 1/4. The distribution you show seems pretty close to what I’d expect. My recommendation is to raise the weight of all actions but „end of chain“. |
Thanks @jlink, I was a bit blind there. I changed the code as follows:
I was expecting to see some normal distribution over the chain size. However, I was wrong. I did some research and this is actually a geometric distribution over chain size. This means, the probability of randomly selecting the end of the chain becomes less and less, the longer the chain becomes. In this case it would be: P(n)=(30/31)^(n-1) * (1/31). This is why the histogram looks as follows:
Is this the desired behavior? |
It's the only logical outcome from throwing the dice with the given probabilities. If you want longer chains, you might just use If you really want equally distributed variation, try something like this: @Provide
Arbitrary<ActionChain<MyStringStack>> actions() {
Arbitrary<Integer> length = Arbitraries.integers().between(1, 1000)
.withDistribution(RandomDistribution.uniform());
return length.flatMap(maxLength -> ActionChain.startWith(...)
.withAction(...)
.withMaxTransformations(maxLength));
} |
It is, but this was not the intent of my question. Given an empty stack, does it make sense to clear it 245 times?
I tend to disagree. I want to generate examples which are more likely to catch a bug. Consider this slightly changed example from the docs:
I was able to run the following property more than 10 times without problems. Even when I lowered, the condition to 10, I only caught it on the 3rd run.
I want to find a combination of actions which leads to an undesired state. If a combination of n actions is fine, then still a combination of n+1 actions can lead to an undesired state. As stated in the code, the actions are independent from each other. Though, potential combinations grow exponentially. Maybe the problem is how to create a proper representation of the sample space?
This looks better and did a better job in catching the 10 element size problem, but did not catch the 33 element size problem. Does |
Without a |
Testing Problem
Consider the following test:
Reports will look similar to this one:
infinite
action chains are biased towards small chains and never seem exceed sizes of the low twenties. This is smaller than the default sizes of 32.Suggested Solution
I would expect that the size is more evenly distributed and that there are chains having a lot of actions (> 100).
The text was updated successfully, but these errors were encountered: