• News
• About

• Industries

• Learning & Support

• Community

• Marketplace

Download # Why I have different results?

I have two BP’s which subdivide a line to pieces with random size.

This one return wrong result: Here I just separate everything to functions: What the reason? Why in the same calculation I got different results?

just one point that popup into my eye at first glance:

it’s me or you are using a random float in range ^^
I don’t understand how you excpect to get same result while using some randomness. (except if you ensure to force the seed and all the thing to kill the randomness)

sorry didn’t look further that.

Oh, it easy to explain I wanna subdivide a ‘line’ let say on few piece with a different size, here how is this algorithm works:

1. Take a number which I choosed for subdivision, 5 for example
2. Divide a line by this number (5)
3. Then when we get a result I choose randomly a number between 50% of this result and 150% of this result ( therefore if I got a 100 on step 2, I chosing random number between 50 and 150 )
4. Save random value to array.
5. After I got a random number, I subtract it from a ‘line’ value, save new value of the line and decrement a number of subdivisions by 1 ( will become 4,3,2,1 in this example )
6. Repeat 1-5 steps, until number of subdivisions will not be equal 1, then we just save value of the line to array
7. check that sum of values in array is equal to original value of line, which we had at the begin

In the end you will have an array with random values which in total will be equal your original value, used as a length of the line

Here is an example of the output:

As you can see ORIGINAL VALUE and ARRAY VAL TOTAL is equal P.S. - sometimes result could be like that: 2000.000122, 1999.999878; but I don’t think that it’s much important, if it is you can just restart an algorithm

ok I understand what your code’s doing. And what do you mean, by not guetting same result

I know from where it should comes, but not really good at explaining it.
BP works with float. I guess just round-off error with the decimal floating-point ( Decimal floating point - Wikipedia ). (and also fact that computer use binary - in base 2 round number aren’t the same that in base 10 )

As u can see I have two different implementation of this algorithm:

• but the first one, return wrong result, the returned value even not nearly equal to original value, it could be less or more up to 60% difference!! (in my example it 2000, but output could be 900 or 2800 absolutely random… )
• the second one works perfect as i want
What is bothering me, is that I do not understand why the first implementation of this algorithm return a wrong result… what the reason of this result??

Here my BP files: LineSubdevision.zip (65.4 KB)

P.S. - there is a two files: ‘LineSubdivision’ which return a wrong result and ‘LineSubdevision2’ which works fine

I wasn’t wrong when I pointed the rand function, but not for the reason I thought.

you have to pin out from your rand function, meaning it run a different random number for those two. Store the output in a var, so you use the same number in your array and to substract from length. I’ll try to do what u said))

Thank u much for your help, it’s works, I still a little confuse why is working by this way but i’ll get it by my own - thank u!!!

This is pretty much me most of the time… 