udaykiranbandi's picture
Update app.py
9e45d8e verified
import streamlit as st
import pandas as pd
import numpy as np
import random
st.title("STATISTICS")
st.subheader('What is Statistics?')
st.markdown("""It is a huge field in this we are going to deal data.The below mentioned are some of the operations which we will be doing on data""",unsafe_allow_html=True)
st.markdown("""
<ul class="icon-bullet">
<li>Collecting</li>
<li>Interpreting</li>
<li>Analysis</li>
<li>Structuring</li>
</ul>""",unsafe_allow_html=True)
st.subheader("Why is Statistics Important?")
st.markdown(""""Statistics is essential for making informed decisions. By transforming raw data into meaningful information, it helps in:
<ul class="icon-bullet">
<li>Understanding trends and patterns.</li>
<li>Making predictions and forecasts.</li>
<li>Identifying relationships between variables.</li>
<li>Communicating findings effectively through data visualization.</li>
</ul>""",unsafe_allow_html=True)
st.title(':red[Terminology]')
st.header('Experiment',divider = True)
st.markdown(""" Test or a procedure which we are carried out to discover something.Given below is one of the example of experminet.
""")
# Real-time Example: Rolling a Die
st.subheader("Example: Rolling a Die")
st.write("""
Let's consider the experiment of rolling a 6-sided die. The possible outcomes are the numbers 1, 2, 3, 4, 5, and 6.
Each number has an equal probability of appearing, which is 1/6.
""")
# Button to roll the die
if st.button('Roll the Die'):
# Simulate the die roll
outcome = random.randint(1, 6)
st.write(f"🎲 You rolled a {outcome}!")
else:
st.write("Click the button to roll the die and observe the outcome of this experiment.")
# Explanation
st.write("""
In this experiment, the action is rolling a die, and the outcomes are the numbers from 1 to 6. Since each number has an equal chance, the probability of each outcome is **1/6**.
An experiment could involve more complex scenarios, such as flipping multiple coins or drawing cards from a deck, but the fundamental idea remains the same: it's an action with a range of possible outcomes.
""")
st.header("Random Experiment",divider = True)
st.write("A random experiment is also an experiment but in order to become a random experiment it should satisfy 2 condition's.")
st.markdown("- It should have more than one outcome.")
st.markdown("- We cannot predict what will be the outcome of the experiment.")
st.subheader("Coin Toss Experiment")
st.write("This simple experiment simulates a random prediction: will it get head or tail? Each time you click the button, you will get a random result.")
if st.button("Toss the Coin"):
result = random.choice(["Head", "Tail"])
st.subheader(f"The result is: {result}")
else:
st.write("Click the button to toss the coin.")
st.header("Trail", divider = True)
st.markdown("""A single execution of random experiment""")
st.subheader("Coin Toss Experiment with Trials (Using Slider)")
st.write("This experiment simulates a random prediction: will it get head or tail, with multiple trials. Use the slider to select the number of trials and click the button to see the results.")
num_trials = st.slider("Select the number of trials:", min_value=1, max_value=100, value=1)
if st.button("Toss the Coin", key="toss_button"):
results = []
for trial in range(1, num_trials + 1):
result = random.choice(["Head", "Tail"])
results.append((trial, result))
st.subheader("Results of the Experiment:")
for trial, result in results:
st.write(f"Trial {trial}: {result}")
head_count = sum(1 for trial, result in results if result == "Head")
tail_count = sum(1 for trial, result in results if result == "Tail")
st.subheader("Summary:")
st.write(f"Total Heads: {head_count}")
st.write(f"Total Tails: {tail_count}")
else:
st.write("Use the slider to select the number of trials, then click the button to toss the coin.")
st.header("Outcome",divider = True)
st.markdown("Outcome is nothing but result of a trail.")
st.header("Sample Space",divider = True)
st.markdown("Set of all possible outcomes of Random Experiment.")
st.subheader("Coin Toss Experiment with Sample Space")
st.write("This experiment simulates a random prediction: will it get a head or tail with respect to trials. It will also display the sample space.")
num_trials = st.slider("Select the number of trials:", min_value=1, max_value=100, value=1, key="trials_slider")
if st.button("Toss the Coin", key="toss"):
results = []
sample_space = ["Head", "Tail"]
for trial in range(1, num_trials + 1):
result = random.choice(sample_space)
results.append((trial, result))
st.subheader("Sample Space:")
st.write(f"The sample space is: {sample_space}")
st.subheader("Results of the Experiment:")
for trial, result in results:
st.write(f"Trial {trial}: {result}")
head_count = sum(1 for trial, result in results if result == "Head")
tail_count = sum(1 for trial, result in results if result == "Tail")
st.subheader("Summary:")
st.write(f"Total Heads: {head_count}")
st.write(f"Total Tails: {tail_count}")
else:
st.write("Use the slider to select the number of trials, then click the button to toss the coin.")
st.header("Event", divider = True)
st.markdown("It's a subset of sample space or in easy term's the question's asked on a random experiemnt.")
st.subheader("Coin Toss Experiment with Events")
st.write("This experiment simulates a random prediction: will it get a head or tail with respect to trials. It will also display the sample space and events.")
num_trials = st.slider("Select the number of trials:", min_value=1, max_value=100, value=1, key="trials_slide")
if st.button("Toss the Coin", key="toss_buton"):
results = []
sample_space = ["Head", "Tail"]
for trial in range(1, num_trials + 1):
result = random.choice(sample_space)
results.append((trial, result))
st.subheader("Sample Space:")
st.write(f"The sample space is: {sample_space}")
st.subheader("Results of the Experiment:")
for trial, result in results:
st.write(f"Trial {trial}: {result}")
head_count = sum(1 for trial, result in results if result == "Head")
tail_count = sum(1 for trial, result in results if result == "Tail")
st.subheader("Events:")
st.write(f"Event A: Getting Head")
st.write(f"Event B: Getting Tail")
st.write(f"Number of times Event A occurred (Heads): {head_count}")
st.write(f"Number of times Event B occurred (Tails): {tail_count}")
st.subheader("Summary:")
st.write(f"Total Trials: {num_trials}")
st.write(f"Total Heads: {head_count}")
st.write(f"Total Tails: {tail_count}")
else:
st.write("Use the slider to select the number of trials, then click the button to toss the coin.")