# Randomize point selection pattern

## Recommended Posts

I am using modulus to add each 10th point to a group:

```@group_targetPoints = 1;

if (@ptnum%10){
i@group_targetPoints = 0;
}```

So I get evenly distributed points: 0, 10, 20, 30, ... etc. I wish to add or subtract a small number from each point number (like int(rand(@ptnum)*3)) to randomize distribution a bit.
Have no idea how to solve this in this case. Adding a small random number to a modulus argument ( 10+int(rand(@ptnum)*3) breaks even pattern dramatically.

VEX_groupSelectRandomize_001.hipnc

##### Share on other sites

@group_targetPoints = 1;
int delta = 2;
i@modulo = 10 + int(ceil(delta * fit01(rand(@ptnum + 354656), -1, 1)));
if(@ptnum%@modulo) {
i@group_targetPoints = 0;
}

I use delta to add or subtract the module 10. Here 10 +- a random between -2 to +2.

I think it's not the good way. This approach seems better:

@group_targetPoints = 0;
int delta = chi("delta");
i@modulo = int(ceil(delta * fit01(rand(@ptnum + 356156), -1, 1)));
if(@ptnum%30 == 0) {
setpointgroup(0,"targetPoints", @ptnum + @modulo, 1);
}

Here for each modulo of 30, i setup in group another point near the point number.

Edited by fsimerey
• 1

##### Share on other sites

here's mine.

var means -/+ var to your given number.

(ideally there should be a check to ensure the var doesn't exceed mod/2...otherwise, neighbours could encroach each other...but you might not care about this...)

```int pts[] = primpoints(0,0);

foreach(int i; pts)
{
if(i%chi("mod")==0) // even distribution
{
// now add a little offset
int range = chi("var")+1;
int vari = fit01(rand(i+ch("seed")),-range,range);
setpointgroup(0,"sel",i+vari,1);

}
}```

Edited by Noobini
• 1

##### Share on other sites

you can add a 'shift' if you like

```foreach(int i; pts)
{
if((i+chi("shift"))%chi("mod")==0) // even distribution
{
// now add a little offset
int range = chi("var")+1;
int vari = fit01(rand(i+ch("seed")),-range,range);
setpointgroup(0,"sel",i+vari,1);

}
}```

• 1

## Create an account

Register a new account