Engee documentation

cummin

The cumulative minimum.

Library

EngeeDSP

Syntax

Function call

  • M = cummin(A) — returns the cumulative minimum elements of the array A.

    • If A — vector, then M — a vector of the same size and type containing the cumulative minima of the vector A.

    • If A — the matrix, then M — a matrix of the same size and type containing cumulative minima in each column of the matrix A.

    • If A — a multidimensional array, then M — an array of the same size and type containing cumulative minima in the first dimension of the array A, the size of which is not equal to 1.

  • M = cummin(A,dim) — returns cumulative measurement minima dim. For example, if A — the matrix, then cummin(A,2) returns cumulative minima across rows of the matrix A.

  • M = cummin(___,direction) — defines the direction for any of the previous syntax options. For example, cummin(A,2,"reverse") returns the cumulative minima of the matrix A acting from the end to the beginning of the second dimension of the matrix A.

  • M = cummin(___,nanflag) — determines whether to exclude or include values NaN to the array A. For example, cummin(A,"includenan") takes into account the values NaN when calculating each minimum. By default cummin excludes values NaN.

Arguments

Input arguments

# A — input array

+ vector | the matrix | multidimensional array

Details

An input array specified as a vector, matrix, or multidimensional array. For complex elements, the function cummin compares their amplitudes. If the amplitudes are equal, cummin It also compares phase angles.

Типы данных

Float32, Float64, Int8, Int16, Int32, Int64, UInt8, UInt16, UInt32, UInt64, Bool

Support for complex numbers

Yes

# dim — the measurement for which the operation is performed

+ a positive integer scalar

Details

The dimension that the operation is performed on, specified as a positive integer scalar. If no dimension is specified, the first dimension of the array is used by default, the size of which is not equal to 1.

Consider a two-dimensional input array A:

  • cummin(A,1) works with consecutive elements in columns A and returns an array of the same size as A, with cumulative minima in each column.

    cummin 1

  • cummin(A,2) works with consecutive elements in strings A and returns an array of the same size as A, with cumulative minima in each row.

    cummin 2

cummin returns A if dim more than ndims(A).

# direction — cumulation direction

+ "forward" (by default) | "reverse"

Details

The direction of cumulation, set by one of the following values:

  • "forward" — work from 1 until the end of the working measurement;

  • "reverse" — end-to-end work 1 working measurement.

# nanflag — condition for missing value

+ "omitmissing" (by default) | "omitnan" | "includemissing" | "includenan"

Details

The condition for processing a missing value, set by one of the following values:

  • "omitmissing" or "omitnan" — ignore the values NaN in A when calculating cumulative minima. If in A there are consecutive initial values NaN, then the corresponding elements in M They are also NaN. Values "omitmissing" and "omitnan" they behave the same way.

  • "includemissing" or "includenan" — enable values NaN in A when calculating cumulative minima. Elements in M they become NaN As soon as in A the first value occurs NaN. Values "includemissing" and "includenan" they behave the same way.

Output arguments

# M — output array

+ vector | the matrix | multidimensional array

Details

The output array returned as a vector, matrix, or multidimensional array.

Examples

Cumulative minimum in the vector

Details

Let’s find the cumulative minimum of a vector of random integers of size 1 on 10.

import EngeeDSP.Functions: randi

v = randi([0,10],1,10)
1×10 Matrix{Float64}:
 9.0  2.0  8.0  2.0  10.0  3.0  2.0  2.0  6.0  5.0
import EngeeDSP.Functions: cummin

M = cummin(v)
1×10 Matrix{Float64}:
 9.0  2.0  8.0  2.0  10.0  3.0  2.0  2.0  6.0  5.0

Cumulative minimum in the columns of the matrix

Details

Let’s find the cumulative minimum of the columns of the matrix with the size 3×3.

A = [3 5 2; 1 6 3; 7 8 1]
3×3 Matrix{Int64}:
 3  5  2
 1  6  3
 7  8  1
import EngeeDSP.Functions: cummin

M = cummin(A)
3×3 Matrix{Float64}:
 3.0  5.0  2.0
 1.0  5.0  2.0
 1.0  5.0  1.0

Cumulative minimum in the rows of the matrix

Details

Let’s find the cumulative minimum of the rows of the matrix with the size 3×3.

A = [3 5 2; 1 6 3; 7 8 1]
3×3 Matrix{Int64}:
 3  5  2
 1  6  3
 7  8  1
import EngeeDSP.Functions: cummin

M = cummin(A, 2)
3×3 Matrix{Float64}:
 3.0  3.0  2.0
 1.0  1.0  1.0
 7.0  7.0  1.0

Reverse cumulative minimum

Details

Calculate the cumulative minimum in the third dimension of the array 2×2×3. We will indicate the direction "reverse" to calculate values from the end of the third dimension to the beginning.

A = cat([1 2; 3 4], [9 10; 11 12], [5 6; 7 8]; dims=3)
2×2×3 Array{Int64, 3}:
[:, :, 1] =
 1  2
 3  4

[:, :, 2] =
  9  10
 11  12

[:, :, 3] =
 5  6
 7  8
import EngeeDSP.Functions: cummin

M = cummin(A, 3, "reverse")
2×2×3 Array{Float64, 3}:
[:, :, 1] =
 1.0  2.0
 3.0  4.0

[:, :, 2] =
 5.0  6.0
 7.0  8.0

[:, :, 3] =
 5.0  6.0
 7.0  8.0

Cumulative minimum, including missing values

Details

Create a matrix containing the values NaN.

A = [3 5 NaN 4; 2 6 2 9; 1 3 0 NaN]
3×4 Matrix{Float64}:
 3.0  5.0  NaN      4.0
 2.0  6.0    2.0    9.0
 1.0  3.0    0.0  NaN

Calculate the cumulative minima of the matrix, including the values NaN. For matrix columns containing any value NaN, the cumulative minimum values become equal NaN as soon as the first value is encountered NaN.

import EngeeDSP.Functions: cummin

M = cummin(A, "includenan")
3×4 Matrix{Float64}:
 3.0  5.0  NaN    4.0
 2.0  5.0  NaN    4.0
 1.0  3.0  NaN  NaN

Recommendations

Meaning "reverse" In many cumulative functions, it allows you to quickly perform directional calculations without having to flip or reflect the input array.