Google Classroom
GeoGebraGeoGebra Classroom

random numbers

random numbers

You can create a random integer with the commands
  • RandomBetween[ 1, 10 ] This command selects an integer between 1 and 10.
  • RandomDiscrete[{1, 2, 3, 4, 5}, {1, 4, 4, 4, 1}] This command uses two lists. The first one contains the possible numbers. The second list gives each umber a probability. In this example the probability to select one of the numbers 2, 3 and 4 is four times as much as the probality to select 1 or 5.

shuffled lists

You can use shuffled lists to add or exclude numbers or to ensure that numbers aren't the same.
  • list1 = Shuffle[{-3, -2, -1, -0.5, 0.5, 1, 2, 3}] creates a list of numbers between -3 and 3 from which 0 is excluded and to which -0.5 and 0.5 are added. The umbers are sorted in a random order.
  • a = list1(1) defines a as the first number in the shuffled list.
  • b = list1(2) ensures that a is not equal to b. This definition makes it possible to define two random but unequal numbers whithin a given range and even exclude or add certain values..

exercises

Try to use random numbers and/or shuffled lists to create numbers following the given conditions.

a random number between 1 and 10.

a random number between 1 and 5 with the probability of the even numbers twice as much as the probability of the odd numbers.

an even number between 1 and 10

an integer between -4 and 4 but not equal to 0 nor to 1

two unequal integers between 1 and 5

a decimal number between 1 and 10 with 1 decimal