TensorTonicTensorTonic
Problems
Study PlansProjectsInterviewPricingFeedback
Problems
Loading...
1 / 1

One-Sample t-Test

Probability and Statistics
Medium

Given a sample x and a hypothesized population mean μ₀, compute the one-sample t-statistic.

One-Sample t-Statistic:

t=xˉ−μ0s/nt = \frac{\bar{x} - \mu_{0}}{s / \sqrt{n}} t=s/n​xˉ−μ0​​

Where: x̄ = sample mean, s = sample standard deviation, n = sample size

Sample standard deviation (Bessel correction):

s=1n−1∑i=1n(xi−xˉ)2s = \sqrt{ \frac{1}{n - 1} \sum_{i=1}^{n} (x_i - \bar{x})^{2} } s=n−11​i=1∑n​(xi​−xˉ)2​

Function Arguments

  • x: list or array - Sample observations
  • mu0: float - Null hypothesis mean (μ₀)
Loading visualization...

Examples

Input: x=[2.1, 2.4, 1.9, 2.6, 2.0], mu0=2.0

Output: t_stat≈1.53

mean=2.20, std≈0.274, t=(2.20-2.0)/(0.274/√5)

Input: x=[3.0, 5.0], mu0=4.0

Output: t_stat=0.0

mean=4.0 equals mu0

Input: x=[1.0, 1.5, 2.0], mu0=3.0

Output: t_stat≈-5.20

negative t-statistic (sample mean < mu0)

Hint 1

Compute sample mean with np.mean().

Hint 2

Use np.sqrt() for sample standard deviation.

Hint 3

Standard error is s / np.sqrt().

Requirements

  • Return scalar float (t-statistic)
  • Must convert x to NumPy array
  • Use Bessel correction (n-1 denominator)
  • No external statistics libraries

Constraints

  • len(x) ≥ 2
  • NumPy only; time limit: 300ms
Try Similar Problems
Chi2 IndependenceBootstrap MeanSample Var StdMean Median ModeExpected Value Discrete

Sign in to take notes on this problem

Case 1
Case 2
Case 3

Accepts: array

Accepts: number

You must run your code first.
PrevNext

One-Sample t-Test

Probability and Statistics
Medium

Given a sample x and a hypothesized population mean μ₀, compute the one-sample t-statistic.

One-Sample t-Statistic:

t=xˉ−μ0s/nt = \frac{\bar{x} - \mu_{0}}{s / \sqrt{n}} t=s/n​xˉ−μ0​​

Where: x̄ = sample mean, s = sample standard deviation, n = sample size

Sample standard deviation (Bessel correction):

s=1n−1∑i=1n(xi−xˉ)2s = \sqrt{ \frac{1}{n - 1} \sum_{i=1}^{n} (x_i - \bar{x})^{2} } s=n−11​i=1∑n​(xi​−xˉ)2​

Function Arguments

  • x: list or array - Sample observations
  • mu0: float - Null hypothesis mean (μ₀)
Loading visualization...

Examples

Input: x=[2.1, 2.4, 1.9, 2.6, 2.0], mu0=2.0

Output: t_stat≈1.53

mean=2.20, std≈0.274, t=(2.20-2.0)/(0.274/√5)

Input: x=[3.0, 5.0], mu0=4.0

Output: t_stat=0.0

mean=4.0 equals mu0

Input: x=[1.0, 1.5, 2.0], mu0=3.0

Output: t_stat≈-5.20

negative t-statistic (sample mean < mu0)

Hint 1

Compute sample mean with np.mean().

Hint 2

Use np.sqrt() for sample standard deviation.

Hint 3

Standard error is s / np.sqrt().

Requirements

  • Return scalar float (t-statistic)
  • Must convert x to NumPy array
  • Use Bessel correction (n-1 denominator)
  • No external statistics libraries

Constraints

  • len(x) ≥ 2
  • NumPy only; time limit: 300ms
Try Similar Problems
Chi2 IndependenceBootstrap MeanSample Var StdMean Median ModeExpected Value Discrete

Sign in to take notes on this problem

Case 1
Case 2
Case 3

Accepts: array

Accepts: number

You must run your code first.