Skip to main content

Metrics

Struct Metrics 

Source
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.

§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.

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.

  • 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.
Source

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 of BasicMetrics, holding essential statistical information.
  • shape: An instance of ShapeMetrics, measuring the geometric properties of the curve.
  • range: An instance of RangeMetrics, describing the range and distribution of the curve.
  • trend: An instance of TrendMetrics, detailing trend-based analytical results.
  • risk: An instance of RiskMetrics, specifying the risk characteristics related to the curve.
§Returns:
  • A new CurveMetrics instance containing the provided metrics.
Source

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 a AnalysisResult structure with basic statistics and shape metrics.
  • Err(CurvesError): An error of type CurveError when 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§

Source§

impl Clone for Metrics

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl ComposeSchema for Metrics

Source§

impl Debug for Metrics

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Metrics

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Serialize for Metrics

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl ToSchema for Metrics

Source§

fn name() -> Cow<'static, str>

Return name of the schema. Read more
Source§

fn schemas(schemas: &mut Vec<(String, RefOr<Schema>)>)

Implement reference utoipa::openapi::schema::Schemas for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> PartialSchema for T
where T: ComposeSchema + ?Sized,

Source§

fn schema() -> RefOr<Schema>

Return ref or schema of implementing type that can then be used to construct combined schemas.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more