eagle0504 commited on
Commit
16c998c
ยท
1 Parent(s): d1dfd01

app added

Browse files
Files changed (3) hide show
  1. app.py +21 -0
  2. pages/1_Introduction_to_Python.py +49 -0
  3. requirements.txt +1 -0
app.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+
4
+ st.set_page_config(
5
+ page_title="Hello",
6
+ page_icon="๐Ÿ‘‹",
7
+ )
8
+
9
+ st.write("# Welcome to AI Decoded! ๐Ÿ‘‹")
10
+
11
+ st.sidebar.success("Select a demo above.")
12
+
13
+ st.markdown(
14
+ """
15
+ Streamlit is an open-source app framework built specifically for
16
+ Machine Learning and Data Science projects.
17
+
18
+ **๐Ÿ‘ˆ Select a demo from the sidebar** to see some examples
19
+ of what Streamlit can do!
20
+ """
21
+ )
pages/1_Introduction_to_Python.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+
4
+ st.markdown(
5
+ """
6
+ # Estimating Pi Using Monte Carlo Simulation
7
+
8
+ ## Executive Summary
9
+
10
+ This notebook demonstrates the application of Monte Carlo methods to estimate the value of Pi. Through a sequence of randomized experiments, it visualizes how increasing the number of points sampled within a unit square (and assessing whether they fall inside a unit circle) converges to a mathematical estimation of Pi.
11
+
12
+ ## Situation/Motivation/Question
13
+
14
+ Estimating the value of Pi (ฯ€) is a classic problem in mathematics and computational science. The value of Pi is central to calculations in geometry, physics, engineering, and beyond. While Pi's decimal representation is infinite, computational methods can approximate its value to varying degrees of accuracy. One popular method for this approximation is the Monte Carlo simulation, which uses randomness to solve problems that might be deterministic in principle. This notebook explores how effectively the Monte Carlo method can estimate Pi and visualizes the convergence of this estimate as the number of trials increases.
15
+
16
+ ## High-Level Overview of the Code
17
+
18
+ The code performs the following operations:
19
+
20
+ 1. **Setup**: Initializes variables and ranges for the simulation. It prepares a range of sample sizes from 100 to 20,000, increasing in steps of 100.
21
+
22
+ 2. **Simulation Loop**:
23
+ - For each sample size, it generates two arrays of random coordinates representing points within a unit square (0,1)ร—(0,1).
24
+ - It then checks if each point lies within the unit circle centered at the origin.
25
+ - It calculates the ratio of points inside the circle to the total points, using this ratio to estimate Pi.
26
+ - Visualizations are generated for each sample size showing:
27
+ - A scatter plot of the points with different colors indicating inside or outside the circle.
28
+ - A line plot showing the convergence of the estimated value of Pi towards the actual value over the sequence of experiments.
29
+
30
+ 3. **Output**:
31
+ - Each plot is saved as an individual image.
32
+ - Finally, these images are compiled into an animated GIF that illustrates the change in the estimate with increasing sample size.
33
+
34
+ 4. **Cleanup**: Closes each plot to free memory, ensuring the notebook runs efficiently.
35
+
36
+ ## Future Outlook
37
+
38
+ The current approach could be extended in several ways:
39
+
40
+ - **Increasing Efficiency**: Implement parallel processing or use more efficient data structures to handle larger sample sizes or to speed up the simulation.
41
+ - **Interactive Visualizations**: Integrate interactive components, such as sliders to change parameters like the sample size in real-time, which would make the demonstration more engaging.
42
+ - **Statistical Analysis**: Extend the notebook to include statistical measures that analyze the variance and convergence rate of the estimates.
43
+ - **Educational Tool**: Develop this notebook into a more comprehensive educational tool that includes explanations of the Monte Carlo method, its mathematical basis, and its applications in other areas.
44
+ - **Advanced Techniques**: Incorporate more sophisticated Monte Carlo methods, such as importance sampling or Markov Chain Monte Carlo, to improve the accuracy of Pi estimations.
45
+
46
+ This notebook serves not only as a method to approximate Pi but also as a demonstration of how random sampling can address complex mathematical problems and provide insights into the behavior of numerical methods.
47
+
48
+ """
49
+ )
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ streamlit