Hi Forum,
I am trying to calculate the probability of each possible output using solve before constraint
Solve before using 2 random variables solve x before y
rand bit x;
rand bit [1:0] y;
constraint a2 { (x == 0) -> (y==0);
solve x before y; }
Within solve x before y as x appears first, I calculate the probability starting with x
As x could be either 0 or 1 i.e probability of each would be (1/2)
When x is 1 , y could be 0/1/2/3.
Hence the probability of y == 0/1/2/3 would be (1/2) divided into 4 equal parts
| x | y | Probability |
|---|---|---|
| 0 | 0 | 1/2 |
| 0 | 1 | 0 |
| 0 | 2 | 0 |
| 0 | 3 | 0 |
| 1 | 0 | 1/8 |
| 1 | 1 | 1/8 |
| 1 | 2 | 1/8 |
| 1 | 3 | 1/8 |
On enhancing the solve before using 3 random variables solve x,y before z
rand bit x;
rand bit [1:0] y,z;
constraint a3 { (x == 0) -> { (y==0); (z==0); }
solve x,y before z; }
| x | y | z | Probability |
|---|---|---|---|
| 0 | 0 | 0 | ? |
| 0 | 0 | 1 | 0 |
| 0 | 0 | 2 | 0 |
| 0 | 0 | 3 | 0 |
| 0 | 1 | 0 | 0 |
| 0 | 1 | 1 | 0 |
| 0 | 1 | 2 | 0 |
| 0 | 1 | 3 | 0 |
| 0 | 2 | 0 | 0 |
| 0 | 2 | 1 | 0 |
| 0 | 2 | 2 | 0 |
| 0 | 2 | 3 | 0 |
| 0 | 3 | 0 | 0 |
| 0 | 3 | 1 | 0 |
| 0 | 3 | 2 | 0 |
| 0 | 3 | 3 | 0 |
| 1 | 0 | 0 | ? |
| 1 | 0 | 1 | ? |
| 1 | 0 | 2 | ? |
| 1 | 0 | 3 | ? |
| 1 | 1 | 0 | ? |
| 1 | 1 | 1 | ? |
| 1 | 1 | 2 | ? |
| 1 | 1 | 3 | ? |
| 1 | 2 | 0 | ? |
| 1 | 2 | 1 | ? |
| 1 | 2 | 2 | ? |
| 1 | 2 | 3 | ? |
| 1 | 3 | 0 | ? |
| 1 | 3 | 1 | ? |
| 1 | 3 | 2 | ? |
| 1 | 3 | 3 | ? |
How do I calculate the probability of each valid combination ?
My intuition is that out of the 5 valid combinations of {x,y} ,
the probability of each would be equal to (1/5).
Hence probability of 1st row ( x == 0 and y == 0 and z == 0 ) would be (1/5)
For the remaining 4 combinations of {x,y} there are 4 possible values of z.
Hence the probability of each of the last 16 rows would be (1/5) x (1/4) i.e (1/20)
(Q) Is my understanding correct ?