I wonder if you could modify the routine so that higher powers could also be forced to be zero. For example, the current routine set the constant coefficient to zero. But, can the 1st order coefficient also be forced to be zero. And so on...
A couple of modifications that could be implemented.
Let there be one input, the order of the denominator, and accept an array. Calculate rms error and return that for the array. Could either set the numerator to the denominator, or sweep the numerator from 2 to the order of the denominator.
Incorporate a lag term, including raising the exponent to a power.
In your examples, you may want to include extracting the polynomial from a psd, generating a time history from a filter on rand, and replotting the resulting psd for comparison.
Thank you for writinig this, it does generate an interesting set of colors that do appear to be contrasting. Would it be possible to generate one, or more, "key" colors that are highly contasted with the rest. I have about 30 lines on a figure, along with the average. While I did make the average wider, it is difficult to determine the color for the "key" line(s) using this routine.
I'm having trouble with this routine. In the example below, the x and y ranges dont' seem to be correct, and also the distribution doesn't look right either.
close all; clc;
events = 1000000;
x = [x; xs];
y = [y; ys];