sparsernorm: Sparse rnorm

View source: R/sparsernorm.R

sparsernormR Documentation

Sparse rnorm

Description

A sparse version of stats::rnorm Outputs a vector where a fraction of values are zeros (determined by sparseness) and the rest are drawn from a random normal distribution using stats::rnorm

Usage

sparsernorm(n, sparseness = 0.1, mean = 0, sd = 1)

Arguments

n

Integer: Length of output vector

sparseness

Float (0, 1): Fraction of required nonzero elements, i.e. output will have ⁠round(sparseness * n) nonzero elements⁠. If sparseness = 0, a vector of zeros length n is returned, if sparseness = 1, rnorm(n, mean, sd) is returned. Default = 0.1

mean

Float: Target mean of nonzero elements, passed to stats::rnorm Default = 0

sd

Float: Target sd of nonzero elements, passed to stats::rnorm Default = 1

Author(s)

E.D. Gennatas


egenn/rtemis documentation built on Oct. 28, 2024, 6:30 a.m.