Learn R Programming

scidb (version 1.2-0)

bernoulli: Sample from populated cells in a SciDB array.

Description

Return a sparse SciDB array that samples from populated cells in the SciDB array x.

Usage

bernoulli (x, prob, seed=sample(2^32 - 1 - 2^31, 1))

Arguments

x
A scidb or scidbdf object.
prob
A number in the interval (0, 1] indicating the probability of a cell being included in the sample.
seed
A 32-bit signed integer random seed value for SciDB's bernoulli operator.

Value

A new sparse scidb or scidbdf object.

Details

This R function corresponds to SciDB's bernoulli operator.

For each non-empty cell in the input array x, generate a number sampled fom a uniform random distribution. If the number is less than or equal to prob, then include the cell in the output array.

See Also

scidb

Examples

Run this code
## Not run: 
# x <- build("i+j", c(10,10), type="double")
# y <- bernoulli(x, 0.5) # Sample about 1/2 the cells of x
# count(y)
# 
# # Note that y is lazily evaluated *and* its value is probablistic. Thus
# # its value will change upon each evaluation. For example:
# count(y)
# count(y)
# 
# # Use scidbeval to force evaluation of y once and for all:
# y <- scidbeval(y)
# count(y)
# count(y)
# ## End(Not run)

Run the code above in your browser using DataLab