3-14-25

Introduction to Hypothesis Testing

  • Hypothesis testing is a statistical method that helps us make decisions or inferences about a population parameter.
  • It involves formulating a null hypothesis (H₀) and an alternative hypothesis (H₁).
  • A test statistic is computed, and a decision is made based on a significance level (α).

3D Plotly Visualization

Explanation of 3D Plot

  • The 3D plot above shows a probability density function of two normally distributed variables.
  • It represents the joint probability distribution, which is useful in hypothesis testing for multivariate data.
  • The peaks indicate high probability density, while the valleys show low probability density.

Visualization

Explanation of Visualization 1

  • This histogram visualizes a normally distributed sample.
  • It helps in understanding the shape of data and checking assumptions for hypothesis testing.

Visualization 2

Explanation of Visualization 2

  • This bar chart compares mean values of two random groups.
  • Hypothesis tests like t-tests are often used to compare group means.

Mathematical Notation

  • The null hypothesis (H₀) assumes no effect or no difference: \[ H_0: \mu_1 = \mu_2 \]

  • The alternative hypothesis (H₁) suggests there is a difference: \[ H_1: \mu_1 \neq \mu_2 \]

  • The t-test statistic formula for comparing two means: \[ t = \frac{\bar{X}_1 - \bar{X}_2}{\sqrt{\frac{s_1^2}{n_1} + \frac{s_2^2}{n_2}}} \]

  • The test statistic follows a t-distribution, and we use the p-value to determine statistical significance.

Confidence Interval & P-Value Formula

  • The confidence interval for a mean difference is:

\[ CI = (\bar{X}_1 - \bar{X}_2) \pm t^* \cdot \sqrt{\frac{s_1^2}{n_1} + \frac{s_2^2}{n_2}} \]

  • The p-value is the probability of observing a test statistic as extreme as the one computed:

\[ p = P(T \geq |t|) \]

R Code for Plotly Plot

library(plotly)
library(ggplot2)

# Generate data for 3D plot
x <- seq(-3, 3, length.out = 30)
y <- seq(-3, 3, length.out = 30)
z <- outer(x, y, function(x, y) dnorm(x) * dnorm(y))
z <- as.matrix(z)  # Ensure z is a matrix

# Create plot
fig <- plot_ly(x = x, y = y, z = z, type = "surface")
fig