MGC()
### Two static clusters (Gaussian with sd of .1 and a Block with width .4)
### with added noise
stream <- DSD_MG(dim = 2,
MGC_Static(den = .45, center = c(1, 0), par = .1, shape = Shape_Gaussian),
MGC_Static(den = .45, center = c(2, 0), par = .4, shape = Shape_Block),
MGC_Noise( den = .1, range = rbind(c(0, 3), c(-1,1)))
)
stream
plot(stream)
### Example of several MGC_Randoms which define clusters that randomly move.
stream <- DSD_MG(dim = 2,
MGC_Random(den = 100, center=c(1, 0), par = .1, rand = .2),
MGC_Random(den = 100, center=c(2, 0), par = .4, shape = Shape_Block, rand = .2)
)
if (FALSE) {
animate_data(stream, 2500, xlim = c(0,3), ylim = c(-1,1), horizon = 100)
}
### Example of several MGC_Functions
### a block-shaped cluster moving from bottom-left to top-right increasing size
c1 <- MGC_Function(
density = function(t){ 100 },
parameter = function(t){ 1 * t },
center = function(t) c(t, t),
shape = Shape_Block
)
### a cluster moving in a circle (default shape is Gaussian)
c2 <- MGC_Function(
density = function(t){ 25 },
parameter = function(t){ 5 },
center= function(t) c(sin(t / 10) * 50 + 50, cos(t / 10) * 50 + 50)
)
stream <- DSD_MG(dim = 2, c1, c2)
## adding noise after the stream was created
add_cluster(stream, MGC_Noise(den = 10, range = rbind(c(-20, 120), c(-20, 120))))
stream
if (FALSE) {
animate_data(stream, 10000, xlim = c(-20, 120), ylim = c(-20, 120), horizon = 100)
}
### Example of several MGC_Linear: A single cluster splits at time 50 into two.
### Note that c2 starts at time = 50!
stream <- DSD_MG(dim = 2)
c1 <- MGC_Linear(dim = 2)
add_keyframe(c1, time = 1, dens = 50, par = 5, center = c(0, 0))
add_keyframe(c1, time = 50, dens = 50, par = 5, center = c(50, 50))
add_keyframe(c1, time = 100,dens = 50, par = 5, center = c(50, 100))
add_cluster(stream, c1)
c2 <- MGC_Linear(dim = 2, shape = Shape_Block)
add_keyframe(c2, time = 50, dens = 25, par = c(10, 10), center = c(50, 50))
add_keyframe(c2, time = 100,dens = 25, par = c(30, 30), center = c(100, 50))
add_cluster(stream, c2)
if (FALSE) {
animate_data(stream, 5000, xlim = c(0, 100), ylim = c(0, 100), horiz = 100)
}
### two fixed and a moving cluster
stream <- DSD_MG(dim = 2,
MGC_Static(dens = 1, par = .1, center = c(0, 0)),
MGC_Static(dens = 1, par = .1, center = c(1, 1)),
MGC_Linear(dim = 2, list(
keyframe(time = 0, dens = 1, par = .1, center = c(0, 0)),
keyframe(time = 1000, dens = 1, par = .1, center = c(1, 1)),
keyframe(time = 2000, dens = 1, par = .1, center = c(0, 0), reset = TRUE)
)))
noise <- MGC_Noise(dens = .1, range = rbind(c(-.2, 1.2), c(-.2, 1.2)))
add_cluster(stream, noise)
if (FALSE) {
animate_data(stream, n = 2000 * 3.1, xlim = c(-.2, 1.2), ylim = c(-.2, 1.2), horiz = 200)
}
Run the code above in your browser using DataLab