Hi folks,
I am trying to create a list of lists of random values between 0 and 1. I can easily create ONE list of random entries, but how do I get multiple, where still all values are completely random (without using Python please , I know there it probably works easily)?
So for this example, how do I get 5 lists of three random numbers between 0 and 1, where all numbers differ (most likely) from each other?
I tried to use the LoopWhile node, but didnât succeed (maybe I am too stupid, maybe the node is not made for complex operations like this?). Probably it doesnât work because my boolean continueWhile input doesnât become a function here, but how would I fix that?
Wire the âcountâ slider into a List.OfRepeatedItems node which has another integer input for the number of lists you want.
Typing from memory on a cell phone, but I often use this one liner design script statement when generating such random data sets: Math.RandomList(List.OfRepeatedItem(listSize,numberOfLists));.
Should work for you if you want to keep the values between 0 and 1. If you want different low and high values you can append * (highValue-lowValue) + lowValue or manage the low and high inputs on the other method (just watch the list levels).
That is actually a pretty slick way to approach it!
Instead of piling together the list with little chunks, create one big list instead, and chop it down! That works!
Thanks a lot Jacob! Your design script solution works.
I would still love to get my while loop going, as this would work for other use cases then, too. When trying what you suggested, it seems that the attribute of being a function does not travel across nodes. Is this expected or a bug?
For your function issue, you need to use Function Compose to string nodes together. Once a node has all inputs it cannot be a function, and functions only pass one level unless you use Function Compose as otherwise function passing would be both intolerably slow and unstable.
Be very careful as it is easy to start a loop with no exit here (save after each run, run after each edit). Check the extended node help on the while loop to be sure you have the right types of inputs.
You are VERY right with your stability judgement of this option.
Dynamo died several times on me.
Now I got it running without it dying, but I donât get the result I want:
What I am trying to achieve: start with an empty list, and then add as many elements (in this case â1â, later it should be random numbers) until you reach the wanted amount. What am I doing wrong here?
Again, while I donât need this at the moment, I think it would be super helpful to understand how to build such more complex loops (I am teaching Dynamo a lot currently, and avoiding Python reduces the complexity of my lessons). Compose.dyn (17.1 KB)
Thanks,
GG
Python and DesignScript are likely easier to teach here, as the use of loops with nodes are typically easier to manage in a custom node environment, and you have to cover functions first which is also hard to include.
That said I recommend using the sample in the extended node help as the base, editing to your needs as applicable.
You could just do the following without a âOfRepeatedItemsâ node. At the end i have added a shuffle node just in case you wanted to shuffle the values to show a different ending.
Thanks, Jacob, funny enough, the help explanation is nearly exactly what I was using as a simple example for using the While loop node in my training. I was hoping to be able to demonstrate it for a more complex task like this one, but if you donât recommend it, I will switch over to DesignScript or Python instead, as you suggested.
Thanks, Brandon, yes, that is what a chop solution would look like! I will probably go for another Random node instead of the shuffle, just to ensure complete randomness, but yes, this approach works.