# How can I control the odds/weighting of random reduce?

I’m trying to perform a random reduce on a subset of items. The idea is that the closer they are to a boundary edge, the higher probability that they have of being reduced.

Is there a way to “weight” the items for a random assignment of true/false?

You might want to consider a different approach. This one comes to mind:

1 Like

Thanks @Joseph_Oster thats a cool solution.

I found something similar on stack overflow and kind of frankensteined it. Its kinda close, but not really what I’m after. Its starting to look like I’ll need to a c# component to make it do what I want though.

Joe’s approach of a gradient is worth considering.
That said, I have used random number with a probability to “weight” the choice of an object removal, or selection of a type of object.
So, lets say we have a line, start and end. The probability of removal at the start is 0, and at the end is 100%. We will remove the item is above a certain threshold.
So, given position of the line, at x,
value = (xposition) *(a random number 0 to 1)
if value>threshold, remove it. or change geometry, or color it blue, or whatever
xposition in this example is a position from zero to 1. could be any position along a line of L length, where the probability of removal = xposition/L. if you want to invert it, then 1-(xposition/l)

This may well simply be calculating Joe’s gradient, but for me, old school, I wanted to see how the remapping was working. Either that or just trying to justify why i have my old college statistics book still in box somewhere.
Also, you can tweak the probability using graph mapper, log, exponent, square, square root, etc if you do not want a linear ‘falloff’

Many different algorithms can be implemented for this using standard components, I see no reason to give up on them and use C#. Are you familiar with Cull Pattern? Surely there must be a way with standard components and distance from the perimeter edge to generate a suitable cull pattern.

But since you didn’t post your geometry, you are on your own.

Hey @Joseph_Oster apologies for not including geometry on the question. Yeah, I did end up using a bit of cull pattern at the end to remove the boxes at the farthest edge.

Long story short, as a training exercise I’m doing that classic grasshopper problem of recreating Eisenman’s Holocaust memorial in Berlin (Peter Eisenman: Designing Berlin's Holocaust Memorial | ArchDaily).

One idea is that if the boxes are in a fixed grid, then control their density towards the edges of the boundary. That led to the question of implementing a weighted random boolean function.

Here is a gh file with a portion of the definition: