Hello.
I'm looking up about rand() expression function using HScript.
Could you tell me the range of a value returned by rand()?
Which pattern below is the range?
0<n<1
0<=n < 1
0<n<=1
0<=n<=1
where n is returned by rand().
In addition,I couldn't make out the difference between rand() and oldrand().
a value returned by random expression
8959 19 1- CaramelPanda
- Member
- 21 posts
- Joined: Jan. 2013
- Offline
- circusmonkey
- Member
- 2624 posts
- Joined: Aug. 2006
- Offline
- dan.baciu
- Member
- 30 posts
- Joined: Sept. 2010
- Offline
- CaramelPanda
- Member
- 21 posts
- Joined: Jan. 2013
- Offline
Thanks for your replies
But just so import for me to know that the value may include zero or one.
Cuz I often use int( rand(seed)*number ) and then judge the value by if().
If the range were 0<n<1, int(n) will be just 1.
if 0<=n<=1 or 0<n<=1,it will be 0 or 1.
So whether including 0 or 1 is very important to use conditional rules.
The random function of Python is 0<=n<1.
But I couldn't look it up about HScript.
But just so import for me to know that the value may include zero or one.
Cuz I often use int( rand(seed)*number ) and then judge the value by if().
If the range were 0<n<1, int(n) will be just 1.
if 0<=n<=1 or 0<n<=1,it will be 0 or 1.
So whether including 0 or 1 is very important to use conditional rules.
The random function of Python is 0<=n<1.
But I couldn't look it up about HScript.
- circusmonkey
- Member
- 2624 posts
- Joined: Aug. 2006
- Offline
- dan.baciu
- Member
- 30 posts
- Joined: Sept. 2010
- Offline
- Sadjad Rabiee
- Member
- 1391 posts
- Joined: Dec. 2010
- Offline
- Sadjad Rabiee
- Member
- 1391 posts
- Joined: Dec. 2010
- Offline
- CaramelPanda
- Member
- 21 posts
- Joined: Jan. 2013
- Offline
- tamte
- Member
- 8583 posts
- Joined: July 2007
- Offline
Joker386it's difficult to know for sure by such example
Check the JK attr in the spread sheet from this file !
in the spreadsheet I can see one 0 and two 1's
but if I append blast sop with point group expression @jk!=0 I get 1 point and @jk!=1 keeps 0 points
so clearly some rounding happening in one or both cases
on top of that changing the expression to floor(rand($PT)) returns all 0's
and changing it to ceil(rand($PT)) returns all 1's except one meaning that one seed returned pure 0 value (seed 2250372)
this was on sample of 5 000 000 seeds
tried for range from -500 000 000 to +500 000 000 seeds, still no 1's
so till this point it looks to me as 0<=n<1
but I guess there may be some seed outside this range with value of 1
can someone provide specific seed where floor(rand(seed)) returns 1?
Tomas Slancik
FX Supervisor
Method Studios, NY
FX Supervisor
Method Studios, NY
- CaramelPanda
- Member
- 21 posts
- Joined: Jan. 2013
- Offline
Actually “1.0” values in the spread sheet seem not to be the same with real 1.0
some expressions such as if($jk==1.0,a,b) doesn't work well.
So, the hypothesis of 0<=n<1 is possible.
I guest the values in the spread sheet are automatically rounded.
Now I'm looking for the precision adjustment but couldn't find where.
some expressions such as if($jk==1.0,a,b) doesn't work well.
So, the hypothesis of 0<=n<1 is possible.
I guest the values in the spread sheet are automatically rounded.
Now I'm looking for the precision adjustment but couldn't find where.
- Sadjad Rabiee
- Member
- 1391 posts
- Joined: Dec. 2010
- Offline
- anon_user_37409885
- Member
- 4189 posts
- Joined: June 2012
- Offline
- CaramelPanda
- Member
- 21 posts
- Joined: Jan. 2013
- Offline
You bet the conversion between binary and decimal number might generate an error.
Longer the decimal point is,less accuracy the result is.
16bit float can express only short-wide range.
So I can almost believe the truth of the spread sheet as for 16bit.
But as for 32bit or 64bit,I can't believe it at all.
The spread sheet doesn't support 32/64bit?
Mathematically the conversion of “1.0” from decimal to binary should not generate an error.Cuz both types can express “1.0” accurately.
My head is crashed out :cry:
Longer the decimal point is,less accuracy the result is.
16bit float can express only short-wide range.
So I can almost believe the truth of the spread sheet as for 16bit.
But as for 32bit or 64bit,I can't believe it at all.
The spread sheet doesn't support 32/64bit?
Mathematically the conversion of “1.0” from decimal to binary should not generate an error.Cuz both types can express “1.0” accurately.
My head is crashed out :cry:
- anon_user_37409885
- Member
- 4189 posts
- Joined: June 2012
- Offline
Why do you say the spreadsheet is 16bit?
6 significants is 32bit. Houdini is generally single precision between nodes afaik
Edit:
It's all here in the documents
http://www.sidefx.com/docs/houdini13.0/nodes/sop/attribcast [sidefx.com]
6 significants is 32bit. Houdini is generally single precision between nodes afaik
Edit:
It's all here in the documents
http://www.sidefx.com/docs/houdini13.0/nodes/sop/attribcast [sidefx.com]
- CaramelPanda
- Member
- 21 posts
- Joined: Jan. 2013
- Offline
- edward
- Member
- 7726 posts
- Joined: July 2005
- Offline
CaramelPanda
It means I doubt the spread sheet values don't express complete exact precision.
Unfortunately, double precision floating isn't currently supported spreadsheet. Double precision floating point values will be casted to single precision and then displayed using a maximum of 6 significant decimal digits. For parameter fields, they are also displayed using a maximum of 6 significant decimal digits.
Feel free to log an issue using the Support menu above on this website for the spreadsheet to show double precision attribute values with greater significant digits. As I recall, there has been various discussions/debates on what the maximum significant decimal digits should be. On one side, you have the more scientifically minded group saying you should use the largest possible value, while the artistic camp feels that the extra digits just provides noise (much truer for the parameter fields than the spreadsheet). And then we have the two (somewhat orthogonal) camps either arguing that this should be user configurable vs the usability camp that you should not have too many choices.
- anon_user_37409885
- Member
- 4189 posts
- Joined: June 2012
- Offline
- CaramelPanda
- Member
- 21 posts
- Joined: Jan. 2013
- Offline
- Sadjad Rabiee
- Member
- 1391 posts
- Joined: Dec. 2010
- Offline
MartybNz
It's easy to check - set the jk attribute to 16bit and the rounding is much more apparent. I would not think the spreadsheet is rounding. It appears to be floating-point precision rounding. Test attricreate at 32 and 64 bit, the rounding is effected.
The if==1.0 statement works fine in the attached.
That's important Tip ! :idea:
-
- Quick Links