-3

I can do this in R for 2 sample T-test:

t.test(x, y = NULL, alternative = c("two.sided", "less", "greater"), mu = 0, 
       paired = FALSE, var.equal = FALSE, conf.level = 0.95)

I want some function where I can pass this mu(difference in mean) parameter in Python ttest?

Ankit Agrawal
  • 11
  • 1
  • 4

1 Answers1

2

R has one function t.test() to perform the Student's T test, while Python employs more methods.

If you want to perform a one sample t-test with mu as the true mean μ of the population from which the data is sampled, you should use scipy.stats.ttest_1samp and pass the parameter through popmean. Docs are here.

If you want to perform a two sample t-test with mu as the difference in means, statsmodels.stats.weightstats.ttest_ind from the statsmodels module is the right function, with mu passed through value. Docs are here, as well as a link to a useful answer.

Other links you may find useful are these:

schrodingercat
  • 246
  • 4
  • 21