// WilsonCowan rate-model neuron — port of SNNModels.jl/src/populations/wilsoncowan.jl.
//
// Wilson-Cowan (1972) is a simplified rate model. Each "neuron"
// stores a real-valued activity x[i] and produces an instantaneous
// firing rate r[i] = tanh(x[i]).
//
// Julia reference (wilsoncowan.jl):
// x[i] += dt * (-x[i] + g[i] + I[i])
// r[i] = tanh(x[i])
///|
/// WilsonCowan parameters — just a marker struct for the population type.
pub(all) struct WCParameter {
// No fields; tag type for the population.
dummy : Float
}
///|
pub fn WCParameter::new() -> WCParameter {
// WCParameter has no fields; just a tag for the population type.
// Use a dummy Float to make the struct well-formed in MoonBit.
{ dummy: 0.0F }
}
///|
/// WilsonCowan population — a 1-D ODE per neuron with tanh output.
/// State variables:
/// - `x[i]` : internal activity (Float)
/// - `r[i]` : output firing rate (Float) = tanh(x[i])
/// - `g[i]` : synaptic input from RateSynapse (Float)
/// - `I[i]` : external input current (Float)
pub struct WilsonCowan {
param : WCParameter
n : Int
x : Array[Float]
r : Array[Float]
g : Array[Float]
i : Array[Float]
}
///|
/// Build a WilsonCowan population. Initial x is Normal(0, 0.5),
/// matching `0.5randn(N)` in the Julia source.
pub fn WilsonCowan::new(n : Int, rng : Xoshiro) -> WilsonCowan {
let x : Array[Float] = Array::make(n, 0.0F)
let r : Array[Float] = Array::make(n, 0.0F)
for k in 0.. Unit {
let n = p.n
for k in 0..