cpp-stat-bench 0.24.0
Benchmark library with statistics for C++.
Loading...
Searching...
No Matches
statistics.h
Go to the documentation of this file.
1/*
2 * Copyright 2021 MusicScience37 (Kenta Kabashima)
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
20#pragma once
21
22#include <utility>
23#include <vector>
24
25namespace stat_bench {
26namespace stat {
27
32public:
46 Statistics(std::vector<double> unsorted_samples,
47 std::vector<double> sorted_samples, double mean, double max, double min,
48 double median, double variance, double standard_deviation,
49 double standard_error)
50 : unsorted_samples_(std::move(unsorted_samples)),
51 sorted_samples_(std::move(sorted_samples)),
52 mean_(mean),
53 max_(max),
54 min_(min),
55 median_(median),
56 variance_(variance),
57 standard_deviation_(standard_deviation),
58 standard_error_(standard_error) {}
59
64 [[nodiscard]] auto unsorted_samples() const noexcept
65 -> const std::vector<double>& {
66 return unsorted_samples_;
67 }
68
74 [[nodiscard]] auto sorted_samples() const noexcept
75 -> const std::vector<double>& {
76 return sorted_samples_;
77 }
78
84 [[nodiscard]] auto mean() const noexcept -> double { return mean_; }
85
91 [[nodiscard]] auto max() const noexcept -> double { return max_; }
92
98 [[nodiscard]] auto min() const noexcept -> double { return min_; }
99
105 [[nodiscard]] auto median() const noexcept -> double { return median_; }
106
112 [[nodiscard]] auto variance() const noexcept -> double { return variance_; }
113
119 [[nodiscard]] auto standard_deviation() const noexcept -> double {
120 return standard_deviation_;
121 }
122
128 [[nodiscard]] auto standard_error() const noexcept -> double {
129 return standard_error_;
130 }
131
132private:
134 std::vector<double> unsorted_samples_;
135
137 std::vector<double> sorted_samples_;
138
140 double mean_;
141
143 double max_;
144
146 double min_;
147
149 double median_;
150
152 double variance_;
153
155 double standard_deviation_;
156
158 double standard_error_;
159};
160
161} // namespace stat
162} // namespace stat_bench
auto unsorted_samples() const noexcept -> const std::vector< double > &
Get the unsorted samples.
Definition statistics.h:64
auto min() const noexcept -> double
Get the min.
Definition statistics.h:98
auto variance() const noexcept -> double
Get the variance.
Definition statistics.h:112
auto median() const noexcept -> double
Get the median.
Definition statistics.h:105
auto max() const noexcept -> double
Get the max.
Definition statistics.h:91
auto standard_error() const noexcept -> double
Get the standard error.
Definition statistics.h:128
auto sorted_samples() const noexcept -> const std::vector< double > &
Get the sorted samples.
Definition statistics.h:74
auto standard_deviation() const noexcept -> double
Get the standard deviation.
Definition statistics.h:119
auto mean() const noexcept -> double
Get the mean.
Definition statistics.h:84
Statistics(std::vector< double > unsorted_samples, std::vector< double > sorted_samples, double mean, double max, double min, double median, double variance, double standard_deviation, double standard_error)
Constructor.
Definition statistics.h:46
Namespace of statistics.
Definition calc_stat.h:29
Namespace of stat_bench source codes.
STL namespace.