I am looking for an app that draws scatter plot of normal distribution based on mean and variance provided by the user
Drop files here
or click to upload
import streamlit as st
import numpy as np
import pandas as pd
st.title("Normal Distribution Scatter Plot")
# User inputs for mean and variance
mean = st.number_input("Enter the mean", value=0.0)
variance = st.number_input("Enter the variance", value=1.0, min_value=0.0)
# Standard deviation is square root of variance
std_dev = np.sqrt(variance)
# Generate random data from normal distribution
if st.button("Generate Plot"):
# Generate 1000 points
data = np.random.normal(mean, std_dev, 1000)
# Create a DataFrame with x values (just indices) and y values (the normal distribution values)
df = pd.DataFrame({
'x': range(len(data)),
'y': data
})
# Display summary statistics
st.write("### Summary Statistics")
st.write(f"Sample Mean: {np.mean(data):.2f}")
st.write(f"Sample Variance: {np.var(data):.2f}")
# Create scatter plot
st.scatter_chart(
data=df,
x='x',
y='y',
size=20,
color='#1f77b4'
)
st.write("""
### About the Plot
- Each point represents a random value drawn from the normal distribution
- The spread of points shows the distribution shape
- More points cluster around the mean value
- Points become sparser as they deviate from the mean
""")
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?