T tt confidence interval in python

I am interested in using python to calculate confidence interval from student t.

I use the StudentTCI () function in Mathematica, and now I need to encode the same function in python http://reference.wolfram.com/mathematica/HypothesisTesting/ref/StudentTCI.html

I'm not quite sure how to build this function myself, but before I start doing this, is this function in python somewhere? How is numpy? (I did not use numpy, and my adviser advised against using numpy, if possible).

What would be the easiest way to solve this problem? Is it possible to copy the source code from StudentTCI () to numpy (if it exists) into my code as a function definition?

edit: I will need to build a student TCI using python code (if possible). The scipy installation has become a dead end. I have the same problem as everyone else, and I cannot require Scipy for the code I distribute if it takes a long time.

Does anyone know how to look at the source code of the algorithm in the scipy version? I think I will reorganize it into a python definition.

+6
source share
1 answer

I think you could use scipy.stats.t and the interval method:

 In [1]: from scipy.stats import t In [2]: t.interval(0.95, 10, loc=1, scale=2) # 95% confidence interval Out[2]: (-3.4562777039298762, 5.4562777039298762) In [3]: t.interval(0.99, 10, loc=1, scale=2) # 99% confidence interval Out[3]: (-5.338545334351676, 7.338545334351676) 

Of course, you can make your own function if you want. Let it look like Mathematica :

 from scipy.stats import t def StudentTCI(loc, scale, df, alpha=0.95): return t.interval(alpha, df, loc, scale) print StudentTCI(1, 2, 10) print StudentTCI(1, 2, 10, 0.99) 

Result:

 (-3.4562777039298762, 5.4562777039298762) (-5.338545334351676, 7.338545334351676) 
+11
source

Source: https://habr.com/ru/post/947700/


All Articles