# \donttest{
# In all examples, x is the row variable and y is the column
# variable of a table.
# Example 1. Simulating a noisy function where y=f(x),
# x may or may not be g(y) with given row.marginal.
tbls <- simulate_tables(n=100, nrow=4, ncol=5, type="functional",
noise=0.2, n.tables = 1,
row.marginal = c(0.3,0.2,0.3,0.2))
par(mfrow=c(2,2))
plot_table(tbls$pattern.list[[1]], main="Ex 1. Functional pattern")
plot_table(tbls$sample.list[[1]], main="Ex 1. Sampled pattern (noise free)")
plot_table(tbls$noise.list[[1]], main="Ex 1. Sampled pattern with 0.2 noise")
plot.new()
# Example 2. Simulating a noisy functional pattern where
# y=f(x), x may or may not be g(y) with given row.marginal.
tbls <- simulate_tables(n=100, nrow=4, ncol=5, type="functional",
noise=0.5, n.tables = 1,
row.marginal = c(0.3,0.2,0.3,0.2))
par(mfrow=c(2,2))
plot_table(tbls$pattern.list[[1]], main="Ex 2. Functioal pattern", col="seagreen2")
plot_table(tbls$sample.list[[1]], main="Ex 2. Sampled pattern (noise free)", col="seagreen2")
plot_table(tbls$noise.list[[1]], main="Ex 2. Sampled pattern with 0.5 noise", col="seagreen2")
plot.new()
# Example 3. Simulating a noisy many.to.one function where
# y=f(x), x!=f(y) with given row.marginal.
tbls <- simulate_tables(n=100, nrow=4, ncol=5, type="many.to.one",
noise=0.2, n.tables = 1,
row.marginal = c(0.4,0.3,0.1,0.2))
par(mfrow=c(2,2))
plot_table(tbls$pattern.list[[1]], main="Ex 3. Many-to-one pattern", col="limegreen")
plot_table(tbls$sample.list[[1]], main="Ex 3. Sampled pattern (noise free)", col="limegreen")
plot_table(tbls$noise.list[[1]], main="Ex 3. Sampled pattern with 0.2 noise", col="limegreen")
plot.new()
# Example 4. Simulating noisy discontinuous
# pattern where y=f(x), x may or may not be g(y) with given row.marginal.
tbls <- simulate_tables(n=100, nrow=4, ncol=5,
type="discontinuous", noise=0.2,
n.tables = 1, row.marginal = c(0.2,0.4,0.2,0.2))
par(mfrow=c(2,2))
plot_table(tbls$pattern.list[[1]], main="Ex 4. Discontinuous pattern", col="springgreen3")
plot_table(tbls$sample.list[[1]], main="Ex 4. Sampled pattern (noise free)", col="springgreen3")
plot_table(tbls$noise.list[[1]], main="Ex 4. Sampled pattern with 0.2 noise", col="springgreen3")
plot.new()
# Example 5. Simulating noisy dependent.non.functional
# pattern where y!=f(x) and x and y are statistically
# dependent.
tbls <- simulate_tables(n=100, nrow=4, ncol=5,
type="dependent.non.functional", noise=0.3,
n.tables = 1, row.marginal = c(0.2,0.4,0.2,0.2))
par(mfrow=c(2,2))
plot_table(tbls$pattern.list[[1]], main="Ex 5. Dependent.non.functional pattern",
col="sienna2", highlight="none")
plot_table(tbls$sample.list[[1]], main="Ex 5. Sampled pattern (noise free)",
col="sienna2", highlight="none")
plot_table(tbls$noise.list[[1]], main="Ex 5. Sampled pattern with 0.3 noise",
col="sienna2", highlight="none")
plot.new()
# Example 6. Simulating a pattern where x and y are
# statistically independent.
tbls <- simulate_tables(n=100, nrow=4, ncol=5, type="independent",
noise=0.3, n.tables = 1,
row.marginal = c(0.4,0.3,0.1,0.2),
col.marginal = c(0.1,0.2,0.4,0.2,0.1))
par(mfrow=c(2,2))
plot_table(tbls$pattern.list[[1]], main="Ex 6. Independent pattern",
col="cornflowerblue", highlight="none")
plot_table(tbls$sample.list[[1]], main="Ex 6. Sampled pattern (noise free)",
col="cornflowerblue", highlight="none")
plot_table(tbls$noise.list[[1]], main="Ex 6. Sampled pattern with 0.3 noise",
col="cornflowerblue", highlight="none")
plot.new()
# Example 7. Simulating a noisy function where y=f(x),
# x may or may not be g(y), with given column marginal
tbls <- simulate_tables(n=100, nrow=4, ncol=5, type="functional",
noise=0.2, n.tables = 1,
col.marginal = c(0.2,0.1,0.4,0.2,0.1))
par(mfrow=c(2,2))
plot_table(tbls$pattern.list[[1]], main="Ex 7. Functional pattern")
plot_table(tbls$sample.list[[1]], main="Ex 7. Sampled pattern (noise free)")
plot_table(tbls$noise.list[[1]], main="Ex 7. Sampled pattern with 0.2 noise")
plot.new()
# Example 8. Simulating a noisy many.to.one function where
# y=f(x), x!=f(y) with given column marginal.
tbls <- simulate_tables(n=100, nrow=4, ncol=4, type="many.to.one",
noise=0.2, n.tables = 1,
col.marginal = c(0.4,0.3,0.1,0.2))
par(mfrow=c(2,2))
plot_table(tbls$pattern.list[[1]], main="Ex 8. Many-to-one pattern", col="limegreen")
plot_table(tbls$sample.list[[1]], main="Ex 8. Sampled pattern (noise free)", col="limegreen")
plot_table(tbls$noise.list[[1]], main="Ex 8. Sampled pattern with 0.2 noise", col="limegreen")
plot.new()
# Example 9. Simulating noisy discontinuous
# pattern where y=f(x), x may or may not be g(y) with given column marginal
tbls <- simulate_tables(n=100, nrow=4, ncol=4,
type="discontinuous", noise=0.2,
n.tables = 1, col.marginal = c(0.1,0.4,0.2,0.3))
par(mfrow=c(2,2))
plot_table(tbls$pattern.list[[1]], main="Ex 9. Discontinuous pattern", col="springgreen3")
plot_table(tbls$sample.list[[1]], main="Ex 9. Sampled pattern (noise free)", col="springgreen3")
plot_table(tbls$noise.list[[1]], main="Ex 9. Sampled pattern with 0.2 noise", col="springgreen3")
plot.new()
# }
Run the code above in your browser using DataLab