Special Relativity in Financial Modeling 1.0.0
Lorentz transforms, spacetime classification, and geodesic price paths for quantitative finance
Loading...
Searching...
No Matches
Public Member Functions | List of all members
srfm::stream::CoordinateNormalizer Class Reference

Rolling z-score normaliser using Welford's online algorithm. More...

#include <coordinate_normalizer.hpp>

Public Member Functions

 CoordinateNormalizer (std::size_t window)
 Construct with a given rolling window size.
 
void update (double close) noexcept
 Ingest one new close price into the rolling window.
 
double normalise (double close) const noexcept
 Return the z-score of value relative to the current window.
 
double mean () const noexcept
 Rolling mean of the window. 0.0 if window not yet full.
 
double sigma () const noexcept
 Rolling sample standard deviation. 0.0 if window not yet full.
 
std::size_t count () const noexcept
 Number of ticks seen so far (saturates at window size).
 
bool warmed_up () const noexcept
 Whether the window has been filled at least once.
 
std::size_t window () const noexcept
 Configured window size.
 
void reset () noexcept
 Reset all state as if no ticks have been seen.
 

Detailed Description

Rolling z-score normaliser using Welford's online algorithm.

Window size is fixed at construction time. Call update() with each new close price, then normalise() to obtain the current z-score.

for (const auto& tick : ticks) {
norm.update(tick.close);
double z = norm.normalise(tick.close);
// z is 0.0 until the window is full
}
Rolling z-score normaliser using Welford's online algorithm.
void update(double close) noexcept
Ingest one new close price into the rolling window.

Definition at line 61 of file coordinate_normalizer.hpp.

Constructor & Destructor Documentation

◆ CoordinateNormalizer()

srfm::stream::CoordinateNormalizer::CoordinateNormalizer ( std::size_t  window)
inlineexplicit

Construct with a given rolling window size.

Parameters
windowNumber of ticks in the rolling window. Must be ≥ 2.

Definition at line 68 of file coordinate_normalizer.hpp.

Member Function Documentation

◆ count()

std::size_t srfm::stream::CoordinateNormalizer::count ( ) const
inlinenoexcept

Number of ticks seen so far (saturates at window size).

Definition at line 141 of file coordinate_normalizer.hpp.

◆ mean()

double srfm::stream::CoordinateNormalizer::mean ( ) const
inlinenoexcept

Rolling mean of the window. 0.0 if window not yet full.

Definition at line 131 of file coordinate_normalizer.hpp.

◆ normalise()

double srfm::stream::CoordinateNormalizer::normalise ( double  close) const
inlinenoexcept

Return the z-score of value relative to the current window.

Returns 0.0 if the window is not yet full or if the standard deviation is effectively zero (constant price series).

Parameters
valueValue to normalise (typically the current close price).
Note
noexcept — arithmetic only.

Definition at line 120 of file coordinate_normalizer.hpp.

◆ reset()

void srfm::stream::CoordinateNormalizer::reset ( )
inlinenoexcept

Reset all state as if no ticks have been seen.

The window size is preserved.

Definition at line 156 of file coordinate_normalizer.hpp.

◆ sigma()

double srfm::stream::CoordinateNormalizer::sigma ( ) const
inlinenoexcept

Rolling sample standard deviation. 0.0 if window not yet full.

Definition at line 134 of file coordinate_normalizer.hpp.

◆ update()

void srfm::stream::CoordinateNormalizer::update ( double  close)
inlinenoexcept

Ingest one new close price into the rolling window.

Updates the internal circular buffer and the running mean/M2 accumulators using Welford's online algorithm. O(1) per call.

Parameters
closeRaw close price. Must be finite and positive.
Note
noexcept — arithmetic only, no allocation.

Definition at line 89 of file coordinate_normalizer.hpp.

◆ warmed_up()

bool srfm::stream::CoordinateNormalizer::warmed_up ( ) const
inlinenoexcept

Whether the window has been filled at least once.

Definition at line 144 of file coordinate_normalizer.hpp.

◆ window()

std::size_t srfm::stream::CoordinateNormalizer::window ( ) const
inlinenoexcept

Configured window size.

Definition at line 147 of file coordinate_normalizer.hpp.


The documentation for this class was generated from the following file: