import csv
import pandas as pd
import plotly.figure_factory as ff
import plotly.graph_objects as go
import statistics
import random

df= pd.read_csv("data.csv")

templist=df["temp"].tolist()
#print(templist)
tempMean= statistics.mean(templist)
#tempstandDeviation=statistics.stdev(templist)
print(tempMean)
#print(tempstandDeviation)
#plot=ff.create_distplot([templist],["temp"],show_hist=False)
#plot.add_trace(go.Scatter(x=[tempMean,tempMean],y=[0,1],mode="lines",name="MEAN"))
#plot.show()

def random_set_of_mean(counter):
    dataset=[]
    for i  in range(0,counter):
        random_index=random.randint(0,len(templist)-1)
        value=templist[random_index]
        dataset.append(value)
    mean=statistics.mean(dataset)
    return mean

def show_fig(mean_list):
    df=mean_list
    mean=statistics.mean(df)
    fig=ff.create_distplot([df],["temp"],show_hist=False)
    fig.add_trace(go.Scatter(x=[mean, mean], y=[0, 1], mode="lines", name="MEAN"))
    fig.show()


def setup():
    mean_list = []
    for i in range(0,1000):
        set_of_means= random_set_of_mean(100)
        mean_list.append(set_of_means)
    show_fig(mean_list)
    
    mean = statistics.mean(mean_list)
    print("Mean of sampling distribution :-",mean )

setup()

def standard_deviation():
    mean_list = []
    for i in range(0,1000):
        set_of_means= random_set_of_mean(100)
        mean_list.append(set_of_means)

    std_deviation = statistics.stdev(mean_list)
    print("Standard deviation of sampling distribution:- ", std_deviation)

standard_deviation()
