My original aim was to perform a ttest and gaining a pvalue. I used OneSampleTTest which looked promising yet the results ended up in stdout like this:
julia> OneSampleTTest([1,2,3,4,5],3.1)
One sample t-test
-----------------
Population details:
parameter of interest: Mean
value under h_0: 3.1
point estimate: 3.0
95% confidence interval: (1.0368, 4.9632)
Test summary:
outcome with 95% confidence: fail to reject h_0
two-sided p-value: 0.8944
Details:
number of observations: 5
t-statistic: -0.14142135623730961
degrees of freedom: 4
empirical standard error: 0.7071067811865476
I wanted to get hold of this value:
two-sided p-value: 0.8944
To redirect an stdout I found this on our website here. But it seems that the output from the OneSampleTTest is unaffected by this.
julia> using HypothesisTests
julia> original_stdout = stdout
Base.TTY(RawFD(0x0000001b) open, 0 bytes waiting)
julia> (rd, wr) = redirect_stdout()
(Base.PipeEndpoint(RawFD(0x00000020) open, 0 bytes waiting), Base.PipeEndpoint(RawFD(0x00000025) open, 0 bytes waiting))
julia> println("test")
julia> s = readline(rd)
"test"
julia> s == "test"
true
julia> OneSampleTTest([1,2,3,4,5],3.1)
One sample t-test
-----------------
Population details:
parameter of interest: Mean
value under h_0: 3.1
point estimate: 3.0
95% confidence interval: (1.0368, 4.9632)
Test summary:
outcome with 95% confidence: fail to reject h_0
two-sided p-value: 0.8944
Details:
number of observations: 5
t-statistic: -0.14142135623730961
degrees of freedom: 4
empirical standard error: 0.7071067811865476
julia>
And if did another s = readline(rd)
it would get stuck, because there is nothing in rd. (I assume)
My only other idea to solve this would have been to try and write the results of the test into a file and parse that file again. But I want to do millions of t-tests and to use a file to store the results and reread them everytime sounds like a terrible performance effort.