random numbers

random numbers
You can create a random integer with the commands [br][list][*][b]RandomBetween[ 1, 10 ][br][/b]This command selects an integer between 1 and 10.[/*][*][b]RandomDiscrete[{1, 2, 3, 4, 5}, {1, 4, 4, 4, 1}][/b][br]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.[/*][/list]
shuffled lists
You can use shuffled lists to add or exclude numbers or to ensure that numbers aren't the same.[br][list][*][b]list1 = Shuffle[{-3, -2, -1, -0.5, 0.5, 1, 2, 3}][/b] 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.[/*][*][b]a = list1(1)[/b] defines a as the first number in the shuffled list.[/*][*][b]b = list1(2)[/b] ensures that a is not equal to b. [br]This definition makes it possible to define two random but unequal numbers whithin a given range and even exclude or add certain values..[/*][/list]
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
Close

Information: random numbers