BUG DESCRIPTION:
----------------
Hmm, how to start..?
noisegen() turns simple things very complicated, in an obscure and threatening way.
1) noisegen() is (so) badly built
2) noisegen() is stiff
3) noisegen() is very poor and useless
-----
1) noisegen() is badly built
----------------------------
a) Contrarily to what the documentation shows, noisegen() returns no explicit output:
--> bruit = noisegen(0.5, 30, 1.0)
Wrong number of output arguments.
b) Instead, it returns some data in the calling workspace, in a completely wild unmanageable way:
i) It returns an undocumented dua_g vector:
--> clear dua_g
--> noisegen(0.5, 30, 1.0)
--> size(dua_g)
ans =
1. 61.
This SPAMS the workspace.
ii) It returns also the handle of a Noise() function:
--> clear Noise
--> noisegen(0.5, 30, 1.0)
--> isdef Noise
ans =
T
--> typeof(Noise)
ans =
function
This way is very awkward:
* It can overwrite existing data in Noise, leading to hardly understandable errors:
--> Noise = "My data title"
Noise =
My data title
--> noisegen(0.5, 30, 1.0)
--> Noise
at line 2 of function Noise
Undefined variable: t
* It prevents naming the function as desired. It is possible to define an alias:
bruit = Noise
but then Noise() is a useless intermediate that spams the workspace.
* It makes hard to understand what noisegen() exactly does.
It is hard enough that even the author that wrote the page does not actually
use the feature in the example #1:
noisegen(0.5, 30, 1.0);
x = -5:0.01:35;
y = feval(x, Noise); // <<< WHY that, instead of y = Noise(x)
plot(x, y);
2) noisegen() is stiff
----------------------
Many major parameters of the noise can't be set:
a) The initial and final constant levels of the noise can't be set.
The initial level is internally set in a random way.
It can be reset on data AFTER calling Noise(), for instance with data = data - data(1)
to set the input level to 0. But then,
- the random part of the noise is no longer centered. Its mean can't be set independently.
- the final constant level of the signal can't be set independently. It is shifted with
the whole signal.
Even for the only initial or final level, tuning it by hand directly on data,
rather than through Noise(), still weakens (if it is possible...) the motivation for
generating a function Noise() instead of directly processing some input data.
b) The type of statistical distribution of the noise amplitude can't be set,
together with related statistical parameters.
This means that this must be done afterwards on processed data.
So, in a whole, why using Noise() if 75% of the job should be anyway done
out of it? It imposes constrains more than it helps.
3) noisegen() is very poor and useless
--------------------------------------
a) Because of the 2.b), noisegen() is much poorer than very simple direct usages of grand().
Besides, the only purpose on the example #2 is exactly to show that. It does not use
noisegen() at all, but replaces it with a one-line instruction that does more work
than noisegen() and required post-processing can do.
This example #2 cheats a little. It uses plot2d2() to mask the fact that data
generated with rand(t, "normal") are not completely similar to Noise() ones:
With Noise(), constant steps covers several data points. When plotting data,
steps are not just a rendering effect as got with plot2d2().
But getting data with actual constant multi-point steps is also trivial
without noisegen(). Example:
clf
u = grand(1,100,"nor",0,2) .*. ones(1,10);
plot(u);
With this simple line:
* we choose the statistical distribution and its parameters
* we choose the number of steps (=100)
* we choose the step's width (=10)
What else? The initial and final levels and their durations?
u2 = [ones(1,100)*-2, u, ones(1,50)*-4];
clf, plot(u2)
Instead, we want to hold the final level?
u3 = [ones(1,100)*-2, u, ones(1,50)*u($)];
clf, plot(u3)
b) noisegen() is used nowhere in the whole native Scilab. Not a single call.
Not a single test.
That's enough.
After removing noisegen(), may be we could have a "How to" to show these trivial
examples.. But it's somewhat every day data generation, trivial when it's not
obfuscated by any awkward pseudo-function.
HOW TO REPRODUCE THE BUG:
-------------------------
Use examples in the documentation, and samples in the above description.
OTHER INFORMATION:
------------------