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 1.19 1.17 linear
#> 2 -1.50 -1.50 linear
#> 3 0.114 0.113 linear
#> 4 -0.806 -0.822 linear
#> 5 0.407 0.414 linear
#> 6 1.74 1.74 linear
#> 7 -0.837 -0.836 linear
#> 8 1.38 1.36 linear
#> 9 -1.26 -1.25 linear
#> 10 1.15 1.13 linear
#> # ℹ 190 more rows
data_gen("polynomial", degree = 4, n = 200)
#> 1 2 3 4
#> [1,] 0.21050040 -1.03564707 -0.398274752 0.973432426
#> [2,] 1.21604319 0.66250468 -0.377538850 -1.181998457
#> [3,] 0.59298776 -0.65471720 -1.017331155 0.020427470
#> [4,] 0.39083363 -0.89658773 -0.747479751 0.611228366
#> [5,] 1.41182191 1.25467852 0.492156094 -0.488387882
#> [6,] -0.64746101 -0.70661731 1.247409643 -0.302653731
#> [7,] 0.34086572 -0.94236312 -0.658859214 0.730876065
#> [8,] 0.68938910 -0.50737046 -1.083077911 -0.291689224
#> [9,] 1.13578905 0.44439401 -0.626229982 -1.240331825
#> [10,] 1.62171101 1.98421716 1.891976806 1.455590216
#> [11,] -0.46020380 -0.91809668 1.027479675 0.314715394
#> [12,] 1.19956657 0.61655677 -0.433424934 -1.203047024
#> [13,] -0.37326107 -0.98977495 0.881091696 0.563867881
#> [14,] 0.67947344 -0.52347992 -1.078507964 -0.259543258
#> [15,] 0.52101831 -0.75124526 -0.939726482 0.245776822
#> [16,] -1.64679525 1.74064293 -1.717380568 1.640874658
#> [17,] 1.47934460 1.47868583 0.886467531 -0.020116369
#> [18,] 1.68376089 2.21865628 2.408563347 2.337925174
#> [19,] 1.59189996 1.87462925 1.661098109 1.086245307
#> [20,] -0.80587283 -0.46682135 1.301391710 -0.829381933
#> [21,] 0.61307610 -0.62571749 -1.034820739 -0.044147967
#> [22,] 1.13411654 0.44000092 -0.630794655 -1.240427047
#> [23,] 0.90548310 -0.10198257 -1.038230150 -0.929708495
#> [24,] -0.56930626 -0.80436379 1.173597899 -0.036746805
#> [25,] 1.66793077 2.15803268 2.272076311 2.097702600
#> [26,] 1.55322898 1.73541650 1.377896848 0.656572059
#> [27,] 0.03659735 -1.10124314 -0.008579466 1.113471127
#> [28,] -0.38878636 -0.97820842 0.908923591 0.521930346
#> [29,] 0.34004570 -0.94306803 -0.657345901 0.732726487
#> [30,] -1.25836333 0.52553505 0.506001115 -1.304142976
#> [31,] 0.37493621 -0.91175361 -0.720075872 0.650725471
#> [32,] 0.41592432 -0.87150797 -0.789130143 0.546347059
#> [33,] -1.17250563 0.30223552 0.786246828 -1.427748501
#> [34,] -0.94066924 -0.21882156 1.227653904 -1.199251205
#> [35,] -0.03454795 -1.10869172 0.156323004 1.105073500
#> [36,] -0.80612490 -0.46639530 1.301363408 -0.830166705
#> [37,] 1.69012006 2.24316646 2.464309914 2.437437807
#> [38,] 0.55442448 -0.70787227 -0.978557563 0.142598453
#> [39,] 0.21758959 -1.03154619 -0.413343050 0.963087706
#> [40,] 0.36371425 -0.92212075 -0.700278163 0.677817515
#> [41,] -1.06198827 0.03893539 1.050693359 -1.403655404
#> [42,] -0.44097513 -0.93539733 0.997177293 0.372646783
#> [43,] -1.31240650 0.67449884 0.293627976 -1.148865763
#> [44,] -0.35770226 -1.00082862 0.852525478 0.604663660
#> [45,] -1.59253183 1.55072920 -1.302963842 0.929869646
#> [46,] 0.45182119 -0.83319220 -0.845095153 0.448513798
#> [47,] 0.08416342 -1.08998391 -0.117970859 1.097514581
#> [48,] -0.36672197 -0.99448620 0.869166370 0.581166846
#> [49,] 1.31256942 0.94381466 0.002454149 -0.950556582
#> [50,] -0.72993833 -0.58873181 1.292786634 -0.583108518
#> [51,] 0.46141932 -0.82246172 -0.859296835 0.421434415
#> [52,] -0.64411773 -0.71107682 1.244838504 -0.291198084
#> [53,] -1.22330200 0.43236667 0.628713965 -1.371686334
#> [54,] 1.11376402 0.38704057 -0.684378124 -1.238234075
#> [55,] 0.85437782 -0.20723152 -1.075664160 -0.796469691
#> [56,] 0.61970645 -0.61594886 -1.040171301 -0.065561394
#> [57,] -1.01783663 -0.05865892 1.128147520 -1.347505835
#> [58,] 1.70773853 2.31154331 2.621529311 2.722331198
#> [59,] 0.58881843 -0.66062361 -1.013464254 0.033761997
#> [60,] 0.88299747 -0.14900631 -1.056907890 -0.873049097
#> [61,] 0.50651976 -0.76929713 -0.921435925 0.289596764
#> [62,] -1.36413523 0.82316761 0.062973490 -0.936139556
#> [63,] -1.55590535 1.42624406 -1.043571307 0.513948913
#> [64,] 0.17951048 -1.05226152 -0.331436412 1.014547297
#> [65,] -1.63418918 1.69593964 -1.617846948 1.465208933
#> [66,] -1.07977123 0.07946822 1.015081211 -1.419431413
#> [67,] 0.51739098 -0.75580543 -0.935230198 0.256798992
#> [68,] 1.12837512 0.42496757 -0.646277111 -1.240431478
#> [69,] 1.44298883 1.35681508 0.667817636 -0.288967928
#> [70,] 1.13127794 0.43255917 -0.638485484 -1.240491406
#> [71,] 1.02735206 0.17244295 -0.872756845 -1.166506964
#> [72,] 0.65518188 -0.56202110 -1.065121575 -0.180631805
#> [73,] -0.55530913 -0.82043533 1.157501536 0.010042456
#> [74,] -0.10623996 -1.10480991 0.321549744 1.057607465
#> [75,] 1.17087088 0.53797535 -0.524741820 -1.228194465
#> [76,] 0.94051969 -0.02647005 -1.001991648 -1.010918960
#> [77,] 0.33499040 -0.94738062 -0.647976716 0.744049847
#> [78,] 0.33792893 -0.94488073 -0.653431148 0.737485486
#> [79,] -1.12520836 0.18622783 0.912175991 -1.439918723
#> [80,] -0.08072879 -1.10750135 0.263040509 1.078943035
#> [81,] 1.50674216 1.57246952 1.061232438 0.209710754
#> [82,] -1.52219167 1.31429598 -0.818909844 0.173890701
#> [83,] -1.23222963 0.45583058 0.598568997 -1.356825823
#> [84,] -0.25007300 -1.06254913 0.638789925 0.849270463
#> [85,] 0.22682325 -1.02603719 -0.432836694 0.949097922
#> [86,] -1.07962797 0.07913888 1.015378433 -1.419321008
#> [87,] 0.35947926 -0.92596034 -0.692711959 0.687867403
#> [88,] 0.81716954 -0.28020609 -1.091925282 -0.690546620
#> [89,] -1.49166947 1.21512565 -0.626921620 -0.100429305
#> [90,] 0.98357758 0.07006966 -0.945118160 -1.097051063
#> [91,] 1.46359652 1.42553470 0.789917477 -0.141508516
#> [92,] -1.57503564 1.49089140 -1.177040909 0.724983065
#> [93,] 0.74178161 -0.41862087 -1.098255175 -0.459755041
#> [94,] 1.40260746 1.22489577 0.442268520 -0.542098349
#> [95,] 0.83346132 -0.24863285 -1.085913879 -0.737725661
#> [96,] -1.13201635 0.20261949 0.895250377 -1.440369537
#> [97,] -1.08208547 0.08479481 1.010256401 -1.421176628
#> [98,] -0.40349907 -0.96675255 0.934652425 0.481101241
#> [99,] -0.15712442 -1.09511867 0.436698387 1.000668287
#> [100,] -0.15186541 -1.09638711 0.424915332 1.007427714
#> [101,] -1.12880473 0.19487398 0.903284591 -1.440245707
#> [102,] -0.67047118 -0.67525035 1.263605226 -0.381459080
#> [103,] 1.27744060 0.83903896 -0.146451207 -1.057417931
#> [104,] -0.82699075 -0.43063802 1.297661040 -0.894172977
#> [105,] 0.63008899 -0.60045562 -1.048120587 -0.099168430
#> [106,] 1.22833692 0.69718120 -0.334173342 -1.163006980
#> [107,] 1.06101933 0.25407836 -0.806726101 -1.205629374
#> [108,] -1.16201188 0.27606766 0.815883566 -1.433614522
#> [109,] -0.09364472 -1.10631962 0.292714651 1.068750127
#> [110,] 0.75980740 -0.38667477 -1.099858563 -0.516449072
#> [111,] -0.79357610 -0.48743356 1.302302818 -0.790789103
#> [112,] 0.37848838 -0.90841366 -0.726265240 0.642012343
#> [113,] -0.45311172 -0.92457337 1.016449178 0.336251114
#> [114,] 0.39072458 -0.89669368 -0.747294397 0.611503658
#> [115,] -0.29241714 -1.04134086 0.725954869 0.761307601
#> [116,] -0.99270828 -0.11226753 1.165443838 -1.305683417
#> [117,] 0.80977540 -0.29434106 -1.094093853 -0.668761290
#> [118,] -0.13643882 -1.09975304 0.390182334 1.026100587
#> [119,] -1.38353285 0.88045078 -0.030643680 -0.838829095
#> [120,] 0.93937908 -0.02897134 -1.003311060 -1.008422776
#> [121,] -1.39316854 0.90921707 -0.078621273 -0.786748983
#> [122,] -1.63891794 1.71266722 -1.654950359 1.530343281
#> [123,] -0.50504848 -0.87455322 1.093088982 0.174387218
#> [124,] -0.59642059 -0.77199147 1.202365300 -0.128307146
#> [125,] 0.14667389 -1.06753535 -0.259086085 1.050655920
#> [126,] 0.26475617 -1.00141596 -0.511217687 0.885634069
#> [127,] -0.89412093 -0.30902965 1.266854303 -1.084677146
#> [128,] -1.49048125 1.21130688 -0.619663615 -0.110486195
#> [129,] 1.50296284 1.55943340 1.036607294 0.176569166
#> [130,] -1.51110777 1.27804344 -0.747949773 0.070675015
#> [131,] -0.40861697 -0.96265470 0.943450300 0.466659263
#> [132,] -0.72120334 -0.60193310 1.289687278 -0.553806878
#> [133,] -1.43647668 1.04105852 -0.306549729 -0.520619033
#> [134,] -0.22349487 -1.07382385 0.582356176 0.898580818
#> [135,] 1.08233496 0.30706720 -0.760107229 -1.223257117
#> [136,] -0.99284361 -0.11198259 1.165255871 -1.305926380
#> [137,] 0.86616843 -0.18346479 -1.068607616 -0.828583415
#> [138,] 1.12223342 0.40896732 -0.662519202 -1.239890016
#> [139,] 1.35677779 1.07957147 0.207739947 -0.775476841
#> [140,] -1.66898009 1.82017251 -1.897411554 1.966017916
#> [141,] 1.56256430 1.76871845 1.444598385 0.755336747
#> [142,] -1.15915714 0.26899128 0.823776893 -1.434888990
#> [143,] -0.24782937 -1.06356161 0.634074227 0.853612709
#> [144,] 0.05096610 -1.09837240 -0.041749224 1.110466040
#> [145,] -1.43777415 1.04507273 -0.313692516 -0.511810364
#> [146,] 0.61290844 -0.62596324 -1.034682696 -0.043607051
#> [147,] 1.36995559 1.12087934 0.272880096 -0.713981120
#> [148,] -0.12504951 -1.10189843 0.364390102 1.038772526
#> [149,] -1.62343001 1.65806532 -1.534466153 1.320377283
#> [150,] 0.08808247 -1.08883187 -0.126921390 1.095434812
#> [151,] -0.49475853 -0.88494000 1.078685269 0.207177855
#> [152,] -1.34562871 0.76929601 0.148637743 -1.019872461
#> [153,] -1.67087448 1.82701438 -1.913074409 1.994744419
#> [154,] -0.23977957 -1.06710211 0.617080082 0.868921371
#> [155,] 0.46144299 -0.82243499 -0.859331454 0.421367166
#> [156,] 0.22182897 -1.02904043 -0.422311983 0.956736832
#> [157,] -1.52863529 1.33549694 -0.860818278 0.235819215
#> [158,] 1.72155767 2.36565814 2.747714670 2.955403082
#> [159,] -0.26600809 -1.05503594 0.672010891 0.817495578
#> [160,] 0.21628177 -1.03231113 -0.410569804 0.965022081
#> [161,] 1.11175145 0.38185361 -0.689481003 -1.237687905
#> [162,] -0.16957248 -1.09187117 0.464462761 0.983877871
#> [163,] 1.24928891 0.75705439 -0.256938613 -1.123915526
#> [164,] 0.89595006 -0.12205612 -1.046578893 -0.906090917
#> [165,] 1.48219127 1.48835245 0.904222721 0.002649877
#> [166,] -1.44580676 1.07000791 -0.358325220 -0.456160322
#> [167,] -1.55821920 1.43402003 -1.059482430 0.538765245
#> [168,] -0.53286518 -0.84529600 1.129987414 0.084213522
#> [169,] -1.71847377 2.00154562 -2.321806013 2.767920323
#> [170,] 0.62049400 -0.61478205 -1.040792714 -0.068107575
#> [171,] 0.36468472 -0.92123526 -0.702004759 0.675500954
#> [172,] -1.31583651 0.68417247 0.279174965 -1.136776200
#> [173,] 1.20630868 0.63528534 -0.410864245 -1.195033499
#> [174,] 1.45104971 1.38358289 0.715008795 -0.232800933
#> [175,] -0.84550198 -0.39810519 1.292090308 -0.949233520
#> [176,] -0.78259244 -0.50556042 1.302346316 -0.755833284
#> [177,] -0.51730000 -0.86187931 1.109712770 0.134933483
#> [178,] 0.90783921 -0.09699019 -1.036068275 -0.935450305
#> [179,] -0.32830171 -1.02024616 0.796805258 0.678209729
#> [180,] -1.01693578 -0.06060504 1.129568388 -1.346124163
#> [181,] 0.30594669 -0.97105603 -0.592862067 0.806232956
#> [182,] 0.34372650 -0.93989224 -0.664124351 0.724390968
#> [183,] -1.48840476 1.20464088 -0.607018355 -0.127951356
#> [184,] 1.03253557 0.18484759 -0.863187472 -1.173384092
#> [185,] 0.92386316 -0.06270944 -1.020319502 -0.973453838
#> [186,] 1.15906169 0.50616853 -0.560137208 -1.234488344
#> [187,] -1.69823973 1.92673819 -2.144469014 2.427009208
#> [188,] 0.34950321 -0.93484735 -0.674687912 0.711156268
#> [189,] -0.08676831 -1.10699496 0.276928399 1.074332737
#> [190,] -0.37418957 -0.98909827 0.882775381 0.561393808
#> [191,] -0.62244076 -0.73938800 1.226859487 -0.216990033
#> [192,] -1.51636425 1.29520194 -0.781424777 0.119106012
#> [193,] -0.37906993 -0.98551004 0.891585358 0.548317837
#> [194,] 0.99660108 0.10008173 -0.925150592 -1.119755053
#> [195,] 0.75627569 -0.39299073 -1.099694728 -0.505401825
#> [196,] -1.44982854 1.08254639 -0.380939296 -0.427569954
#> [197,] -0.27868071 -1.04865781 0.698076015 0.791074178
#> [198,] -1.48228973 1.18506594 -0.570063919 -0.178576383
#> [199,] 0.32518504 -0.95558338 -0.629611124 0.765595721
#> [200,] 0.56899191 -0.68818146 -0.993988192 0.096778274
#> attr(,"coefs")
#> attr(,"coefs")$alpha
#> [1] 0.4989729 0.4723856 0.5162145 0.5139908
#>
#> attr(,"coefs")$norm2
#> [1] 1.00000000 200.00000000 16.58458087 1.11767200 0.07007317
#> [6] 0.00429851
#>
#> 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 0.227 0.255 linear
#> 2 1.05 1.04 linear
#> 3 0.448 0.465 linear
#> 4 -1.34 -1.33 linear
#> 5 1.60 1.58 linear
#> 6 1.47 1.46 linear
#> 7 0.815 0.777 linear
#> 8 0.560 0.558 linear
#> 9 -0.00611 0.0204 linear
#> 10 -1.55 -1.57 linear
#> # ℹ 2,592 more rows