invalid_ratio (Descriptive Statistics) 1.x.x.x

Import

#include <archr/stats/invalid_ratio.h>
#include <archr/stats/invalid_ratio.hpp>
import archr.stats
atomsLoads('archr')

Synopsis

  double archr_stats_invalid_ratio_f32(const float *first, size_t nbelem);  (1)  double archr_stats_invalid_ratio_f64(const double *first, size_t nbelem);  (2)
  double invalid_ratio(const float *first, size_t nbelem);  (1)  double invalid_ratio(const double *first, size_t nbelem);  (2)  double invalid_ratio(const float *first, const float *last);  (3)  double invalid_ratio(const double *first, const double *last);  (4) template double invalid_ratio(const Range& data);  (5)
 subroutine archr_stats_invalid_ratio_f32(real(8) :: r, real(4), dimension(*), parameter :: first, integer(4) :: nbelem)  (1) subroutine archr_stats_invalid_ratio_f64(real(8) :: r, real(8), dimension(*), parameter :: first, integer(4) :: nbelem)  (2)
 def invalid_ratio(first): return r  (1)
 function r = archr_stats_invalid_ratio(first)  (1)

Description

This function computes the percentage of elements stored in:

• (1,2) the [first, last[ range
• (3,4) the [first, first+nbelem[ range that are not representing valid numbers (i.e are equivalent to the IEEE754 NaN value).

Parameters

 first the beginning of the range of elements to process. last the end of the range of elements to process. nbelem the number of elements to process.

Return value

The percentage of elements in the given range or container which are equivalent to NaN.

Example

#include <archr/stats/invalid_ratio.h>
#include <stdio.h>

int main()
{
float fnan = 0.f/0.f;
float v[] = {1,fnan,3,4,fnan,6};

printf("invalid_ratio(1,NaN,3,4,NaN,6) = %f\n", archr_stats_invalid_ratio_f32(&v[0],6) );

return 0;
}


Possible Output

invalid_ratio(1,NaN,3,4,NaN,6) = 0.333333
invalid_ratio(1,NaN,3,4)       = 0.250000

#include <archr/stats/invalid_ratio.hpp>
#include <iostream>
#include <vector>

int main()
{
float fnan = 0.f/0.f;
std::vector<float> v{1,fnan,3,4,fnan,6};

std::cout << "invalid_ratio(1,NaN,3,4,NaN,6) = " << archr::stats::invalid_ratio(v) << "\n";
std::cout << "invalid_ratio(1,NaN,3,4,NaN)   = " << archr::stats::invalid_ratio(v.data(), 5) << "\n";
std::cout << "invalid_ratio(1,NaN,3,4)       = " << archr::stats::invalid_ratio(v.data(), v.data() + 4) << "\n";

return 0;
}


Possible Output

invalid_ratio(1,NaN,3,4,NaN,6) = 0.333333
invalid_ratio(1,NaN,3,4,NaN)   = 0.4
invalid_ratio(1,NaN,3,4)       = 0.25