Cheetah - SKA - PSS - Prototype Time Domain Search Pipeline
PowerSeries.cpp
1 /*
2  * The MIT License (MIT)
3  *
4  * Copyright (c) 2016 The SKA organisation
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in all
14  * copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  */
24 #include "cheetah/data/PowerSeries.h"
25 
26 
27 namespace ska {
28 namespace cheetah {
29 namespace data {
30 
31 using boost::math::complement;
32 using boost::math::cdf;
33 using boost::math::quantile;
34 
35 template <typename Arch, typename ValueType, typename Alloc>
36 PowerSeries<Arch, ValueType, Alloc>::PowerSeries(std::size_t size, Allocator const& allocator)
37  : PowerSeries<Arch, ValueType, Alloc>(1.0 * hz, 2, size, allocator)
38 {
39 }
40 
41 template <typename Arch, typename ValueType, typename Alloc>
43 {
44 }
45 
46 template <typename Arch, typename ValueType, typename Alloc>
48  , std::size_t size, Allocator const& allocator)
49  : FrequencySeries<Arch,ValueType,Alloc>(size, allocator)
50  , _dof(degrees_of_freedom)
51  , _distribution(_dof)
52  , _gaussian()
53 {
54  this->frequency_step(df);
55 }
56 
57 template <typename Arch, typename ValueType, typename Alloc>
59 {
60  return _dof;
61 }
62 
63 template <typename Arch, typename ValueType, typename Alloc>
65 {
66  _dof = degrees_of_freedom;
67  _distribution = ChiSquaredType(_dof);
68 }
69 
70 template <typename Arch, typename ValueType, typename Alloc>
72 {
73  return cdf(complement(_distribution,(double) power));
74 }
75 
76 template <typename Arch, typename ValueType, typename Alloc>
78 {
79  return (float) quantile(complement(_gaussian,pvalue(power)));
80 }
81 
82 template <typename Arch, typename ValueType, typename Alloc>
84 {
85  double p = cdf(complement(_gaussian,(double) sigma));
86  return (float) quantile(complement(_distribution,p));
87 }
88 
89 } // namespace data
90 } // namespace cheetah
91 } // namespace ska
FourierFrequencyType const & frequency_step() const
Retrieve the frequency step of the series.
float power_to_equiv_sigma(float power) const
For a given power level compute the Gaussian equivalent sigma.
Definition: PowerSeries.cpp:77
PowerSeries(std::size_t size=0, Allocator const &allocator=Allocator())
Create a new default PowerSeries instance.
Definition: PowerSeries.cpp:36
A container of Fourier series data.
Some limits and constants for FLDO.
Definition: Brdz.h:35
Class for power series (detected FrequencySeries).
Definition: PowerSeries.h:58
float equiv_sigma_to_power(float sigma) const
Compute the power that corresponds to a Gaussian equivalent sigma.
Definition: PowerSeries.cpp:83
double pvalue(float power) const
Return the statistical probability of a given power level occurring.
Definition: PowerSeries.cpp:71
std::size_t size() const
the size of the series
Definition: Series.cpp:109
double degrees_of_freedom() const
Retreive the (assumed) degrees of freedom of the data distribution.
Definition: PowerSeries.cpp:58