Randomisation_dist

I am getting unexpected output for this randopmised distribution , -please help why this is like that

module random_dist;

class rd;
rand bit [31:0]a;
constraint c{ a dist{4:=5, 2:=5};};
endclass

rd obj;
initial begin 
obj = new;
repeat(10)begin 
obj.randomize();
$display(obj.a);
end
end
endmodule

and the output is

#          2
#          2
#          2
#          2
#          2
#          4
#          4
#          2
#          4
#          2
# **

In reply to rakesh reddy:

i am not getting 5 number of 4’s and 5 number of 2’s can any one tell me my mistake in this code

In reply to rakesh reddy:
Your distribution constraint says for each randomization, the odds of choosing a 4 or 2 are 50%/50%. This is the same as flipping a coin 10 times in a row and expecting to see the same side exactly 5 times. The odd of that happening are quite low (10 choose 5)/2**10 = ~25%).

In reply to dave_59:

Dave, then what is the use of dist operator for getting the randmisation distribution

In reply to rakesh reddy:
Your distribution can only bee seen with longer tests. As you increase the number of randomizations, the results will approach you distribution. However, the chances of the results giving you exactly your distribution decreases.