Stochastic AND with one neuron
Experiment: Stochastic AND with one decision neuron
Experiment date: July 31, 2026
Distribution: Sensory 0.1.1 for Windows
The model receives two raw bits [A,B]. AND is linearly separable, so one decision
neuron is sufficient. It does not apply a deterministic threshold: it converts
the linear potential into a probability with a sigmoid and samples an event via
fire when random() < p. Its on fire handler sets an observable spike to 1.
net = (A + B) / 2
p = sigmoid(10 * (net - 0.75))
fire ~ Bernoulli(p)
Approximate theoretical probabilities of output 1:
| A | B | net | P(1) |
|---|---|---|---|
| 0 | 0 | 0.00 | 0.00055 |
| 0 | 1 | 0.50 | 0.07586 |
| 1 | 0 | 0.50 | 0.07586 |
| 1 | 1 | 1.00 | 0.92414 |
The neuron usually follows AND but occasionally makes a stochastic error.
inverseTemp controls sharpness: a larger value approaches a deterministic
threshold, while a smaller value increases randomness. seed 73 initializes the
reproducible per-neuron RNG.
Validate the model
.\bin\cognia.exe .\Cognia\examples\02-stochastic-and-one-neuron\stochastic-and.cognia
Start the server
The network uses fixed analytical weights, so no training is required:
.\bin\cognia_serve.exe `
.\Cognia\examples\02-stochastic-and-one-neuron\stochastic-and.cognia `
--network StochasticAndNetwork --host 127.0.0.1 --port 8080
Diagnostic REST probe from PHP
php .\Cognia\examples\02-stochastic-and-one-neuron\sample.php 0 0 500
php .\Cognia\examples\02-stochastic-and-one-neuron\sample.php 0 1 500
php .\Cognia\examples\02-stochastic-and-one-neuron\sample.php 1 0 500
php .\Cognia\examples\02-stochastic-and-one-neuron\sample.php 1 1 500
The client uses the stateful /reset → /perceive → repeated /step sequence.
Repeated stateless /evaluate calls would replay the same seeded RNG sequence
after every reset and would not reveal the stochastic frequency.
The runtime evaluates fire when once per logical tick after network settling.
The same-tick on fire assignment is visible in top[] and the signal actuator;
REST also returns fired and fire_probability. For efficient statistics,
POST /step accepts count_fires: true and returns fire_count for the whole
batch. /reset also resets the per-neuron RNG, making seeded runs reproducible.
and.dataset documents the target truth table. A discrete Bernoulli event is not
differentiable, and the current delta trainer cannot separate learning the linear
probability from random sampling. This demonstration therefore uses analytical
fixed weights (1.0, threshold 0.75).