Generate Synthetic Data with Various Structures
data_gen.Rd
Generates either:
Structured (x, y) scatter data (linear, sine, circle, etc.), or
A matrix of scaled orthogonal polynomial features.
Arguments
- type
Character string. Options:
"polynomial"
for orthogonal polynomial features"linear"
,"sine"
,"circle"
,"cluster"
,"snake"
,"outliers"
,"sparse"
,"clumpy"
,"skewed"
,"striated"
,"concave"
,"monotonic"
,"doughnut"
, or"all"
to generate all scatter structures.
- n
Integer. Number of samples to generate. Default is 500.
- degree
Integer. Degree of polynomial features (only for
type = "polynomial"
).- seed
Optional integer. Sets random seed for reproducibility.
Value
If
type = "polynomial"
, returns a matrix (n
xdegree
).Otherwise a tibble with columns:
x
: Numeric vector of x-valuesy
: Numeric vector of y-valuesstructure
: Character name of the structure type
Examples
data_gen("linear", n = 200)
#> # A tibble: 200 × 3
#> x y structure
#> <dbl> <dbl> <chr>
#> 1 0.543 0.536 linear
#> 2 -0.890 -0.882 linear
#> 3 -1.54 -1.54 linear
#> 4 1.26 1.24 linear
#> 5 -1.45 -1.43 linear
#> 6 1.54 1.56 linear
#> 7 0.298 0.308 linear
#> 8 -1.12 -1.11 linear
#> 9 1.26 1.25 linear
#> 10 -1.56 -1.58 linear
#> # ℹ 190 more rows
data_gen("polynomial", degree = 4, n = 200)
#> 1 2 3 4
#> [1,] 1.329043217 0.720433574 -0.308849982 -1.18946790
#> [2,] -1.371922092 1.187353508 -0.628946490 -0.13102446
#> [3,] -0.157840970 -1.093256438 0.474523980 0.97861343
#> [4,] 1.703584333 1.977026593 2.030174511 1.99532032
#> [5,] 0.322263322 -1.062086976 -0.631698680 0.85977172
#> [6,] 0.951576126 -0.220364238 -1.206519954 -1.06783925
#> [7,] -0.804648316 -0.299138643 1.143078050 -0.85607993
#> [8,] 0.515056142 -0.900758369 -0.990069639 0.35645880
#> [9,] -1.058637550 0.275143086 0.719327990 -1.21915030
#> [10,] -0.110548115 -1.113665796 0.369370617 1.04553459
#> [11,] -1.071465251 0.308073222 0.683420658 -1.21541173
#> [12,] -1.230632602 0.748076346 0.106043669 -0.90998567
#> [13,] -0.375808132 -0.932869537 0.893666650 0.48453493
#> [14,] 1.610743951 1.635545078 1.292528153 0.75081399
#> [15,] 1.366674139 0.832142958 -0.146170966 -1.06143637
#> [16,] -0.744256755 -0.413908185 1.171790042 -0.68637856
#> [17,] 0.618451725 -0.779107941 -1.129768773 0.01931742
#> [18,] -1.218324704 0.711978919 0.159786265 -0.95293932
#> [19,] -0.542583869 -0.736546737 1.104098867 -0.03601880
#> [20,] 0.501002171 -0.915400187 -0.967851630 0.39947435
#> [21,] -0.102974387 -1.116457591 0.352213776 1.05473766
#> [22,] 0.793387315 -0.517434885 -1.251562667 -0.58401496
#> [23,] 1.416821201 0.986056447 0.094015891 -0.83547212
#> [24,] -1.278556881 0.891943067 -0.118554697 -0.70701907
#> [25,] 0.526218307 -0.888806445 -1.007200474 0.32173512
#> [26,] 1.250547209 0.497870346 -0.601785417 -1.35437498
#> [27,] -0.386792278 -0.921902317 0.910998079 0.45297968
#> [28,] 0.500527905 -0.915886387 -0.967089481 0.40091175
#> [29,] -0.055805475 -1.130882820 0.243748797 1.10236360
#> [30,] -1.075797748 0.319280506 0.670950696 -1.21353198
#> [31,] 0.126417545 -1.138661346 -0.187952220 1.12338056
#> [32,] -1.144906955 0.503873973 0.448067457 -1.13819457
#> [33,] 0.594439512 -0.809546147 -1.101296493 0.10029077
#> [34,] -1.103645240 0.392344226 0.586616857 -1.19371735
#> [35,] 0.107354560 -1.141415430 -0.142733963 1.13348246
#> [36,] -1.341800775 1.089863520 -0.453479823 -0.34478524
#> [37,] 0.089230835 -1.143260720 -0.099623393 1.14042542
#> [38,] -1.504055904 1.639607843 -1.526827054 1.16558335
#> [39,] 1.190425108 0.336963364 -0.785717915 -1.39882214
#> [40,] -0.655316759 -0.567696676 1.170939071 -0.40825370
#> [41,] -0.789909277 -0.327920908 1.152393579 -0.81656193
#> [42,] -0.271079368 -1.023535903 0.708292554 0.75647614
#> [43,] 0.531985422 -0.882519295 -1.015868485 0.30360951
#> [44,] 1.617673245 1.660349243 1.343757548 0.83168125
#> [45,] -0.469614164 -0.830296075 1.026684707 0.20082361
#> [46,] 0.515770085 -0.900002469 -0.991179155 0.35425233
#> [47,] 1.193452538 0.344867510 -0.777262896 -1.39810416
#> [48,] -1.138564272 0.486475745 0.470439553 -1.14886649
#> [49,] 1.681343289 1.893419370 1.843235010 1.66446050
#> [50,] -1.341222590 1.088012540 -0.450213889 -0.34861819
#> [51,] -0.811485518 -0.285617794 1.138237244 -0.87394139
#> [52,] 0.555281088 -0.856346374 -1.049576683 0.22919214
#> [53,] 0.090494675 -1.143156483 -0.102632431 1.14002561
#> [54,] -0.776968291 -0.352781055 1.159328051 -0.78079079
#> [55,] 1.722147216 2.047675941 2.191246370 2.28812574
#> [56,] 0.615985731 -0.782294816 -1.126962698 0.02768970
#> [57,] -1.328152896 1.046376322 -0.377404737 -0.43261564
#> [58,] 0.526668421 -0.888318489 -1.007881520 0.32032490
#> [59,] 1.371328905 0.846186658 -0.125014122 -1.04319986
#> [60,] 1.554905325 1.439685038 0.901523731 0.16469367
#> [61,] -0.197351350 -1.072271525 0.559318043 0.91062947
#> [62,] 0.063616408 -1.144583565 -0.038590283 1.14579776
#> [63,] -0.426440472 -0.880012455 0.969800373 0.33513846
#> [64,] -0.783103274 -0.341043406 1.156184461 -0.79786925
#> [65,] 1.652489019 1.786643274 1.610396529 1.26657953
#> [66,] -0.401551113 -0.906730404 0.933587213 0.40980705
#> [67,] -0.953763214 0.020078615 0.958080980 -1.15790093
#> [68,] 0.855107447 -0.408357435 -1.253431887 -0.78649859
#> [69,] -1.059605459 0.277614649 0.716671236 -1.21896214
#> [70,] -0.859442818 -0.187765932 1.094781728 -0.98981885
#> [71,] 1.264204306 0.535577159 -0.555203981 -1.33488409
#> [72,] -0.449942765 -0.853478871 1.001729880 0.26270469
#> [73,] -1.405437650 1.298275767 -0.836649867 0.14054840
#> [74,] -1.543685882 1.783057604 -1.838675108 1.68165449
#> [75,] -1.231429197 0.750424629 0.102510530 -0.90708055
#> [76,] -1.589393430 1.952980837 -2.223881412 2.35825991
#> [77,] 0.887504748 -0.347604309 -1.244720687 -0.88677995
#> [78,] 1.533222269 1.365557524 0.759962315 -0.03286037
#> [79,] 1.732976530 2.089256853 2.287356883 2.46612016
#> [80,] -0.246117356 -1.041432621 0.659349490 0.81245503
#> [81,] -0.711201941 -0.473183130 1.177239317 -0.58606069
#> [82,] 0.038672889 -1.144425171 0.020844475 1.14602320
#> [83,] -1.461207689 1.488562810 -1.212175064 0.67673720
#> [84,] -1.627878012 2.099768529 -2.569969455 2.99974242
#> [85,] 0.064559112 -1.144561559 -0.040837344 1.14569235
#> [86,] -0.800061968 -0.308148236 1.146140013 -0.84392862
#> [87,] -0.759040785 -0.386585709 1.167045948 -0.72971331
#> [88,] 0.258324738 -1.096761064 -0.492722861 0.97668758
#> [89,] -0.773351337 -0.359660669 1.161060657 -0.77062352
#> [90,] 0.519489309 -0.896045760 -0.996928707 0.34272559
#> [91,] -0.551957673 -0.723618140 1.112206531 -0.06699238
#> [92,] 1.535142037 1.372077082 0.772267868 -0.01602000
#> [93,] 1.473295593 1.166297133 0.397696225 -0.49783148
#> [94,] -1.320877284 1.023368152 -0.337712661 -0.47720777
#> [95,] 0.894591306 -0.333994259 -1.241887397 -0.90801952
#> [96,] 0.318089143 -1.064636809 -0.622864975 0.86825692
#> [97,] 0.752891352 -0.584254839 -1.237933905 -0.44573669
#> [98,] 0.767569981 -0.560469222 -1.243964419 -0.49619931
#> [99,] -1.499360407 1.622850161 -1.491215267 1.10858857
#> [100,] -0.156060619 -1.094117700 0.470633106 0.98142262
#> [101,] 1.156801558 0.250591131 -0.874026127 -1.39680201
#> [102,] 0.307268617 -1.071060501 -0.599799432 0.88971060
#> [103,] 0.381575136 -1.021536517 -0.752978682 0.72711091
#> [104,] 1.383477382 0.883073486 -0.068709186 -0.99302278
#> [105,] 0.831206320 -0.451634565 -1.255512328 -0.70961120
#> [106,] 1.575993499 1.512813482 1.044670794 0.37264682
#> [107,] -0.163232960 -1.090603649 0.486272874 0.96996984
#> [108,] -0.654624662 -0.568822241 1.170743592 -0.40600401
#> [109,] 1.007274681 -0.102099579 -1.149299158 -1.20096580
#> [110,] 0.478490238 -0.937909495 -0.930808025 0.46662992
#> [111,] -1.089991325 0.356298019 0.628875905 -1.20513127
#> [112,] -0.258714631 -1.032579575 0.684253254 0.78467084
#> [113,] -1.630726452 2.110768089 -2.596389572 3.04993981
#> [114,] -0.202564999 -1.069234957 0.570270348 0.90086887
#> [115,] 0.984260431 -0.151828551 -1.175748598 -1.14911501
#> [116,] 1.089037574 0.084399908 -1.021775483 -1.34206510
#> [117,] -0.804193126 -0.300034991 1.143388576 -0.85487995
#> [118,] 0.967919826 -0.186399500 -1.192114899 -1.10953965
#> [119,] -1.536534434 1.756904871 -1.780896581 1.58380641
#> [120,] -0.136100987 -1.103275618 0.426634951 1.01137825
#> [121,] 0.183166117 -1.125527695 -0.321246713 1.07649264
#> [122,] -0.161861683 -1.091284623 0.483289968 0.97218735
#> [123,] 1.139874346 0.208090028 -0.914660088 -1.38917214
#> [124,] 1.528432862 1.349329492 0.729454529 -0.07433055
#> [125,] 0.679256493 -0.696115118 -1.189975793 -0.19002484
#> [126,] -1.314021893 1.001799995 -0.300858713 -0.51782938
#> [127,] -0.958987524 0.032187460 0.948419789 -1.16442175
#> [128,] -0.005043079 -1.140704552 0.124626719 1.13452781
#> [129,] 0.814238208 -0.481562791 -1.254818269 -0.65378622
#> [130,] 0.209476936 -1.116931618 -0.382076282 1.04635002
#> [131,] 1.366578934 0.831856238 -0.146601293 -1.06180371
#> [132,] -0.629245928 -0.609336963 1.161664370 -0.32295555
#> [133,] -0.865329126 -0.175391976 1.088275944 -1.00279673
#> [134,] 0.733781217 -0.614480693 -1.228276901 -0.37963219
#> [135,] -0.564945688 -0.705371571 1.122711445 -0.11000934
#> [136,] 0.021553347 -1.143490438 0.061570545 1.14332150
#> [137,] -1.218557925 0.712659695 0.158782635 -0.95215883
#> [138,] 0.730657468 -0.619341753 -1.226507599 -0.36879423
#> [139,] -0.553275314 -0.721784655 1.113311070 -0.07135177
#> [140,] 1.163512597 0.267623282 -0.857213176 -1.39863122
#> [141,] 0.236358434 -1.106508878 -0.443376860 1.01018498
#> [142,] 1.613345184 1.644843563 1.311688513 0.78095427
#> [143,] -1.504211909 1.640165474 -1.528015052 1.16749175
#> [144,] 0.585332282 -0.820744601 -1.089840586 0.13064886
#> [145,] -1.363245976 1.159059154 -0.577328547 -0.19546581
#> [146,] -0.151229297 -1.096418258 0.460046047 0.98893329
#> [147,] 0.973827670 -0.173971289 -1.186426275 -1.12410021
#> [148,] -0.628650996 -0.610268989 1.161407458 -0.32099763
#> [149,] -1.268178449 0.860340456 -0.067819278 -0.75595774
#> [150,] -1.385971199 1.233536368 -0.714397315 -0.02162187
#> [151,] -0.414056957 -0.893483417 0.952083743 0.37256881
#> [152,] 0.324333592 -1.060807505 -0.636066383 0.85552047
#> [153,] 0.689426342 -0.681406252 -1.198288375 -0.22538216
#> [154,] 0.733099488 -0.615543484 -1.227895295 -0.37726754
#> [155,] -0.355409227 -0.952502662 0.860343630 0.54175017
#> [156,] -1.300266280 0.958847862 -0.228495961 -0.59532538
#> [157,] -1.296727249 0.947867387 -0.210218955 -0.61441015
#> [158,] 1.021539846 -0.070665527 -1.130870334 -1.23065130
#> [159,] -1.116677407 0.427147956 0.544631099 -1.17966940
#> [160,] -0.282698336 -1.014718036 0.730502686 0.72916955
#> [161,] 1.571086282 1.495705413 1.010874910 0.32283460
#> [162,] 0.900746937 -0.322078592 -1.239150966 -0.92624653
#> [163,] 0.544250113 -0.868894980 -1.033879313 0.26466274
#> [164,] -0.476129930 -0.822421499 1.034583373 0.18010283
#> [165,] 1.665141893 1.833230469 1.711162311 1.43677578
#> [166,] -1.252885465 0.814223238 0.004816930 -0.82297483
#> [167,] 0.595079512 -0.808752032 -1.102088152 0.09814958
#> [168,] 1.737507985 2.106735958 2.328045660 2.54219527
#> [169,] -1.021887527 0.182891668 0.813940206 -1.21544308
#> [170,] -1.163074584 0.554219286 0.381789845 -1.10312641
#> [171,] -1.442353503 1.423434041 -1.080974566 0.48321994
#> [172,] 0.237909615 -1.105856848 -0.446884733 1.00793493
#> [173,] -0.036055417 -1.135406738 0.197641505 1.11725872
#> [174,] 1.438602384 1.054705308 0.206901450 -0.71616277
#> [175,] -1.572803573 1.890751961 -2.080861016 2.10225801
#> [176,] 1.282845944 0.587736797 -0.488677605 -1.30224177
#> [177,] 0.083731008 -1.143671655 -0.086525389 1.14201783
#> [178,] -1.066365749 0.294937027 0.697876207 -1.21722236
#> [179,] -0.397962942 -0.910464981 0.928170202 0.42038222
#> [180,] 0.600276356 -0.802268975 -1.108450739 0.08072661
#> [181,] 1.362441218 0.819415141 -0.165211065 -1.07755107
#> [182,] 0.862038122 -0.395563130 -1.252145794 -0.80836045
#> [183,] -0.221409053 -1.057739648 0.609356530 0.86410232
#> [184,] -1.090147295 0.356707364 0.628403094 -1.20501956
#> [185,] 1.264765183 0.537134870 -0.553252157 -1.33400477
#> [186,] 1.397405231 0.925779687 -0.002207075 -0.93080873
#> [187,] -0.277924755 -1.018378285 0.721423115 0.74048222
#> [188,] -1.505534751 1.644896147 -1.538101167 1.18371244
#> [189,] 1.627337227 1.695126465 1.416218977 0.94757669
#> [190,] 1.052159766 -0.001616359 -1.085928995 -1.28745645
#> [191,] -0.883598602 -0.136480401 1.066408681 -1.04115594
#> [192,] -0.501130546 -0.791303381 1.063140085 0.09970291
#> [193,] -1.026580978 0.194500775 0.802529828 -1.21705924
#> [194,] -0.392782267 -0.915804929 0.920263791 0.43556209
#> [195,] -0.293515690 -1.006230129 0.750838739 0.70305756
#> [196,] 1.464327210 1.137185393 0.347065786 -0.55770074
#> [197,] -0.688004530 -0.513284619 1.176932963 -0.51329778
#> [198,] -1.158310119 0.540942962 0.399487832 -1.11297820
#> [199,] -0.088090115 -1.121560725 0.318272874 1.07157989
#> [200,] -1.257894125 0.829268166 -0.018695147 -0.80168537
#> attr(,"coefs")
#> attr(,"coefs")$alpha
#> [1] 0.4770152 0.5084470 0.5013686 0.4914184
#>
#> attr(,"coefs")$norm2
#> [1] 1.00000000 200.00000000 16.91032938 1.09207845 0.06643508
#> [6] 0.00402836
#>
#> attr(,"degree")
#> [1] 1 2 3 4
#> attr(,"class")
#> [1] "poly" "matrix"
data_gen("all", n = 200)
#> # A tibble: 2,602 × 3
#> x y structure
#> <dbl> <dbl> <chr>
#> 1 1.33 1.34 linear
#> 2 0.101 0.0971 linear
#> 3 0.826 0.814 linear
#> 4 0.756 0.735 linear
#> 5 -0.851 -0.864 linear
#> 6 0.595 0.586 linear
#> 7 -1.04 -1.03 linear
#> 8 0.654 0.661 linear
#> 9 -1.10 -1.06 linear
#> 10 0.978 0.964 linear
#> # ℹ 2,592 more rows