-: Alright, now the last of the brand new
Dynamic Array functions that we're gonna cover
is Randarray.
And what Randarray is designed to do is generate a one
or two dimensional array of random numbers.
It's very, very similar to your traditional
Rand or Rand between functions.
The difference, as the name suggests,
is that those legacy functions return a single random number
per formula whereas Randarray can produce multiple results.
So syntax wise, there's actually no required arguments here.
Just like Rand, if you left this function entirely blank,
it's gonna return one single random number.
It's gonna be between zero and one with a decimal,
but that's not much fun.
What we wanna do is practice actually customizing
these parameters to do some more interesting things.
We can tell the Randarray function to
return a certain number of random values
based on a specified number of rows.
Default would be one.
Same thing with columns.
If we want a two dimensional array,
again default would be one column wide,
and then you can specify a minimum value, a maximum value,
and whether or not you want to return random integers
or decimals.
So the default behavior for those parameters
would be a minimum of zero. a maximum of one,
and decimal values as opposed to integers.
If you do want integers, you'd specify a one or a true
for that final parameter of the formula.
So pretty straightforward.
Here's what it looks like.
In this case, we're using a Randarray function,
with a rows argument of 10, a columns argument of seven,
a minimum of zero, a maximum of 100,
and a true or a one parameter to specify that we only want
whole numbers or integers returned.
And as a result, get something that looks like this.
It's a two dimensional array, 10 rows by seven columns
of random whole numbers that all fall between zero and 100.
So little pro tip here, Randarray is one of those
functions that you would almost never use on its own,
unless you just want a fun little random number generator.
Instead, it's often nested within other
dynamic array functions.
One really common use case is to randomly sort lists
of data, and that's exactly what we're gonna talk about
in the next lesson, creating random top end lists
using this Randarray function.
So good stuff ahead.
Stay tuned for that demo.