mode

Functions

int main(int argc, char *argv[])

mode [ option ] [ infile ]

  • -l int

    • length of vector \((1 \le M + 1)\)

  • -m int

    • order of vector \((0 \le M)\)

  • -b int

    • find \(N\)-best values \((1 \le N)\)

  • -w int

    • way to find value

      • 0 find value from a vector

      • 1 find value from vector sequence for each dimension

  • -c str

    • int-type counts

  • infile str

    • double-type data sequence

  • stdout

    • double-type mode

echo 0 3 3 4 8 8 8 1 | x2x +ad | mode -b 2 -w 1 | x2x +da
# 8, 3
echo 0 3 3 4 8 8 8 1 | x2x +ad | mode -l 4 -w 0 | x2x +da
# 3, 8
Parameters:
  • argc[in] Number of arguments.

  • argv[in] Argument vector.

Returns:

0 on success, 1 on failure.

See also

minmax

class ModeAccumulation

Compute mode given data sequence.

Public Functions

explicit ModeAccumulation(int num_best)
Parameters:

num_best[in] Number of modes.

inline int GetNumBest() const
Returns:

Number of modes.

inline bool IsValid() const
Returns:

True if this object is valid.

bool GetMode(int rank, const ModeAccumulation::Buffer &buffer, double *value, int *count) const

Get \(n\)-th mode value and its count.

Parameters:
  • rank[in] Rank \(n\).

  • buffer[in] Buffer.

  • value[out] Mode value.

  • count[out] Count of the mode value.

Returns:

True on success, false on failure.

void Clear(ModeAccumulation::Buffer *buffer) const

Clear buffer.

Parameters:

buffer[out] Buffer.

bool Run(double data, ModeAccumulation::Buffer *buffer) const

Accumulate mode.

Parameters:
  • data[in] Input data.

  • buffer[inout] Buffer.

Returns:

True on success, false on failure.

class Buffer

Buffer for ModeAccumulation.