Synthetic PRBS identification data
A maximum-length PRBS of order 7, held for five samples, switches between −1 and 1 and drives G(s) = 1/(s² + 0.4s + 1). The record is 30 seconds at dt = 0.05, with output noise 0.04 and seed 19. One step cannot excite this bandwidth.
Experiment
u ∈ {−1, +1} from a period-127 PRBS; G(s) = 1 / (s^2 + 0.4 s + 1)
What this page generates
System identification wants an input that keeps moving. A pseudo-random binary sequence is a deterministic bit stream with a flat-ish spectrum and a sharp autocorrelation. This bench builds it with a Fibonacci linear-feedback shift register whose taps were chosen so the period is 2^7 − 1 = 127 bits and the register never falls into the all-zero lockup. Each bit is held for five samples. At dt = 0.05 that hold is 0.25 seconds. Over 30 seconds the input keeps switching; it does not settle at −1.
Bits map to +amplitude and −amplitude, here +1 and −1, so the input is centered. That is kinder to a linear fit than a 0/1 sequence with a large mean. The plant is a second-order lag with a bit more damping than the step-response page: 2 ζ ω = 0.4 and ω = 1, so ζ = 0.2. The output wiggles for the whole record because the input does. Measurement noise of standard deviation 0.04 is added after the RK4 step and uses the mulberry32 stream. The bit generator does not consume that stream. The two mechanisms share the numeric seed but not the random draws.
A student implementation that XORs the wrong taps can collapse after a handful of bits and then sit at one level. If your PRBS dies, compare it with this file before you retune the plant. The CSV columns match the other control pages: time, input, output_clean, output. The banner is the synthetic-data line. This is not a relay test from a physical loop.
Generating rule
Experiment
u ∈ {−1, +1} from a period-127 PRBS; G(s) = 1 / (s^2 + 0.4 s + 1)
Check values
Worked numbers
Seed 19 produced 601 rows from t = 0 to t = 30.00. The clean output peaks at 0.832 and ends at -0.744. The input changes value 61 times. Those figures describe this seed only; they are not a laboratory trial.
Parameters and defaults
| Parameter | Default | Range | Effect |
|---|---|---|---|
| PRBS order | 7 | 2 to 12 | Register length. Period is 2^n − 1 bits. |
| hold | 5 samples | ≥ 1 | How long each bit is held. Sets the fastest switching. |
| amplitude | 1 | finite | Levels are +amplitude and −amplitude. |
| plant | 1 / (s² + 0.4s + 1) | proper transfer function | What filters the switching input. |
| dt / duration | 0.05 s / 30 s | duration > dt | 601 rows, long enough for many bit flips. |
| noise std | 0.04 | ≥ 0 | Sensor noise, independent of the LFSR. |
| seed | 19 | unsigned 32-bit | Initializes the shift register and the sensor noise. |
Python for this seed
Full script with mulberry32() & box_muller() available via Copy Python above
# SYNTHETIC DATA - generated by MockDataLab (mockdatalab.com)
# This file is synthetic and must not be presented as real measurements, clinical data, or results from a physical instrument.
# generator: control-transfer-function
# seed: 19
# G(s) = (1) / (s^2 + 0.4*s + 1)
# numerator (highest power first): 1
# denominator (highest power first): 1, 0.4, 1
# input: prbs amplitude=1 order=7 hold=5
# integrator: RK4 with zero-order hold
# mulberry32() and box_muller() are included when you copy the full script.
SEED = 19
DT = 0.05
STEPS = 600
NOISE = 0.04
A = np.array([[0.0, 1.0], [-1.0, -0.4]], dtype=np.float64)
B = np.array([0.0, 1.0], dtype=np.float64)
C = np.array([1.0, 0.0], dtype=np.float64)
D = 0.0
TAPS = {"2":[0,1],"3":[0,1],"4":[0,1],"5":[0,1,2,3],"6":[0,1],"7":[0,1],"8":[0,1,2,7],"9":[0,1,2,7],"10":[0,1,2,5],"11":[0,1,2,4],"12":[0,1,2,8]}
def prbs_bits(order, seed, count):
taps = TAPS[str(order)]
mask = (1 << order) - 1
state = (abs(int(seed)) & mask) or 1
bits = []
for _ in range(count):
bits.append(state & 1)
feedback = 0
for shift in taps:
feedback ^= (state >> shift) & 1
state = ((state >> 1) | (feedback << (order - 1))) & mask
return bits
BITS = prbs_bits(7, 19, 121)
HOLD = 5
AMP = 1.0
def input_at(i, t):
bit = BITS[min(len(BITS) - 1, i // HOLD)]
return AMP if bit else -AMP
def deriv(x, u):
return A @ x + B * u
def rk4(x, u, dt):
k1 = deriv(x, u)
k2 = deriv(x + 0.5 * dt * k1, u)
k3 = deriv(x + 0.5 * dt * k2, u)
k4 = deriv(x + dt * k3, u)
return x + (dt / 6.0) * (k1 + 2.0 * k2 + 2.0 * k3 + k4)
rng = mulberry32(SEED)
state = np.zeros(A.shape[0], dtype=np.float64)
time = np.empty(STEPS + 1, dtype=np.float64)
inp = np.empty(STEPS + 1, dtype=np.float64)
clean = np.empty(STEPS + 1, dtype=np.float64)
output = np.empty(STEPS + 1, dtype=np.float64)
for i in range(STEPS + 1):
t = i * DT
u = float(input_at(i, t))
y = float(C @ state + D * u)
time[i] = t
inp[i] = u
clean[i] = y
output[i] = y + (NOISE * box_muller(rng) if NOISE > 0 else 0.0)
if i < STEPS and state.size:
state = rk4(state, u, DT)
columns = ["time", "input", "output_clean", "output"]
data = np.column_stack([time, inp, clean, output])
Exercises
- EXERCISE 01Give a subspace or prediction-error demo an input that is not a single step.
- EXERCISE 02Count input transitions and confirm the sequence does not die.
- EXERCISE 03Compare identification error on this file with error on the step-response file.
Questions
Why are there two random mechanisms?
The bits are a shift register. The sensor noise is Gaussian. They both start from seed 19 but they do not share draws, so editing the noise level does not shift the bit boundaries.
Is the clock the sample time?
The bit clock is hold times dt. The output is sampled every dt, including in the middle of a hold, where u is constant.
Can I use this as a real relay experiment?
No. Quote it as synthetic data from MockDataLab with seed 19.
Related
- what a single step looks like on a similar plant
- a one-tone input instead of a binary one
- a simpler plant with a closed form
- change the PRBS order
- the PRBS CSV
- Static CSV for seed 19
SYNTHETIC DATA - generated by MockDataLab (mockdatalab.com). Do not present the download as a real measurement.