Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| import pandas as pd | |
| import numpy as np | |
| import matplotlib.pyplot as plt | |
| import random | |
| st.markdown(""" | |
| <style> | |
| /* Set a soft background color */ | |
| body { | |
| background-color: #eef2f7; | |
| } | |
| /* Style for main title */ | |
| h1 { | |
| color: #00FFFF; | |
| font-family: 'Roboto', sans-serif; | |
| font-weight: 700; | |
| text-align: center; | |
| margin-bottom: 25px; | |
| } | |
| /* Style for headers */ | |
| h2 { | |
| color: #FFFACD; | |
| font-family: 'Roboto', sans-serif; | |
| font-weight: 600; | |
| margin-top: 30px; | |
| } | |
| /* Style for subheaders */ | |
| h3 { | |
| color: #ba95b0; | |
| font-family: 'Roboto', sans-serif; | |
| font-weight: 500; | |
| margin-top: 20px; | |
| } | |
| .custom-subheader { | |
| color: #00FFFF; | |
| font-family: 'Roboto', sans-serif; | |
| font-weight: 600; | |
| margin-bottom: 15px; | |
| } | |
| /* Paragraph styling */ | |
| p { | |
| font-family: 'Georgia', serif; | |
| line-height: 1.8; | |
| color: #FFFFFF; /* Darker text color for better visibility */ | |
| margin-bottom: 20px; | |
| } | |
| /* List styling with checkmark bullets */ | |
| .icon-bullet { | |
| list-style-type: none; | |
| padding-left: 20px; | |
| } | |
| .icon-bullet li { | |
| font-family: 'Georgia', serif; | |
| font-size: 1.1em; | |
| margin-bottom: 10px; | |
| color: #FFFFF0; /* Darker text color for better visibility */ | |
| } | |
| .icon-bullet li::before { | |
| content: "✔️"; | |
| padding-right: 10px; | |
| color: #b3b3ff; | |
| } | |
| /* Sidebar styling */ | |
| .sidebar .sidebar-content { | |
| background-color: #ffffff; | |
| border-radius: 10px; | |
| padding: 15px; | |
| } | |
| .sidebar h2 { | |
| color: #495057; | |
| } | |
| </style> | |
| """, unsafe_allow_html=True) | |
| st.title('PROBABILITY') | |
| st.markdown("""Probability is a measure of how likely an event is to occur and is expressed as a number between 0 and 1, where: | |
| <ul class="icon-bullet"> | |
| <li> 0 means the event will definitely not happen.</li> | |
| <li> 1 means the event will definitely happen.</li> | |
| </ul> | |
| """,unsafe_allow_html=True) | |
| st.latex(r""" | |
| P(E) = \frac{\text{Number of favorable outcomes}}{\text{Total number of possible outcomes}} | |
| """) | |
| st.markdown("""Probability is classifed into 2 types: | |
| <ul class="icon-bullet"> | |
| <li>Empirical probability</li> | |
| <li>Theoretical probability</li> | |
| </ul> | |
| """,unsafe_allow_html=True) | |
| st.subheader("Empirical probability") | |
| st.markdown("""Empirical Probability is a type of probability that is determined based on Trails rather than theoretical calculations""",unsafe_allow_html=True) | |
| st.latex(r""" | |
| P(E) = \frac{\text{Number of Favorable Outcomes}}{\text{Total Number of Trials}} | |
| """) | |
| st.markdown("""At infinity Empirical probability will become Theoretical probability""",unsafe_allow_html=True) | |
| st.title("Empirical probability_Caluculation") | |
| st.write(""" | |
| This simple experiment will tell you Empirical probability when you click button | |
| """) | |
| Trail_3 = st.number_input("Number of Trials:", min_value=1, max_value=100, value=7,key="Trail_3") | |
| if st.button('Start the Experiment: Will it Rain or Not?',key="start_experiment_2"): | |
| st.write(f"Running {Trail_3} trials...") | |
| list1=[] | |
| for i in range(1, Trail_3 + 1): | |
| result = random.choice(['Rain', 'No Rain']) | |
| list1+=[result] | |
| rain=np.sum(np.array(list1)=='Rain') | |
| no_rain=np.sum(np.array(list1)=='No Rain') | |
| p_rain=round(rain/Trail_3,2) | |
| p_no_rain=round(no_rain/Trail_3,2) | |
| st.write(f"Event_1:Probability of having rain:{p_rain}") | |
| st.write(f"Event_1:Probability of having no_rain:{p_no_rain}") | |
| st.subheader("Theoretical probability") | |
| st.markdown(""" | |
| Theoretical probability is a type of probability that is calculated based on the possible outcomes and the best part of Theoretical probability is it is independent of Trails.""",unsafe_allow_html=True) | |
| st.latex(r"P(E) = \frac{\text{Number of favorable outcomes}}{\text{Total number of possible outcomes}}") | |
| st.title("Theoretical probability_Caluculation") | |
| st.write(""" | |
| This simple experiment will tell you Theoretical probability when you click button | |
| """) | |
| Trail_4 = st.number_input("Number of Trials:", min_value=1, max_value=100, value=7,key="Trail_4") | |
| if st.button('Start the Experiment: Will it Rain or Not?',key="start_experiment_3"): | |
| st.write(f"Running {Trail_4} trials...") | |
| list1=[] | |
| for i in range(1, Trail_4 + 1): | |
| result = random.choice(['Rain', 'No Rain']) | |
| list1+=[result] | |
| p_rain_1=1/len(np.unique(list1)) | |
| p_no_rain_1=1/len(np.unique(list1)) | |
| st.write(f"Event_1:Probability of having rain:{p_rain_1}") | |
| st.write(f"Event_1:Probability of having no_rain:{p_no_rain_1}") |