# divide in exact ratio using vex

## Recommended Posts

hi...

i want random value between 0 -3 in the ratio of 2:2:6...

i used "fit(rand(@ptnum),0,1,0,3)" and it gives me random no. between 0 to 3 but i also want to get them in exact ratio in a procedural way

Edited by vineet

##### Share on other sites

Do you need float values? Values 0-2 on 40% of points and 2-3 on 60% of points? I would use this, attached is the test file:

```float myrandom;
myrandom = rand(@ptnum)*10;  // float values 0-10
if (myrandom < 4){
myrandom = fit(myrandom,0,4,0,2);
} else {
myrandom = fit(myrandom,4,10,2,3);
}```

10.hiplc

##### Share on other sites

thanks for the reply ikoon your expression is cool i also used same kind of logic for my work but now  i want to make it more procedural so that we can change the no. of objects as well as the ratio at any point of time

i will share with you when i will be done with this thanks

##### Share on other sites

You can also append a ramp after a random VOP to control the ratio.

random_ramp_vop.hipnc

• 2

##### Share on other sites

thank you konstantin for your reply..........i tried that method earlier but that doesn't give me the exact control for the ratio

## Create an account

Register a new account