SlideShare a Scribd company logo
1 of 3
Download to read offline
Use Python Code to add a block of code to count the number of dots within the red circle on the
graph that is produced.
import sys
import numpy as np # an alias for the namespace
import random
import matplotlib.pyplot as plt
#setting MC parameters
NumP=10000 # generate how many random point in side the square
n=100
#MC simulation block
pi_all=[]
#
for j in range(n):
cordx=[];cordy=[] # initialize the two empty coordinate lists
inside=0
for i in range(0,NumP): #generate random coordinates
cordx.append(random.random())
cordy.append(random.random())
r2 = cordx[i]*cordx[i]+cordy[i]*cordy[i]
if r2 <= 1:
inside=inside+1
# write control to count inside
pit= 4.0*inside/NumP
#End of sampling
pi_all.append(pit)
#print out result
print("pi: ","{:10.6f}".format(pit))
plt.hist(pi_all) # print hist of the sampling
# plot the random pair: cordx,cordy graphically for the last MC simulation
Symbol=10
LineW = 3
Lsp=100
f = plt.figure()
f.set_figwidth(8)
f.set_figheight(8)
plt.xlim(0,1)
plt.ylim(0,1)
plt.xlabel('X Cordinate')
plt.ylabel('Y Cordinate')
plt.scatter(cordx, cordy, s=Symbol,marker='o')
#plot circle
x = np.linspace(0,1,Lsp)
y = np.sqrt(1. - x*x)
plt.plot(x, y,'-r',color='red', linestyle='-', lw=LineW)
plt.show()
Use Python Code to add a block of code to count the number of dots wit.pdf

More Related Content

Similar to Use Python Code to add a block of code to count the number of dots wit.pdf

Class 8b: Numpy & Matplotlib
Class 8b: Numpy & MatplotlibClass 8b: Numpy & Matplotlib
Class 8b: Numpy & MatplotlibMarc Gouw
 
Write code in c++ Program to a topological sort on a graph Program pl.docx
Write code in c++ Program to a topological sort on a graph  Program pl.docxWrite code in c++ Program to a topological sort on a graph  Program pl.docx
Write code in c++ Program to a topological sort on a graph Program pl.docxnoreendchesterton753
 
Lab. Programs in C
Lab. Programs in CLab. Programs in C
Lab. Programs in CSaket Pathak
 
Modify this code to use multiple threads with the same data1.Modif.pdf
Modify this code to use multiple threads with the same data1.Modif.pdfModify this code to use multiple threads with the same data1.Modif.pdf
Modify this code to use multiple threads with the same data1.Modif.pdfmallik3000
 
Using an Array include ltstdiohgt include ltmpih.pdf
Using an Array include ltstdiohgt include ltmpih.pdfUsing an Array include ltstdiohgt include ltmpih.pdf
Using an Array include ltstdiohgt include ltmpih.pdfgiriraj65
 
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docxeugeniadean34240
 
PYTHON_PROGRAM(1-34).pdf
PYTHON_PROGRAM(1-34).pdfPYTHON_PROGRAM(1-34).pdf
PYTHON_PROGRAM(1-34).pdfNeeraj381934
 
PVS-Studio team experience: checking various open source projects, or mistake...
PVS-Studio team experience: checking various open source projects, or mistake...PVS-Studio team experience: checking various open source projects, or mistake...
PVS-Studio team experience: checking various open source projects, or mistake...Andrey Karpov
 
c plus plus programsSlide
c plus plus programsSlidec plus plus programsSlide
c plus plus programsSlideharman kaur
 
matplotlib-installatin-interactive-contour-example-guide
matplotlib-installatin-interactive-contour-example-guidematplotlib-installatin-interactive-contour-example-guide
matplotlib-installatin-interactive-contour-example-guideArulalan T
 
Computer_Practicals-file.doc.pdf
Computer_Practicals-file.doc.pdfComputer_Practicals-file.doc.pdf
Computer_Practicals-file.doc.pdfHIMANSUKUMAR12
 
A scrupulous code review - 15 bugs in C++ code
A scrupulous code review - 15 bugs in C++ codeA scrupulous code review - 15 bugs in C++ code
A scrupulous code review - 15 bugs in C++ codePVS-Studio LLC
 
C++ Code as Seen by a Hypercritical Reviewer
C++ Code as Seen by a Hypercritical ReviewerC++ Code as Seen by a Hypercritical Reviewer
C++ Code as Seen by a Hypercritical ReviewerAndrey Karpov
 
Write an MPI program to accomplish the following for a numbe.pdf
Write an MPI program to accomplish the following for a numbe.pdfWrite an MPI program to accomplish the following for a numbe.pdf
Write an MPI program to accomplish the following for a numbe.pdfaaryanentp
 

Similar to Use Python Code to add a block of code to count the number of dots wit.pdf (20)

Class 8b: Numpy & Matplotlib
Class 8b: Numpy & MatplotlibClass 8b: Numpy & Matplotlib
Class 8b: Numpy & Matplotlib
 
C++ file
C++ fileC++ file
C++ file
 
Write code in c++ Program to a topological sort on a graph Program pl.docx
Write code in c++ Program to a topological sort on a graph  Program pl.docxWrite code in c++ Program to a topological sort on a graph  Program pl.docx
Write code in c++ Program to a topological sort on a graph Program pl.docx
 
Lab. Programs in C
Lab. Programs in CLab. Programs in C
Lab. Programs in C
 
Modify this code to use multiple threads with the same data1.Modif.pdf
Modify this code to use multiple threads with the same data1.Modif.pdfModify this code to use multiple threads with the same data1.Modif.pdf
Modify this code to use multiple threads with the same data1.Modif.pdf
 
Using an Array include ltstdiohgt include ltmpih.pdf
Using an Array include ltstdiohgt include ltmpih.pdfUsing an Array include ltstdiohgt include ltmpih.pdf
Using an Array include ltstdiohgt include ltmpih.pdf
 
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
 
PYTHON_PROGRAM(1-34).pdf
PYTHON_PROGRAM(1-34).pdfPYTHON_PROGRAM(1-34).pdf
PYTHON_PROGRAM(1-34).pdf
 
PVS-Studio team experience: checking various open source projects, or mistake...
PVS-Studio team experience: checking various open source projects, or mistake...PVS-Studio team experience: checking various open source projects, or mistake...
PVS-Studio team experience: checking various open source projects, or mistake...
 
CPP Homework Help
CPP Homework HelpCPP Homework Help
CPP Homework Help
 
C lab-programs
C lab-programsC lab-programs
C lab-programs
 
c plus plus programsSlide
c plus plus programsSlidec plus plus programsSlide
c plus plus programsSlide
 
matplotlib-installatin-interactive-contour-example-guide
matplotlib-installatin-interactive-contour-example-guidematplotlib-installatin-interactive-contour-example-guide
matplotlib-installatin-interactive-contour-example-guide
 
Computer_Practicals-file.doc.pdf
Computer_Practicals-file.doc.pdfComputer_Practicals-file.doc.pdf
Computer_Practicals-file.doc.pdf
 
PRACTICAL FILE(COMP SC).pptx
PRACTICAL FILE(COMP SC).pptxPRACTICAL FILE(COMP SC).pptx
PRACTICAL FILE(COMP SC).pptx
 
A scrupulous code review - 15 bugs in C++ code
A scrupulous code review - 15 bugs in C++ codeA scrupulous code review - 15 bugs in C++ code
A scrupulous code review - 15 bugs in C++ code
 
SCIPY-SYMPY.pdf
SCIPY-SYMPY.pdfSCIPY-SYMPY.pdf
SCIPY-SYMPY.pdf
 
C++ Code as Seen by a Hypercritical Reviewer
C++ Code as Seen by a Hypercritical ReviewerC++ Code as Seen by a Hypercritical Reviewer
C++ Code as Seen by a Hypercritical Reviewer
 
Matlab project
Matlab projectMatlab project
Matlab project
 
Write an MPI program to accomplish the following for a numbe.pdf
Write an MPI program to accomplish the following for a numbe.pdfWrite an MPI program to accomplish the following for a numbe.pdf
Write an MPI program to accomplish the following for a numbe.pdf
 

More from aonetechcomputers

Use modular arithmetic operations to computer 1210mod7- Show and uploa.pdf
Use modular arithmetic operations to computer 1210mod7- Show and uploa.pdfUse modular arithmetic operations to computer 1210mod7- Show and uploa.pdf
Use modular arithmetic operations to computer 1210mod7- Show and uploa.pdfaonetechcomputers
 
Use K-maps to find MSOP and MPOS expressions for the following incompl.pdf
Use K-maps to find MSOP and MPOS expressions for the following incompl.pdfUse K-maps to find MSOP and MPOS expressions for the following incompl.pdf
Use K-maps to find MSOP and MPOS expressions for the following incompl.pdfaonetechcomputers
 
Use Java to implement bottom-up LR parser for the following grammar an.pdf
Use Java to implement bottom-up LR parser for the following grammar an.pdfUse Java to implement bottom-up LR parser for the following grammar an.pdf
Use Java to implement bottom-up LR parser for the following grammar an.pdfaonetechcomputers
 
Use C program and please do not use outside c99 mode Write a C program.pdf
Use C program and please do not use outside c99 mode Write a C program.pdfUse C program and please do not use outside c99 mode Write a C program.pdf
Use C program and please do not use outside c99 mode Write a C program.pdfaonetechcomputers
 
Use Chapter 17 Problem 42 on Page 852 To prepare the following- 1- Pre.pdf
Use Chapter 17 Problem 42 on Page 852 To prepare the following- 1- Pre.pdfUse Chapter 17 Problem 42 on Page 852 To prepare the following- 1- Pre.pdf
Use Chapter 17 Problem 42 on Page 852 To prepare the following- 1- Pre.pdfaonetechcomputers
 
Use any one of the previous homework assignments in which you created.pdf
Use any one of the previous homework assignments in which you created.pdfUse any one of the previous homework assignments in which you created.pdf
Use any one of the previous homework assignments in which you created.pdfaonetechcomputers
 
Use a for loop Write a Python function that does the following- 1- Its.pdf
Use a for loop Write a Python function that does the following- 1- Its.pdfUse a for loop Write a Python function that does the following- 1- Its.pdf
Use a for loop Write a Python function that does the following- 1- Its.pdfaonetechcomputers
 
Use an array and two index variables- Write functions or methods push (1).pdf
Use an array and two index variables-  Write functions or methods push (1).pdfUse an array and two index variables-  Write functions or methods push (1).pdf
Use an array and two index variables- Write functions or methods push (1).pdfaonetechcomputers
 
Use a combination of information learned from chapters 3-5 and what yo.pdf
Use a combination of information learned from chapters 3-5 and what yo.pdfUse a combination of information learned from chapters 3-5 and what yo.pdf
Use a combination of information learned from chapters 3-5 and what yo.pdfaonetechcomputers
 
us4 foday reports that about 25- of ah peison parofes become repeat of.pdf
us4 foday reports that about 25- of ah peison parofes become repeat of.pdfus4 foday reports that about 25- of ah peison parofes become repeat of.pdf
us4 foday reports that about 25- of ah peison parofes become repeat of.pdfaonetechcomputers
 
Use the following sentence to match the phrase on the left to the most.pdf
Use the following sentence to match the phrase on the left to the most.pdfUse the following sentence to match the phrase on the left to the most.pdf
Use the following sentence to match the phrase on the left to the most.pdfaonetechcomputers
 
Use the following image to answer the questions below- You have discov.pdf
Use the following image to answer the questions below- You have discov.pdfUse the following image to answer the questions below- You have discov.pdf
Use the following image to answer the questions below- You have discov.pdfaonetechcomputers
 
Use Exoels function options to find the following z values for the sta.pdf
Use Exoels function options to find the following z values for the sta.pdfUse Exoels function options to find the following z values for the sta.pdf
Use Exoels function options to find the following z values for the sta.pdfaonetechcomputers
 
Use the Dividend Growth Model to determine the expected annual growth.pdf
Use the Dividend Growth Model to determine the expected annual growth.pdfUse the Dividend Growth Model to determine the expected annual growth.pdf
Use the Dividend Growth Model to determine the expected annual growth.pdfaonetechcomputers
 
Use the definition of O to show that n2+5nO(n2) (1).pdf
Use the definition of O to show that n2+5nO(n2) (1).pdfUse the definition of O to show that n2+5nO(n2) (1).pdf
Use the definition of O to show that n2+5nO(n2) (1).pdfaonetechcomputers
 
Use the dataset below to calculate the Q1-.pdf
Use the dataset below to calculate the Q1-.pdfUse the dataset below to calculate the Q1-.pdf
Use the dataset below to calculate the Q1-.pdfaonetechcomputers
 
use C++ with QT The Memento pattern is used for capturing and externa.pdf
use C++  with QT The Memento pattern is used for capturing and externa.pdfuse C++  with QT The Memento pattern is used for capturing and externa.pdf
use C++ with QT The Memento pattern is used for capturing and externa.pdfaonetechcomputers
 
use any photo Latest Club Activities Robo-Vision- Giving your robot ey.pdf
use any photo Latest Club Activities Robo-Vision- Giving your robot ey.pdfuse any photo Latest Club Activities Robo-Vision- Giving your robot ey.pdf
use any photo Latest Club Activities Robo-Vision- Giving your robot ey.pdfaonetechcomputers
 
Use the COUNTIF function to construct frequency distributions for gend (1).pdf
Use the COUNTIF function to construct frequency distributions for gend (1).pdfUse the COUNTIF function to construct frequency distributions for gend (1).pdf
Use the COUNTIF function to construct frequency distributions for gend (1).pdfaonetechcomputers
 
Use the cladogram to answer the following questions- 11-) Is a bony sk.pdf
Use the cladogram to answer the following questions- 11-) Is a bony sk.pdfUse the cladogram to answer the following questions- 11-) Is a bony sk.pdf
Use the cladogram to answer the following questions- 11-) Is a bony sk.pdfaonetechcomputers
 

More from aonetechcomputers (20)

Use modular arithmetic operations to computer 1210mod7- Show and uploa.pdf
Use modular arithmetic operations to computer 1210mod7- Show and uploa.pdfUse modular arithmetic operations to computer 1210mod7- Show and uploa.pdf
Use modular arithmetic operations to computer 1210mod7- Show and uploa.pdf
 
Use K-maps to find MSOP and MPOS expressions for the following incompl.pdf
Use K-maps to find MSOP and MPOS expressions for the following incompl.pdfUse K-maps to find MSOP and MPOS expressions for the following incompl.pdf
Use K-maps to find MSOP and MPOS expressions for the following incompl.pdf
 
Use Java to implement bottom-up LR parser for the following grammar an.pdf
Use Java to implement bottom-up LR parser for the following grammar an.pdfUse Java to implement bottom-up LR parser for the following grammar an.pdf
Use Java to implement bottom-up LR parser for the following grammar an.pdf
 
Use C program and please do not use outside c99 mode Write a C program.pdf
Use C program and please do not use outside c99 mode Write a C program.pdfUse C program and please do not use outside c99 mode Write a C program.pdf
Use C program and please do not use outside c99 mode Write a C program.pdf
 
Use Chapter 17 Problem 42 on Page 852 To prepare the following- 1- Pre.pdf
Use Chapter 17 Problem 42 on Page 852 To prepare the following- 1- Pre.pdfUse Chapter 17 Problem 42 on Page 852 To prepare the following- 1- Pre.pdf
Use Chapter 17 Problem 42 on Page 852 To prepare the following- 1- Pre.pdf
 
Use any one of the previous homework assignments in which you created.pdf
Use any one of the previous homework assignments in which you created.pdfUse any one of the previous homework assignments in which you created.pdf
Use any one of the previous homework assignments in which you created.pdf
 
Use a for loop Write a Python function that does the following- 1- Its.pdf
Use a for loop Write a Python function that does the following- 1- Its.pdfUse a for loop Write a Python function that does the following- 1- Its.pdf
Use a for loop Write a Python function that does the following- 1- Its.pdf
 
Use an array and two index variables- Write functions or methods push (1).pdf
Use an array and two index variables-  Write functions or methods push (1).pdfUse an array and two index variables-  Write functions or methods push (1).pdf
Use an array and two index variables- Write functions or methods push (1).pdf
 
Use a combination of information learned from chapters 3-5 and what yo.pdf
Use a combination of information learned from chapters 3-5 and what yo.pdfUse a combination of information learned from chapters 3-5 and what yo.pdf
Use a combination of information learned from chapters 3-5 and what yo.pdf
 
us4 foday reports that about 25- of ah peison parofes become repeat of.pdf
us4 foday reports that about 25- of ah peison parofes become repeat of.pdfus4 foday reports that about 25- of ah peison parofes become repeat of.pdf
us4 foday reports that about 25- of ah peison parofes become repeat of.pdf
 
Use the following sentence to match the phrase on the left to the most.pdf
Use the following sentence to match the phrase on the left to the most.pdfUse the following sentence to match the phrase on the left to the most.pdf
Use the following sentence to match the phrase on the left to the most.pdf
 
Use the following image to answer the questions below- You have discov.pdf
Use the following image to answer the questions below- You have discov.pdfUse the following image to answer the questions below- You have discov.pdf
Use the following image to answer the questions below- You have discov.pdf
 
Use Exoels function options to find the following z values for the sta.pdf
Use Exoels function options to find the following z values for the sta.pdfUse Exoels function options to find the following z values for the sta.pdf
Use Exoels function options to find the following z values for the sta.pdf
 
Use the Dividend Growth Model to determine the expected annual growth.pdf
Use the Dividend Growth Model to determine the expected annual growth.pdfUse the Dividend Growth Model to determine the expected annual growth.pdf
Use the Dividend Growth Model to determine the expected annual growth.pdf
 
Use the definition of O to show that n2+5nO(n2) (1).pdf
Use the definition of O to show that n2+5nO(n2) (1).pdfUse the definition of O to show that n2+5nO(n2) (1).pdf
Use the definition of O to show that n2+5nO(n2) (1).pdf
 
Use the dataset below to calculate the Q1-.pdf
Use the dataset below to calculate the Q1-.pdfUse the dataset below to calculate the Q1-.pdf
Use the dataset below to calculate the Q1-.pdf
 
use C++ with QT The Memento pattern is used for capturing and externa.pdf
use C++  with QT The Memento pattern is used for capturing and externa.pdfuse C++  with QT The Memento pattern is used for capturing and externa.pdf
use C++ with QT The Memento pattern is used for capturing and externa.pdf
 
use any photo Latest Club Activities Robo-Vision- Giving your robot ey.pdf
use any photo Latest Club Activities Robo-Vision- Giving your robot ey.pdfuse any photo Latest Club Activities Robo-Vision- Giving your robot ey.pdf
use any photo Latest Club Activities Robo-Vision- Giving your robot ey.pdf
 
Use the COUNTIF function to construct frequency distributions for gend (1).pdf
Use the COUNTIF function to construct frequency distributions for gend (1).pdfUse the COUNTIF function to construct frequency distributions for gend (1).pdf
Use the COUNTIF function to construct frequency distributions for gend (1).pdf
 
Use the cladogram to answer the following questions- 11-) Is a bony sk.pdf
Use the cladogram to answer the following questions- 11-) Is a bony sk.pdfUse the cladogram to answer the following questions- 11-) Is a bony sk.pdf
Use the cladogram to answer the following questions- 11-) Is a bony sk.pdf
 

Recently uploaded

Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 

Recently uploaded (20)

Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 

Use Python Code to add a block of code to count the number of dots wit.pdf

  • 1. Use Python Code to add a block of code to count the number of dots within the red circle on the graph that is produced. import sys import numpy as np # an alias for the namespace import random import matplotlib.pyplot as plt #setting MC parameters NumP=10000 # generate how many random point in side the square n=100 #MC simulation block pi_all=[] # for j in range(n): cordx=[];cordy=[] # initialize the two empty coordinate lists inside=0 for i in range(0,NumP): #generate random coordinates cordx.append(random.random()) cordy.append(random.random()) r2 = cordx[i]*cordx[i]+cordy[i]*cordy[i] if r2 <= 1: inside=inside+1 # write control to count inside pit= 4.0*inside/NumP #End of sampling
  • 2. pi_all.append(pit) #print out result print("pi: ","{:10.6f}".format(pit)) plt.hist(pi_all) # print hist of the sampling # plot the random pair: cordx,cordy graphically for the last MC simulation Symbol=10 LineW = 3 Lsp=100 f = plt.figure() f.set_figwidth(8) f.set_figheight(8) plt.xlim(0,1) plt.ylim(0,1) plt.xlabel('X Cordinate') plt.ylabel('Y Cordinate') plt.scatter(cordx, cordy, s=Symbol,marker='o') #plot circle x = np.linspace(0,1,Lsp) y = np.sqrt(1. - x*x) plt.plot(x, y,'-r',color='red', linestyle='-', lw=LineW) plt.show()