generate_sobol_owen_set: Generate Owen-scrambled Sobol Set

Description Usage Arguments Value Examples

View source: R/generate_values.R

Description

Generate a set of values from an Owen-scrambled Sobol set.

Usage

1

Arguments

n

The number of values (per dimension) to extract.

dim

The number of dimensions of the sequence.

seed

Default '0'. The random seed.

Value

An 'n' x 'dim' matrix with all the calculated values from the set.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
#Generate a 2D sample:
points2d = generate_sobol_owen_set(n=1000, dim = 2)
plot(points2d, xlim=c(0,1),ylim=c(0,1))

#Generate a longer sequence of values from that set
points2d = generate_sobol_owen_set(n=1500, dim = 2)
plot(points2d, xlim=c(0,1),ylim=c(0,1))

#'#Integrate the value of pi by counting the number of randomly generated points that fall
#within the unit circle.
pointset = matrix(generate_sobol_owen_set(10000,dim=2),ncol=2)

pi_estimate = 4*sum(pointset[,1] * pointset[,1] + pointset[,2] * pointset[,2] < 1)/10000
pi_estimate

spacefillr documentation built on Feb. 23, 2021, 5:10 p.m.