spread (Descriptive Statistics)


Import

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

Synopsis

 float archr_stats_spread_f32(const float *first, size_t nbelem);
(1)
 double archr_stats_spread_f64(const double *first, size_t nbelem);
(2)
 int8_t archr_stats_spread_i8(const int8_t *first, size_t nbelem);
(3)
 int16_t archr_stats_spread_i16(const int16_t *first, size_t nbelem);
(4)
 int32_t archr_stats_spread_i32(const int32_t *first, size_t nbelem);
(5)
 int64_t archr_stats_spread_i64(const int64_t *first, size_t nbelem);
(6)
 uint8_t archr_stats_spread_u8(const uint8_t *first, size_t nbelem);
(7)
 uint16_t archr_stats_spread_u16(const uint16_t *first, size_t nbelem);
(8)
 uint32_t archr_stats_spread_u32(const uint32_t *first, size_t nbelem);
(9)
 uint64_t archr_stats_spread_u64(const uint64_t *first, size_t nbelem);
(10)
 float spread(const float *first, size_t nbelem);
(1)
 double spread(const double *first, size_t nbelem);
(2)
 int8_t spread(const int8_t *first, size_t nbelem);
(3)
 int16_t spread(const int16_t *first, size_t nbelem);
(4)
 int32_t spread(const int32_t *first, size_t nbelem);
(5)
 int64_t spread(const int64_t *first, size_t nbelem);
(6)
 uint8_t spread(const uint8_t *first, size_t nbelem);
(7)
 uint16_t spread(const uint16_t *first, size_t nbelem);
(8)
 uint32_t spread(const uint32_t *first, size_t nbelem);
(9)
 uint64_t spread(const uint64_t *first, size_t nbelem);
(10)
 float spread(const float *first, const float *last);
(11)
 double spread(const double *first, const double *last);
(12)
 int8_t spread(const int8_t *first, const int8_t *last);
(13)
 int16_t spread(const int16_t *first, const int16_t *last);
(14)
 int32_t spread(const int32_t *first, const int32_t *last);
(15)
 int64_t spread(const int64_t *first, const int64_t *last);
(16)
 uint8_t spread(const uint8_t *first, const uint8_t *last);
(17)
 uint16_t spread(const uint16_t *first, const uint16_t *last);
(18)
 uint32_t spread(const uint32_t *first, const uint32_t *last);
(19)
 uint64_t spread(const uint64_t *first, const uint64_t *last);
(20)
template <typename Range> typename Range::value_type spread(const Range& data);
(21)
subroutine archr_stats_spread_f32(real(4) :: r, real(4), dimension(*), parameter :: first, integer(4) :: nbelem)
(1)
subroutine archr_stats_spread_f64(real(8) :: r, real(8), dimension(*), parameter :: first, integer(4) :: nbelem)
(2)
subroutine archr_stats_spread_i8(integer(1) :: r, integer(1), dimension(*), parameter :: first, integer(4) :: nbelem)
(3)
subroutine archr_stats_spread_i16(integer(2) :: r, integer(2), dimension(*), parameter :: first, integer(4) :: nbelem)
(4)
subroutine archr_stats_spread_i32(integer(4) :: r, integer(4), dimension(*), parameter :: first, integer(4) :: nbelem)
(5)
subroutine archr_stats_spread_i64(integer(8) :: r, integer(8), dimension(*), parameter :: first, integer(4) :: nbelem)
(6)
subroutine archr_stats_spread_u8(integer(1) :: r, integer(1), dimension(*), parameter :: first, integer(4) :: nbelem)
(7)
subroutine archr_stats_spread_u16(integer(2) :: r, integer(2), dimension(*), parameter :: first, integer(4) :: nbelem)
(8)
subroutine archr_stats_spread_u32(integer(4) :: r, integer(4), dimension(*), parameter :: first, integer(4) :: nbelem)
(9)
subroutine archr_stats_spread_u64(integer(8) :: r, integer(8), dimension(*), parameter :: first, integer(4) :: nbelem)
(10)
def spread(first):
    return r
(1)
function r = archr_stats_spread(first)
(1)

Description

This function computes the spread of the elements stored in:

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 spread of the elements in the given range defined as the difference between the maximum and minimum value of the elements in the range.

Example

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

int main()
{
 float v[] = {1,-2,3,-4,5,-6};

  printf("spread(1,-2,3,-4,5,-6) = %f\n", archr_stats_spread_f32(&v[0],6) );

  return 0;
}

Possible Output

spread(1,-2,3,-4,5,-6) = 11.000000
spread(1,-2,3,-4)      = 7.000000
#include <archr/stats/spread.hpp>
#include <iostream>
#include <vector>

int main()
{
 std::vector<float> v{1,-2,3,-4,5,-6};

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

  return 0;
}

Possible Output

spread(1,-2,3,-4,5,-6) = 11
spread(1,-2,3,-4,5)    = 9
spread(1,-2,3)         = 5

Possible Output