import streamlit as st import pandas as pd import numpy as np import matplotlib.pyplot as plt import random st.markdown(""" """, 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: """,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: """,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}")