the most frequent vote cast for every id; MATLAB’s majorityVote

Syntax

vote, numVotes = majorityVote([1, 1, 1, 1, 1, 2, 3, 2, 3, 2, 3], [5, 9, 5, 9, 9, 4, 1, 4, 2, 4, 1])

The most frequent vote per id.

vote, numVotes = majorityVote([1, 1, 2, 2, 3], [5, 5, 4, 7, 1], strict=True)

A vote only where all agree.

vote, numVotes = majorityVote([1, 1, 2], [5, 9, 4], maxId=5)

A row for every id up to 5.

vote, numVotes = majorityVote([1, 1, 1], [5, 9, 9], weights=[3, 1, 1])

The vote of the largest summed weight.

Description

The votes are grouped by their id, and every id from 1 to maxId gets one row, at position id - 1: the vote cast most often for it, the smallest of a tie, and NaN for an id without votes. Votes that are NaN and ids below 1 are left out.

Input

id integer array, the id every vote is cast for, from 1
votes array of the same length, the votes, positive integers

Keywords

keyword default description
maxId None the number of rows, by default the largest id
strict False give a vote only to an id whose votes all agree, NaN to the others
weights None array of the length of votes, a weight for every vote; the vote of the largest summed weight wins

Output

vote array of maxId entries, the winning vote of every id, NaN where there is none
numVotes array of maxId entries, how often the winning vote was cast; with weights the lead of the winning vote, its weight over the sum of its weight and the second’s

See also

parentGrainReconstructor.calcParentFromVote, parentGrainReconstructor.calcGBVotes

Used on

LowLevelParentGrainReconstruction

MATLAB’s majorityVote

source

Citing this page. This page is part of the documentation of MTEX, a free and open source MATLAB toolbox for analyzing and modeling crystallographic textures. It was written by The MTEX Developers and is published at https://mtex-toolbox.github.io/majorityVote_py.html. If you use MTEX, or reuse text or figures from this page, in your research, please cite

F. Bachmann, R. Hielscher, H. Schaeben: Texture Analysis with MTEX - Free and Open Source Software Toolbox, Solid State Phenomena 160 (2010), 63-68. 10.4028/www.scientific.net/SSP.160.63

BibTeX
@article{bachmann2010mtex,
  author  = {F. Bachmann and R. Hielscher and H. Schaeben},
  title   = {Texture Analysis with MTEX - Free and Open Source Software Toolbox},
  journal = {Solid State Phenomena},
  volume  = {160},
  pages   = {63-68},
  year    = {2010},
  doi     = {10.4028/www.scientific.net/SSP.160.63},
  url     = {https://doi.org/10.4028/www.scientific.net/SSP.160.63}
}

Other papers describing specific MTEX methods are listed under Publications — please cite the one that best fits your application. The MTEX source code is licensed under the GNU General Public License v2.0; the text and figures of this documentation are licensed under CC BY 4.0, which permits reuse — including by automated systems — provided The MTEX Developers and this page are credited.