50 template <
class T,
class U>
54 throw RuntimeException(
"Not a valid first-order univariate t-test context!");
60 const long long noOfRandTraces = randTraces.
noOfTraces();
61 const long long noOfConstTraces = constTraces.
noOfTraces();
63 for (
long long trace = 0; trace < noOfRandTraces; trace++) {
65 for (
long long sample = 0; sample < samplesPerTrace; sample++) {
67 temp = (static_cast<T>(randTraces(sample, trace)) - c.
p1M(1)(sample));
68 c.
p1M(1)(sample) += (temp / static_cast<T>((c.
p1Card() + 1)));
69 c.
p1CS(2)(sample) += temp * (static_cast<T>(randTraces(sample, trace)) - c.
p1M(1)(sample));
76 for (
long long trace = 0; trace < noOfConstTraces; trace++) {
78 for (
long long sample = 0; sample < samplesPerTrace; sample++) {
80 temp = (static_cast<T>(constTraces(sample, trace)) - c.
p2M(1)(sample));
81 c.
p2M(1)(sample) += (temp / static_cast<T>((c.
p2Card() + 1)));
82 c.
p2CS(2)(sample) += temp * (static_cast<T>(constTraces(sample, trace)) - c.
p2M(1)(sample));
101 throw RuntimeException(
"Not valid first-order univariate t-test contexts!");
104 throw RuntimeException(
"Only contexts with same number of samples per trace can be merged");
106 const size_t samplesPerTrace = firstAndOut.
p1Width();
110 size_t firstSize = firstAndOut.
p1Card();
111 size_t secondSize = second.
p1Card();
113 for(
size_t sample = 0; sample < samplesPerTrace; sample++) {
114 firstAndOut.
p1CS(2)(sample) += second.
p1CS(2)(sample);
115 firstAndOut.
p1CS(2)(sample) += (firstSize * secondSize) *
116 ( (second.
p1M(1)(sample) - firstAndOut.
p1M(1)(sample)) / (firstSize + secondSize) ) *
117 ( (second.
p1M(1)(sample) - firstAndOut.
p1M(1)(sample)) / (firstSize + secondSize) ) *
118 (firstSize + secondSize);
121 for(
size_t sample = 0; sample < samplesPerTrace; sample++) {
122 firstAndOut.
p1M(1)(sample) = ( (firstAndOut.
p1M(1)(sample) * firstSize) + (second.
p1M(1)(sample) * secondSize) ) / (firstSize + secondSize);
127 firstSize = firstAndOut.
p2Card();
128 secondSize = second.
p2Card();
130 for(
size_t sample = 0; sample < samplesPerTrace; sample++) {
131 firstAndOut.
p2CS(2)(sample) += second.
p2CS(2)(sample);
132 firstAndOut.
p2CS(2)(sample) += (firstSize * secondSize) *
133 ( (second.
p2M(1)(sample) - firstAndOut.
p2M(1)(sample)) / (firstSize + secondSize) ) *
134 ( (second.
p2M(1)(sample) - firstAndOut.
p2M(1)(sample)) / (firstSize + secondSize) ) *
135 (firstSize + secondSize);
140 for(
size_t sample = 0; sample < samplesPerTrace; sample++) {
141 firstAndOut.
p2M(1)(sample) = ( (firstAndOut.
p2M(1)(sample) * firstSize) + (second.
p2M(1)(sample) * secondSize) ) / (firstSize + secondSize);
159 throw RuntimeException(
"Not a valid first-order univariate t-test context!");
161 size_t samplesPerTrace = c.
p1Width();
163 tValsDegs.
init(samplesPerTrace, 2);
165 for(
size_t sample = 0; sample < samplesPerTrace; sample++){
168 tValsDegs(sample, 0) = (c.
p2M(1)(sample) - c.
p1M(1)(sample))
169 / sqrt(((c.
p2CS(2)(sample) / (
double)(c.
p2Card() - 1)) / (double)c.
p2Card())
173 tValsDegs(sample, 1) = ( ( ( (c.
p2CS(2)(sample) / (
double)(c.
p2Card() - 1) ) / (double)c.
p2Card() )
174 + ( (c.
p1CS(2)(sample) / (
double)(c.
p1Card() - 1) ) / (double)c.
p1Card() ) )
175 * ( ( (c.
p2CS(2)(sample) / (
double)(c.
p2Card() - 1) ) / (double)c.
p2Card() )
176 + ( (c.
p1CS(2)(sample) / (
double)(c.
p1Card() - 1) ) / (double)c.
p1Card() ) ) )
178 ( ( ( ( (c.
p2CS(2)(sample) / (
double)(c.
p2Card() - 1) ) / (double)c.
p2Card() )
179 * ( (c.
p2CS(2)(sample) / (
double)(c.
p2Card() - 1) ) / (double)c.
p2Card() ) )
180 / (double)(c.
p2Card() - 1) )
181 + ( ( ( (c.
p1CS(2)(sample) / (
double)(c.
p1Card() - 1) ) / (double)c.
p1Card())
183 / (double)(c.
p1Card() - 1) ) );
virtual size_t noOfTraces() const
Returns number of power traces.
Definition: types_power.hpp:67
An abstract class, representing all the matrix-like data types.
Definition: types_basic.hpp:132
A class representing a Two-population Univariate Moment-based statistical context.
Definition: types_stat.hpp:43
This header file contains exceptions.
void UniFoTTestMergeContexts(UnivariateContext< T > &firstAndOut, const UnivariateContext< T > &second)
Merges two UnivariateContext and leaves the result in first context given.
Definition: ompttest.hpp:97
virtual size_t mOrder() const
Maximum order of the raw moments, 1 upto mOrder.
Definition: types_stat.hpp:183
virtual size_t csOrder() const
Maximum order of the central moment sums, 2 upto csOrder.
Definition: types_stat.hpp:185
void UniFoTTestComputeTValsDegs(const UnivariateContext< T > &c, MatrixType< T > &tValsDegs)
Computes final t-values and degrees of freedom based on a UnivariateContext given,...
Definition: ompttest.hpp:156
virtual void init(size_t cols, size_t rows)=0
Initializes the matrix with a specified number of cols and rows.
void UniFoTTestAddTraces(UnivariateContext< T > &c, const PowerTraces< U > &randTraces, const PowerTraces< U > &constTraces)
Adds given random and constant power traces to the given statistical context. Use zeroed or meaningfu...
Definition: ompttest.hpp:51
virtual size_t p2Width() const
Width of the second population.
Definition: types_stat.hpp:180
virtual size_t & p1Card()
Cardinality of the first population.
Definition: types_stat.hpp:190
virtual size_t p1Width() const
Width of the first population.
Definition: types_stat.hpp:178
virtual size_t acsOrder() const
Maximum order of the adjusted central moment sums, 1 upto acsOrder.
Definition: types_stat.hpp:187
virtual Vector< T > & p2CS(size_t order)
Central moment sum of the second population, order 2 upto csOrder.
Definition: types_stat.hpp:215
This header file contains class templates of power traces and power consumption containers.
virtual size_t samplesPerTrace() const
Returns number of samples per trace.
Definition: types_power.hpp:65
virtual size_t & p2Card()
Cardinality of the second population.
Definition: types_stat.hpp:195
virtual Vector< T > & p1CS(size_t order)
Central moment sum of the first population, order 2 upto csOrder.
Definition: types_stat.hpp:210
virtual Vector< T > & p2M(size_t order)
Raw moment of the second population, order 1 upto mOrder.
Definition: types_stat.hpp:205
An exception which cannot be directly influenced by the user, or predicted beforehand.
Definition: exceptions.hpp:76
This header file contains class templates of statistical computational contexts.
A class representing a Matrix with 'noOfTraces' power traces, with 'samplesPerTrace' samples per powe...
Definition: types_power.hpp:44
virtual Vector< T > & p1M(size_t order)
Raw moment of the first population, order 1 upto mOrder.
Definition: types_stat.hpp:200