Question
Your task is to compare 5 different distributions. The five distributions are as follows: a t-distribution with 9, 99, 999, and 9999 degrees of freedom
Your task is to compare 5 different distributions. The five distributions are as follows:
-
a t-distribution with 9, 99, 999, and 9999 degrees of freedom with mean 0 and standard deviation 2
-
sample size is 10, 100, 1000,10000 respectively
-
a normal distribution with mean 0 and standard deviation 2
Compare the five distributions using a violin plot within a single figure so that each of the curves is in a different color.
You can use the method ".ppf(.)" to get the density at a point of a scipy distribution. You might want to use scipy.stats.t, scipy.stats.norm, scipy.stats.norm.rvs, and/or stats.t.rvs.
# STARTING CODE
import scipy.stats as stats import numpy as np import matplotlib.pyplot as plt import pandas as pd def make_t_distribution(sample_size, mean, sd): t_sample = stats.t.rvs(sample_size - 1, mean, sd, sample_size) # Random t-distribution sample sample_mean = np.mean(t_sample) # sample mean sample_std = np.std(t_sample) # sample standard deviation t_dist = stats.t(df = sample_size - 1, loc = sample_mean, scale = sample_std) # make a t-distribution based on the sample x_axis = np.linspace(t_dist.ppf(0.0001), t_dist.ppf(0.9999), 500) # Generate an x-axis based on t-quantile values return t_dist, x_axis
# CREATE VIOLIN PLOT HERE def make_prob_plot():
return None make_prob_plot()
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started