December 4th, 2013, 02:56 PM
Spliting a value into x random values
I need to find a way to split up a value into multiple smaller values, adding up to said value.
Splitting up 100 to 6 different values could look something like this:
13, 25, 4, 42, 6 , 10
My problem is that i need random numbers. I thought about just doing some loop stuff but it always ends up destroying any result. Because i'd get stuff like 40, 20, 40, 0,0,0.
Loops are biased in this case. So i'd need some math solution for it. Or a workaround to fix this loop bias.
Or.. anything really. I have the feeling it's really easy and i just don't see it :/
December 4th, 2013, 03:18 PM
Is there a maximum value that you could get to split? A varying number of splits? Any technical restrictions like memory usage or execution time?
December 4th, 2013, 03:34 PM
Well yea there is a maximum. I'm not sure what yet though. It might be somewhere around 10000. But as i said, i'm not sure yet, that might change. Maybe it's just around 1000, can't tell yet.
If by "varying number of splits" you mean the amount of numbers i'd like to split the value on then yes. It'll be somewhere around a dozen. So it should work well for pretty much any number you throw at it.
Memory usage shouldn't be important, as long as you don't go totaly nuts and start to talk about a few hundred MB or something :P
Execution time is not really critical, but obviously it shouldn't take a whole second or something.