import random

# randint(a, b) # range from a to b & includes a and b as well
print(random.randint(1, 5))

# SEED
# random.seed(3)
print(f"Random no. with seed 3 - {random.randint(1, 5)}")  # will generate a random number

# if you want to use the same random number (or same sequence of random numbers) once again in your
# program use the same seed you used before
# random.seed(3)
print(f"Random no. with seed 3 - {random.randint(1, 5)}")  # same random number as before

'''
A random number is generated by some operation on previous value. If there is no previous 
value then the current time is taken as previous value automatically. We can provide this 
previous value by own using random.seed(x) where x could be any number or string etc. 
random.randint() is not actually perfect random number, it could be predicted via random.seed(x). 
Hence, generating a random number is not actually random, because it runs on algorithms. 
Algorithms always give the same output based on the same input. This means, it depends on the 
value of the seed. So, in order to make it more random, time is automatically assigned to seed(). 
'''

mylist = list(range(1, 20))
print(mylist)   # [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
# random.choices(sequence) return list by default k = 1
print(random.choices(mylist))   # [7]

# CHOICES WITH REPLACEMENT
# though duplication is not guaranteed
print(random.choices(population=mylist, k=10))  # [18, 6, 4, 16, 8, 3, 9, 14, 12, 2]

# SAMPLE WITHOUT REPLACEMENT
print(random.sample(population=mylist, k=10))  # [3, 15, 18, 14, 9, 5, 4, 2, 7, 19]

random.shuffle(mylist)  # it returns nothing but original sequence is affected
print(mylist)  # [8, 11, 6, 14, 19, 18, 4, 12, 16, 5, 17, 15, 3, 2, 9, 1, 13, 10, 7]
# random.shuffle() works only on mutable sequences ; ex. - random.shuffle() will not work on tuple
# To shuffle an immutable sequence and return a new shuffled list, use sample(x, k=len(x)) instead.

# UNIFORM & GAUSS DISTRIBUTION
print(random.uniform(1.5, 100))  # 93.091505177311
print(random.gauss(mu=0, sigma=1))  # -0.31585904714252705
