SlideShare a Scribd company logo
4
Most read
6
Most read
Experiment Name: Write a program to implement Linear Congruential Generators in
python.
Objective: A linear congruential generator (LCG) is an algorithm that yields a sequence of
pseudo-randomized numbers calculated with a discontinuous piecewise linear equation. This
program is to implement LCG.
Source Code:
m=16;
a=5.0;
c=3.0;
z=7.0;
for num in range (1,21):
r=(a*z+c)%m;
z=r;
#print z/m;
print r ;
Reference: https://en.wikipedia.org/wiki/Linear_congruential_generator
Experiment Name: Write a program to implement Bernouli distribution in python.
Objective: The Bernoulli distribution essentially models a single trial of flipping a weighted
coin. It is the probability distribution of a random variable taking on only two values,
1 ("success") and 0 ("failure") with complementary probabilities p and 1-p respectively. This
program is to implement Bernouli distribution in python.
Source Code:
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,21):
r=(a*z+c)%m;
#print r;
z=r;
u.append(z/m)
#print z/m;
#print r,z/m ;
p = input("")
a = test(p)
print u
print a
Reference: https://brilliant.org/wiki/bernoulli-distribution/
Experiment Name: Write a program to implement Binomal distribution in python.
Objective: A binomial distribution is the sum of independent and identically distributed
Bernoulli random variables. This program is to implement Binomal in python.
Source Code:
u = []
count = []
m = 16
a = 5
c = 3
z = 7
for num in range (m):
r = (a*z+c)%m
z = r
u.append(float(z)/m)
print u
def test(w):
count = 0
for i in w:
print u[0] ," ",i
if u[0]<=i:
count+=1;
return count
p = []
f = input("")
fori in range(f):
j = input("")
p.append( float(j))
l = len(p)
c = test(p)
print c," ",l
print float(c)/float(l)
Reference: http://onlinestatbook.com/2/probability/binomial.html
Experiment Name: Write a program to implement geometry distribution in python.
Objective: The geometric distribution is a special case of the negative binomial distribution. It
deals with the number of trials required for a single success. Thus, the geometric distribution is a
negative binomial distribution where the number of successes (r) is equal to 1. This program is to
implement geometry algorithm in python.
Source Code:
u = []
count = []
m = 16
a = 5
c = 3
z = 7
for num in range (m):
r = (a*z+c)%m
z = r
u.append(float(z)/m)
print u
def test(w):
count = 0
for i in w:
print u[0] ," ",i
if u[0]<=i:
count+=1
else:
break
return count
p = []
f = input("")
fori in range(f):
j = input("")
p.append( float(j))
l = len(p)
c = test(p)
print c," ",l
print float(c)/float(l)
Reference: stattrek.com/statistics/dictionary.aspx?definition=geometric_distribution
Experiment Name: Write a program to find GCD in python.
Objective: The greatest common divisor (G.C.D) of two numbers is the largest positive integer
that perfectly divides the two given numbers. This program is implementing to find GCD
number.
Source Code:
def gcd(a, b):
if b == 0:
return a
return gcd(b, a%b)
a = input("Enter first number: ")
b = input("Enter second number: ")
result = gcd(a,b)
print result
Reference: https://www.programiz.com/python-programming/examples/hcf
Experiment name: Write a program to find LCM in python.
Objective: The least common multiple (L.C.M.) of two numbers is the smallest positive
integer that is perfectly divisible by the two given numbers. This program is to implement LCM
in python.
Source Code:
def gcd(a, b):
if b == 0:
return a
return gcd(b, a%b)
a = input("Enter first number: ")
b = input("Enter second number: ")
result = gcd(a,b)
print a*b/result
Reference: https://www.programiz.com/python-programming/examples/lcm
Ad

Recommended

Optimization/Gradient Descent
Optimization/Gradient Descent
kandelin
 
(Machine Learning) Ensemble learning
(Machine Learning) Ensemble learning
Omkar Rane
 
Adaptive Machine Learning for Credit Card Fraud Detection
Adaptive Machine Learning for Credit Card Fraud Detection
Andrea Dal Pozzolo
 
Random variate generation
Random variate generation
De La Salle University-Manila
 
Gradient descent method
Gradient descent method
Prof. Neeta Awasthy
 
A Style-Based Generator Architecture for Generative Adversarial Networks
A Style-Based Generator Architecture for Generative Adversarial Networks
ivaderivader
 
2. Data Preprocessing.pdf
2. Data Preprocessing.pdf
Jyoti Yadav
 
Machine Learning: Bias and Variance Trade-off
Machine Learning: Bias and Variance Trade-off
International Institute of Information Technology (I²IT)
 
CVPR 2018 Paper Reading MobileNet V2
CVPR 2018 Paper Reading MobileNet V2
Khang Pham
 
Birch Algorithm With Solved Example
Birch Algorithm With Solved Example
kailash shaw
 
Chp. 2 simulation examples
Chp. 2 simulation examples
Pravesh Negi
 
Algorithms - "Chapter 2 getting started"
Algorithms - "Chapter 2 getting started"
Ra'Fat Al-Msie'deen
 
Bias and variance trade off
Bias and variance trade off
VARUN KUMAR
 
Logistic regression in Machine Learning
Logistic regression in Machine Learning
Kuppusamy P
 
Convolutional Neural Networks : Popular Architectures
Convolutional Neural Networks : Popular Architectures
ananth
 
Genetic programming
Genetic programming
Dr. C.V. Suresh Babu
 
2005: Natural Computing - Concepts and Applications
2005: Natural Computing - Concepts and Applications
Leandro de Castro
 
Section5 Rbf
Section5 Rbf
kylin
 
Optimization for Neural Network Training - Veronica Vilaplana - UPC Barcelona...
Optimization for Neural Network Training - Veronica Vilaplana - UPC Barcelona...
Universitat Politècnica de Catalunya
 
lecture4 raster details in computer graphics(Computer graphics tutorials)
lecture4 raster details in computer graphics(Computer graphics tutorials)
Daroko blog(www.professionalbloggertricks.com)
 
Video display devices
Video display devices
shalinikarunakaran1
 
Machine Learning With Logistic Regression
Machine Learning With Logistic Regression
Knoldus Inc.
 
UNIT 1 Machine Learning [KCS-055] (1).pptx
UNIT 1 Machine Learning [KCS-055] (1).pptx
RohanPathak30
 
Machine Learning-Linear regression
Machine Learning-Linear regression
kishanthkumaar
 
Implement principal component analysis (PCA) in python from scratch
Implement principal component analysis (PCA) in python from scratch
EshanAgarwal4
 
An Introduction to Neural Architecture Search
An Introduction to Neural Architecture Search
Bill Liu
 
Android Malware 2020 (CCCS-CIC-AndMal-2020)
Android Malware 2020 (CCCS-CIC-AndMal-2020)
Indraneel Dabhade
 
Visualizing Data Using t-SNE
Visualizing Data Using t-SNE
David Khosid
 
Python Programming - IX. On Randomness
Python Programming - IX. On Randomness
Ranel Padon
 
Basic python laboratoty_ PSPP Manual .docx
Basic python laboratoty_ PSPP Manual .docx
Kirubaburi R
 

More Related Content

What's hot (20)

CVPR 2018 Paper Reading MobileNet V2
CVPR 2018 Paper Reading MobileNet V2
Khang Pham
 
Birch Algorithm With Solved Example
Birch Algorithm With Solved Example
kailash shaw
 
Chp. 2 simulation examples
Chp. 2 simulation examples
Pravesh Negi
 
Algorithms - "Chapter 2 getting started"
Algorithms - "Chapter 2 getting started"
Ra'Fat Al-Msie'deen
 
Bias and variance trade off
Bias and variance trade off
VARUN KUMAR
 
Logistic regression in Machine Learning
Logistic regression in Machine Learning
Kuppusamy P
 
Convolutional Neural Networks : Popular Architectures
Convolutional Neural Networks : Popular Architectures
ananth
 
Genetic programming
Genetic programming
Dr. C.V. Suresh Babu
 
2005: Natural Computing - Concepts and Applications
2005: Natural Computing - Concepts and Applications
Leandro de Castro
 
Section5 Rbf
Section5 Rbf
kylin
 
Optimization for Neural Network Training - Veronica Vilaplana - UPC Barcelona...
Optimization for Neural Network Training - Veronica Vilaplana - UPC Barcelona...
Universitat Politècnica de Catalunya
 
lecture4 raster details in computer graphics(Computer graphics tutorials)
lecture4 raster details in computer graphics(Computer graphics tutorials)
Daroko blog(www.professionalbloggertricks.com)
 
Video display devices
Video display devices
shalinikarunakaran1
 
Machine Learning With Logistic Regression
Machine Learning With Logistic Regression
Knoldus Inc.
 
UNIT 1 Machine Learning [KCS-055] (1).pptx
UNIT 1 Machine Learning [KCS-055] (1).pptx
RohanPathak30
 
Machine Learning-Linear regression
Machine Learning-Linear regression
kishanthkumaar
 
Implement principal component analysis (PCA) in python from scratch
Implement principal component analysis (PCA) in python from scratch
EshanAgarwal4
 
An Introduction to Neural Architecture Search
An Introduction to Neural Architecture Search
Bill Liu
 
Android Malware 2020 (CCCS-CIC-AndMal-2020)
Android Malware 2020 (CCCS-CIC-AndMal-2020)
Indraneel Dabhade
 
Visualizing Data Using t-SNE
Visualizing Data Using t-SNE
David Khosid
 
CVPR 2018 Paper Reading MobileNet V2
CVPR 2018 Paper Reading MobileNet V2
Khang Pham
 
Birch Algorithm With Solved Example
Birch Algorithm With Solved Example
kailash shaw
 
Chp. 2 simulation examples
Chp. 2 simulation examples
Pravesh Negi
 
Algorithms - "Chapter 2 getting started"
Algorithms - "Chapter 2 getting started"
Ra'Fat Al-Msie'deen
 
Bias and variance trade off
Bias and variance trade off
VARUN KUMAR
 
Logistic regression in Machine Learning
Logistic regression in Machine Learning
Kuppusamy P
 
Convolutional Neural Networks : Popular Architectures
Convolutional Neural Networks : Popular Architectures
ananth
 
2005: Natural Computing - Concepts and Applications
2005: Natural Computing - Concepts and Applications
Leandro de Castro
 
Section5 Rbf
Section5 Rbf
kylin
 
Optimization for Neural Network Training - Veronica Vilaplana - UPC Barcelona...
Optimization for Neural Network Training - Veronica Vilaplana - UPC Barcelona...
Universitat Politècnica de Catalunya
 
Machine Learning With Logistic Regression
Machine Learning With Logistic Regression
Knoldus Inc.
 
UNIT 1 Machine Learning [KCS-055] (1).pptx
UNIT 1 Machine Learning [KCS-055] (1).pptx
RohanPathak30
 
Machine Learning-Linear regression
Machine Learning-Linear regression
kishanthkumaar
 
Implement principal component analysis (PCA) in python from scratch
Implement principal component analysis (PCA) in python from scratch
EshanAgarwal4
 
An Introduction to Neural Architecture Search
An Introduction to Neural Architecture Search
Bill Liu
 
Android Malware 2020 (CCCS-CIC-AndMal-2020)
Android Malware 2020 (CCCS-CIC-AndMal-2020)
Indraneel Dabhade
 
Visualizing Data Using t-SNE
Visualizing Data Using t-SNE
David Khosid
 

Similar to A lab report on modeling and simulation with python code (20)

Python Programming - IX. On Randomness
Python Programming - IX. On Randomness
Ranel Padon
 
Basic python laboratoty_ PSPP Manual .docx
Basic python laboratoty_ PSPP Manual .docx
Kirubaburi R
 
Random Number Generators 2018
Random Number Generators 2018
rinnocente
 
Python lab manual all the experiments are available
Python lab manual all the experiments are available
Nitesh Dubey
 
III MCS python lab (1).pdf
III MCS python lab (1).pdf
srxerox
 
Teknik Simulasi
Teknik Simulasi
Rezzy Caraka
 
PythonPF.pdf
PythonPF.pdf
Rishab Saini
 
Random number generation
Random number generation
vinay126me
 
Python Tidbits
Python Tidbits
Mitchell Vitez
 
ECE-PYTHON.docx
ECE-PYTHON.docx
Chaithanya89350
 
Lecture 5 – Computing with Numbers (Math Lib).pptx
Lecture 5 – Computing with Numbers (Math Lib).pptx
jovannyflex
 
Lecture 5 – Computing with Numbers (Math Lib).pptx
Lecture 5 – Computing with Numbers (Math Lib).pptx
jovannyflex
 
BUilt in Functions and Simple programs in R.pdf
BUilt in Functions and Simple programs in R.pdf
karthikaparthasarath
 
17 PYTHON MODULES-2.pdf
17 PYTHON MODULES-2.pdf
JeevithaG22
 
numdoc
numdoc
webuploader
 
AI_Lab_File()[1]sachin_final (1).pdf
AI_Lab_File()[1]sachin_final (1).pdf
pankajkaushik2216
 
Random thoughts on IoT
Random thoughts on IoT
Mark Carney
 
PRACTICAL FILE(COMP SC).pptx
PRACTICAL FILE(COMP SC).pptx
AbhinavGupta257043
 
thesis_final_draft
thesis_final_draft
Bill DeRose
 
Lecture 5 numbers and built in functions
Lecture 5 numbers and built in functions
alvin567
 
Python Programming - IX. On Randomness
Python Programming - IX. On Randomness
Ranel Padon
 
Basic python laboratoty_ PSPP Manual .docx
Basic python laboratoty_ PSPP Manual .docx
Kirubaburi R
 
Random Number Generators 2018
Random Number Generators 2018
rinnocente
 
Python lab manual all the experiments are available
Python lab manual all the experiments are available
Nitesh Dubey
 
III MCS python lab (1).pdf
III MCS python lab (1).pdf
srxerox
 
Random number generation
Random number generation
vinay126me
 
Lecture 5 – Computing with Numbers (Math Lib).pptx
Lecture 5 – Computing with Numbers (Math Lib).pptx
jovannyflex
 
Lecture 5 – Computing with Numbers (Math Lib).pptx
Lecture 5 – Computing with Numbers (Math Lib).pptx
jovannyflex
 
BUilt in Functions and Simple programs in R.pdf
BUilt in Functions and Simple programs in R.pdf
karthikaparthasarath
 
17 PYTHON MODULES-2.pdf
17 PYTHON MODULES-2.pdf
JeevithaG22
 
AI_Lab_File()[1]sachin_final (1).pdf
AI_Lab_File()[1]sachin_final (1).pdf
pankajkaushik2216
 
Random thoughts on IoT
Random thoughts on IoT
Mark Carney
 
thesis_final_draft
thesis_final_draft
Bill DeRose
 
Lecture 5 numbers and built in functions
Lecture 5 numbers and built in functions
alvin567
 
Ad

More from Alamgir Hossain (13)

How to write a project proposal for software engineering course
How to write a project proposal for software engineering course
Alamgir Hossain
 
Malware Detection Approaches using Data Mining Techniques.pptx
Malware Detection Approaches using Data Mining Techniques.pptx
Alamgir Hossain
 
5 nested if in c with proper example
5 nested if in c with proper example
Alamgir Hossain
 
4. decision making and some basic problem
4. decision making and some basic problem
Alamgir Hossain
 
3. user input and some basic problem
3. user input and some basic problem
Alamgir Hossain
 
2. introduction of a c program
2. introduction of a c program
Alamgir Hossain
 
1. importance of c
1. importance of c
Alamgir Hossain
 
Computer graphics lab report with code in cpp
Computer graphics lab report with code in cpp
Alamgir Hossain
 
Report on student-faculty document sharing android project
Report on student-faculty document sharing android project
Alamgir Hossain
 
Lab report on to plot efficiency of pure and slotted aloha in matlab a data c...
Lab report on to plot efficiency of pure and slotted aloha in matlab a data c...
Alamgir Hossain
 
Lab report for Prolog program in artificial intelligence.
Lab report for Prolog program in artificial intelligence.
Alamgir Hossain
 
Digital signal Processing all matlab code with Lab report
Digital signal Processing all matlab code with Lab report
Alamgir Hossain
 
Microsoft Teams
Microsoft Teams
Alamgir Hossain
 
How to write a project proposal for software engineering course
How to write a project proposal for software engineering course
Alamgir Hossain
 
Malware Detection Approaches using Data Mining Techniques.pptx
Malware Detection Approaches using Data Mining Techniques.pptx
Alamgir Hossain
 
5 nested if in c with proper example
5 nested if in c with proper example
Alamgir Hossain
 
4. decision making and some basic problem
4. decision making and some basic problem
Alamgir Hossain
 
3. user input and some basic problem
3. user input and some basic problem
Alamgir Hossain
 
2. introduction of a c program
2. introduction of a c program
Alamgir Hossain
 
Computer graphics lab report with code in cpp
Computer graphics lab report with code in cpp
Alamgir Hossain
 
Report on student-faculty document sharing android project
Report on student-faculty document sharing android project
Alamgir Hossain
 
Lab report on to plot efficiency of pure and slotted aloha in matlab a data c...
Lab report on to plot efficiency of pure and slotted aloha in matlab a data c...
Alamgir Hossain
 
Lab report for Prolog program in artificial intelligence.
Lab report for Prolog program in artificial intelligence.
Alamgir Hossain
 
Digital signal Processing all matlab code with Lab report
Digital signal Processing all matlab code with Lab report
Alamgir Hossain
 
Ad

Recently uploaded (20)

Rapid Prototyping for XR: Lecture 5 - Cross Platform Development
Rapid Prototyping for XR: Lecture 5 - Cross Platform Development
Mark Billinghurst
 
Cadastral Maps
Cadastral Maps
Google
 
Introduction to sensing and Week-1.pptx
Introduction to sensing and Week-1.pptx
KNaveenKumarECE
 
DESIGN OF REINFORCED CONCRETE ELEMENTS S
DESIGN OF REINFORCED CONCRETE ELEMENTS S
prabhusp8
 
Solar thermal – Flat plate and concentrating collectors .pptx
Solar thermal – Flat plate and concentrating collectors .pptx
jdaniabraham1
 
AI_Presentation (1). Artificial intelligence
AI_Presentation (1). Artificial intelligence
RoselynKaur8thD34
 
Rapid Prototyping for XR: Lecture 4 - High Level Prototyping.
Rapid Prototyping for XR: Lecture 4 - High Level Prototyping.
Mark Billinghurst
 
Rapid Prototyping for XR: Lecture 1 Introduction to Prototyping
Rapid Prototyping for XR: Lecture 1 Introduction to Prototyping
Mark Billinghurst
 
Machine Learning - Classification Algorithms
Machine Learning - Classification Algorithms
resming1
 
MATERIAL SCIENCE LECTURE NOTES FOR DIPLOMA STUDENTS
MATERIAL SCIENCE LECTURE NOTES FOR DIPLOMA STUDENTS
SAMEER VISHWAKARMA
 
Learning – Types of Machine Learning – Supervised Learning – Unsupervised UNI...
Learning – Types of Machine Learning – Supervised Learning – Unsupervised UNI...
23Q95A6706
 
How to Un-Obsolete Your Legacy Keypad Design
How to Un-Obsolete Your Legacy Keypad Design
Epec Engineered Technologies
 
20CE404-Soil Mechanics - Slide Share PPT
20CE404-Soil Mechanics - Slide Share PPT
saravananr808639
 
IPL_Logic_Flow.pdf Mainframe IPLMainframe IPL
IPL_Logic_Flow.pdf Mainframe IPLMainframe IPL
KhadijaKhadijaAouadi
 
Introduction to Python Programming Language
Introduction to Python Programming Language
merlinjohnsy
 
Generative AI & Scientific Research : Catalyst for Innovation, Ethics & Impact
Generative AI & Scientific Research : Catalyst for Innovation, Ethics & Impact
AlqualsaDIResearchGr
 
System design handwritten notes guidance
System design handwritten notes guidance
Shabista Imam
 
Rapid Prototyping for XR: Lecture 6 - AI for Prototyping and Research Directi...
Rapid Prototyping for XR: Lecture 6 - AI for Prototyping and Research Directi...
Mark Billinghurst
 
Complete University of Calculus :: 2nd edition
Complete University of Calculus :: 2nd edition
Shabista Imam
 
Abraham Silberschatz-Operating System Concepts (9th,2012.12).pdf
Abraham Silberschatz-Operating System Concepts (9th,2012.12).pdf
Shabista Imam
 
Rapid Prototyping for XR: Lecture 5 - Cross Platform Development
Rapid Prototyping for XR: Lecture 5 - Cross Platform Development
Mark Billinghurst
 
Cadastral Maps
Cadastral Maps
Google
 
Introduction to sensing and Week-1.pptx
Introduction to sensing and Week-1.pptx
KNaveenKumarECE
 
DESIGN OF REINFORCED CONCRETE ELEMENTS S
DESIGN OF REINFORCED CONCRETE ELEMENTS S
prabhusp8
 
Solar thermal – Flat plate and concentrating collectors .pptx
Solar thermal – Flat plate and concentrating collectors .pptx
jdaniabraham1
 
AI_Presentation (1). Artificial intelligence
AI_Presentation (1). Artificial intelligence
RoselynKaur8thD34
 
Rapid Prototyping for XR: Lecture 4 - High Level Prototyping.
Rapid Prototyping for XR: Lecture 4 - High Level Prototyping.
Mark Billinghurst
 
Rapid Prototyping for XR: Lecture 1 Introduction to Prototyping
Rapid Prototyping for XR: Lecture 1 Introduction to Prototyping
Mark Billinghurst
 
Machine Learning - Classification Algorithms
Machine Learning - Classification Algorithms
resming1
 
MATERIAL SCIENCE LECTURE NOTES FOR DIPLOMA STUDENTS
MATERIAL SCIENCE LECTURE NOTES FOR DIPLOMA STUDENTS
SAMEER VISHWAKARMA
 
Learning – Types of Machine Learning – Supervised Learning – Unsupervised UNI...
Learning – Types of Machine Learning – Supervised Learning – Unsupervised UNI...
23Q95A6706
 
20CE404-Soil Mechanics - Slide Share PPT
20CE404-Soil Mechanics - Slide Share PPT
saravananr808639
 
IPL_Logic_Flow.pdf Mainframe IPLMainframe IPL
IPL_Logic_Flow.pdf Mainframe IPLMainframe IPL
KhadijaKhadijaAouadi
 
Introduction to Python Programming Language
Introduction to Python Programming Language
merlinjohnsy
 
Generative AI & Scientific Research : Catalyst for Innovation, Ethics & Impact
Generative AI & Scientific Research : Catalyst for Innovation, Ethics & Impact
AlqualsaDIResearchGr
 
System design handwritten notes guidance
System design handwritten notes guidance
Shabista Imam
 
Rapid Prototyping for XR: Lecture 6 - AI for Prototyping and Research Directi...
Rapid Prototyping for XR: Lecture 6 - AI for Prototyping and Research Directi...
Mark Billinghurst
 
Complete University of Calculus :: 2nd edition
Complete University of Calculus :: 2nd edition
Shabista Imam
 
Abraham Silberschatz-Operating System Concepts (9th,2012.12).pdf
Abraham Silberschatz-Operating System Concepts (9th,2012.12).pdf
Shabista Imam
 

A lab report on modeling and simulation with python code

  • 1. Experiment Name: Write a program to implement Linear Congruential Generators in python. Objective: A linear congruential generator (LCG) is an algorithm that yields a sequence of pseudo-randomized numbers calculated with a discontinuous piecewise linear equation. This program is to implement LCG. Source Code: m=16; a=5.0; c=3.0; z=7.0; for num in range (1,21): r=(a*z+c)%m; z=r; #print z/m; print r ; Reference: https://en.wikipedia.org/wiki/Linear_congruential_generator
  • 2. Experiment Name: Write a program to implement Bernouli distribution in python. Objective: The Bernoulli distribution essentially models a single trial of flipping a weighted coin. It is the probability distribution of a random variable taking on only two values, 1 ("success") and 0 ("failure") with complementary probabilities p and 1-p respectively. This program is to implement Bernouli distribution in python. Source Code: 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,21): r=(a*z+c)%m; #print r; z=r; u.append(z/m)
  • 3. #print z/m; #print r,z/m ; p = input("") a = test(p) print u print a Reference: https://brilliant.org/wiki/bernoulli-distribution/
  • 4. Experiment Name: Write a program to implement Binomal distribution in python. Objective: A binomial distribution is the sum of independent and identically distributed Bernoulli random variables. This program is to implement Binomal in python. Source Code: u = [] count = [] m = 16 a = 5 c = 3 z = 7 for num in range (m): r = (a*z+c)%m z = r u.append(float(z)/m) print u def test(w): count = 0 for i in w: print u[0] ," ",i if u[0]<=i: count+=1; return count p = []
  • 5. f = input("") fori in range(f): j = input("") p.append( float(j)) l = len(p) c = test(p) print c," ",l print float(c)/float(l) Reference: http://onlinestatbook.com/2/probability/binomial.html
  • 6. Experiment Name: Write a program to implement geometry distribution in python. Objective: The geometric distribution is a special case of the negative binomial distribution. It deals with the number of trials required for a single success. Thus, the geometric distribution is a negative binomial distribution where the number of successes (r) is equal to 1. This program is to implement geometry algorithm in python. Source Code: u = [] count = [] m = 16 a = 5 c = 3 z = 7 for num in range (m): r = (a*z+c)%m z = r u.append(float(z)/m) print u def test(w): count = 0 for i in w: print u[0] ," ",i if u[0]<=i: count+=1
  • 7. else: break return count p = [] f = input("") fori in range(f): j = input("") p.append( float(j)) l = len(p) c = test(p) print c," ",l print float(c)/float(l) Reference: stattrek.com/statistics/dictionary.aspx?definition=geometric_distribution
  • 8. Experiment Name: Write a program to find GCD in python. Objective: The greatest common divisor (G.C.D) of two numbers is the largest positive integer that perfectly divides the two given numbers. This program is implementing to find GCD number. Source Code: def gcd(a, b): if b == 0: return a return gcd(b, a%b) a = input("Enter first number: ") b = input("Enter second number: ") result = gcd(a,b) print result Reference: https://www.programiz.com/python-programming/examples/hcf
  • 9. Experiment name: Write a program to find LCM in python. Objective: The least common multiple (L.C.M.) of two numbers is the smallest positive integer that is perfectly divisible by the two given numbers. This program is to implement LCM in python. Source Code: def gcd(a, b): if b == 0: return a return gcd(b, a%b) a = input("Enter first number: ") b = input("Enter second number: ") result = gcd(a,b) print a*b/result Reference: https://www.programiz.com/python-programming/examples/lcm