SlideShare a Scribd company logo
import matplotlib.pyplot as plt
import numpy as np
from scipy.stats import norm,binom,poisson,uniform,expon
from math import sqrt,exp
from scipy.integrate import quad
def uni2(n,N,s):
x1,x2 = 0,0
for i in range(N):
if s[i]>= (n+sqrt(n))/2: #P(X >= n+sqrt(n))/2)
x1 += 1
x2 = x1/N
return x2
def uni(n,N,s):
x3,x4 = 0,0,
for i in range(N):
if np.abs(s[i]-u)>= sqrt(n)/2:
x3 += 1
x4=x3/N
return x4
def uni3(n,N,s,x):
x5,x6=0,0
for i in range(N):
if np.abs(s[i]-u)>= x*sqrt(n):
x5+=1
x6=x5/N
return x6
def chebyshev(u,sigma,n):
return sigma/((sqrt(n))/2)**2
chebylist=[]
def markov(u,n):
return u/((n+sqrt(n))/2)
markovlist=[]
def chernoff(v,n,t):
return v/exp(t*((n+sqrt(n))/2))
chernofflist = []
def hoeffding(x):
return 2*exp(-x**2)
def chebyshev2(p,x):
return p*(1-p)/x**2
###### X suit B(n,1/2)
N= 100
p=0.5
t=0.5
x= 1
xlist = np.arange(0.5,100,0.1)
binom1=[]
binom2=[]
binom3=[]
chernofflist = []
chebylist=[]
chebylist2=[]
markovlist=[]
hoeffdinglist=[]
for n in xlist:
u=n*p
s = np.random.binomial(n,p,N)
sigma = n*p*(1-p)
v = (exp(t)*p + (1-p))**n
binom1.append(uni(n,N,s))
binom2.append(uni2(n,N,s))
binom3.append(uni3(n,N,s,x))
chebylist.append(chebyshev(u,sigma,n))
markovlist.append(markov(u,n))
chernofflist.append(chernoff(v,n,t))
hoeffdinglist.append(hoeffding(x))
chebylist2.append(chebyshev2(p,x))
plt.plot(xlist,binom1,label='P(|X- 'r'$frac {n}{2}| geqslantfrac {sqrt{n}} {2})$')
plt.plot(xlist,chebylist,label = 'Chebyshev')
plt.xlabel('n')
plt.ylabel('Probabilité')
plt.legend()
plt.show()
###############Chebyshev = 1 inutile et on remarque numériquement que : P(|X-n/2|⩾√n/2)⩽1/2
########*Chernoff et markov loin d'être optimaux et on remarque numériquement que :
P(X⩾(n+√n)/2)⩽1/4
plt.plot(xlist,binom2,label='P(X'r'$ geqslant frac {n+sqrt{n}} {2})$')
plt.plot(xlist,chernofflist, label = 'Chernoff')
plt.plot(xlist,markovlist,label = 'Markov')
plt.xlabel('n')
plt.ylabel('Probabilité')
plt.ylim(ymax=1)
plt.legend()
plt.show()
##############
### P(|X- n/2|⩾x√n)⩽p(1−p)/x²: Chebyshev
###P(|X- n/2|⩾x√n)⩽2exp(−2x²): Hoeffding
plt.plot(xlist,binom3,label='P(|X- 'r'$frac {n}{2}| geqslant xsqrt{n})$' )
plt.plot(xlist,hoeffdinglist,label = 'Hoeffding')
plt.plot(xlist,chebylist2,label = 'Chebyshev')
plt.xlabel('n')
plt.ylabel('P(|X- 'r'$frac {n}{2}| geqslant xsqrt{n})$')
plt.legend()
plt.show()
####### Comparaison Chebyshev et Hoeffding en fonction de x
blist = np.arange(0.5,10,0.1)
chebylist3=[]
hoeffdinglist2=[]
for x in blist :
hoeffdinglist2.append(hoeffding(x))
chebylist3.append(chebyshev2(p,x))
plt.plot(blist,hoeffdinglist2,label = 'Hoeffding')
plt.plot(blist,chebylist3,label = 'Chebyshev')
plt.xlabel('x')
plt.legend()
plt.show()

More Related Content

What's hot

Noise detection from the signal matlab code, Signal Diagnosis
Noise detection from the signal matlab code, Signal Diagnosis Noise detection from the signal matlab code, Signal Diagnosis
Noise detection from the signal matlab code, Signal Diagnosis
Bharti Airtel Ltd.
 
Applications of maxima and minima
Applications of maxima and minimaApplications of maxima and minima
Applications of maxima and minimarouwejan
 
Lesson20 Tangent Planes Slides+Notes
Lesson20   Tangent Planes Slides+NotesLesson20   Tangent Planes Slides+Notes
Lesson20 Tangent Planes Slides+NotesMatthew Leingang
 
Tangent plane
Tangent planeTangent plane
Tangent plane
yash patel
 
Python.St.Petersburg Paradox sim
Python.St.Petersburg Paradox simPython.St.Petersburg Paradox sim
Python.St.Petersburg Paradox simTianqi Huang, CFA
 
Equation plane
Equation planeEquation plane
Equation plane
cmnell
 
DISTANCE FORMULA
DISTANCE FORMULADISTANCE FORMULA
DISTANCE FORMULA
SKY HAWKS' ACADEMY
 
Statistics for Economics Final Exam Cheat Sheet
Statistics for Economics Final Exam Cheat SheetStatistics for Economics Final Exam Cheat Sheet
Statistics for Economics Final Exam Cheat Sheet
Laurel Ayuyao
 
Infrome 7 matlab
Infrome 7 matlabInfrome 7 matlab
Infrome 7 matlab
Washo Ramos
 
The Moore-Spiegel Oscillator
The Moore-Spiegel OscillatorThe Moore-Spiegel Oscillator
The Moore-Spiegel Oscillator
Abhranil Das
 
Seg code
Seg codeSeg code
Seg code
wi7sonjoseph
 
Python Tidbits
Python TidbitsPython Tidbits
Python Tidbits
Mitchell Vitez
 
Statistics Powerpoint Standard Dev.
Statistics Powerpoint Standard Dev.Statistics Powerpoint Standard Dev.
Statistics Powerpoint Standard Dev.arm74
 
EJERCICIOS PROPUESTOS DE BOOLE
EJERCICIOS PROPUESTOS DE BOOLEEJERCICIOS PROPUESTOS DE BOOLE
EJERCICIOS PROPUESTOS DE BOOLE
Yosel97
 
MATHS SYMBOLS - PROPERTIES of EXPONENTS
MATHS SYMBOLS - PROPERTIES of EXPONENTSMATHS SYMBOLS - PROPERTIES of EXPONENTS
MATHS SYMBOLS - PROPERTIES of EXPONENTS
Ist. Superiore Marini-Gioia - Enzo Exposyto
 
Perforacion de pozos, grupo d3 b, tarea numero 1
Perforacion de pozos, grupo d3 b, tarea numero 1Perforacion de pozos, grupo d3 b, tarea numero 1
Perforacion de pozos, grupo d3 b, tarea numero 1Kt Silva
 

What's hot (20)

Noise detection from the signal matlab code, Signal Diagnosis
Noise detection from the signal matlab code, Signal Diagnosis Noise detection from the signal matlab code, Signal Diagnosis
Noise detection from the signal matlab code, Signal Diagnosis
 
Applications of maxima and minima
Applications of maxima and minimaApplications of maxima and minima
Applications of maxima and minima
 
Lec 3-mcgregor
Lec 3-mcgregorLec 3-mcgregor
Lec 3-mcgregor
 
Lesson20 Tangent Planes Slides+Notes
Lesson20   Tangent Planes Slides+NotesLesson20   Tangent Planes Slides+Notes
Lesson20 Tangent Planes Slides+Notes
 
Tangent plane
Tangent planeTangent plane
Tangent plane
 
Vcs9
Vcs9Vcs9
Vcs9
 
Python.St.Petersburg Paradox sim
Python.St.Petersburg Paradox simPython.St.Petersburg Paradox sim
Python.St.Petersburg Paradox sim
 
Equation plane
Equation planeEquation plane
Equation plane
 
DISTANCE FORMULA
DISTANCE FORMULADISTANCE FORMULA
DISTANCE FORMULA
 
Statistics for Economics Final Exam Cheat Sheet
Statistics for Economics Final Exam Cheat SheetStatistics for Economics Final Exam Cheat Sheet
Statistics for Economics Final Exam Cheat Sheet
 
Infrome 7 matlab
Infrome 7 matlabInfrome 7 matlab
Infrome 7 matlab
 
The Moore-Spiegel Oscillator
The Moore-Spiegel OscillatorThe Moore-Spiegel Oscillator
The Moore-Spiegel Oscillator
 
Quadratic formula 2
Quadratic formula 2Quadratic formula 2
Quadratic formula 2
 
ppt of Calculus
ppt of Calculusppt of Calculus
ppt of Calculus
 
Seg code
Seg codeSeg code
Seg code
 
Python Tidbits
Python TidbitsPython Tidbits
Python Tidbits
 
Statistics Powerpoint Standard Dev.
Statistics Powerpoint Standard Dev.Statistics Powerpoint Standard Dev.
Statistics Powerpoint Standard Dev.
 
EJERCICIOS PROPUESTOS DE BOOLE
EJERCICIOS PROPUESTOS DE BOOLEEJERCICIOS PROPUESTOS DE BOOLE
EJERCICIOS PROPUESTOS DE BOOLE
 
MATHS SYMBOLS - PROPERTIES of EXPONENTS
MATHS SYMBOLS - PROPERTIES of EXPONENTSMATHS SYMBOLS - PROPERTIES of EXPONENTS
MATHS SYMBOLS - PROPERTIES of EXPONENTS
 
Perforacion de pozos, grupo d3 b, tarea numero 1
Perforacion de pozos, grupo d3 b, tarea numero 1Perforacion de pozos, grupo d3 b, tarea numero 1
Perforacion de pozos, grupo d3 b, tarea numero 1
 

Similar to Codecomparaison

Algorithm Design and Analysis - Practical File
Algorithm Design and Analysis - Practical FileAlgorithm Design and Analysis - Practical File
Algorithm Design and Analysis - Practical File
KushagraChadha1
 
Cs580
Cs580Cs580
Open GL T0074 56 sm4
Open GL T0074 56 sm4Open GL T0074 56 sm4
Open GL T0074 56 sm4Roziq Bahtiar
 
Simple Neural Network Python Code
Simple Neural Network Python CodeSimple Neural Network Python Code
Simple Neural Network Python Code
Andres Mendez-Vazquez
 
SCIPY-SYMPY.pdf
SCIPY-SYMPY.pdfSCIPY-SYMPY.pdf
SCIPY-SYMPY.pdf
FreddyGuzman19
 
SPDE presentation 2012
SPDE presentation 2012SPDE presentation 2012
SPDE presentation 2012
Zheng Mengdi
 
curve fitting lecture slides February 24
curve fitting lecture slides February 24curve fitting lecture slides February 24
curve fitting lecture slides February 24
TaiwoD
 
PROBABILITY DISTRIBUTION
PROBABILITY DISTRIBUTIONPROBABILITY DISTRIBUTION
PROBABILITY DISTRIBUTION
shahzadebaujiti
 
When running the code below I am getting some errors (see image)- The.docx
When running the code below I am getting some errors (see image)- The.docxWhen running the code below I am getting some errors (see image)- The.docx
When running the code below I am getting some errors (see image)- The.docx
maximapikvu8
 
Numerical Method Assignment
Numerical Method AssignmentNumerical Method Assignment
Numerical Method Assignment
ashikul akash
 
Rasterisation of a circle by the bresenham algorithm
Rasterisation of a circle by the bresenham algorithmRasterisation of a circle by the bresenham algorithm
Rasterisation of a circle by the bresenham algorithmKALAIRANJANI21
 
Rasterisation of a circle by the bresenham algorithm
Rasterisation of a circle by the bresenham algorithmRasterisation of a circle by the bresenham algorithm
Rasterisation of a circle by the bresenham algorithmKALAIRANJANI21
 
Computer Aided Manufacturing Design
Computer Aided Manufacturing DesignComputer Aided Manufacturing Design
Computer Aided Manufacturing Design
V Tripathi
 
Tutorial on convolutional neural networks
Tutorial on convolutional neural networksTutorial on convolutional neural networks
Tutorial on convolutional neural networks
Hojin Yang
 
Practicle 1.docx
Practicle 1.docxPracticle 1.docx
Practicle 1.docx
GaneshPawar819187
 
Informe laboratorio n°1
Informe laboratorio n°1Informe laboratorio n°1
Informe laboratorio n°1
luisescobedo38
 
Statistical inference formulasheet
Statistical inference formulasheetStatistical inference formulasheet
Statistical inference formulasheetPimsat University
 
Finite elements : basis functions
Finite elements : basis functionsFinite elements : basis functions
Finite elements : basis functions
Tarun Gehlot
 
Computer Graphics Lab File C Programs
Computer Graphics Lab File C ProgramsComputer Graphics Lab File C Programs
Computer Graphics Lab File C Programs
Kandarp Tiwari
 

Similar to Codecomparaison (20)

Algorithm Design and Analysis - Practical File
Algorithm Design and Analysis - Practical FileAlgorithm Design and Analysis - Practical File
Algorithm Design and Analysis - Practical File
 
Cs580
Cs580Cs580
Cs580
 
Open GL T0074 56 sm4
Open GL T0074 56 sm4Open GL T0074 56 sm4
Open GL T0074 56 sm4
 
Simple Neural Network Python Code
Simple Neural Network Python CodeSimple Neural Network Python Code
Simple Neural Network Python Code
 
SCIPY-SYMPY.pdf
SCIPY-SYMPY.pdfSCIPY-SYMPY.pdf
SCIPY-SYMPY.pdf
 
SPDE presentation 2012
SPDE presentation 2012SPDE presentation 2012
SPDE presentation 2012
 
curve fitting lecture slides February 24
curve fitting lecture slides February 24curve fitting lecture slides February 24
curve fitting lecture slides February 24
 
PROBABILITY DISTRIBUTION
PROBABILITY DISTRIBUTIONPROBABILITY DISTRIBUTION
PROBABILITY DISTRIBUTION
 
When running the code below I am getting some errors (see image)- The.docx
When running the code below I am getting some errors (see image)- The.docxWhen running the code below I am getting some errors (see image)- The.docx
When running the code below I am getting some errors (see image)- The.docx
 
Numerical Method Assignment
Numerical Method AssignmentNumerical Method Assignment
Numerical Method Assignment
 
Rasterisation of a circle by the bresenham algorithm
Rasterisation of a circle by the bresenham algorithmRasterisation of a circle by the bresenham algorithm
Rasterisation of a circle by the bresenham algorithm
 
Rasterisation of a circle by the bresenham algorithm
Rasterisation of a circle by the bresenham algorithmRasterisation of a circle by the bresenham algorithm
Rasterisation of a circle by the bresenham algorithm
 
Computer Aided Manufacturing Design
Computer Aided Manufacturing DesignComputer Aided Manufacturing Design
Computer Aided Manufacturing Design
 
Tutorial on convolutional neural networks
Tutorial on convolutional neural networksTutorial on convolutional neural networks
Tutorial on convolutional neural networks
 
5.n nmodels i
5.n nmodels i5.n nmodels i
5.n nmodels i
 
Practicle 1.docx
Practicle 1.docxPracticle 1.docx
Practicle 1.docx
 
Informe laboratorio n°1
Informe laboratorio n°1Informe laboratorio n°1
Informe laboratorio n°1
 
Statistical inference formulasheet
Statistical inference formulasheetStatistical inference formulasheet
Statistical inference formulasheet
 
Finite elements : basis functions
Finite elements : basis functionsFinite elements : basis functions
Finite elements : basis functions
 
Computer Graphics Lab File C Programs
Computer Graphics Lab File C ProgramsComputer Graphics Lab File C Programs
Computer Graphics Lab File C Programs
 

Recently uploaded

This 7-second Brain Wave Ritual Attracts Money To You.!
This 7-second Brain Wave Ritual Attracts Money To You.!This 7-second Brain Wave Ritual Attracts Money To You.!
This 7-second Brain Wave Ritual Attracts Money To You.!
nirahealhty
 
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
3ipehhoa
 
History+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shopHistory+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shop
laozhuseo02
 
The+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptxThe+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptx
laozhuseo02
 
Bridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptx
Bridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptxBridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptx
Bridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptx
Brad Spiegel Macon GA
 
一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理
一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理
一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理
keoku
 
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
3ipehhoa
 
BASIC C++ lecture NOTE C++ lecture 3.pptx
BASIC C++ lecture NOTE C++ lecture 3.pptxBASIC C++ lecture NOTE C++ lecture 3.pptx
BASIC C++ lecture NOTE C++ lecture 3.pptx
natyesu
 
一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理
一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理
一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理
ufdana
 
Internet-Security-Safeguarding-Your-Digital-World (1).pptx
Internet-Security-Safeguarding-Your-Digital-World (1).pptxInternet-Security-Safeguarding-Your-Digital-World (1).pptx
Internet-Security-Safeguarding-Your-Digital-World (1).pptx
VivekSinghShekhawat2
 
一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理
一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理
一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理
eutxy
 
Latest trends in computer networking.pptx
Latest trends in computer networking.pptxLatest trends in computer networking.pptx
Latest trends in computer networking.pptx
JungkooksNonexistent
 
1.Wireless Communication System_Wireless communication is a broad term that i...
1.Wireless Communication System_Wireless communication is a broad term that i...1.Wireless Communication System_Wireless communication is a broad term that i...
1.Wireless Communication System_Wireless communication is a broad term that i...
JeyaPerumal1
 
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024
APNIC
 
Multi-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Multi-cluster Kubernetes Networking- Patterns, Projects and GuidelinesMulti-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Multi-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Sanjeev Rampal
 
How to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptxHow to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptx
Gal Baras
 
Comptia N+ Standard Networking lesson guide
Comptia N+ Standard Networking lesson guideComptia N+ Standard Networking lesson guide
Comptia N+ Standard Networking lesson guide
GTProductions1
 
test test test test testtest test testtest test testtest test testtest test ...
test test  test test testtest test testtest test testtest test testtest test ...test test  test test testtest test testtest test testtest test testtest test ...
test test test test testtest test testtest test testtest test testtest test ...
Arif0071
 
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
3ipehhoa
 
guildmasters guide to ravnica Dungeons & Dragons 5...
guildmasters guide to ravnica Dungeons & Dragons 5...guildmasters guide to ravnica Dungeons & Dragons 5...
guildmasters guide to ravnica Dungeons & Dragons 5...
Rogerio Filho
 

Recently uploaded (20)

This 7-second Brain Wave Ritual Attracts Money To You.!
This 7-second Brain Wave Ritual Attracts Money To You.!This 7-second Brain Wave Ritual Attracts Money To You.!
This 7-second Brain Wave Ritual Attracts Money To You.!
 
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
 
History+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shopHistory+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shop
 
The+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptxThe+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptx
 
Bridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptx
Bridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptxBridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptx
Bridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptx
 
一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理
一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理
一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理
 
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
 
BASIC C++ lecture NOTE C++ lecture 3.pptx
BASIC C++ lecture NOTE C++ lecture 3.pptxBASIC C++ lecture NOTE C++ lecture 3.pptx
BASIC C++ lecture NOTE C++ lecture 3.pptx
 
一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理
一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理
一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理
 
Internet-Security-Safeguarding-Your-Digital-World (1).pptx
Internet-Security-Safeguarding-Your-Digital-World (1).pptxInternet-Security-Safeguarding-Your-Digital-World (1).pptx
Internet-Security-Safeguarding-Your-Digital-World (1).pptx
 
一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理
一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理
一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理
 
Latest trends in computer networking.pptx
Latest trends in computer networking.pptxLatest trends in computer networking.pptx
Latest trends in computer networking.pptx
 
1.Wireless Communication System_Wireless communication is a broad term that i...
1.Wireless Communication System_Wireless communication is a broad term that i...1.Wireless Communication System_Wireless communication is a broad term that i...
1.Wireless Communication System_Wireless communication is a broad term that i...
 
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024
 
Multi-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Multi-cluster Kubernetes Networking- Patterns, Projects and GuidelinesMulti-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Multi-cluster Kubernetes Networking- Patterns, Projects and Guidelines
 
How to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptxHow to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptx
 
Comptia N+ Standard Networking lesson guide
Comptia N+ Standard Networking lesson guideComptia N+ Standard Networking lesson guide
Comptia N+ Standard Networking lesson guide
 
test test test test testtest test testtest test testtest test testtest test ...
test test  test test testtest test testtest test testtest test testtest test ...test test  test test testtest test testtest test testtest test testtest test ...
test test test test testtest test testtest test testtest test testtest test ...
 
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
 
guildmasters guide to ravnica Dungeons & Dragons 5...
guildmasters guide to ravnica Dungeons & Dragons 5...guildmasters guide to ravnica Dungeons & Dragons 5...
guildmasters guide to ravnica Dungeons & Dragons 5...
 

Codecomparaison

  • 1. import matplotlib.pyplot as plt import numpy as np from scipy.stats import norm,binom,poisson,uniform,expon from math import sqrt,exp from scipy.integrate import quad def uni2(n,N,s): x1,x2 = 0,0 for i in range(N): if s[i]>= (n+sqrt(n))/2: #P(X >= n+sqrt(n))/2) x1 += 1 x2 = x1/N return x2 def uni(n,N,s): x3,x4 = 0,0, for i in range(N): if np.abs(s[i]-u)>= sqrt(n)/2: x3 += 1 x4=x3/N return x4 def uni3(n,N,s,x): x5,x6=0,0 for i in range(N): if np.abs(s[i]-u)>= x*sqrt(n): x5+=1 x6=x5/N return x6 def chebyshev(u,sigma,n): return sigma/((sqrt(n))/2)**2 chebylist=[] def markov(u,n): return u/((n+sqrt(n))/2) markovlist=[] def chernoff(v,n,t): return v/exp(t*((n+sqrt(n))/2)) chernofflist = [] def hoeffding(x): return 2*exp(-x**2) def chebyshev2(p,x): return p*(1-p)/x**2
  • 2. ###### X suit B(n,1/2) N= 100 p=0.5 t=0.5 x= 1 xlist = np.arange(0.5,100,0.1) binom1=[] binom2=[] binom3=[] chernofflist = [] chebylist=[] chebylist2=[] markovlist=[] hoeffdinglist=[] for n in xlist: u=n*p s = np.random.binomial(n,p,N) sigma = n*p*(1-p) v = (exp(t)*p + (1-p))**n binom1.append(uni(n,N,s)) binom2.append(uni2(n,N,s)) binom3.append(uni3(n,N,s,x)) chebylist.append(chebyshev(u,sigma,n)) markovlist.append(markov(u,n)) chernofflist.append(chernoff(v,n,t)) hoeffdinglist.append(hoeffding(x)) chebylist2.append(chebyshev2(p,x)) plt.plot(xlist,binom1,label='P(|X- 'r'$frac {n}{2}| geqslantfrac {sqrt{n}} {2})$') plt.plot(xlist,chebylist,label = 'Chebyshev') plt.xlabel('n') plt.ylabel('Probabilité') plt.legend() plt.show() ###############Chebyshev = 1 inutile et on remarque numériquement que : P(|X-n/2|⩾√n/2)⩽1/2 ########*Chernoff et markov loin d'être optimaux et on remarque numériquement que : P(X⩾(n+√n)/2)⩽1/4 plt.plot(xlist,binom2,label='P(X'r'$ geqslant frac {n+sqrt{n}} {2})$') plt.plot(xlist,chernofflist, label = 'Chernoff') plt.plot(xlist,markovlist,label = 'Markov')
  • 3. plt.xlabel('n') plt.ylabel('Probabilité') plt.ylim(ymax=1) plt.legend() plt.show() ############## ### P(|X- n/2|⩾x√n)⩽p(1−p)/x²: Chebyshev ###P(|X- n/2|⩾x√n)⩽2exp(−2x²): Hoeffding plt.plot(xlist,binom3,label='P(|X- 'r'$frac {n}{2}| geqslant xsqrt{n})$' ) plt.plot(xlist,hoeffdinglist,label = 'Hoeffding') plt.plot(xlist,chebylist2,label = 'Chebyshev') plt.xlabel('n') plt.ylabel('P(|X- 'r'$frac {n}{2}| geqslant xsqrt{n})$') plt.legend() plt.show() ####### Comparaison Chebyshev et Hoeffding en fonction de x blist = np.arange(0.5,10,0.1) chebylist3=[] hoeffdinglist2=[] for x in blist : hoeffdinglist2.append(hoeffding(x)) chebylist3.append(chebyshev2(p,x)) plt.plot(blist,hoeffdinglist2,label = 'Hoeffding') plt.plot(blist,chebylist3,label = 'Chebyshev') plt.xlabel('x') plt.legend() plt.show()