Source code for irfpy.util.confidence

# -*- coding: utf-8 -*-
"""
Created on Tue Jun  4 19:17:23 2019

A Unified Approach to the Classical
Statistical Analysis of Small Signals
Feldman and Cousins

DOI: 	10.1103/PhysRevD.57.3873


@author: Martin Wieser

Swedish Institute of Space Physics
Bengt Hultqvists väg 1
SE-981 92 Kiruna
Sweden

"""

import numpy as np


_fcbackground = [0.0,0.5,1.0,1.5,2.0,2.5,3.0,3.5,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0]

_fc90str1=r"""0.00,1.29 0.00,0.80 0.00,0.54 0.00,0.41 0.00,0.41 0.00,0.25 0.00,0.25 0.00,0.21 0.00,0.21 0.00,0.19
0.37,2.75 0.00,2.25 0.00,1.75 0.00,1.32 0.00,0.97 0.00,0.68 0.00,0.50 0.00,0.50 0.00,0.36 0.00,0.30
0.74,4.25 0.44,3.75 0.14,3.25 0.00,2.75 0.00,2.25 0.00,1.80 0.00,1.41 0.00,1.09 0.00,0.81 0.00,0.47
1.10,5.30 0.80,4.80 0.54,4.30 0.32,3.80 0.00,3.30 0.00,2.80 0.00,2.30 0.00,1.84 0.00,1.45 0.00,0.91
2.34,6.78 1.84,6.28 1.34,5.78 0.91,5.28 0.44,4.78 0.25,4.28 0.00,3.78 0.00,3.28 0.00,2.78 0.00,1.90
2.75,7.81 2.25,7.31 1.75,6.81 1.32,6.31 0.97,5.81 0.68,5.31 0.45,4.81 0.20,4.31 0.00,3.81 0.00,2.81
3.82,9.28 3.32,8.78 2.82,8.28 2.32,7.78 1.82,7.28 1.37,6.78 1.01,6.28 0.62,5.78 0.36,5.28 0.00,4.28
4.25,10.30 3.75,9.80 3.25,9.30 2.75,8.80 2.25,8.30 1.80,7.80 1.41,7.30 1.09,6.80 0.81,6.30 0.32,5.30
5.30,11.32 4.80,10.82 4.30,10.32 3.80,9.82 3.30,9.32 2.80,8.82 2.30,8.32 1.84,7.82 1.45,7.32 0.82,6.32
6.33,12.79 5.83,12.29 5.33,11.79 4.83,11.29 4.33,10.79 3.83,10.29 3.33,9.79 2.83,9.29 2.33,8.79 1.44,7.79
6.78,13.81 6.28,13.31 5.78,12.81 5.28,12.31 4.78,11.81 4.28,11.31 3.78,10.81 3.28,10.31 2.78,9.81 1.90,8.81
7.81,14.82 7.31,14.32 6.81,13.82 6.31,13.32 5.81,12.82 5.31,12.32 4.81,11.82 4.31,11.32 3.81,10.82 2.81,9.82
8.83,16.29 8.33,15.79 7.83,15.29 7.33,14.79 6.83,14.29 6.33,13.79 5.83,13.29 5.33,12.79 4.83,12.29 3.83,11.29
9.28,17.30 8.78,16.80 8.28,16.30 7.78,15.80 7.28,15.30 6.78,14.80 6.28,14.30 5.78,13.80 5.28,13.30 4.28,12.30
10.30,18.32 9.80,17.82 9.30,17.32 8.80,16.82 8.30,16.32 7.80,15.82 7.30,15.32 6.80,14.82 6.30,14.32 5.30,13.32
11.32,19.32 10.82,18.82 10.32,18.32 9.82,17.82 9.32,17.32 8.82,16.82 8.32,16.32 7.82,15.82 7.32,15.32 6.32,14.32
12.33,20.80 11.83,20.30 11.33,19.80 10.83,19.30 10.33,18.80 9.83,18.30 9.33,17.80 8.83,17.30 8.33,16.80 7.33,15.80
12.79,21.81 12.29,21.31 11.79,20.81 11.29,20.31 10.79,19.81 10.29,19.31 9.79,18.81 9.29,18.31 8.79,17.81 7.79,16.81
13.81,22.82 13.31,22.32 12.81,21.82 12.31,21.32 11.81,20.82 11.31,20.32 10.81,19.82 10.31,19.32 9.81,18.82 8.81,17.82
14.82,23.82 14.32,23.32 13.82,22.82 13.32,22.32 12.82,21.82 12.32,21.32 11.82,20.82 11.32,20.32 10.82,19.82 9.82,18.82
15.83,25.30 15.33,24.80 14.83,24.30 14.33,23.80 13.83,23.30 13.33,22.80 12.83,22.30 12.33,21.80 11.83,21.30 10.83,20.30"""

_fc90str2=r"""0.00,0.18 0.00,0.17 0.00,0.17 0.00,0.17 0.00,0.16 0.00,0.16 0.00,0.16 0.00,0.16 0.00,0.16 0.00,0.15
0.00,0.24 0.00,0.21 0.00,0.20 0.00,0.19 0.00,0.18 0.00,0.17 0.00,0.17 0.00,0.17 0.00,0.17 0.00,0.16
0.00,0.31 0.00,0.27 0.00,0.23 0.00,0.21 0.00,0.20 0.00,0.19 0.00,0.19 0.00,0.18 0.00,0.18 0.00,0.18
0.00,0.69 0.00,0.42 0.00,0.31 0.00,0.26 0.00,0.23 0.00,0.22 0.00,0.21 0.00,0.20 0.00,0.20 0.00,0.19
0.00,1.22 0.00,0.69 0.00,0.60 0.00,0.38 0.00,0.30 0.00,0.26 0.00,0.24 0.00,0.23 0.00,0.22 0.00,0.21
0.00,1.92 0.00,1.23 0.00,0.99 0.00,0.60 0.00,0.48 0.00,0.35 0.00,0.29 0.00,0.26 0.00,0.24 0.00,0.23
0.00,3.28 0.00,2.38 0.00,1.65 0.00,1.06 0.00,0.63 0.00,0.53 0.00,0.42 0.00,0.33 0.00,0.29 0.00,0.26
0.00,4.30 0.00,3.30 0.00,2.40 0.00,1.66 0.00,1.07 0.00,0.88 0.00,0.53 0.00,0.47 0.00,0.38 0.00,0.32
0.31,5.32 0.00,4.32 0.00,3.32 0.00,2.41 0.00,1.67 0.00,1.46 0.00,0.94 0.00,0.62 0.00,0.48 0.00,0.43
0.69,6.79 0.27,5.79 0.00,4.79 0.00,3.79 0.00,2.87 0.00,2.10 0.00,1.46 0.00,0.94 0.00,0.78 0.00,0.50
1.22,7.81 0.69,6.81 0.23,5.81 0.00,4.81 0.00,3.81 0.00,2.89 0.00,2.11 0.00,1.47 0.00,1.03 0.00,0.84
1.92,8.82 1.23,7.82 0.60,6.82 0.19,5.82 0.00,4.82 0.00,3.82 0.00,2.90 0.00,2.12 0.00,1.54 0.00,1.31
2.83,10.29 1.94,9.29 1.12,8.29 0.60,7.29 0.12,6.29 0.00,5.29 0.00,4.29 0.00,3.36 0.00,2.57 0.00,1.89
3.28,11.30 2.38,10.30 1.65,9.30 1.06,8.30 0.60,7.30 0.05,6.30 0.00,5.30 0.00,4.30 0.00,3.37 0.00,2.57
4.30,12.32 3.30,11.32 2.40,10.32 1.66,9.32 1.07,8.32 0.53,7.32 0.00,6.32 0.00,5.32 0.00,4.32 0.00,3.38
5.32,13.32 4.32,12.32 3.32,11.32 2.41,10.32 1.67,9.32 1.00,8.32 0.53,7.32 0.00,6.32 0.00,5.32 0.00,4.32
6.33,14.80 5.33,13.80 4.33,12.80 3.33,11.80 2.43,10.80 1.46,9.80 0.94,8.80 0.47,7.80 0.00,6.80 0.00,5.80
6.79,15.81 5.79,14.81 4.79,13.81 3.79,12.81 2.87,11.81 2.10,10.81 1.46,9.81 0.94,8.81 0.48,7.81 0.00,6.81
7.81,16.82 6.81,15.82 5.81,14.82 4.81,13.82 3.81,12.82 2.89,11.82 2.11,10.82 1.47,9.82 0.93,8.82 0.43,7.82
8.82,17.82 7.82,16.82 6.82,15.82 5.82,14.82 4.82,13.82 3.82,12.82 2.90,11.82 2.12,10.82 1.48,9.82 0.84,8.82
9.83,19.30 8.83,18.30 7.83,17.30 6.83,16.30 5.83,15.30 4.83,14.30 3.83,13.30 2.91,12.30 2.12,11.30 1.31,10.30"""

_fc68str1=r"""0 0.00,1.29 0.00,0.80 0.00,0.54 0.00,0.41 0.00,0.41 0.00,0.25 0.00,0.25 0.00,0.21 0.00,0.21 0.00,0.19
1 0.37,2.75 0.00,2.25 0.00,1.75 0.00,1.32 0.00,0.97 0.00,0.68 0.00,0.50 0.00,0.50 0.00,0.36 0.00,0.30
2 0.74,4.25 0.44,3.75 0.14,3.25 0.00,2.75 0.00,2.25 0.00,1.80 0.00,1.41 0.00,1.09 0.00,0.81 0.00,0.47
3 1.10,5.30 0.80,4.80 0.54,4.30 0.32,3.80 0.00,3.30 0.00,2.80 0.00,2.30 0.00,1.84 0.00,1.45 0.00,0.91
4 2.34,6.78 1.84,6.28 1.34,5.78 0.91,5.28 0.44,4.78 0.25,4.28 0.00,3.78 0.00,3.28 0.00,2.78 0.00,1.90
5 2.75,7.81 2.25,7.31 1.75,6.81 1.32,6.31 0.97,5.81 0.68,5.31 0.45,4.81 0.20,4.31 0.00,3.81 0.00,2.81
6 3.82,9.28 3.32,8.78 2.82,8.28 2.32,7.78 1.82,7.28 1.37,6.78 1.01,6.28 0.62,5.78 0.36,5.28 0.00,4.28
7 4.25,10.30 3.75,9.80 3.25,9.30 2.75,8.80 2.25,8.30 1.80,7.80 1.41,7.30 1.09,6.80 0.81,6.30 0.32,5.30
8 5.30,11.32 4.80,10.82 4.30,10.32 3.80,9.82 3.30,9.32 2.80,8.82 2.30,8.32 1.84,7.82 1.45,7.32 0.82,6.32
9 6.33,12.79 5.83,12.29 5.33,11.79 4.83,11.29 4.33,10.79 3.83,10.29 3.33,9.79 2.83,9.29 2.33,8.79 1.44,7.79
10 6.78,13.81 6.28,13.31 5.78,12.81 5.28,12.31 4.78,11.81 4.28,11.31 3.78,10.81 3.28,10.31 2.78,9.81 1.90,8.81
11 7.81,14.82 7.31,14.32 6.81,13.82 6.31,13.32 5.81,12.82 5.31,12.32 4.81,11.82 4.31,11.32 3.81,10.82 2.81,9.82
12 8.83,16.29 8.33,15.79 7.83,15.29 7.33,14.79 6.83,14.29 6.33,13.79 5.83,13.29 5.33,12.79 4.83,12.29 3.83,11.29
13 9.28,17.30 8.78,16.80 8.28,16.30 7.78,15.80 7.28,15.30 6.78,14.80 6.28,14.30 5.78,13.80 5.28,13.30 4.28,12.30
14 10.30,18.32 9.80,17.82 9.30,17.32 8.80,16.82 8.30,16.32 7.80,15.82 7.30,15.32 6.80,14.82 6.30,14.32 5.30,13.32
15 11.32,19.32 10.82,18.82 10.32,18.32 9.82,17.82 9.32,17.32 8.82,16.82 8.32,16.32 7.82,15.82 7.32,15.32 6.32,14.32
16 12.33,20.80 11.83,20.30 11.33,19.80 10.83,19.30 10.33,18.80 9.83,18.30 9.33,17.80 8.83,17.30 8.33,16.80 7.33,15.80
17 12.79,21.81 12.29,21.31 11.79,20.81 11.29,20.31 10.79,19.81 10.29,19.31 9.79,18.81 9.29,18.31 8.79,17.81 7.79,16.81
18 13.81,22.82 13.31,22.32 12.81,21.82 12.31,21.32 11.81,20.82 11.31,20.32 10.81,19.82 10.31,19.32 9.81,18.82 8.81,17.82
19 14.82,23.82 14.32,23.32 13.82,22.82 13.32,22.32 12.82,21.82 12.32,21.32 11.82,20.82 11.32,20.32 10.82,19.82 9.82,18.82
20 15.83,25.30 15.33,24.80 14.83,24.30 14.33,23.80 13.83,23.30 13.33,22.80 12.83,22.30 12.33,21.80 11.83,21.30 10.83,20.30"""

_fc68str2=r"""0 0.00,0.18 0.00,0.17 0.00,0.17 0.00,0.17 0.00,0.16 0.00,0.16 0.00,0.16 0.00,0.16 0.00,0.16 0.00,0.15
1 0.00,0.24 0.00,0.21 0.00,0.20 0.00,0.19 0.00,0.18 0.00,0.17 0.00,0.17 0.00,0.17 0.00,0.17 0.00,0.16
2 0.00,0.31 0.00,0.27 0.00,0.23 0.00,0.21 0.00,0.20 0.00,0.19 0.00,0.19 0.00,0.18 0.00,0.18 0.00,0.18
3 0.00,0.69 0.00,0.42 0.00,0.31 0.00,0.26 0.00,0.23 0.00,0.22 0.00,0.21 0.00,0.20 0.00,0.20 0.00,0.19
4 0.00,1.22 0.00,0.69 0.00,0.60 0.00,0.38 0.00,0.30 0.00,0.26 0.00,0.24 0.00,0.23 0.00,0.22 0.00,0.21
5 0.00,1.92 0.00,1.23 0.00,0.99 0.00,0.60 0.00,0.48 0.00,0.35 0.00,0.29 0.00,0.26 0.00,0.24 0.00,0.23
6 0.00,3.28 0.00,2.38 0.00,1.65 0.00,1.06 0.00,0.63 0.00,0.53 0.00,0.42 0.00,0.33 0.00,0.29 0.00,0.26
7 0.00,4.30 0.00,3.30 0.00,2.40 0.00,1.66 0.00,1.07 0.00,0.88 0.00,0.53 0.00,0.47 0.00,0.38 0.00,0.32
8 0.31,5.32 0.00,4.32 0.00,3.32 0.00,2.41 0.00,1.67 0.00,1.46 0.00,0.94 0.00,0.62 0.00,0.48 0.00,0.43
9 0.69,6.79 0.27,5.79 0.00,4.79 0.00,3.79 0.00,2.87 0.00,2.10 0.00,1.46 0.00,0.94 0.00,0.78 0.00,0.50
10 1.22,7.81 0.69,6.81 0.23,5.81 0.00,4.81 0.00,3.81 0.00,2.89 0.00,2.11 0.00,1.47 0.00,1.03 0.00,0.84
11 1.92,8.82 1.23,7.82 0.60,6.82 0.19,5.82 0.00,4.82 0.00,3.82 0.00,2.90 0.00,2.12 0.00,1.54 0.00,1.31
12 2.83,10.29 1.94,9.29 1.12,8.29 0.60,7.29 0.12,6.29 0.00,5.29 0.00,4.29 0.00,3.36 0.00,2.57 0.00,1.89
13 3.28,11.30 2.38,10.30 1.65,9.30 1.06,8.30 0.60,7.30 0.05,6.30 0.00,5.30 0.00,4.30 0.00,3.37 0.00,2.57
14 4.30,12.32 3.30,11.32 2.40,10.32 1.66,9.32 1.07,8.32 0.53,7.32 0.00,6.32 0.00,5.32 0.00,4.32 0.00,3.38
15 5.32,13.32 4.32,12.32 3.32,11.32 2.41,10.32 1.67,9.32 1.00,8.32 0.53,7.32 0.00,6.32 0.00,5.32 0.00,4.32
16 6.33,14.80 5.33,13.80 4.33,12.80 3.33,11.80 2.43,10.80 1.46,9.80 0.94,8.80 0.47,7.80 0.00,6.80 0.00,5.80
17 6.79,15.81 5.79,14.81 4.79,13.81 3.79,12.81 2.87,11.81 2.10,10.81 1.46,9.81 0.94,8.81 0.48,7.81 0.00,6.81
18 7.81,16.82 6.81,15.82 5.81,14.82 4.81,13.82 3.81,12.82 2.89,11.82 2.11,10.82 1.47,9.82 0.93,8.82 0.43,7.82
19 8.82,17.82 7.82,16.82 6.82,15.82 5.82,14.82 4.82,13.82 3.82,12.82 2.90,11.82 2.12,10.82 1.48,9.82 0.84,8.82
20 9.83,19.30 8.83,18.30 7.83,17.30 6.83,16.30 5.83,15.30 4.83,14.30 3.83,13.30 2.91,12.30 2.12,11.30 1.31,10.30"""

_fc90str1=r"""0 0.00,2.44 0.00,1.94 0.00,1.61 0.00,1.33 0.00,1.26 0.00,1.18 0.00,1.08 0.00,1.06 0.00,1.01 0.00,0.98
1 0.11,4.36 0.00,3.86 0.00,3.36 0.00,2.91 0.00,2.53 0.00,2.19 0.00,1.88 0.00,1.59 0.00,1.39 0.00,1.22
2 0.53,5.91 0.03,5.41 0.00,4.91 0.00,4.41 0.00,3.91 0.00,3.45 0.00,3.04 0.00,2.67 0.00,2.33 0.00,1.73
3 1.10,7.42 0.60,6.92 0.10,6.42 0.00,5.92 0.00,5.42 0.00,4.92 0.00,4.42 0.00,3.95 0.00,3.53 0.00,2.78
4 1.47,8.60 1.17,8.10 0.74,7.60 0.24,7.10 0.00,6.60 0.00,6.10 0.00,5.60 0.00,5.10 0.00,4.60 0.00,3.60
5 1.84,9.99 1.53,9.49 1.25,8.99 0.93,8.49 0.43,7.99 0.00,7.49 0.00,6.99 0.00,6.49 0.00,5.99 0.00,4.99
6 2.21,11.47 1.90,10.97 1.61,10.47 1.33,9.97 1.08,9.47 0.65,8.97 0.15,8.47 0.00,7.97 0.00,7.47 0.00,6.47
7 3.56,12.53 3.06,12.03 2.56,11.53 2.09,11.03 1.59,10.53 1.18,10.03 0.89,9.53 0.39,9.03 0.00,8.53 0.00,7.53
8 3.96,13.99 3.46,13.49 2.96,12.99 2.51,12.49 2.14,11.99 1.81,11.49 1.51,10.99 1.06,10.49 0.66,9.99 0.00,8.99
9 4.36,15.30 3.86,14.80 3.36,14.30 2.91,13.80 2.53,13.30 2.19,12.80 1.88,12.30 1.59,11.80 1.33,11.30 0.43,10.30
10 5.50,16.50 5.00,16.00 4.50,15.50 4.00,15.00 3.50,14.50 3.04,14.00 2.63,13.50 2.27,13.00 1.94,12.50 1.19,11.50
11 5.91,17.81 5.41,17.31 4.91,16.81 4.41,16.31 3.91,15.81 3.45,15.31 3.04,14.81 2.67,14.31 2.33,13.81 1.73,12.81
12 7.01,19.00 6.51,18.50 6.01,18.00 5.51,17.50 5.01,17.00 4.51,16.50 4.01,16.00 3.54,15.50 3.12,15.00 2.38,14.00
13 7.42,20.05 6.92,19.55 6.42,19.05 5.92,18.55 5.42,18.05 4.92,17.55 4.42,17.05 3.95,16.55 3.53,16.05 2.78,15.05
14 8.50,21.50 8.00,21.00 7.50,20.50 7.00,20.00 6.50,19.50 6.00,19.00 5.50,18.50 5.00,18.00 4.50,17.50 3.59,16.50
15 9.48,22.52 8.98,22.02 8.48,21.52 7.98,21.02 7.48,20.52 6.98,20.02 6.48,19.52 5.98,19.02 5.48,18.52 4.48,17.52
16 9.99,23.99 9.49,23.49 8.99,22.99 8.49,22.49 7.99,21.99 7.49,21.49 6.99,20.99 6.49,20.49 5.99,19.99 4.99,18.99
17 11.04,25.02 10.54,24.52 10.04,24.02 9.54,23.52 9.04,23.02 8.54,22.52 8.04,22.02 7.54,21.52 7.04,21.02 6.04,20.02
18 11.47,26.16 10.97,25.66 10.47,25.16 9.97,24.66 9.47,24.16 8.97,23.66 8.47,23.16 7.97,22.66 7.47,22.16 6.47,21.16
19 12.51,27.51 12.01,27.01 11.51,26.51 11.01,26.01 10.51,25.51 10.01,25.01 9.51,24.51 9.01,24.01 8.51,23.51 7.51,22.51
20 13.55,28.52 13.05,28.02 12.55,27.52 12.05,27.02 11.55,26.52 11.05,26.02 10.55,25.52 10.05,25.02 9.55,24.52 8.55,23.52"""

_fc90str2=r"""0 0.00,0.97 0.00,0.95 0.00,0.94 0.00,0.94 0.00,0.93 0.00,0.93 0.00,0.92 0.00,0.92 0.00,0.92 0.00,0.92
1 0.00,1.14 0.00,1.10 0.00,1.07 0.00,1.05 0.00,1.03 0.00,1.01 0.00,1.00 0.00,0.99 0.00,0.99 0.00,0.98
2 0.00,1.57 0.00,1.38 0.00,1.27 0.00,1.21 0.00,1.15 0.00,1.11 0.00,1.09 0.00,1.08 0.00,1.06 0.00,1.05
3 0.00,2.14 0.00,1.75 0.00,1.49 0.00,1.37 0.00,1.29 0.00,1.24 0.00,1.21 0.00,1.18 0.00,1.15 0.00,1.14
4 0.00,2.83 0.00,2.56 0.00,1.98 0.00,1.82 0.00,1.57 0.00,1.45 0.00,1.37 0.00,1.31 0.00,1.27 0.00,1.24
5 0.00,4.07 0.00,3.28 0.00,2.60 0.00,2.38 0.00,1.85 0.00,1.70 0.00,1.58 0.00,1.48 0.00,1.39 0.00,1.32
6 0.00,5.47 0.00,4.54 0.00,3.73 0.00,3.02 0.00,2.40 0.00,2.21 0.00,1.86 0.00,1.67 0.00,1.55 0.00,1.47
7 0.00,6.53 0.00,5.53 0.00,4.58 0.00,3.77 0.00,3.26 0.00,2.81 0.00,2.23 0.00,2.07 0.00,1.86 0.00,1.69
8 0.00,7.99 0.00,6.99 0.00,5.99 0.00,5.05 0.00,4.22 0.00,3.49 0.00,2.83 0.00,2.62 0.00,2.11 0.00,1.95
9 0.00,9.30 0.00,8.30 0.00,7.30 0.00,6.30 0.00,5.30 0.00,4.30 0.00,3.93 0.00,3.25 0.00,2.64 0.00,2.45
10 0.22,10.50 0.00,9.50 0.00,8.50 0.00,7.50 0.00,6.50 0.00,5.56 0.00,4.71 0.00,3.95 0.00,3.27 0.00,3.00
11 1.01,11.81 0.02,10.81 0.00,9.81 0.00,8.81 0.00,7.81 0.00,6.81 0.00,5.81 0.00,4.81 0.00,4.39 0.00,3.69
12 1.57,13.00 0.83,12.00 0.00,11.00 0.00,10.00 0.00,9.00 0.00,8.00 0.00,7.00 0.00,6.05 0.00,5.19 0.00,4.42
13 2.14,14.05 1.50,13.05 0.65,12.05 0.00,11.05 0.00,10.05 0.00,9.05 0.00,8.05 0.00,7.05 0.00,6.08 0.00,5.22
14 2.83,15.50 2.13,14.50 1.39,13.50 0.47,12.50 0.00,11.50 0.00,10.50 0.00,9.50 0.00,8.50 0.00,7.50 0.00,6.55
15 3.48,16.52 2.56,15.52 1.98,14.52 1.26,13.52 0.30,12.52 0.00,11.52 0.00,10.52 0.00,9.52 0.00,8.52 0.00,7.52
16 4.07,17.99 3.28,16.99 2.60,15.99 1.82,14.99 1.13,13.99 0.14,12.99 0.00,11.99 0.00,10.99 0.00,9.99 0.00,8.99
17 5.04,19.02 4.11,18.02 3.32,17.02 2.38,16.02 1.81,15.02 0.98,14.02 0.00,13.02 0.00,12.02 0.00,11.02 0.00,10.02
18 5.47,20.16 4.54,19.16 3.73,18.16 3.02,17.16 2.40,16.16 1.70,15.16 0.82,14.16 0.00,13.16 0.00,12.16 0.00,11.16
19 6.51,21.51 5.51,20.51 4.58,19.51 3.77,18.51 3.05,17.51 2.21,16.51 1.58,15.51 0.67,14.51 0.00,13.51 0.00,12.51
20 7.55,22.52 6.55,21.52 5.55,20.52 4.55,19.52 3.55,18.52 2.81,17.52 2.23,16.52 1.48,15.52 0.53,14.52 0.00,13.52"""

_fc95str1=r"""0 0.00,3.09 0.00,2.63 0.00,2.33 0.00,2.05 0.00,1.78 0.00,1.78 0.00,1.63 0.00,1.63 0.00,1.57 0.00,1.54
1 0.05,5.14 0.00,4.64 0.00,4.14 0.00,3.69 0.00,3.30 0.00,2.95 0.00,2.63 0.00,2.33 0.00,2.08 0.00,1.88
2 0.36,6.72 0.00,6.22 0.00,5.72 0.00,5.22 0.00,4.72 0.00,4.25 0.00,3.84 0.00,3.46 0.00,3.11 0.00,2.49
3 0.82,8.25 0.32,7.75 0.00,7.25 0.00,6.75 0.00,6.25 0.00,5.75 0.00,5.25 0.00,4.78 0.00,4.35 0.00,3.58
4 1.37,9.76 0.87,9.26 0.37,8.76 0.00,8.26 0.00,7.76 0.00,7.26 0.00,6.76 0.00,6.26 0.00,5.76 0.00,4.84
5 1.84,11.26 1.47,10.76 0.97,10.26 0.47,9.76 0.00,9.26 0.00,8.76 0.00,8.26 0.00,7.76 0.00,7.26 0.00,6.26
6 2.21,12.75 1.90,12.25 1.61,11.75 1.11,11.25 0.61,10.75 0.11,10.25 0.00,9.75 0.00,9.25 0.00,8.75 0.00,7.75
7 2.58,13.81 2.27,13.31 1.97,12.81 1.69,12.31 1.29,11.81 0.79,11.31 0.29,10.81 0.00,10.31 0.00,9.81 0.00,8.81
8 2.94,15.29 2.63,14.79 2.33,14.29 2.05,13.79 1.78,13.29 1.48,12.79 0.98,12.29 0.48,11.79 0.00,11.29 0.00,10.29
9 4.36,16.77 3.86,16.27 3.36,15.77 2.91,15.27 2.46,14.77 1.96,14.27 1.62,13.77 1.20,13.27 0.70,12.77 0.00,11.77
10 4.75,17.82 4.25,17.32 3.75,16.82 3.30,16.32 2.92,15.82 2.57,15.32 2.25,14.82 1.82,14.32 1.43,13.82 0.43,12.82
11 5.14,19.29 4.64,18.79 4.14,18.29 3.69,17.79 3.30,17.29 2.95,16.79 2.63,16.29 2.33,15.79 2.04,15.29 1.17,14.29
12 6.32,20.34 5.82,19.84 5.32,19.34 4.82,18.84 4.32,18.34 3.85,17.84 3.44,17.34 3.06,16.84 2.69,16.34 1.88,15.34
13 6.72,21.80 6.22,21.30 5.72,20.80 5.22,20.30 4.72,19.80 4.25,19.30 3.84,18.80 3.46,18.30 3.11,17.80 2.47,16.80
14 7.84,22.94 7.34,22.44 6.84,21.94 6.34,21.44 5.84,20.94 5.34,20.44 4.84,19.94 4.37,19.44 3.94,18.94 3.10,17.94
15 8.25,24.31 7.75,23.81 7.25,23.31 6.75,22.81 6.25,22.31 5.75,21.81 5.25,21.31 4.78,20.81 4.35,20.31 3.58,19.31
16 9.34,25.40 8.84,24.90 8.34,24.40 7.84,23.90 7.34,23.40 6.84,22.90 6.34,22.40 5.84,21.90 5.34,21.40 4.43,20.40
17 9.76,26.81 9.26,26.31 8.76,25.81 8.26,25.31 7.76,24.81 7.26,24.31 6.76,23.81 6.26,23.31 5.76,22.81 4.84,21.81
18 10.84,27.84 10.34,27.34 9.84,26.84 9.34,26.34 8.84,25.84 8.34,25.34 7.84,24.84 7.34,24.34 6.84,23.84 5.84,22.84
19 11.26,29.31 10.76,28.81 10.26,28.31 9.76,27.81 9.26,27.31 8.76,26.81 8.26,26.31 7.76,25.81 7.26,25.31 6.26,24.31
20 12.33,30.33 11.83,29.83 11.33,29.33 10.83,28.83 10.33,28.33 9.83,27.83 9.33,27.33 8.83,26.83 8.33,26.33 7.33,25.33"""

_fc95str2=r"""0 0.00,1.52 0.00,1.51 0.00,1.50 0.00,1.49 0.00,1.49 0.00,1.48 0.00,1.48 0.00,1.48 0.00,1.47 0.00,1.47
1 0.00,1.78 0.00,1.73 0.00,1.69 0.00,1.66 0.00,1.64 0.00,1.61 0.00,1.60 0.00,1.59 0.00,1.58 0.00,1.56
2 0.00,2.28 0.00,2.11 0.00,1.98 0.00,1.86 0.00,1.81 0.00,1.77 0.00,1.74 0.00,1.72 0.00,1.70 0.00,1.67
3 0.00,2.91 0.00,2.69 0.00,2.37 0.00,2.17 0.00,2.06 0.00,1.98 0.00,1.93 0.00,1.89 0.00,1.82 0.00,1.80
4 0.00,4.05 0.00,3.35 0.00,3.01 0.00,2.54 0.00,2.37 0.00,2.23 0.00,2.11 0.00,2.04 0.00,1.99 0.00,1.95
5 0.00,5.33 0.00,4.52 0.00,3.79 0.00,3.15 0.00,2.94 0.00,2.65 0.00,2.43 0.00,2.30 0.00,2.20 0.00,2.13
6 0.00,6.75 0.00,5.82 0.00,4.99 0.00,4.24 0.00,3.57 0.00,3.14 0.00,2.78 0.00,2.62 0.00,2.48 0.00,2.35
7 0.00,7.81 0.00,6.81 0.00,5.87 0.00,5.03 0.00,4.28 0.00,4.00 0.00,3.37 0.00,3.15 0.00,2.79 0.00,2.59
8 0.00,9.29 0.00,8.29 0.00,7.29 0.00,6.35 0.00,5.50 0.00,4.73 0.00,4.03 0.00,3.79 0.00,3.20 0.00,3.02
9 0.00,10.77 0.00,9.77 0.00,8.77 0.00,7.77 0.00,6.82 0.00,5.96 0.00,5.18 0.00,4.47 0.00,3.81 0.00,3.60
10 0.00,11.82 0.00,10.82 0.00,9.82 0.00,8.82 0.00,7.82 0.00,6.87 0.00,6.00 0.00,5.21 0.00,4.59 0.00,4.24
11 0.17,13.29 0.00,12.29 0.00,11.29 0.00,10.29 0.00,9.29 0.00,8.29 0.00,7.34 0.00,6.47 0.00,5.67 0.00,4.93
12 0.92,14.34 0.00,13.34 0.00,12.34 0.00,11.34 0.00,10.34 0.00,9.34 0.00,8.34 0.00,7.37 0.00,6.50 0.00,5.70
13 1.68,15.80 0.69,14.80 0.00,13.80 0.00,12.80 0.00,11.80 0.00,10.80 0.00,9.80 0.00,8.80 0.00,7.85 0.00,6.96
14 2.28,16.94 1.46,15.94 0.46,14.94 0.00,13.94 0.00,12.94 0.00,11.94 0.00,10.94 0.00,9.94 0.00,8.94 0.00,7.94
15 2.91,18.31 2.11,17.31 1.25,16.31 0.25,15.31 0.00,14.31 0.00,13.31 0.00,12.31 0.00,11.31 0.00,10.31 0.00,9.31
16 3.60,19.40 2.69,18.40 1.98,17.40 1.04,16.40 0.04,15.40 0.00,14.40 0.00,13.40 0.00,12.40 0.00,11.40 0.00,10.40
17 4.05,20.81 3.35,19.81 2.63,18.81 1.83,17.81 0.83,16.81 0.00,15.81 0.00,14.81 0.00,13.81 0.00,12.81 0.00,11.81
18 4.91,21.84 4.11,20.84 3.18,19.84 2.53,18.84 1.63,17.84 0.63,16.84 0.00,15.84 0.00,14.84 0.00,13.84 0.00,12.84
19 5.33,23.31 4.52,22.31 3.79,21.31 3.15,20.31 2.37,19.31 1.44,18.31 0.44,17.31 0.00,16.31 0.00,15.31 0.00,14.31
20 6.33,24.33 5.39,23.33 4.57,22.33 3.82,21.33 2.94,20.33 2.23,19.33 1.25,18.33 0.25,17.33 0.00,16.33 0.00,15.33"""

_fc99str1=r"""0 0.00,4.74 0.00,4.24 0.00,3.80 0.00,3.50 0.00,3.26 0.00,3.26 0.00,3.05 0.00,3.05 0.00,2.98 0.00,2.94
1 0.01,6.91 0.00,6.41 0.00,5.91 0.00,5.41 0.00,4.91 0.00,4.48 0.00,4.14 0.00,4.09 0.00,3.89 0.00,3.59
2 0.15,8.71 0.00,8.21 0.00,7.71 0.00,7.21 0.00,6.71 0.00,6.24 0.00,5.82 0.00,5.42 0.00,5.06 0.00,4.37
3 0.44,10.47 0.00,9.97 0.00,9.47 0.00,8.97 0.00,8.47 0.00,7.97 0.00,7.47 0.00,6.97 0.00,6.47 0.00,5.57
4 0.82,12.23 0.32,11.73 0.00,11.23 0.00,10.73 0.00,10.23 0.00,9.73 0.00,9.23 0.00,8.73 0.00,8.23 0.00,7.30
5 1.28,13.75 0.78,13.25 0.28,12.75 0.00,12.25 0.00,11.75 0.00,11.25 0.00,10.75 0.00,10.25 0.00,9.75 0.00,8.75
6 1.79,15.27 1.29,14.77 0.79,14.27 0.29,13.77 0.00,13.27 0.00,12.77 0.00,12.27 0.00,11.77 0.00,11.27 0.00,10.27
7 2.33,16.77 1.83,16.27 1.33,15.77 0.83,15.27 0.33,14.77 0.00,14.27 0.00,13.77 0.00,13.27 0.00,12.77 0.00,11.77
8 2.91,18.27 2.41,17.77 1.91,17.27 1.41,16.77 0.91,16.27 0.41,15.77 0.00,15.27 0.00,14.77 0.00,14.27 0.00,13.27
9 3.31,19.46 3.00,18.96 2.51,18.46 2.01,17.96 1.51,17.46 1.01,16.96 0.51,16.46 0.01,15.96 0.00,15.46 0.00,14.46
10 3.68,20.83 3.37,20.33 3.07,19.83 2.63,19.33 2.13,18.83 1.63,18.33 1.13,17.83 0.63,17.33 0.13,16.83 0.00,15.83
11 4.05,22.31 3.73,21.81 3.43,21.31 3.14,20.81 2.77,20.31 2.27,19.81 1.77,19.31 1.27,18.81 0.77,18.31 0.00,17.31
12 4.41,23.80 4.10,23.30 3.80,22.80 3.50,22.30 3.22,21.80 2.93,21.30 2.43,20.80 1.93,20.30 1.43,19.80 0.43,18.80
13 5.83,24.92 5.33,24.42 4.83,23.92 4.33,23.42 3.83,22.92 3.33,22.42 3.02,21.92 2.60,21.42 2.10,20.92 1.10,19.92
14 6.31,26.33 5.81,25.83 5.31,25.33 4.86,24.83 4.46,24.33 4.10,23.83 3.67,23.33 3.17,22.83 2.78,22.33 1.78,21.33
15 6.70,27.81 6.20,27.31 5.70,26.81 5.24,26.31 4.84,25.81 4.48,25.31 4.14,24.81 3.82,24.31 3.42,23.81 2.48,22.81
16 7.76,28.85 7.26,28.35 6.76,27.85 6.26,27.35 5.76,26.85 5.26,26.35 4.76,25.85 4.26,25.35 3.89,24.85 3.15,23.85
17 8.32,30.33 7.82,29.83 7.32,29.33 6.82,28.83 6.32,28.33 5.85,27.83 5.42,27.33 5.03,26.83 4.67,26.33 3.73,25.33
18 8.71,31.81 8.21,31.31 7.71,30.81 7.21,30.31 6.71,29.81 6.24,29.31 5.82,28.81 5.42,28.31 5.06,27.81 4.37,26.81
19 9.88,32.85 9.38,32.35 8.88,31.85 8.38,31.35 7.88,30.85 7.38,30.35 6.88,29.85 6.40,29.35 5.97,28.85 5.01,27.85
20 10.28,34.32 9.78,33.82 9.28,33.32 8.78,32.82 8.28,32.32 7.78,31.82 7.28,31.32 6.81,30.82 6.37,30.32 5.57,29.32"""

_fc99str2=r"""0 0.00,2.91 0.00,2.90 0.00,2.89 0.00,2.88 0.00,2.88 0.00,2.87 0.00,2.87 0.00,2.86 0.00,2.86 0.00,2.86
1 0.00,3.42 0.00,3.31 0.00,3.21 0.00,3.18 0.00,3.15 0.00,3.11 0.00,3.09 0.00,3.07 0.00,3.06 0.00,3.03
2 0.00,4.13 0.00,3.89 0.00,3.70 0.00,3.56 0.00,3.44 0.00,3.39 0.00,3.35 0.00,3.32 0.00,3.26 0.00,3.23
3 0.00,5.25 0.00,4.59 0.00,4.35 0.00,4.06 0.00,3.89 0.00,3.77 0.00,3.65 0.00,3.56 0.00,3.51 0.00,3.47
4 0.00,6.47 0.00,5.73 0.00,5.04 0.00,4.79 0.00,4.39 0.00,4.17 0.00,4.02 0.00,3.91 0.00,3.82 0.00,3.74
5 0.00,7.81 0.00,6.97 0.00,6.21 0.00,5.50 0.00,5.17 0.00,4.67 0.00,4.42 0.00,4.24 0.00,4.11 0.00,4.01
6 0.00,9.27 0.00,8.32 0.00,7.47 0.00,6.68 0.00,5.96 0.00,5.46 0.00,5.05 0.00,4.83 0.00,4.63 0.00,4.44
7 0.00,10.77 0.00,9.77 0.00,8.82 0.00,7.95 0.00,7.16 0.00,6.42 0.00,5.73 0.00,5.48 0.00,5.12 0.00,4.82
8 0.00,12.27 0.00,11.27 0.00,10.27 0.00,9.31 0.00,8.44 0.00,7.63 0.00,6.88 0.00,6.18 0.00,5.83 0.00,5.29
9 0.00,13.46 0.00,12.46 0.00,11.46 0.00,10.46 0.00,9.46 0.00,8.50 0.00,7.69 0.00,7.34 0.00,6.62 0.00,5.95
10 0.00,14.83 0.00,13.83 0.00,12.83 0.00,11.83 0.00,10.83 0.00,9.87 0.00,8.98 0.00,8.16 0.00,7.39 0.00,7.07
11 0.00,16.31 0.00,15.31 0.00,14.31 0.00,13.31 0.00,12.31 0.00,11.31 0.00,10.35 0.00,9.46 0.00,8.63 0.00,7.84
12 0.00,17.80 0.00,16.80 0.00,15.80 0.00,14.80 0.00,13.80 0.00,12.80 0.00,11.80 0.00,10.83 0.00,9.94 0.00,9.09
13 0.10,18.92 0.00,17.92 0.00,16.92 0.00,15.92 0.00,14.92 0.00,13.92 0.00,12.92 0.00,11.92 0.00,10.92 0.00,9.98
14 0.78,20.33 0.00,19.33 0.00,18.33 0.00,17.33 0.00,16.33 0.00,15.33 0.00,14.33 0.00,13.33 0.00,12.33 0.00,11.36
15 1.48,21.81 0.48,20.81 0.00,19.81 0.00,18.81 0.00,17.81 0.00,16.81 0.00,15.81 0.00,14.81 0.00,13.81 0.00,12.81
16 2.18,22.85 1.18,21.85 0.18,20.85 0.00,19.85 0.00,18.85 0.00,17.85 0.00,16.85 0.00,15.85 0.00,14.85 0.00,13.85
17 2.89,24.33 1.89,23.33 0.89,22.33 0.00,21.33 0.00,20.33 0.00,19.33 0.00,18.33 0.00,17.33 0.00,16.33 0.00,15.33
18 3.53,25.81 2.62,24.81 1.62,23.81 0.62,22.81 0.00,21.81 0.00,20.81 0.00,19.81 0.00,18.81 0.00,17.81 0.00,16.81
19 4.13,26.85 3.31,25.85 2.35,24.85 1.35,23.85 0.35,22.85 0.00,21.85 0.00,20.85 0.00,19.85 0.00,18.85 0.00,17.85
20 4.86,28.32 3.93,27.32 3.08,26.32 2.08,25.32 1.08,24.32 0.08,23.32 0.00,22.32 0.00,21.32 0.00,20.32 0.00,19.32"""


_fcg=r"""-3.0 0.00 0.04 0.00 0.26 0.00 0.42 0.00 0.80
-2.9 0.00 0.04 0.00 0.27 0.00 0.44 0.00 0.82
-2.8 0.00 0.04 0.00 0.28 0.00 0.45 0.00 0.84
-2.7 0.00 0.04 0.00 0.29 0.00 0.47 0.00 0.87
-2.6 0.00 0.05 0.00 0.30 0.00 0.48 0.00 0.89
-2.5 0.00 0.05 0.00 0.32 0.00 0.50 0.00 0.92
-2.4 0.00 0.05 0.00 0.33 0.00 0.52 0.00 0.95
-2.3 0.00 0.05 0.00 0.34 0.00 0.54 0.00 0.99
-2.2 0.00 0.06 0.00 0.36 0.00 0.56 0.00 1.02
-2.1 0.00 0.06 0.00 0.38 0.00 0.59 0.00 1.06
-2.0 0.00 0.07 0.00 0.40 0.00 0.62 0.00 1.10
-1.9 0.00 0.08 0.00 0.43 0.00 0.65 0.00 1.14
-1.8 0.00 0.09 0.00 0.45 0.00 0.68 0.00 1.19
-1.7 0.00 0.10 0.00 0.48 0.00 0.72 0.00 1.24
-1.6 0.00 0.11 0.00 0.52 0.00 0.76 0.00 1.29
-1.5 0.00 0.13 0.00 0.56 0.00 0.81 0.00 1.35
-1.4 0.00 0.15 0.00 0.60 0.00 0.86 0.00 1.41
-1.3 0.00 0.17 0.00 0.64 0.00 0.91 0.00 1.47
-1.2 0.00 0.20 0.00 0.70 0.00 0.97 0.00 1.54
-1.1 0.00 0.23 0.00 0.75 0.00 1.04 0.00 1.61
-1.0 0.00 0.27 0.00 0.81 0.00 1.10 0.00 1.68
-0.9 0.00 0.32 0.00 0.88 0.00 1.17 0.00 1.76
-0.8 0.00 0.37 0.00 0.95 0.00 1.25 0.00 1.84
-0.7 0.00 0.43 0.00 1.02 0.00 1.33 0.00 1.93
-0.6 0.00 0.49 0.00 1.10 0.00 1.41 0.00 2.01
-0.5 0.00 0.56 0.00 1.18 0.00 1.49 0.00 2.10
-0.4 0.00 0.64 0.00 1.27 0.00 1.58 0.00 2.19
-0.3 0.00 0.72 0.00 1.36 0.00 1.67 0.00 2.28
-0.2 0.00 0.81 0.00 1.45 0.00 1.77 0.00 2.38
-0.1 0.00 0.90 0.00 1.55 0.00 1.86 0.00 2.48
0.0 0.00 1.00 0.00 1.64 0.00 1.96 0.00 2.58
0.1 0.00 1.10 0.00 1.74 0.00 2.06 0.00 2.68
0.2 0.00 1.20 0.00 1.84 0.00 2.16 0.00 2.78
0.3 0.00 1.30 0.00 1.94 0.00 2.26 0.00 2.88
0.4 0.00 1.40 0.00 2.04 0.00 2.36 0.00 2.98
0.5 0.02 1.50 0.00 2.14 0.00 2.46 0.00 3.08
0.6 0.07 1.60 0.00 2.24 0.00 2.56 0.00 3.18
0.7 0.11 1.70 0.00 2.34 0.00 2.66 0.00 3.28
0.8 0.15 1.80 0.00 2.44 0.00 2.76 0.00 3.38
0.9 0.19 1.90 0.00 2.54 0.00 2.86 0.00 3.48
1.0 0.24 2.00 0.00 2.64 0.00 2.96 0.00 3.58
1.1 0.30 2.10 0.00 2.74 0.00 3.06 0.00 3.68
1.2 0.35 2.20 0.00 2.84 0.00 3.16 0.00 3.78
1.3 0.42 2.30 0.02 2.94 0.00 3.26 0.00 3.88
1.4 0.49 2.40 0.12 3.04 0.00 3.36 0.00 3.98
1.5 0.56 2.50 0.22 3.14 0.00 3.46 0.00 4.08
1.6 0.64 2.60 0.31 3.24 0.00 3.56 0.00 4.18
1.7 0.72 2.70 0.38 3.34 0.06 3.66 0.00 4.28
1.8 0.81 2.80 0.45 3.44 0.16 3.76 0.00 4.38
1.9 0.90 2.90 0.51 3.54 0.26 3.86 0.00 4.48
2.0 1.00 3.00 0.58 3.64 0.35 3.96 0.00 4.58
2.1 1.10 3.10 0.65 3.74 0.45 4.06 0.00 4.68
2.2 1.20 3.20 0.72 3.84 0.53 4.16 0.00 4.78
2.3 1.30 3.30 0.79 3.94 0.61 4.26 0.00 4.88
2.4 1.40 3.40 0.87 4.04 0.69 4.36 0.07 4.98
2.5 1.50 3.50 0.95 4.14 0.76 4.46 0.17 5.08
2.6 1.60 3.60 1.02 4.24 0.84 4.56 0.27 5.18
2.7 1.70 3.70 1.11 4.34 0.91 4.66 0.37 5.28
2.8 1.80 3.80 1.19 4.44 0.99 4.76 0.47 5.38
2.9 1.90 3.90 1.28 4.54 1.06 4.86 0.57 5.48
3.0 2.00 4.00 1.37 4.64 1.14 4.96 0.67 5.58
3.1 2.10 4.10 1.46 4.74 1.22 5.06 0.77 5.68"""


_fcbg=r"""0.0 1.29 2.44 3.09 4.74
0.5 1.52 2.86 3.59 5.28
1.0 1.82 3.28 4.05 5.79
1.5 2.07 3.62 4.43 6.27
2.0 2.29 3.94 4.76 6.69
2.5 2.45 4.20 5.08 7.11
3.0 2.62 4.42 5.36 7.49
3.5 2.78 4.63 5.62 7.87
4.0 2.91 4.83 5.86 8.18
5.0 3.18 5.18 6.32 8.76
6.0 3.43 5.53 6.75 9.35
7.0 3.63 5.90 7.14 9.82
8.0 3.86 6.18 7.49 10.27
9.0 4.03 6.49 7.81 10.69
10.0 4.20 6.76 8.13 11.09
11.0 4.42 7.02 8.45 11.46
12.0 4.56 7.28 8.72 11.83
13.0 4.71 7.51 9.01 12.22
14.0 4.87 7.75 9.27 12.56
15.0 5.03 7.99 9.54 12.90"""



# convert the tables from the paper to an usable array

def _decode_interval(lo,hi):
    interval = np.zeros((21,20,2))
    arr = lo.split(sep='\n')
    for fg in range(21):
        li = arr[fg].split(sep=' ')
        for k in range(1,11):
            lowhi = li[k].split(sep=',')
            interval[fg,k-1,0] = float(lowhi[0])
            interval[fg,k-1,1] = float(lowhi[1])
    arr = hi.split(sep='\n')
    for fg in range(21):
        li = arr[fg].split(sep=' ')
        for k in range(1,11):
            lowhi = li[k].split(sep=',')
            interval[fg,k-1+10,0] = float(lowhi[0])
            interval[fg,k-1+10,1] = float(lowhi[1])
    return interval

_interval68 = _decode_interval(_fc68str1,_fc68str2)        # fg,bgindex,interval (interval: 0 = low,1= high)
_interval90 = _decode_interval(_fc90str1,_fc90str2)
_interval95 = _decode_interval(_fc95str1,_fc95str2)
_interval99 = _decode_interval(_fc99str1,_fc99str2)


def _decode_gauss(s):
    gauss = np.zeros((62,4,2))
    x0 = np.zeros((62,))
    arr = s.split(sep='\n')
    for fg in range(62):
        li = arr[fg].split(sep=' ')
        x0[fg] = float(li[0])
        for k in range(1,9):
            gauss[fg, (k-1) // 2, (k-1) % 2] = float(li[k])
    return x0,gauss

_x0,_gausslimits = _decode_gauss(_fcg)



def _decode_sensitivity(s):
    sens = np.zeros((20,4))
    x0 = np.zeros((20,))
    arr = s.split(sep='\n')
    for fg in range(20):
        li = arr[fg].split(sep=' ')
        x0[fg] = float(li[0])
        for k in range(1,5):
            sens[fg, k-1] = float(li[k])
    return x0,sens

_x0s,_senslimits = _decode_sensitivity(_fcbg)

# not use these data


[docs]def scalar_confinterval68(n0,background): r""" Returns 68% confidence interval for n0-backgorund. n0 must be an integer >=0, background is a float number. This function only accepts scalars and not numpy arrays. """ if not np.isfinite(n0): return np.nan, np.nan assert n0>=0 assert background >= 0.0 if (background <= 15.0) and (n0 <= 20): # Poisson approximation for low count rates n0ind = int(n0+0.5) lowlimit = np.interp(background,_fcbackground,_interval68[n0ind,:,0]) highlimit = np.interp(background,_fcbackground,_interval68[n0ind,:,1]) else: # check if a gaussian approximation is reasonable sigma = (n0+background)**0.5 # this is a bit too large n0norm = (n0-background)/sigma if n0norm >= min(_x0) and n0norm <= max(_x0): # interpolate using limited gauss lowlimit = np.interp(n0norm,_x0,_gausslimits[:,0,0])*sigma highlimit = np.interp(n0norm,_x0,_gausslimits[:,0,1])*sigma elif n0norm <= min(_x0): # very large background and small n0, something is weird lowlimit = np.nan highlimit = np.nan else: # large numbers limit can be used try: e = n0 - background lowlimit = e-1.0*sigma highlimit = e+1.0*sigma except: lowlimit = np.nan highlimit = np.nan return lowlimit,highlimit
[docs]def scalar_confinterval90(n0,background): r""" Returns 90% confidence interval for n0-backgorund. n0 must be an integer >=0, background is a float number >= 0.0. This function only accepts scalars and not numpy arrays. """ if not np.isfinite(n0): return np.nan, np.nan assert n0>=0 assert background >= 0.0 if (background <= 15.0) and (n0 <= 20): # Poisson approximation for low count rates n0ind = int(n0+0.5) lowlimit = np.interp(background,_fcbackground,_interval90[n0ind,:,0]) highlimit = np.interp(background,_fcbackground,_interval90[n0ind,:,1]) else: # check if a gaussian approximation is reasonable sigma = (n0+background)**0.5 n0norm = (n0-background)/sigma if n0norm >= min(_x0) and n0norm <= max(_x0): # interpolate using limited gauss lowlimit = np.interp(n0norm,_x0,_gausslimits[:,1,0])*sigma highlimit = np.interp(n0norm,_x0,_gausslimits[:,1,1])*sigma elif n0norm <= min(_x0): # very large background and small n0, something is weird lowlimit = np.nan highlimit = np.nan else: # large numbers limit can be used try: e = n0 - background lowlimit = e-1.645*sigma highlimit = e+1.645*sigma except: lowlimit = np.nan highlimit = np.nan return lowlimit,highlimit
[docs]def scalar_confinterval95(n0,background): r""" Returns 95% confidence interval for n0-backgorund. n0 must be an integer >=0, background is a float number >= 0.0. This function only accepts scalars and not numpy arrays. """ if not np.isfinite(n0): return np.nan, np.nan assert n0>=0 assert background >= 0.0 if (background <= 15.0) and (n0 <= 20): # Poisson approximation for low count rates n0ind = int(n0+0.5) lowlimit = np.interp(background,_fcbackground,_interval95[n0ind,:,0]) highlimit = np.interp(background,_fcbackground,_interval95[n0ind,:,1]) else: # check if a gaussian approximation is reasonable sigma = (n0+background)**0.5 n0norm = (n0-background)/sigma if n0norm >= min(_x0) and n0norm <= max(_x0): # interpolate using limited gauss lowlimit = np.interp(n0norm,_x0,_gausslimits[:,2,0])*sigma highlimit = np.interp(n0norm,_x0,_gausslimits[:,2,1])*sigma elif n0norm <= min(_x0): # very large background and small n0, something is weird lowlimit = np.nan highlimit = np.nan else: # large numbers limit can be used try: e = n0 - background lowlimit = e-2.0*sigma highlimit = e+2.0*sigma except: lowlimit = np.nan highlimit = np.nan return lowlimit,highlimit
[docs]def scalar_confinterval99(n0,background): r""" Returns 99% confidence interval for n0-backgorund. n0 must be an integer >=0, background is a float number >= 0.0. This function only accepts scalars and not numpy arrays. """ if not np.isfinite(n0): return np.nan, np.nan assert n0 >= 0 assert background >= 0.0 if (background <= 15.0) and (n0 <= 20): # Poisson approximation for low count rates n0ind = int(n0+0.5) lowlimit = np.interp(background,_fcbackground,_interval99[n0ind,:,0]) highlimit = np.interp(background,_fcbackground,_interval99[n0ind,:,1]) else: # check if a gaussian approximation is reasonable sigma = (n0+background)**0.5 n0norm = (n0-background)/sigma if n0norm >= min(_x0) and n0norm <= max(_x0): # interpolate using limited gauss lowlimit = np.interp(n0norm,_x0,_gausslimits[:,3,0])*sigma highlimit = np.interp(n0norm,_x0,_gausslimits[:,3,1])*sigma elif n0norm <= min(_x0): # very large background and small n0, something is weird lowlimit = np.nan highlimit = np.nan else: # large numbers limit can be used try: e = n0 - background lowlimit = e-3.0*sigma highlimit = e+3.0*sigma except: lowlimit = np.nan highlimit = np.nan return lowlimit,highlimit
[docs]def scalar_sensitivity68(background): r""" returns 68% an upper limit for the signal assuming there are is zero counts measured and a background is present. """ assert background >= 0.0 if background <=15.0: bg = np.interp(background,_x0s,_senslimits[:,0]) else: bg = 1.3*background**0.5 # note that this is slightly wrong! return bg
[docs]def scalar_sensitivity90(background): r""" returns 90% an upper limit for the signal assuming there are is zero counts measured and a background is present. """ assert background >= 0.0 if background <=15.0: bg = np.interp(background,_x0s,_senslimits[:,1]) else: bg = 1.25*1.645*(background**0.5) # note that this is slightly wrong! return bg
[docs]def scalar_sensitivity95(background): r""" returns 95% an upper limit for the signal assuming there are is zero counts measured and a background is present. """ assert background >= 0.0 if background <=15.0: bg = np.interp(background,_x0s,_senslimits[:,2]) else: bg = 2.45*(background**0.5) # note that this is slightly wrong! return bg
[docs]def scalar_sensitivity99(background): r""" returns 99% an upper limit for the signal assuming there are is zero counts measured and a background is present. """ assert background >= 0.0 if background <=15.0: bg = np.interp(background,_x0s,_senslimits[:,3]) else: bg = 3.30*(background**0.5) # note that this is slightly wrong! return bg
# vectorize everything confinterval68 = np.vectorize(scalar_confinterval68) confinterval90 = np.vectorize(scalar_confinterval90) confinterval95 = np.vectorize(scalar_confinterval95) confinterval99 = np.vectorize(scalar_confinterval99) sensitivity68 = np.vectorize(scalar_sensitivity68) sensitivity90 = np.vectorize(scalar_sensitivity90) sensitivity95 = np.vectorize(scalar_sensitivity95) sensitivity99 = np.vectorize(scalar_sensitivity99) import unittest import doctest
[docs]def doctests(): return unittest.TestSuite(( doctest.DocTestSuite(), ))
if __name__ == '__main__': unittest.main(defaultTest='doctests')