Learn Python in Malayalam|Chapter 16|Probaility in Python| Coin toss problem
This is the 16th video on Learn python in Malayalam. This video clearly explains below topics,
use the below time link to skip to the specific topics
Topics covered in this video
Coin toss program - 00:23
calculating probability - 04:57
plotting absolute error plotting -- 07:53
Program used
Program for coin toss
import random
def coinToss(number): # defining the function for coin toss
recordList= [] # multiple assignment
for i in range(number): # do this 'number' amount of times
flip = random.randint(0, 1)
if (flip == 0): # here if condition is not neccessory
print("Heads")
recordList.append(1)
else:
print("Tails")
recordList.append(0)
print("Coin Toss result is :",str(recordList))
print("No of Heads :",recordList.count(1), "No of Tails :",recordList.count(0))
coinToss(10) # calling the function with 10 flips
program for calculating probability of coin toss
import random
import matplotlib.pyplot as plt
N = 50
ab_errList = []
recordList= []
for i in range(N): # do this 'number' amount of times
flip = random.randint(0, 1)
if (flip == 0):
print("Heads")
recordList.append(1)
else:
print("Tails")
recordList.append(0)
print("Coin Toss result is :",str(recordList))
print("Value of N is :",N)
print("No of Heads :",recordList.count(1), "No of Tails :",recordList.count(0))
Prob_H = (recordList.count(1))/N
Prob_T = (recordList.count(0))/N
print("Probability of Head is :",Prob_H)
print("Probability of Tail is :",Prob_T)
ab_err = 0.5 - Prob_H
print("Absolute error :",round(ab_err,3))
print("")
ab_errList.append(round(ab_err,3))
Program for plotting absolute error of coin toss
import random
import matplotlib.pyplot as plt
N = [10, 100, 500,1000,5000,10000,50000]
ab_errList = []
for j in N:
recordList= []
for i in range(j): # do this 'number' amount of times
flip = random.randint(0, 1)
if (flip == 0):
print("Heads")
recordList.append(1)
else:
print("Tails")
recordList.append(0)
print("Coin Toss result is :",str(recordList))
print("Value of N is :",j)
print("No of Heads :",recordList.count(1), "No of Tails :",recordList.count(0))
Prob_H = (recordList.count(1))/j
Prob_T = (recordList.count(0))/j
print("Probability of Head is :",Prob_H)
print("Probability of Tail is :",Prob_T)
ab_err = 0.5 - Prob_H
print("Absolute error :",round(ab_err,3))
print("")
ab_errList.append(round(ab_err,3))
print(ab_errList)
plt.plot(N,ab_errList)
plt.title("N vs Absolute error")
plt.xlabel("N")
plt.ylabel("Absolute error")
plt.show()
For more details check out here : https://iammanuprasad.blogspot.com/
Learn Python in Malayalam Playlist:
• Learn Python in Malayalam
Chapter 1 - • Learn Python in Malayalam | For Ultim...
Introduction to programming
Introduction to Python
Introduction to Google Co-lab
How to setup Google Co-lab
Chapter 2 - • Learn Python in Malayalam | Chapter 2...
Python Identifiers
Lines and Indentation
Multi-Line Statements
Chapter 3 - • Learn Python in Malayalam | Chapter 3...
Quotation in python
Comments in python
Assigning values to variable
Chapter 4 - • Learn Python in Malayalam | Chapter 4...
Data types
Numbers
Strings
Chapter 5 - • Learn Python in Malayalam | Chapter 5...
Data types
Lists
Tuple
Dictionary
Chapter 6 - • Learn Python in Malayalam | Chapter 6...
Decision making
Chapter 7 - • Learn Python in Malayalam|Chapter 7| ...
Loops in Python
Chapter 8 - • Learn Python in Malayalam | Chapter 8...
Functions in python
Chapter 9 - • Learn Python in Malayalam | Chapter 9...
Classes in python
Chapter 10 - • Learn Python in Malayalam |Chapter 10...
Matrix in python
Chapter 11 - • Learn Python in Malayalam|Chapter 11 ...
Plotting in Python
Chapter 12 - • Learn Python in Malayalam|Chapter 12|...
File handling in python
Chapter 13 - • Learn Python in Malayalam | Chapter 1...
System linear equation solution
Example with explanation
Program for solving linear equation
Chapter 14 - • Learn Python in Malayalam|Chapter 14 ...
differentiation in python
power rule
product rule
multi-variable function
first order differential equation response
Chapter 15 - • Learn Python in Malayalam | Chapter 1...
integration in python
integration with double integral
integration with triple integral
integration with infinity limit
If you like my video please subscribe my channel and share
Important links & key words
https://www.python.org/
Google COLAB
Music: https://www.bensound.com
Reff : https://www.tutorialspoint.com/python...
https://www.w3schools.com/
https://towardsdatascience.com/taking...
ECL 201 SCIENTIFIC COMPUTING LABORATORY
Experiment 9: Coin Toss and the Level Crossing Problem
Смотрите видео Learn Python in Malayalam|Chapter 16 | Probability in Python | Coin toss problem | absolute error онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь iammanuprasad 12 Декабрь 2020, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 594 раз и оно понравилось 19 людям.