IMPORTANT NOTICE: Please be advised that the Verification Academy Forums will be offline for scheduled maintenance on Sunday, March 23rd at 4:00 US/Pacific.
So in the above code, each element is randomized based on the distribution.i.e. each of them is individually constrained. Is my understanding correct? If so, is there a way to constrain the occurrence of a set of values to occur all across the array with our distribution. Is this possible or individually constraining each element does a implicit constrain on the the array as a whole?
The foreach construct gets unrolled in a constraint expression, so each element gets individually constrained. But a distribution constraint is only a weighting. What statistical difference do you expect from constraining the array as a whole versus each element?
BTW, the dist constraint you wrote is comparable to writing
arr[I] dist {[0:10]:=9,[20:50]:=74,[70:90]:=17};
make sure you understand the difference between ‘:=’ and ‘:/’.
The use of :/ was intentional as I want the whole range (wanted to assign weight per range and not per element) to have the weight and not each element having the weight.
About my original problem, I wanted to have some sort of dependency between all the elements. Say, with the above “dist”, I would want my whole array to follow the distribution by enforcing some sort of rule that the values of all the elements in the array, follow the weights provided in the “dist”.
For example: if we read out the array of size 100, we would want range (elements) [0:10] occur 20% (around 20 entries), [20:50] occur 60% (around 60 entries) and [70:90] occur 20% (around 20 entries). I am aware that for such a small sample size, exact % is not feasible. But this is the goal that I am after.
Please let me know if there is any issue with my understanding.
In reply to DK87:
I think you have the meaning of ‘:=’ and ‘:/’ reversed.
But in any case, I think the dist constraint does what you want. A simple experiment will confirm if you increases the array size, or increase the number of randomizations.