Learn R Programming

uniformly (version 0.5.0)

runif_in_pball: Uniform sampling in a p-ball

Description

Uniform sampling in a p-ball (arbitrary dimension).

Usage

runif_in_pball(n, d, p, r = 1)

Value

The simulations in a n times d matrix.

Arguments

n

number of simulations

d

dimension

p

exponent in the p-norm, a positive number

r

positive number, the radius

Examples

Run this code
sims <- runif_in_pball(500, d = 2, p = 1)
plot(sims, xlim = c(-1, 1), ylim = c(-1, 1), asp = 1)

Run the code above in your browser using DataLab