use neuromod::LifNeuron;
fn main() {
println!("=== Basic LIF Neuron Example ===\n");
let mut neuron = LifNeuron::new();
println!("Initial neuron state:");
println!(" Membrane potential: {:.4}", neuron.membrane_potential);
println!(" Threshold: {:.4}", neuron.threshold);
println!(" Decay rate: {:.4}\n", neuron.decay_rate);
println!("Simulating 20 time steps with pulsed input:\n");
for step in 0..20 {
let stimulus = if (5..10).contains(&step) { 0.08 } else { 0.01 };
neuron.integrate(stimulus);
if let Some(peak) = neuron.check_fire() {
println!("Step {:2}: Input={:.3} → SPIKE! (peak potential: {:.4})",
step, stimulus, peak);
} else {
println!("Step {:2}: Input={:.3} → Potential: {:.4}",
step, stimulus, neuron.membrane_potential);
}
}
println!("\n=== Simulation Complete ===");
println!("This demonstrates:");
println!(" • LIF neuron integrates input over time");
println!(" • Passive leak causes potential to decay");
println!(" • Spike occurs when potential exceeds threshold");
println!(" • After spike, potential resets to 0");
}