Hypotheses (Math)

\[ H_0: \mu = \mu_0 \]

\[ H_a: \mu \neq \mu_0 \]

## Test Statistic (Math)

\[ t = \frac{\bar{x} - \mu_0}{s / \sqrt{n}} \]

Where: - \(\bar{x}\) is the sample mean
- \(s\) is the sample standard deviation
- \(n\) is the sample size
- \(\mu_0\) is the hypothesized population mean

Example Data

##     weight
## 1 46.83109
## 2 51.72347
## 3 47.66921
## 4 47.72799
## 5 46.00377
## 6 48.76433

Histogram of Weights (ggplot)

Boxplot of Weights (ggplot)

t-Test Output

## 
##  One Sample t-test
## 
## data:  weights
## t = -4.3778, df = 39, p-value = 8.712e-05
## alternative hypothesis: true mean is not equal to 50
## 95 percent confidence interval:
##  48.55722 49.46912
## sample estimates:
## mean of x 
##  49.01317

Plotly 3D Visualization

R Code Used

t.test(weights, mu = 50)

plot_ly(
  data = df3,
  x = ~mean,
  y = ~sd,
  z = ~t,
  type = "scatter3d",
  mode = "markers",
  marker = list(size = 3)
) |>
  layout(
    title = "3D View of t-Statistic Behavior",
    scene = list(
      xaxis = list(title = "Sample Mean"),
      yaxis = list(title = "Sample SD"),
      zaxis = list(title = "t Statistic")
    )
  )