Jump to: Board index » General » Fusion

Getting a random number between X and Y Real numbers

Learn about 3D compositing, animation, broadcast design and VFX workflows.
  • Author
  • Message
Offline

joemart

  • Posts: 96
  • Joined: Wed Apr 14, 2021 3:16 pm
  • Real Name: Joseph Martire

Getting a random number between X and Y Real numbers

PostMon Dec 20, 2021 9:27 pm

I feel that this question involves more LUA than DR, but I will ask it anyway:

I'm trying to get a real number within specific parameters. Whenever I use the expression "random(0.0006, 0.0008)", I get an integer. How would I go and do a function that returns any real number from within given parameters if possible?
Offline

xunile

  • Posts: 3109
  • Joined: Mon Apr 23, 2018 5:21 am
  • Real Name: Eric Eisenmann

Re: Getting a random number between X and Y Real numbers

PostTue Dec 21, 2021 1:49 am

If you only want .0006 .0007 .0008 as your possible results, you could try the following code.

Code: Select all
math.random(6,8) / 1000
Attachments
2021-12-20.jpg
2021-12-20.jpg (236.8 KiB) Viewed 1725 times
2021-12-20 (1).jpg
2021-12-20 (1).jpg (237.82 KiB) Viewed 1725 times
Win 10 Home | Intel i7 - 10700f 64 GB 1 TB GB SSD 2 TB SSD
RTX-3060 12 GB | Resolve Studio 18.6.6| Fusion Studio 18.6.6

Win 10 Home | Intel Core I7-7700HQ 32 GB 1 TB NVME SSD 1 TB SATA SSD
GTX-1060-6GB | Resolve 17.4.6
Offline

joemart

  • Posts: 96
  • Joined: Wed Apr 14, 2021 3:16 pm
  • Real Name: Joseph Martire

Re: Getting a random number between X and Y Real numbers

PostTue Dec 21, 2021 1:58 am

xunile wrote:If you only want .0006 .0007 .0008 as your possible results, you could try the following code.

Code: Select all
math.random(6,8) / 1000


Well, any real number between .0006 and .0008, for example .00061, .00062, .000601, .000602, etc. and how I would control the decimal spaces? I'm not sure how you can do this in LUA.
Offline
User avatar

brunocbreis

  • Posts: 94
  • Joined: Fri Jun 21, 2019 8:54 pm
  • Location: São Paulo, Brazil
  • Real Name: Bruno Reis

Re: Getting a random number between X and Y Real numbers

PostTue Dec 21, 2021 12:41 pm

Code: Select all
math.random(6000,8000) / 1000000
worked for me! :D Add more zeros to both the numerator and the denominator for more precision
Mac Studio (2022)
M1 Max 64GB
DVR / Fusion Studio 18.6
Offline

joemart

  • Posts: 96
  • Joined: Wed Apr 14, 2021 3:16 pm
  • Real Name: Joseph Martire

Re: Getting a random number between X and Y Real numbers

PostTue Dec 21, 2021 3:38 pm

brunocbreis wrote:
Code: Select all
math.random(6000,8000) / 1000000
worked for me! :D Add more zeros to both the numerator and the denominator for more precision


Brilliant! That works perfectly! Thank you!

Return to Fusion

Who is online

Users browsing this forum: No registered users and 20 guests