-
Notifications
You must be signed in to change notification settings - Fork 1
/
drt_betaprob.pro
68 lines (64 loc) · 1.73 KB
/
drt_betaprob.pro
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
; docformat = 'rst'
;
;+
;
; Compute confidence interval from beta distribution. Outputs fractional range
; of confidence interval, normalized to total number.
; Routine from E. Cameron 2011, PASP
;
; :Categories:
; DRTOOLS
;
; :Returns:
; Postscript plots.
;
; :Params:
; k: in, required, type=double
; Number in which quantity is measured.
; n: in, required, type=double
; Total number.
;
; :Keywords:
; c: in, optional, type=double, default=0.683
; Confidence interval for which to compute probability.
;
; :Author:
; David S. N. Rupke::
; Rhodes College
; Department of Physics
; 2000 N. Parkway
; Memphis, TN 38104
; drupke@gmail.com
;
; :History:
; ChangeHistory::
; 2018jun15, DSNR, created
;
; :Copyright:
; Copyright (C) 2018 David S. N. Rupke
;
; This program is free software: you can redistribute it and/or
; modify it under the terms of the GNU General Public License as
; published by the Free Software Foundation, either version 3 of
; the License or any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
; General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program. If not, see
; http://www.gnu.org/licenses/.
;
;-
function drt_betaprob,k,n,c=c
if not keyword_set(c) then c=0.683d
z = DINDGEN(10000)*0.0001d
Beta = IBETA(k+1,n-k+1,z)
ill = VALUE_LOCATE(Beta,(1-c)/2)
iul = VALUE_LOCATE(Beta,1-(1-c)/2)
plower = z[ill]
pupper = z[iul]
return,[plower,pupper]
end