sum_largest function

Sum of Largest Values

Sum of Largest Values

The sum of the largest kk values of a vector or matrix. methods

sum_largest(x, k)

Arguments

  • x: An Expression , vector, or matrix.
  • k: The number of largest values to sum over.

Returns

An Expression representing the sum of the largest k values of the input.

Examples

set.seed(122) m <- 300 n <- 9 X <- matrix(stats::rnorm(m*n), nrow = m, ncol = n) X <- cbind(rep(1,m), X) b <- c(0, 0.8, 0, 1, 0.2, 0, 0.4, 1, 0, 0.7) y <- X %*% b + stats::rnorm(m) beta <- Variable(n+1) obj <- sum_largest((y - X %*% beta)^2, 100) prob <- Problem(Minimize(obj)) result <- solve(prob) result$getValue(beta)
  • Maintainer: Anqi Fu
  • License: Apache License 2.0 | file LICENSE
  • Last published: 2024-11-07