Unexpected Random distribution

Hi ,

I am trying to do a simple randomization with dist in sv , I am not getting the result as i have distributed .
My expected output : 10- one times , 11- Five times, 12 three times , 13-one times

class Packet;
  rand int a;
  constraint c { a dist { 10:=1, 11:=5,12:=3,13:=1}; }
endclass


module test();

Packet pkt;

initial 
begin
  pkt = new();

  repeat(10) 
  begin
    if(pkt.randomize()) $display("%d",pkt.a);
  end

end
endmodule

V C S   S i m u l a t i o n   R e p o r t 
         10
         12
         10
         13
         11
         10
         11
         11
         13
         12

Cadence output 
ncsim> run
         12
         11
         12
         11
         11
         10
         10
         11
         10
         11

Can you please make me understand ? Thanks in advance .

By
Siraj

Your sample size is too small. Try repeat(1000). I get this distribution with irun:

     93 a=         10
    479 a=         11
    315 a=         12
    113 a=         13

Roughly 5 times as many 11’s as 10’s, as expected.

And the output from Questa is

# run -all 
#          11
#          11
#          11
#          11
#          12
#          12
#          11
#          12
#          11
#          11

However if you run the loop 100 times, you will get
10- 8 times , 11- 53 times, 12 28 times , 13-11 times

A distribution specifies a statistical probability. You have to generate a significant number of random values to approach the distribution you specified.

If you need the exact distribution with only 10 values, then put them in an array and shuffle() the array ordering.