Dec 29, 2020 07:20 AM
HI there - I am wanting to try to efficiently add various combos of multiple arrays to try to find a set that has non-zero elements.
This is an abbreviated version. I have a set of ~300 arrays x 30 elements in each array to try to find a complete set of sets.
let arr1 = [0, 1, 0, 1, 0, 1, 0, 0, 1, 0]
let arr2 = [1, 0, 0, 1, 1, 1, 1, 0, 0, 1]
let arr3 = [1, 1, 0, 1, 1, 1, 0, 0, 0, 0]
let arr4 = [0, 1, 0, 0, 1, 1, 0, 1, 0, 0]
Assume that instead of individual arrays, there is one matrix and we are adding the combination of columns in matrices to find a matching set.
Dec 29, 2020 10:14 AM
It’s nice to see that data science is drifting into Airtable conversations because it suggests there are actually lots of data worth sciencing about. :winking_face:
When faced with this type of challenge I tend to lean on JSON objects as a way to perform aggregations like this. With a given key, it’s easy to traverse the array collections instantiating a unique and then summing totals or averages for numeric data types. This is typically the world of ElasticSearch and Python (numpy) but objects occasionally provide a workable outcome.
What if… you aggregated the sets and computed the average sum of each array value while also building a unique JSON object for each set collection. When complete, you would need only discard any objects with an average of zero in any element, leaving you with all the sets that are non-zero.
Bottom line - this question is more likely to get some helpful suggestions when published in StackOverflow or presented to @JonathanBowen. :winking_face:
Dec 29, 2020 12:00 PM
I am updating to clarify that I am actually using a matrix and want to add all the combos of each column together.
Thanks for tagging someone who is likely to know and understand.
Dec 30, 2020 11:41 AM
@Rose_Haft1 - Can you explain some more about what you are trying to do or link to a resource which explains in more detail?