# Python program for bernouli u = [] def test(p): printf() if u[0] <= p: return 1 else: return 0 def printf(): m = 16; a = 5.0; c = 3.0; z = 7.0; for num in range(1, 10): r = (a * z + c) % m; # print r; z = r; u.append(z / m) # print z/m; # print r,z/m ; p = input("Enter the value of p(s) : ") a = test(p) print "Random numbers are : " print u print "Result is : ",a
#Output-----------------
#Enter the value of p(s) : .50 #Random numbers are : #[0.375, 0.0625, 0.5, 0.6875, 0.625, 0.3125, 0.75, 0.9375, 0.875] #Result is : 1
No comments:
Post a Comment