# -*- coding: utf-8 -*-
"""lab 6 offline 1

Automatically generated by Colaboratory.

Original file is located at
    https://colab.research.google.com/drive/1L3bhuyVyatepplsO3FGpacWZflBabhHV
"""

#libraries
import math
import matplotlib.pyplot as plt


def random_numbers(N):
  #initial values 
  #z_1 first random number generator

  z_1 = [12,7]
  first_random_numbers =[12/16, 7/16]

  #z_2 second ranmdom number generator
  z_2 = [3,5]
  second_random_numbers = [3/17, 5/17]

  # z_3 third random number generator
  z_3 =[2,7]
  third_random_numbers = [2/15, 7/15]

  # final random number 
  first_one =(first_random_numbers[0] + second_random_numbers[0] + third_random_numbers[0]) % 1 
  second_one =(first_random_numbers[1] + second_random_numbers[1] + third_random_numbers[1]) % 1 

  wichman_hill_random_numbers = [first_one, second_one]

  for i in range(2,N+3):
    #first random number calculation
    z_1.append((13 * z_1[i-1] + z_1[i-2] + 3) % 16)
    first_random_numbers.append(z_1[i] / 16 ) 
    
    # second random number calculation
    z_2.append( (12 * (z_2[i-1])**2 + 13* z_2[i-2]) % 17)
    second_random_numbers.append(z_2[i] /17) 

    # third random number calculation
    z_3.append(( ( z_3 [i-1] )** 3 + z_3[i-2]  ) % 15) 
    third_random_numbers.append(z_3[i] /15)

    #calculating the final random numbers
    wichman_hill_random_numbers.append( (first_random_numbers[i] + second_random_numbers[i] + third_random_numbers[i]) % 1 )
  #showing the graph
  
  #print("For Sample Point:",N)
  plt.figure(figsize=(8,5))
  plt.hist(wichman_hill_random_numbers,bins=20,rwidth=.75)
  plt.title("For sample point : {}".format(N))
  plt.show()
  print("")

#sample point
N=[100,1000,5000]
for i in N:
  random_numbers(i)
# -*- coding: utf-8 -*-
"""lab 6 offline 1

Automatically generated by Colaboratory.

Original file is located at
    https://colab.research.google.com/drive/1L3bhuyVyatepplsO3FGpacWZflBabhHV
"""

#libraries
import math
import matplotlib.pyplot as plt


def random_numbers(N):
  #initial values 
  #z_1 first random number generator

  z_1 = [12,7]
  first_random_numbers =[12/16, 7/16]

  #z_2 second ranmdom number generator
  z_2 = [3,5]
  second_random_numbers = [3/17, 5/17]

  # z_3 third random number generator
  z_3 =[2,7]
  third_random_numbers = [2/15, 7/15]

  # final random number 
  first_one =(first_random_numbers[0] + second_random_numbers[0] + third_random_numbers[0]) % 1 
  second_one =(first_random_numbers[1] + second_random_numbers[1] + third_random_numbers[1]) % 1 

  wichman_hill_random_numbers = [first_one, second_one]

  for i in range(2,N+3):
    #first random number calculation
    z_1.append((13 * z_1[i-1] + z_1[i-2] + 3) % 16)
    first_random_numbers.append(z_1[i] / 16 ) 
    
    # second random number calculation
    z_2.append( (12 * (z_2[i-1])**2 + 13* z_2[i-2]) % 17)
    second_random_numbers.append(z_2[i] /17) 

    # third random number calculation
    z_3.append(( ( z_3 [i-1] )** 3 + z_3[i-2]  ) % 15) 
    third_random_numbers.append(z_3[i] /15)

    #calculating the final random numbers
    wichman_hill_random_numbers.append( (first_random_numbers[i] + second_random_numbers[i] + third_random_numbers[i]) % 1 )
  #showing the graph
  
  #print("For Sample Point:",N)
  plt.figure(figsize=(8,5))
  plt.hist(wichman_hill_random_numbers,bins=20,rwidth=.75)
  plt.title("For sample point : {}".format(N))
  plt.show()
  print("")

#sample point
N=[100,1000,5000]
for i in N:
  random_numbers(i)
# -*- coding: utf-8 -*- lab 6 offline 1  Automatically generated by Colaboratory.  Original file is located at     https://colab.research.google.com/drive/1L3bhuyVyatepplsO3FGpacWZflBabhHV #libraries #initial values #z_1 first random number generator #z_2 second ranmdom number generator # z_3 third random number generator # final random number #first random number calculation # second random number calculation # third random number calculation #calculating the final random numbers #showing the graph #print("For Sample Point:",N) #sample point