Data Generators¶
Warning
This section may be subject of larger changes and/or redesigns. For example it is planned to absorb joshday/DataGenerator.jl
Noisy Function¶
-
noisy_function(fun, x; noise, f_rand) → Tuple¶ Generates a noisy response
yfor the given functionfunby addingnoise .* f_randn(length(x))to the result offun(x).Parameters: - fun (Function) – The function for which one wants to
generate some noisy response variables. Can be any
univariate function accepting a
Float64. - x (Vector) – The feature vector of numbers that should be used
as input for
fun(x). This variable will also be returned by the function for consistency with other generators. - noise (Float64) – The scaling factor for the noise. This
number will be multiplied to the output of
f_rand. - f_rand (Function) – The function creating the random
numbers to be added as noise to the result of
fun.
Returns: A tuple of two vectors. The first vector
xdenotes the independent variable (feature) and the second vectoryrepresents a noisy estimate of the given functionfun, which is “simulated” by adding some rescaled random numbers to its output.x, y = noisy_function(fun, x; noise = 0.01, f_rand = randn)
- fun (Function) – The function for which one wants to
generate some noisy response variables. Can be any
univariate function accepting a
Noisy Sin¶
-
noisy_sin(n, start, stop; noise, f_rand)¶ Generates
nnoisy equally spaced samples of a sinus fromstarttostopby addingnoise .* f_randn(length(x))to the result offun(x).Parameters: - n (Int) – Number of observations to generate.
- start (Int) – The lowest value used as input for
sin - stop (Int) – The largest value used as input for
sin - noise (Float64) – The scaling factor for the noise. This
number will be multiplied to the output of
f_rand. - f_rand (Function) – The function creating the random
numbers to be added as noise to the result of
sin.
Returns: A tuple of two vectors. The first vector
xdenotes the independent variable (feature) and the second vectoryrepresents a noisy estimate ofsin, which is “simulated” by adding some rescaled random numbers to its output.x, y = noisy_sin(n, start, stop; noise = 0.3, f_rand = randn)
Noisy Polynome¶
-
noisy_poly(coef, x; noise, f_rand)¶ Generates a noisy response for a polynomial of degree
length(coef)using the vectorxas input and addingnoise .* f_randn(length(x))to the result.Parameters: - coef (Vector) – Contains the coefficients for the terms of the polynome. The first element denotes the coefficient for the term with the highest degree, while the last element denotes the intercept.
- x (Vector) – The feature vector of numbers that should be used as the data for the polynome. This variable will also be returned by the function for consistency with other generators.
- noise (Float64) – The scaling factor for the noise. This
number will be multiplied to the output of
f_rand. - f_rand (Function) – The function creating the random numbers to be added as noise to the result of the polynome.
Returns: A tuple of two vectors. The first vector
xdenotes the independent variable (feature) and the second vectoryrepresents a noisy estimate of the given polynome, which is “simulated” by adding some rescaled random numbers to its output.x, y = noisy_poly(coef, x; noise = 0.01, f_rand = randn)