Skip to content
Advertisement

Populating an even distribution of values across multiple axis?

Basic Example:

JavaScript

Axis Value Counts:

  • Where the axis all have an equal distribution of values
JavaScript
JavaScript

My attempt thus far:

JavaScript

Output:

JavaScript

So, I have the conditions I need on one axis, but not on the other.

How can I update my method/create a method to meet both conditions?

Advertisement

Answer

You can tile you input and use a custom roll to shift each row independently:

JavaScript

Output:

JavaScript

Alternative order:

JavaScript

Output:

JavaScript

Other alternative: use a custom strided_indexing_roll function.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement