Jump to content
Sign in to follow this  
ryz

Randomization a few used values with dist

Recommended Posts

Is there any good way of doing an distributed randomization with dist for a few values that I know will be used and a lot of other values that could be good to test.

I have a field that can take the value 0-511 where the values 63, 127, 255 and 511 will be used in the product but the other values should work. I therefore want to specify that the values 63, 127, 255 and 511 should be generated much more often then other values. What I have come up with is.

1)

top_seg_cfg_length dist {
    63:=4,
    127:=4,
    255:=4,
    511:=4,
    [0:62]    :/ 1,
    [64:126]  :/ 1,
    [128:254] :/ 1,
    [256:510] :/ 1
    };

which I think is ugly and a lot of unnecessary code. What I really would like to specify is

2)

top_seg_cfg_length dist {
    63:=4,
    127:=4,
    255:=4,
    511:=4,
    others    :/ 1,
    };

What will be the result if I would write

3)

top_seg_cfg_length dist {
    63:=4,
    127:=4,
    255:=4,
    511:=4,
    [0:511]   :/ 1,
    };

Share this post


Link to post
Share on other sites

3) should of course have been

top_seg_cfg_length dist {

63:=1,

127:=1,

255:=1,

511:=1,

[0:511] :/ 1,

};

to much copy and paste.

The problem with this is that other constrains can affect the distribution quite a lot. lets say we have the constrain

x dist {[0:3]:=1, [0:511]\=1} and then in some test case adds the constrains x < 5; That will boost the probability for [0:3] quite a lot. This would not be a problem with an others clause. In my case this is not a problem and I might never have any problem with it but it is something you have to keep in mind.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×