pub struct Metrics {
pub basic: BasicMetrics,
pub shape: ShapeMetrics,
pub range: RangeMetrics,
pub trend: TrendMetrics,
pub risk: RiskMetrics,
}Expand description
Represents a comprehensive set of statistical and analytical metrics for curve data.
§Overview
The CurveMetrics structure aggregates various metrics that describe different
aspects of a curve in a unified form. It provides an encapsulated representation of
curve information that spans different categories, including basic statistical measures,
shape characteristics, range details, trend analysis, and risk evaluation.
§Usage
This structure is particularly helpful in domains requiring holistic curve analysis, such as:
- Financial Analysis: Used to analyze return curves and assess the risk-return trade-offs for financial products or strategies.
- Data Science: Provides comprehensive insights into a dataset’s distribution, shape, and trends over time.
- Scientific Research: Useful for analyzing phenomena modeled by curves in domains like physics, biology, or economics.
§Field Descriptions
- basic:
BasicMetrics- Contains mean, median, mode, and standard deviation of the dataset.
- shape:
ShapeMetrics- Captures the shape-related characteristics such as skewness, kurtosis, and extrema (peaks/valleys).
- range:
RangeMetrics- Includes range, min/max points, and quartiles for the dataset.
- trend:
TrendMetrics- Represents the directional tendencies, moving averages, and regression characteristics.
- risk:
RiskMetrics- Evaluates financial risk metrics such as volatility and Sharpe ratio.
§Example Workflow
The CurveMetrics structure is usually constructed by combining its fields using the individual
metric structures (BasicMetrics, ShapeMetrics, RangeMetrics, TrendMetrics, RiskMetrics).
It is often initialized as part of a larger curve analysis operation and may be transformed or queried for
generating insights.
§Related Concepts
BasicMetrics: Encodes fundamental statistics.ShapeMetrics: Provides characteristics associated with curve shape.RangeMetrics: Range and quartile information for a curve.TrendMetrics: Trendline and regression fit metrics.RiskMetrics: Quantifies financial risk.
§Examples of Associated Tools
- Statistical Analysis: Plots, descriptive statistics, trend analysis.
- Visualizations: Understand curve behavior (e.g., peaks, valleys).
- Financial Metrics: Sharpe ratio, coefficient of variation, and VaR for understanding portfolio risks.
§Remarks
The CurveMetrics struct is designed to be reusable across various analytical contexts,
providing a versatile and standardized way to represent curve characteristics.
Fields§
§basic: BasicMetrics- Basic Metrics (
basic): Includes fundamental statistical measures such as mean, median, mode, and standard deviation. These measures provide a quick overview of the distribution of the observations within the curve.
shape: ShapeMetrics- Shape Metrics (
shape): Captures the structural characteristics of the curve, such as skewness, kurtosis, the locations of peaks and valleys, and the points where the curve inflects. Useful for understanding curve symmetry, tail behavior, and general shape nuances.
range: RangeMetrics- Range Metrics (
range): Describes the range of the data, including minimum and maximum observed points, the extent between these points, and quartile-based statistical details such as interquartile range. Particularly helpful when analyzing variability in data distribution.
trend: TrendMetrics- Trend Metrics (
trend): Measures the directional tendencies of the curve over time. Includes the slope, intercept, and statistical goodness-of-fit (R² value) as well as moving averages. Ideal for identifying long-term trends and evaluating the predictive nature of the curve.
risk: RiskMetrics- Risk Metrics (
risk): Quantifies curve risk using various financial metrics, such as volatility, value-at-risk (VaR), expected shortfall, coefficient of variation, and the Sharpe ratio. These metrics are often used to evaluate the risk-return profile in financial contexts.
Implementations§
Source§impl Metrics
Represents a set of metrics associated with analyzing and interpreting a curve.
impl Metrics
Represents a set of metrics associated with analyzing and interpreting a curve.
This structure encapsulates multiple types of metrics, each responsible for a specific aspect of curve analysis. These include basic statistical measures, shape-related properties, range characteristics, trend analysis, and risk factors.
§Fields
basic: Basic statistical metrics such as mean, median, mode, and standard deviation.shape: Metrics that describe the shape of the curve, such as skewness, kurtosis, and points of interest (peaks, valleys, and inflection points).range: Range-based metrics specifying properties like the minimum and maximum values on the curve, quartiles, and interquartile range.trend: Metrics related to overall trends in the curve, such as slope, intercept, R-squared value, and moving average data points.risk: Risk-related metrics, including volatility, value at risk (VaR), expected shortfall, coefficient of variation, and the Sharpe ratio.
§Notes
This implementation ensures modularity by separating distinct aspects of curve analysis into specific metric structures. These metrics can be used individually or collectively for advanced data analysis or curve interpretation tasks.
§Related Structures
BasicMetrics: Provides basic statistical metrics about the dataset.ShapeMetrics: Describes the geometric properties of the curve.RangeMetrics: Assesses the range and quartile characteristics of the curve.TrendMetrics: Analyzes trends within the data to understand directional behavior.RiskMetrics: Highlights risk-based metrics for financial, statistical, or analytical use cases.AnalysisResult: The result type combining key metrics into a single analytic perspective.CurveError: Represents potential errors that may arise during curve analysis operations.
Sourcepub fn new(
basic: BasicMetrics,
shape: ShapeMetrics,
range: RangeMetrics,
trend: TrendMetrics,
risk: RiskMetrics,
) -> Self
pub fn new( basic: BasicMetrics, shape: ShapeMetrics, range: RangeMetrics, trend: TrendMetrics, risk: RiskMetrics, ) -> Self
§new
Constructs a new instance of CurveMetrics and initializes all relevant fields with the provided
metric structures.
§Parameters:
basic: An instance ofBasicMetrics, holding essential statistical information.shape: An instance ofShapeMetrics, measuring the geometric properties of the curve.range: An instance ofRangeMetrics, describing the range and distribution of the curve.trend: An instance ofTrendMetrics, detailing trend-based analytical results.risk: An instance ofRiskMetrics, specifying the risk characteristics related to the curve.
§Returns:
- A new
CurveMetricsinstance containing the provided metrics.
Sourcepub fn analysis_result(&self) -> Result<AnalysisResult, CurveError>
pub fn analysis_result(&self) -> Result<AnalysisResult, CurveError>
§curve_analysis_result
Generates a high-level analysis result from the metrics encapsulated within the CurveMetrics instance.
§Returns:
Ok(CurveAnalysisResult): A result that contains analyzed data in the form of aAnalysisResultstructure with basic statistics and shape metrics.Err(CurvesError): An error of typeCurveErrorwhen analysis fails.
The result provides the basic statistical measures (BasicMetrics) and
shape metrics (ShapeMetrics) that were part of the CurveMetrics instance.
§Errors
Currently infallible - the conversion is a direct field
re-pack. The Result signature is retained so future
implementations that validate the metrics invariants (e.g.
non-negative variance) can surface
CurveError::MetricsError without breaking callers.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Metrics
impl RefUnwindSafe for Metrics
impl Send for Metrics
impl Sync for Metrics
impl Unpin for Metrics
impl UnsafeUnpin for Metrics
impl UnwindSafe for Metrics
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> PartialSchema for Twhere
T: ComposeSchema + ?Sized,
impl<T> PartialSchema for Twhere
T: ComposeSchema + ?Sized,
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.