Last data update: 2014.03.03

R: Returns unique state assignment from a (row-wise) weight...
weight_matrix2statesR Documentation

Returns unique state assignment from a (row-wise) weight matrix

Description

Converts a probabilistic cluster assignment to a unique cluster assignment using the

'argmax' rule:

state of row i is assigned as the position of the maximum in that row (ties are broken at random).

'sample' rule

state of row i is sampled from the discrete distribution where probabilities equal the weight vector in row i

Usage

weight_matrix2states(weight.matrix, rule = c("argmax", "sample"))

Arguments

weight.matrix

an N \times K matrix

rule

how do we choose the state given the weight matrix. c("argmax", "sample").

See Also

states2weight_matrix

Examples

WW <- matrix(runif(12), ncol = 3)
WW <- normalize(WW)
WW
weight_matrix2states(WW)
weight_matrix2states(WW, "sample")
# another 'sample' is in general different from previous conversion unless WW is
# a 0/1 matrix
weight_matrix2states(WW, "sample")

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(LICORS)
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/LICORS/weight_matrix2states.Rd_%03d_medium.png", width=480, height=480)
> ### Name: weight_matrix2states
> ### Title: Returns unique state assignment from a (row-wise) weight matrix
> ### Aliases: weight_matrix2states
> ### Keywords: array manip
> 
> ### ** Examples
> 
> WW <- matrix(runif(12), ncol = 3)
> WW <- normalize(WW)
> WW
          [,1]      [,2]      [,3]
[1,] 0.3285279 0.1723526 0.4991194
[2,] 0.4484425 0.4028641 0.1486935
[3,] 0.4440188 0.1722098 0.3837714
[4,] 0.2979005 0.2542371 0.4478624
> weight_matrix2states(WW)
> weight_matrix2states(WW, "sample")
> # another 'sample' is in general different from previous conversion unless WW is
> # a 0/1 matrix
> weight_matrix2states(WW, "sample")
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>