Added rand function
This commit is contained in:
parent
80e746e046
commit
6014483d1c
3 changed files with 29 additions and 0 deletions
|
|
@ -6,3 +6,4 @@ export(computeRows)
|
||||||
export(learn_simple_partition)
|
export(learn_simple_partition)
|
||||||
export(ownNum2Str)
|
export(ownNum2Str)
|
||||||
export(repmat)
|
export(repmat)
|
||||||
|
importFrom(stats,runif)
|
||||||
|
|
|
||||||
9
R/rand.R
Normal file
9
R/rand.R
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
#' @title Generate matrix with U(0, 1) trials
|
||||||
|
#' @description Imitates the behavior of `rand()` on Matlab
|
||||||
|
#' @param r number of rows of output matrix
|
||||||
|
#' @param c number of columns of output matrix
|
||||||
|
#' @return \eqn{r \times c} matrix with random trials from a standard uniform distribution.
|
||||||
|
#' @importFrom stats runif
|
||||||
|
rand <- function(r = 1, c = 1) {
|
||||||
|
matrix(runif(r * c), r, c)
|
||||||
|
}
|
||||||
19
man/rand.Rd
Normal file
19
man/rand.Rd
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
% Generated by roxygen2: do not edit by hand
|
||||||
|
% Please edit documentation in R/rand.R
|
||||||
|
\name{rand}
|
||||||
|
\alias{rand}
|
||||||
|
\title{Generate matrix with U(0, 1) trials}
|
||||||
|
\usage{
|
||||||
|
rand(r = 1, c = 1)
|
||||||
|
}
|
||||||
|
\arguments{
|
||||||
|
\item{r}{number of rows of output matrix}
|
||||||
|
|
||||||
|
\item{c}{number of columns of output matrix}
|
||||||
|
}
|
||||||
|
\value{
|
||||||
|
\eqn{r \times c} matrix with random trials from a standard uniform distribution.
|
||||||
|
}
|
||||||
|
\description{
|
||||||
|
Imitates the behavior of `rand()` on Matlab
|
||||||
|
}
|
||||||
Loading…
Add table
Reference in a new issue