percpos(x: array,dim?: 0 | 1,): number
Percentage of positive values in array or matrix.
Calculates the percentage of positive (non-negative) values in an array or matrix. This is a common metric to assess the consistency of returns.
Percentage of positive values in a single array
Percentage of positive values in a single array
import { assertEquals } from "jsr:@std/assert"; const x = [0.003, 0.026, 0.015, -0.009, 0.014, 0.024, 0.015, 0.066, -0.014, 0.039]; assertEquals(percpos(x), 0.8);
x: array
array of elements
percpos(x: matrix,dim?: 0 | 1,): array | matrix
Percentage of positive values in array or matrix.
Calculates the percentage of positive (non-negative) values in an array or matrix. This is a common metric to assess the consistency of returns.
Percentage of positive values in a single array
Percentage of positive values in a single array
import { assertEquals } from "jsr:@std/assert"; const x = [0.003, 0.026, 0.015, -0.009, 0.014, 0.024, 0.015, 0.066, -0.014, 0.039]; assertEquals(percpos(x), 0.8);
x: matrix
array of elements