From 587c6a48df4fc71c9e15d9566ca0106e6103e5f1 Mon Sep 17 00:00:00 2001 From: Nuno Fachada Date: Mon, 3 Jun 2024 17:33:27 +0100 Subject: [PATCH] Docs: examples/theory: follow Blue style --- docs/src/examples.md | 237 +++++++++++++++++++++---------------------- docs/src/theory.md | 6 +- 2 files changed, 119 insertions(+), 124 deletions(-) diff --git a/docs/src/examples.md b/docs/src/examples.md index b81ac45..2e52d00 100644 --- a/docs/src/examples.md +++ b/docs/src/examples.md @@ -18,7 +18,7 @@ available For plotting an example directly, e.g. for `e001`, run: ```julia -plot(e001.points[:, 1], e001.points[:, 2], seriestype = :scatter, group = e001.clusters) +plot(e001.points[:, 1], e001.points[:, 2], seriestype=:scatter, group=e001.clusters) ``` ### Manipulating the direction of cluster-supporting lines @@ -34,9 +34,9 @@ nothing # hide ``` ```@example 2d_dir -e001 = clugen(2, 4, 200, [1, 0], 0, [10, 10], 10, 1.5, 0.5; rng = seed) -e002 = clugen(2, 4, 200, [1, 1], 0, [10, 10], 10, 1.5, 0.5; rng = seed) -e003 = clugen(2, 4, 200, [0, 1], 0, [10, 10], 10, 1.5, 0.5; rng = seed) +e001 = clugen(2, 4, 200, [1, 0], 0, [10, 10], 10, 1.5, 0.5; rng=seed) +e002 = clugen(2, 4, 200, [1, 1], 0, [10, 10], 10, 1.5, 0.5; rng=seed) +e003 = clugen(2, 4, 200, [0, 1], 0, [10, 10], 10, 1.5, 0.5; rng=seed) nothing # hide ``` @@ -67,10 +67,10 @@ nothing #hide ``` ```@example 2d_angdisp -e004 = clugen(2, 6, 500, [1, 0], 0, [10, 10], 10, 1.5, 0.5; rng = seed) -e005 = clugen(2, 6, 500, [1, 0], pi / 8, [10, 10], 10, 1.5, 0.5; rng = seed) +e004 = clugen(2, 6, 500, [1, 0], 0, [10, 10], 10, 1.5, 0.5; rng=seed) +e005 = clugen(2, 6, 500, [1, 0], pi / 8, [10, 10], 10, 1.5, 0.5; rng=seed) e006 = clugen(2, 6, 500, [1, 0], 0, [10, 10], 10, 1.5, 0.5; - angle_deltas_fn = angdel_90_fn, rng = seed) + angle_deltas_fn=angdel_90_fn, rng=seed) nothing # hide ``` @@ -99,12 +99,9 @@ nothing #hide ``` ```@example 2d_llen -e007 = clugen(2, 5, 800, [1, 0], pi / 10, [10, 10], 0, 0, 0.5; - point_dist_fn = "n", rng = seed) -e008 = clugen(2, 5, 800, [1, 0], pi / 10, [10, 10], 10, 0, 0.5; - point_dist_fn = "n", rng = seed) -e009 = clugen(2, 5, 800, [1, 0], pi / 10, [10, 10], 30, 0, 0.5; - point_dist_fn = "n", rng = seed) +e007 = clugen(2, 5, 800, [1, 0], pi / 10, [10, 10], 0, 0, 0.5; point_dist_fn="n", rng=seed) +e008 = clugen(2, 5, 800, [1, 0], pi / 10, [10, 10], 10, 0, 0.5; point_dist_fn="n", rng=seed) +e009 = clugen(2, 5, 800, [1, 0], pi / 10, [10, 10], 30, 0, 0.5; point_dist_fn="n", rng=seed) nothing # hide ``` @@ -129,18 +126,18 @@ using CluGen, Distributions, Plots, Main.CluGenExtras # hide seed = 11 # Custom llengths function: line lengths grow for each new cluster -llen_grow_fn(nclu, llen, llenstd; rng = nothing) = +llen_grow_fn(nclu, llen, llenstd; rng=nothing) = llen * (collect(0:(nclu - 1)) + llenstd * randn(rng, nclu)) nothing #hide ``` ```@example 2d_llendisp e010 = clugen(2, 5, 800, [1, 0], pi / 10, [10, 10], 15, 0.0, 0.5; - point_dist_fn = "n", rng = seed) + point_dist_fn="n", rng=seed) e011 = clugen(2, 5, 800, [1, 0], pi / 10, [10, 10], 15, 10.0, 0.5; - point_dist_fn = "n", rng = seed) + point_dist_fn="n", rng=seed) e012 = clugen(2, 5, 800, [1, 0], pi / 10, [10, 10], 10, 0.1, 0.5; - llengths_fn = llen_grow_fn, point_dist_fn = "n", rng = seed) + llengths_fn=llen_grow_fn, point_dist_fn="n", rng=seed) nothing # hide ``` @@ -169,9 +166,9 @@ nothing #hide ``` ```@example 2d_clusep -e013 = clugen(2, 8, 1000, [1, 1], pi / 4, [10, 10], 10, 2, 2.5; rng = seed) -e014 = clugen(2, 8, 1000, [1, 1], pi / 4, [30, 10], 10, 2, 2.5; rng = seed) -e015 = clugen(2, 8, 1000, [1, 1], pi / 4, [10, 30], 10, 2, 2.5; rng = seed) +e013 = clugen(2, 8, 1000, [1, 1], pi / 4, [10, 10], 10, 2, 2.5; rng=seed) +e014 = clugen(2, 8, 1000, [1, 1], pi / 4, [30, 10], 10, 2, 2.5; rng=seed) +e015 = clugen(2, 8, 1000, [1, 1], pi / 4, [10, 30], 10, 2, 2.5; rng=seed) nothing # hide ``` @@ -202,11 +199,11 @@ nothing #hide ``` ```@example 2d_cluoff -e016 = clugen(2, 8, 1000, [1, 1], pi / 4, [10, 10], 10, 2, 2.5; rng = seed) +e016 = clugen(2, 8, 1000, [1, 1], pi / 4, [10, 10], 10, 2, 2.5; rng=seed) e017 = clugen(2, 8, 1000, [1, 1], pi / 4, [10, 10], 10, 2, 2.5; - cluster_offset = [20, -20], rng = seed) + cluster_offset=[20, -20], rng=seed) e018 = clugen(2, 8, 1000, [1, 1], pi / 4, [10, 10], 10, 2, 2.5; - cluster_offset = [-50, -50], clucenters_fn = centers_diag_fn, rng = seed) + cluster_offset=[-50, -50], clucenters_fn=centers_diag_fn, rng=seed) nothing # hide ``` @@ -235,9 +232,9 @@ nothing #hide ``` ```@example 2d_projnorm -e019 = clugen(2, 4, 1000, [1, 0], pi / 2, [20, 20], 13, 2, 0.0; rng = seed) -e020 = clugen(2, 4, 1000, [1, 0], pi / 2, [20, 20], 13, 2, 1.0; rng = seed) -e021 = clugen(2, 4, 1000, [1, 0], pi / 2, [20, 20], 13, 2, 3.0; rng = seed) +e019 = clugen(2, 4, 1000, [1, 0], pi / 2, [20, 20], 13, 2, 0.0; rng=seed) +e020 = clugen(2, 4, 1000, [1, 0], pi / 2, [20, 20], 13, 2, 1.0; rng=seed) +e021 = clugen(2, 4, 1000, [1, 0], pi / 2, [20, 20], 13, 2, 3.0; rng=seed) nothing # hide ``` @@ -265,11 +262,11 @@ nothing #hide ```@example 2d_projunif e022 = clugen(2, 4, 1000, [1, 0], pi / 2, [20, 20], 13, 2, 0.0; - proj_dist_fn = "unif", rng = seed) + proj_dist_fn="unif", rng=seed) e023 = clugen(2, 4, 1000, [1, 0], pi / 2, [20, 20], 13, 2, 1.0; - proj_dist_fn = "unif", rng = seed) + proj_dist_fn="unif", rng=seed) e024 = clugen(2, 4, 1000, [1, 0], pi / 2, [20, 20], 13, 2, 3.0; - proj_dist_fn = "unif", rng = seed) + proj_dist_fn="unif", rng=seed) nothing # hide ``` @@ -300,11 +297,11 @@ nothing #hide ```@example 2d_projlap e025 = clugen(2, 4, 1000, [1, 0], pi / 2, [20, 20], 13, 2, 0.0; - proj_dist_fn = proj_laplace, rng = seed) + proj_dist_fn=proj_laplace, rng=seed) e026 = clugen(2, 4, 1000, [1, 0], pi / 2, [20, 20], 13, 2, 1.0; - proj_dist_fn = proj_laplace, rng = seed) + proj_dist_fn=proj_laplace, rng=seed) e027 = clugen(2, 4, 1000, [1, 0], pi / 2, [20, 20], 13, 2, 3.0; - proj_dist_fn = proj_laplace, rng = seed) + proj_dist_fn=proj_laplace, rng=seed) nothing # hide ``` @@ -336,11 +333,11 @@ nothing #hide ``` ```@example 2d_pt_n_1 -e028 = clugen(2, 5, 1500, [1, 0], pi / 3, [20, 20], 12, 3, 1.0; rng = seed) +e028 = clugen(2, 5, 1500, [1, 0], pi / 3, [20, 20], 12, 3, 1.0; rng=seed) e029 = clugen(2, 5, 1500, [1, 0], pi / 3, [20, 20], 12, 3, 1.0; - proj_dist_fn = "unif", rng = seed) + proj_dist_fn="unif", rng=seed) e030 = clugen(2, 5, 1500, [1, 0], pi / 3, [20, 20], 12, 3, 1.0; - proj_dist_fn = proj_laplace, rng = seed) + proj_dist_fn=proj_laplace, rng=seed) nothing # hide ``` @@ -372,11 +369,11 @@ nothing #hide ```@example 2d_pt_n e031 = clugen(2, 5, 1500, [1, 0], pi / 3, [20, 20], 12, 3, 1.0; - point_dist_fn = "n", rng = seed) + point_dist_fn="n", rng=seed) e032 = clugen(2, 5, 1500, [1, 0], pi / 3, [20, 20], 12, 3, 1.0; - point_dist_fn = "n", proj_dist_fn = "unif", rng = seed) + point_dist_fn="n", proj_dist_fn="unif", rng=seed) e033 = clugen(2, 5, 1500, [1, 0], pi / 3, [20, 20], 12, 3, 1.0; - point_dist_fn = "n", proj_dist_fn = proj_laplace, rng = seed) + point_dist_fn="n", proj_dist_fn=proj_laplace, rng=seed) nothing # hide ``` @@ -414,11 +411,11 @@ nothing #hide ```@example 2d_ptexp e034 = clugen(2, 5, 1500, [1, 0], pi / 3, [20, 20], 12, 3, 1.0; - point_dist_fn = clupoints_n_1_exp, rng = seed) + point_dist_fn=clupoints_n_1_exp, rng=seed) e035 = clugen(2, 5, 1500, [1, 0], pi / 3, [20, 20], 12, 3, 1.0; - point_dist_fn = clupoints_n_1_exp, proj_dist_fn = "unif", rng = seed) + point_dist_fn=clupoints_n_1_exp, proj_dist_fn="unif", rng=seed) e036 = clugen(2, 5, 1500, [1, 0], pi / 3, [20, 20], 12, 3, 1.0; - point_dist_fn = clupoints_n_1_exp, proj_dist_fn = proj_laplace, rng = seed) + point_dist_fn=clupoints_n_1_exp, proj_dist_fn=proj_laplace, rng=seed) nothing # hide ``` @@ -445,27 +442,25 @@ seed = 9 # Custom clusizes_fn (e038): cluster sizes determined via the uniform distribution, # no correction for total points -clusizes_unif(nclu, npts, ae; rng = nothing) = +clusizes_unif(nclu, npts, ae; rng=nothing) = rand(rng, DiscreteUniform(1, 2 * npts / nclu), nclu) # Custom clusizes_fn (e039): clusters all have the same size, no correction for total points -clusizes_equal(nclu, npts, ae; rng = nothing) = (npts ÷ nclu) .* ones(Integer, nclu) +clusizes_equal(nclu, npts, ae; rng=nothing) = (npts ÷ nclu) .* ones(Integer, nclu) # Custom clucenters_fn (all): yields fixed positions for the clusters -centers_fixed(nclu, csep, coff; rng = nothing) = +centers_fixed(nclu, csep, coff; rng=nothing) = [-csep[1] -csep[2]; csep[1] -csep[2]; -csep[1] csep[2]; csep[1] csep[2]] nothing #hide ``` ```@example 2d_clusizes e037 = clugen(2, 4, 1500, [1, 1], pi, [20, 20], 0, 0, 5; - clucenters_fn = centers_fixed, point_dist_fn = "n", rng = seed) + clucenters_fn=centers_fixed, point_dist_fn="n", rng=seed) e038 = clugen(2, 4, 1500, [1, 1], pi, [20, 20], 0, 0, 5; - clucenters_fn = centers_fixed, clusizes_fn = clusizes_unif, point_dist_fn = "n", - rng = seed) + clucenters_fn=centers_fixed, clusizes_fn=clusizes_unif, point_dist_fn="n", rng=seed) e039 = clugen(2, 4, 1500, [1, 1], pi, [20, 20], 0, 0, 5; - clucenters_fn = centers_fixed, clusizes_fn = clusizes_equal, point_dist_fn = "n", - rng = seed) + clucenters_fn=centers_fixed, clusizes_fn=clusizes_equal, point_dist_fn="n", rng=seed) nothing # hide ``` @@ -494,19 +489,19 @@ nothing #hide ```@example 2d_directopt e040 = clugen(2, 4, 1000, [-1, 1], 0, [0, 0], 0, 0, 0.2; - proj_dist_fn = "unif", point_dist_fn = "n", clusizes_fn = [50, 200, 500, 2000], - llengths_fn = [0, 2, 4, 6], clucenters_fn = [-5 -5; -2.5 -2.5; 0 0; 2.5 2.5], - rng = seed) + proj_dist_fn="unif", point_dist_fn="n", clusizes_fn=[50, 200, 500, 2000], + llengths_fn=[0, 2, 4, 6], clucenters_fn=[-5 -5; -2.5 -2.5; 0 0; 2.5 2.5], + rng=seed) e041 = clugen(2, 5, 1000, [1 1; 1 0; 1 0; 0 1; 0 1], 0, [0, 0], 0, 0, 0.2; - proj_dist_fn = "unif", point_dist_fn = "n", clusizes_fn = [200, 500, 500, 500, 500], - llengths_fn = [0, 5, 5, 5, 5], clucenters_fn = [0 0; 0 5; 0 -5; 5 0; -5 0], - rng = seed) + proj_dist_fn="unif", point_dist_fn="n", clusizes_fn=[200, 500, 500, 500, 500], + llengths_fn=[0, 5, 5, 5, 5], clucenters_fn=[0 0; 0 5; 0 -5; 5 0; -5 0], + rng=seed) e042 = clugen(2, 5, 1000, [0 1; 0.25 0.75; 0.5 0.5; 0.75 0.25; 1 0], 0, [0, 0], 5, 0, 0.2; - proj_dist_fn = "unif", point_dist_fn = "n", clusizes_fn = 500 * ones(Int32,5), - clucenters_fn = [-5 0; -3 -0.3; -1 -0.8; 1 -1.6; 3 -2.5], - rng = seed) + proj_dist_fn="unif", point_dist_fn="n", clusizes_fn=500 * ones(Int32,5), + clucenters_fn=[-5 0; -3 -0.3; -1 -0.8; 1 -1.6; 3 -2.5], + rng=seed) nothing # hide ``` @@ -530,7 +525,7 @@ available For plotting an example directly, e.g. for `e043`, run: ```julia -plot(e043.points[:, 1], e043.points[:, 2], e043.points[:, 3], seriestype = :scatter, group = e043.clusters)`. +plot(e043.points[:, 1], e043.points[:, 2], e043.points[:, 3], seriestype=:scatter, group=e043.clusters)`. ``` ### Manipulating the direction of cluster-supporting lines @@ -546,9 +541,9 @@ nothing #hide ``` ```@example 3d_dir -e043 = clugen(3, 4, 500, [1, 0, 0], 0, [10, 10, 10], 15, 1.5, 0.5; rng = seed) -e044 = clugen(3, 4, 500, [1, 1, 1], 0, [10, 10, 10], 15, 1.5, 0.5; rng = seed) -e045 = clugen(3, 4, 500, [0, 0, 1], 0, [10, 10, 10], 15, 1.5, 0.5; rng = seed) +e043 = clugen(3, 4, 500, [1, 0, 0], 0, [10, 10, 10], 15, 1.5, 0.5; rng=seed) +e044 = clugen(3, 4, 500, [1, 1, 1], 0, [10, 10, 10], 15, 1.5, 0.5; rng=seed) +e045 = clugen(3, 4, 500, [0, 0, 1], 0, [10, 10, 10], 15, 1.5, 0.5; rng=seed) nothing # hide ``` @@ -579,10 +574,10 @@ nothing #hide ``` ```@example 3d_angdisp -e046 = clugen(3, 6, 1000, [1, 0, 0], 0, [10, 10, 10], 15, 1.5, 0.5; rng = seed) -e047 = clugen(3, 6, 1000, [1, 0, 0], pi / 8, [10, 10, 10], 15, 1.5, 0.5; rng = seed) +e046 = clugen(3, 6, 1000, [1, 0, 0], 0, [10, 10, 10], 15, 1.5, 0.5; rng=seed) +e047 = clugen(3, 6, 1000, [1, 0, 0], pi / 8, [10, 10, 10], 15, 1.5, 0.5; rng=seed) e048 = clugen(3, 6, 1000, [1, 0, 0], 0, [10, 10, 10], 15, 1.5, 0.5; - angle_deltas_fn = angdel_90_fn, rng = seed) + angle_deltas_fn=angdel_90_fn, rng=seed) nothing # hide ``` @@ -613,9 +608,9 @@ nothing #hide ``` ```@example 3d_dirclu_angd -e049 = clugen(3, 5, 1000, dirs, 0, zeros(3), 10, 0, 0.1; rng = seed) -e050 = clugen(3, 5, 1000, dirs, π/12, zeros(3), 10, 0, 0.1; rng = seed) -e051 = clugen(3, 5, 1000, dirs, π/4, zeros(3), 10, 0, 0.1; rng = seed) +e049 = clugen(3, 5, 1000, dirs, 0, zeros(3), 10, 0, 0.1; rng=seed) +e050 = clugen(3, 5, 1000, dirs, π/12, zeros(3), 10, 0, 0.1; rng=seed) +e051 = clugen(3, 5, 1000, dirs, π/4, zeros(3), 10, 0, 0.1; rng=seed) nothing # hide ``` @@ -646,11 +641,11 @@ nothing #hide ```@example 3d_llen e052 = clugen(3, 5, 800, [1, 0, 0], pi / 10, [10, 10, 10], 0, 0, 0.5; - point_dist_fn = "n", rng = seed) + point_dist_fn="n", rng=seed) e053 = clugen(3, 5, 800, [1, 0, 0], pi / 10, [10, 10, 10], 10, 0, 0.5; - point_dist_fn = "n", rng = seed) + point_dist_fn="n", rng=seed) e054 = clugen(3, 5, 800, [1, 0, 0], pi / 10, [10, 10, 10], 30, 0, 0.5; - point_dist_fn = "n", rng = seed) + point_dist_fn="n", rng=seed) nothing # hide ``` @@ -676,18 +671,18 @@ using CluGen, Distributions, Plots, Main.CluGenExtras # hide seed = 11 # Custom llengths function: line lengths tend to grow for each new cluster -llen_grow_fn(nclu, llen, llenstd; rng = nothing) = +llen_grow_fn(nclu, llen, llenstd; rng=nothing) = llen * (collect(0:(nclu - 1)) + llenstd * randn(rng, nclu)) nothing #hide ``` ```@example 3d_len_disp e055 = clugen(3, 5, 800, [1, 0, 0], pi / 10, [10, 10, 10], 15, 0.0, 0.5; - point_dist_fn = "n", rng = seed) + point_dist_fn="n", rng=seed) e056 = clugen(3, 5, 800, [1, 0, 0], pi / 10, [10, 10, 10], 15, 10.0, 0.5; - point_dist_fn = "n", rng = seed) + point_dist_fn="n", rng=seed) e057 = clugen(3, 5, 800, [1, 0, 0], pi / 10, [10, 10, 10], 10, 0.1, 0.5; - llengths_fn = llen_grow_fn, point_dist_fn = "n", rng = seed) + llengths_fn=llen_grow_fn, point_dist_fn="n", rng=seed) nothing # hide ``` @@ -717,9 +712,9 @@ nothing #hide ``` ```@example 3d_clusep -e058 = clugen(3, 8, 1000, [1, 1, 1], pi / 4, [30, 10, 10], 25, 4, 3; rng = seed) -e059 = clugen(3, 8, 1000, [1, 1, 1], pi / 4, [10, 30, 10], 25, 4, 3; rng = seed) -e060 = clugen(3, 8, 1000, [1, 1, 1], pi / 4, [10, 10, 30], 25, 4, 3; rng = seed) +e058 = clugen(3, 8, 1000, [1, 1, 1], pi / 4, [30, 10, 10], 25, 4, 3; rng=seed) +e059 = clugen(3, 8, 1000, [1, 1, 1], pi / 4, [10, 30, 10], 25, 4, 3; rng=seed) +e060 = clugen(3, 8, 1000, [1, 1, 1], pi / 4, [10, 10, 30], 25, 4, 3; rng=seed) nothing # hide ``` @@ -750,11 +745,11 @@ nothing #hide ``` ```@example 3d_cluoff -e061 = clugen(3, 8, 1000, [1, 1, 1], pi / 4, [10, 10, 10], 12, 3, 2.5; rng = seed) +e061 = clugen(3, 8, 1000, [1, 1, 1], pi / 4, [10, 10, 10], 12, 3, 2.5; rng=seed) e062 = clugen(3, 8, 1000, [1, 1, 1], pi / 4, [10, 10, 10], 12, 3, 2.5; - cluster_offset = [20, -20, 20], rng = seed) + cluster_offset=[20, -20, 20], rng=seed) e063 = clugen(3, 8, 1000, [1, 1, 1], pi / 4, [10, 10, 10], 12, 3, 2.5; - cluster_offset = [-50, -50, -50], clucenters_fn = centers_diag_fn, rng = seed) + cluster_offset=[-50, -50, -50], clucenters_fn=centers_diag_fn, rng=seed) nothing # hide ``` @@ -784,9 +779,9 @@ nothing #hide ``` ```@example 3d_normproj -e064 = clugen(3, 4, 1000, [1, 0, 0], pi / 2, [20, 20, 20], 13, 2, 0.0; rng = seed) -e065 = clugen(3, 4, 1000, [1, 0, 0], pi / 2, [20, 20, 20], 13, 2, 1.0; rng = seed) -e066 = clugen(3, 4, 1000, [1, 0, 0], pi / 2, [20, 20, 20], 13, 2, 3.0; rng = seed) +e064 = clugen(3, 4, 1000, [1, 0, 0], pi / 2, [20, 20, 20], 13, 2, 0.0; rng=seed) +e065 = clugen(3, 4, 1000, [1, 0, 0], pi / 2, [20, 20, 20], 13, 2, 1.0; rng=seed) +e066 = clugen(3, 4, 1000, [1, 0, 0], pi / 2, [20, 20, 20], 13, 2, 3.0; rng=seed) nothing # hide ``` @@ -815,11 +810,11 @@ nothing #hide ```@example 3d_unifproj e067 = clugen(3, 4, 1000, [1, 0, 0], pi / 2, [20, 20, 20], 13, 2, 0.0; - proj_dist_fn = "unif", rng = seed) + proj_dist_fn="unif", rng=seed) e068 = clugen(3, 4, 1000, [1, 0, 0], pi / 2, [20, 20, 20], 13, 2, 1.0; - proj_dist_fn = "unif", rng = seed) + proj_dist_fn="unif", rng=seed) e069 = clugen(3, 4, 1000, [1, 0, 0], pi / 2, [20, 20, 20], 13, 2, 3.0; - proj_dist_fn = "unif", rng = seed) + proj_dist_fn="unif", rng=seed) nothing # hide ``` @@ -851,11 +846,11 @@ nothing #hide ```@example 3d_custfproj e070 = clugen(3, 4, 1000, [1, 0, 0], pi / 2, [20, 20, 20], 13, 2, 0.0; - proj_dist_fn = proj_laplace, rng = seed) + proj_dist_fn=proj_laplace, rng=seed) e071 = clugen(3, 4, 1000, [1, 0, 0], pi / 2, [20, 20, 20], 13, 2, 1.0; - proj_dist_fn = proj_laplace, rng = seed) + proj_dist_fn=proj_laplace, rng=seed) e072 = clugen(3, 4, 1000, [1, 0, 0], pi / 2, [20, 20, 20], 13, 2, 3.0; - proj_dist_fn = proj_laplace, rng = seed) + proj_dist_fn=proj_laplace, rng=seed) nothing # hide ``` @@ -888,11 +883,11 @@ nothing #hide ``` ```@example 3d_n_1 -e073 = clugen(3, 5, 1500, [1, 0, 0], pi / 3, [20, 20, 20], 22, 3, 2; rng = seed) +e073 = clugen(3, 5, 1500, [1, 0, 0], pi / 3, [20, 20, 20], 22, 3, 2; rng=seed) e074 = clugen(3, 5, 1500, [1, 0, 0], pi / 3, [20, 20, 20], 22, 3, 2; - proj_dist_fn = "unif", rng = seed) + proj_dist_fn="unif", rng=seed) e075 = clugen(3, 5, 1500, [1, 0, 0], pi / 3, [20, 20, 20], 22, 3, 2; - proj_dist_fn = proj_laplace, rng = seed) + proj_dist_fn=proj_laplace, rng=seed) nothing # hide ``` @@ -924,11 +919,11 @@ nothing #hide ```@example 3d_n e076 = clugen(3, 5, 1500, [1, 0, 0], pi / 3, [20, 20, 20], 22, 3, 2; - point_dist_fn = "n", rng = seed) + point_dist_fn="n", rng=seed) e077 = clugen(3, 5, 1500, [1, 0, 0], pi / 3, [20, 20, 20], 22, 3, 2; - point_dist_fn = "n", proj_dist_fn = "unif", rng = seed) + point_dist_fn="n", proj_dist_fn="unif", rng=seed) e078 = clugen(3, 5, 1500, [1, 0, 0], pi / 3, [20, 20, 20], 22, 3, 2; - point_dist_fn = "n", proj_dist_fn = proj_laplace, rng = seed) + point_dist_fn="n", proj_dist_fn=proj_laplace, rng=seed) nothing # hide ``` @@ -966,11 +961,11 @@ nothing #hide ```@example 3d_custpt e079 = clugen(3, 5, 1500, [1, 0, 0], pi / 3, [20, 20, 20], 22, 3, 2; - point_dist_fn = clupoints_n_1_exp, rng = seed) + point_dist_fn=clupoints_n_1_exp, rng=seed) e080 = clugen(3, 5, 1500, [1, 0, 0], pi / 3, [20, 20, 20], 22, 3, 2; - point_dist_fn = clupoints_n_1_exp, proj_dist_fn = "unif", rng = seed) + point_dist_fn=clupoints_n_1_exp, proj_dist_fn="unif", rng=seed) e081 = clugen(3, 5, 1500, [1, 0, 0], pi / 3, [20, 20, 20], 22, 3, 2; - point_dist_fn = clupoints_n_1_exp, proj_dist_fn = proj_laplace, rng = seed) + point_dist_fn=clupoints_n_1_exp, proj_dist_fn=proj_laplace, rng=seed) nothing # hide ``` @@ -997,11 +992,11 @@ seed = 9 # Custom clusizes_fn (e083): cluster sizes determined via the uniform distribution, # no correction for total points -clusizes_unif(nclu, npts, ae; rng = nothing) = +clusizes_unif(nclu, npts, ae; rng=nothing) = rand(rng, DiscreteUniform(1, 2 * npts / nclu), nclu) # Custom clusizes_fn (e084): clusters all have the same size, no correction for total points -clusizes_equal(nclu, npts, ae; rng = nothing) = (npts ÷ nclu) .* ones(Integer, nclu) +clusizes_equal(nclu, npts, ae; rng=nothing) = (npts ÷ nclu) .* ones(Integer, nclu) # Custom clucenters_fn (all): yields fixed positions for the clusters centers_fixed(nclu, csep, coff; rng=nothing) = @@ -1012,13 +1007,13 @@ nothing #hide ```@example 3d_clusizes e082 = clugen(3, 4, 1500, [1, 1, 1], pi, [20, 20, 20], 0, 0, 5; - clucenters_fn = centers_fixed, point_dist_fn = "n", rng = seed) + clucenters_fn=centers_fixed, point_dist_fn="n", rng=seed) e083 = clugen(3, 4, 1500, [1, 1, 1], pi, [20, 20, 20], 0, 0, 5; - clucenters_fn = centers_fixed, clusizes_fn = clusizes_unif, point_dist_fn = "n", - rng = seed) + clucenters_fn=centers_fixed, clusizes_fn=clusizes_unif, point_dist_fn="n", + rng=seed) e084 = clugen(3, 4, 1500, [1, 1, 1], pi, [20, 20, 20], 0, 0, 5; - clucenters_fn = centers_fixed, clusizes_fn = clusizes_equal, point_dist_fn = "n", - rng = seed) + clucenters_fn=centers_fixed, clusizes_fn=clusizes_equal, point_dist_fn="n", + rng=seed) nothing # hide ``` @@ -1050,9 +1045,9 @@ proj_laplace(len, n, rng) = rand(rng, Laplace(0, len / 6), n) ``` ```julia -e085 = clugen(1, 3, 2000, [1], 0, [10], 6, 1.5, 0; rng = seed) -e086 = clugen(1, 3, 2000, [1], 0, [10], 6, 1.5, 0; proj_dist_fn = "unif", rng = seed) -e087 = clugen(1, 3, 2000, [1], 0, [10], 6, 1.5, 0; proj_dist_fn = proj_laplace, rng = seed) +e085 = clugen(1, 3, 2000, [1], 0, [10], 6, 1.5, 0; rng=seed) +e086 = clugen(1, 3, 2000, [1], 0, [10], 6, 1.5, 0; proj_dist_fn="unif", rng=seed) +e087 = clugen(1, 3, 2000, [1], 0, [10], 6, 1.5, 0; proj_dist_fn=proj_laplace, rng=seed) ``` ```julia @@ -1079,9 +1074,9 @@ seed = 27 # Custom proj_dist_fn: point projections placed using the Laplace distribution proj_laplace(len, n, rng) = rand(rng, Laplace(0, len / 6), n) -e085 = clugen(1, 3, 2000, [1], 0, [10], 6, 1.5, 0; rng = seed) -e086 = clugen(1, 3, 2000, [1], 0, [10], 6, 1.5, 0; proj_dist_fn = "unif", rng = seed) -e087 = clugen(1, 3, 2000, [1], 0, [10], 6, 1.5, 0; proj_dist_fn = proj_laplace, rng = seed) +e085 = clugen(1, 3, 2000, [1], 0, [10], 6, 1.5, 0; rng=seed) +e086 = clugen(1, 3, 2000, [1], 0, [10], 6, 1.5, 0; proj_dist_fn="unif", rng=seed) +e087 = clugen(1, 3, 2000, [1], 0, [10], 6, 1.5, 0; proj_dist_fn=proj_laplace, rng=seed) plt = plot_examples_1d( e085, "e085: proj_dist_fn=\"norm\" (default)", @@ -1111,7 +1106,7 @@ nothing #hide ``` ```@example 5d_defopt -e088 = clugen(nd, 6, 1500, [1, 1, 0.5, 0, 0], pi / 16, 30 .* ones(nd), 30, 4, 3; rng = seed) +e088 = clugen(nd, 6, 1500, [1, 1, 0.5, 0, 0], pi / 16, 30 .* ones(nd), 30, 4, 3; rng=seed) nothing # hide ``` @@ -1139,7 +1134,7 @@ nothing #hide ```@example 5d_unif_n e089 = clugen(nd, 6, 1500, [0.1, 0.3, 0.5, 0.3, 0.1], pi / 12, 30 .* ones(nd), 35, 5, 3.5; - proj_dist_fn = "unif", point_dist_fn = "n", rng = seed) + proj_dist_fn="unif", point_dist_fn="n", rng=seed) nothing # hide ``` @@ -1171,9 +1166,9 @@ nothing # hide ```@example mrg_cg e090 = clugen(2, 5, 1000, [1, 1], pi / 12, [20, 20], 14, 1.2, 1.5; - proj_dist_fn = "unif", point_dist_fn = "n", rng = seed1) + proj_dist_fn="unif", point_dist_fn="n", rng=seed1) e091 = clugen(2, 3, 1500, [1, 0], 0.05, [20, 20], 0, 0, 4; - point_dist_fn="n", cluster_offset = [20, 0], rng = seed2) + point_dist_fn="n", cluster_offset=[20, 0], rng=seed2) e092 = clumerge(e090, e091) nothing # hide ``` @@ -1220,7 +1215,7 @@ nothing # hide ENV["GKSwstype"] = "100" # hide using CluGen, Distributions, Plots, Main.CluGenExtras # hide -e094 = (points = 120 * rand(500, 2) .- 60, clusters = ones(Int32, 500)) +e094 = (points=120 * rand(500, 2) .- 60, clusters=ones(Int32, 500)) e095 = clumerge(e094, e092) # clumerge(e094, e090, e091) would also work nothing # hide ``` @@ -1255,14 +1250,14 @@ nothing # hide ```@example mrg_cg_mlj # From the MLJ package -X, y = make_moons(100; noise = 0.05, as_table = false, rng = seed1) +X, y = make_moons(100; noise=0.05, as_table=false, rng=seed1) nothing # hide ``` ```@example mrg_cg_mlj e096 = (points=X, clusters=y) e097 = clugen(2, 5, 200, [1, 1], pi / 12, [1, 1], 0.1, 0.01, 0.25; - proj_dist_fn = "unif", point_dist_fn = "n", rng = seed2) + proj_dist_fn="unif", point_dist_fn="n", rng=seed2) e098 = clumerge(e096, e097) nothing # hide ``` @@ -1282,8 +1277,8 @@ nothing # hide We can also hierarchize clusters from different sources: ```@example mrg_cg_mlj -e099 = Dict(pairs(e096)); e099[:hclusters] = ones(Int32, length(e099[:clusters])) -e100 = Dict(pairs(e097)); e100[:hclusters] = ones(Int32, length(e100[:clusters])) +e099 = Dict(pairs(e096)); e099[:hclusters]=ones(Int32, length(e099[:clusters])) +e100 = Dict(pairs(e097)); e100[:hclusters]=ones(Int32, length(e100[:clusters])) e101 = clumerge(e099, e100; clusters_field=:hclusters) nothing # hide ``` diff --git a/docs/src/theory.md b/docs/src/theory.md index eb75e13..dadb94f 100644 --- a/docs/src/theory.md +++ b/docs/src/theory.md @@ -37,7 +37,7 @@ using CluGen, LinearAlgebra, Plots, Main.CluGenExtras # Create clusters d = [1, 1] nclu = 4 -r = clugen(2, nclu, 200, d, pi/16, [10, 10], 10, 1.5, 1; rng = 1234) +r = clugen(2, nclu, 200, d, pi/16, [10, 10], 10, 1.5, 1; rng=1234) plt, _ = plot_story_2d(d, r) savefig(plt, "algorithm.svg") @@ -72,7 +72,7 @@ and plotted with the following instructions: ```julia-repl julia> using CluGen, Plots -julia> r = clugen(2, 4, 200, [1, 1], pi/16, [10, 10], 10, 1.5, 1; rng = 1234); +julia> r = clugen(2, 4, 200, [1, 1], pi/16, [10, 10], 10, 1.5, 1; rng=1234); -julia> plot(r.points[:,1], r.points[:,2], seriestype = :scatter, group=r.clusters) +julia> plot(r.points[:,1], r.points[:,2], seriestype=:scatter, group=r.clusters) ```