projSimplex: project to a simplex

View source: R/cpaProgs.R

projSimplexR Documentation

project to a simplex

Description

internal function; project an n-dim vector y to the simplex S_n with sum constrained to 1

Usage

projSimplex(y, c = 1)

Arguments

y

n-dim vector

c

constraint; equals one by default

Value

simplex S_n with sum constrained to 1

Examples

y1 <- c(1,1)
p1 <- projSimplex(y1)
p1
y2 <- c(0.1, 0.3)
p2 <- projSimplex(y2)
p2


mooredf22/protlocassign documentation built on Sept. 13, 2023, 3:57 p.m.