Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
dream
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
dream
Commits
bb1bd489
Commit
bb1bd489
authored
Dec 17, 2013
by
panos
Committed by
Jérome Perrin
Jan 20, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Insert comments on ConfidenceIntervals script
parent
591fa527
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
13 deletions
+11
-13
dream/simulation/outputanalysis/ConfidenceIntervals.py
dream/simulation/outputanalysis/ConfidenceIntervals.py
+11
-13
No files found.
dream/simulation/outputanalysis/ConfidenceIntervals.py
View file @
bb1bd489
...
...
@@ -22,32 +22,29 @@ Created on 16 Nov 2013
@author: Panos
'''
from
rpy2.robjects.packages
import
importr
from
rpy2
import
robjects
MASS
=
importr
(
'MASS'
)
#The ConfidenceIntervals object
class
Intervals
:
#Calculate the p (decimal number) confidence intervals for a sample of data
def
ConfidIntervals
(
self
,
data
,
p
):
data
=
robjects
.
FloatVector
(
data
)
data
=
robjects
.
FloatVector
(
data
)
#The given list changes into float vector in order to be handled by RPy2
alpha
=
1
-
p
rsqrt
=
robjects
.
r
[
'sqrt'
]
rsd
=
robjects
.
r
[
'sd'
]
rmean
=
robjects
.
r
[
'mean'
]
rsqrt
=
robjects
.
r
[
'sqrt'
]
#Call square root function - R function
rsd
=
robjects
.
r
[
'sd'
]
#Call standard deviation function - R function
rmean
=
robjects
.
r
[
'mean'
]
#Call mean function - R function
t
=
len
(
data
)
n
=
rsqrt
(
t
)
b
=
rsd
(
data
)
rqt
=
robjects
.
r
[
'qt'
]
rqt
=
robjects
.
r
[
'qt'
]
#Call the cumulative probability distribution function for t distribution
q
=
rqt
((
1
-
(
alpha
/
2
)),
t
-
1
)
m
=
rmean
(
data
)
m
=
rmean
(
data
)
#Calculate the sample average value
me
=
q
[
0
]
*
(
b
[
0
]
/
n
[
0
])
me
=
q
[
0
]
*
(
b
[
0
]
/
n
[
0
])
#Calculate the margin of error
#Calculate the lower and the upper bound
lo
=
m
[
0
]
-
me
up
=
m
[
0
]
+
me
l
=
[
lo
,
up
]
...
...
@@ -56,3 +53,4 @@ class Intervals:
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment