Quantum spin models for numerosity perception

Humans share with animals, both vertebrates and invertebrates, the capacity to sense the number of items in their environment already at birth. The pervasiveness of this skill across the animal kingdom suggests that it should emerge in very simple populations of neurons. Current modelling literature, however, has struggled to suggest a simple architecture carrying out this task, with most proposals suggesting the emergence of number sense in multi-layered complex neural networks, and typically requiring supervised learning. We present a simple quantum spin model with all-to-all connectivity, where numerosity is encoded in the spectrum after stimulation with a number of transient signals occurring in a random or orderly temporal sequence. We use a paradigmatic simulational approach borrowed from the theory and methods of open quantum systems out of equilibrium, as a possible way to describe information processing in neural systems. Our method is able to capture many of the perceptual characteristics of numerosity in such systems. The frequency components of the magnetization spectra at harmonics of the system's tunneling frequency increase with the number of stimuli presented. The amplitude decoding of each spectrum, performed with an ideal-observer model, reveals that the system follows Weber's law, one of the hallmarks of numerosity perception across the animal kingdom. This contrasts with the well-known failure to reproduce Weber's law with linear system or accumulators models.


Introduction
Humans and animals possess the ability to estimate how many objects are present in a given space or in a time interval, that is their numerosity.Humans perform this task remarkably well, with an error rate of about 20% over a very large range of items, up to 200 [1][2][3][4].
Determining the number of elements in a set is traditionally associated with counting.However, it emerges as a perceptual function taking place even without attention and with higher precision than related perceptual functions (such as area and density estimation) [5,6].Several neurophysiological studies have demonstrated that, in the primate, brain neurons selective to numerosity do exist and their tuning is proportional to the preferred numerosity [7].Remarkably, it is known that the task-associated uncertainty increases linearly with the numerosity itself, a law named after Weber [1].Weber's law occurs regardless of the modality of presentation, i.e. whether numbers are delivered as distinct items in a single display, or as a sequence of items in the visual, auditory or tactile modality, as well as in the same position or in different ones.All these observations point to Weber's law as a hallmark of the central mechanism which estimates numerosity from different sensory formats.Indeed, Weber's law fails only under particular circumstances [3,8], such as when items are too close together to be segregated, and mechanisms for estimation are based on the visual-texture grain and follow a square-root law.Interestingly, individual performance with sparse displays is predictive of mathematical literacy of the individual, whereas performance with high clutter display does not [9].This suggests that the perceptual mechanisms for rapid estimation of sparse displays are core to mathematical knowledge, whereas those that enable perception in high clutter displays are not.
It is as well interesting that Weber's law cannot be attained by the simplest model of numerosity perception, which is one that counts the number of items in a region of space (or events in a period of time).In fact, the statistics of the latter follow a Poissonian distribution, implying that the variance scales with numerosity and hence that the standard deviation scales with its square root.This is a well-known problem in time perception where a central assumption is Poisson pacemaker: here, Weber's law has been modelled only resorting to ad-hoc assumptions, otherwise it resembles the signature behaviour with cluttered presentations [10,11].Currently, the neural mechanisms allowing Weber's law over such a large range of numerosities and conditions are not yet known.
Artificial Neural Network have been demonstrated to be a valid approach to the simulation of many aspect of perception.Pioneering work by John Hopfield, employing statistical mechanics, demonstrated that it was possible to study the behaviour of unsupervised networks comprised of simple processing units, based on spin-glass models in physics [12].Interestingly, Stoianov and Zorzi using a network of this kind, successfully modelled human processing of numerosity [13].The network, comprising one input layer and 2 hidden layers and trained in the classification of 2 dimensional stimuli containing various number of objects, spontaneously built a representation of numerosity, which could then be decoded by a simple linear classifier.If, in this model, the representations read-out of the classifier were used to perform a numerosity comparison, the behaviour would comply with Weber's Law.
More recently, Nasr et al. [14] have found that some units of a deep convolutional neural network (CNN) designed and trained for objects recognition, could also perform number discrimination on static displays.Using 8 convolutional layers for local filtering and 5 pooling layers for aggregated response, this CNN exhibited numerosity recognition in around 10% of its units, with an approximate Weber's law behaviour.Similar conclusions have been drawn with untrained networks [15], once again involving a limited amount of units.While these results are encouraging, a number of questions arise.In particular, whether numerosity perception is a global property of such neuronal network, since it is only encoded in a small percentage of a highly complex architecture.Another important problem involves the generalization to dynamic stimuli that unfold over space and time.
On the other hand, the last decade has seen the emergence of quantum models [16] to tackle non-linear complex dynamics.This Quantum-like paradigm [17] is based on the idea that the mathematical toolbox of quantum mechanics can describe phenomena which do not need to be quantum.Here, we note that while the classical models introduced by Hopfield [12] and our quantum mechanical model use similar spin Hamiltonians, see e.g.[18], the approaches are substantially different.The classical models focus on using adaptable statistical structures [19,20] aiming at defining a flexible network connectivity suited for learning models [21] to encode the input information.In contrast, our quantum spin model highlight the fact that minimal symmetric small-sized networks, with pre-determined connectivity, are enough to recover input information.
Examples of the use of quantum models include the study of the generation of persistent quantum-chaotic patterns at a microscopic scale and the amplification of quantum effects to a macroscopic scale have been investigated [16,22].Quantum versions of the IIT theory for consciousness [23,24] and information processing [25] have also been proposed.The general features have been explored by using dissipative quantum models of the brain, driven by entanglement, and the corresponding use of quantum field theory to model brain functional activity [26].Mathematical methods of quantum theory, especially quantum measurement theory, have been used to describe information processes in biosystems, and then applied to model combinations of cognitive effects and gene regulation [27].Quantum-inspired techniques in machine learning have also been introduced in psychology [28] leading to the field of the so-called quantum cognition [29], hinging instead on the mathematical structure of quantum probability.This approach has been used to address cognitive phenomena, such as reinforcement learning during human decision-making [28], known to be hard to be described by means of classical probability theory [30].For example, when incompatible events are involved, incompatibility produces superposition states of uncertainty which eventually result in violations of classical/probability laws [31].Along these lines, it has been highlighted how, to some extent, the brain could work as a not only classical but also quantum Bayesian-inference machine [32,33].Moreover, several proposals for the use of quantum spin models and neuronal activity has been discussed [12,34].
Such approaches do not necessarily imply the emergence of microscopic quantum effects in the brain.This timely area of research per se [35][36][37], has been recently revisited based on increasing experimental efforts [38,39] also in view of proposed theories [40].This flourishing research field is developing in parallel to advancements in the field of quantum biology [41], following on tremendous progress in experimental methods to investigate energy-excitation transfers in light-harvesting complexes [42].
Here, we use the nature of quantum-mechanics as a formal toolbox to describe the highly dynamical complexity underlying the encoding of numerosity perception.We present an example of a coarse-grained quantum model as a mathematical toolbox to map information processing of a network of neurons.We find that under general enough conditions, a quantum network with a very simple architecture is capable of counting the number of events as a global property, even when these excitations are introduced randomly in space and/or in time, with no need of any training and standard agnostic decoding.

Methods
Our main goal is to design a successful model for numerosity perception as an intrinsic and very general tool for dynamical stimuli.
When dealing with a network of neurons and its mapping into a quantum model, a rather natural idea is to associate to each neuron an on-off state of activity which, in the quantum domain, can be described in terms of a spin 1/2.Assuming this as a starting point, our modelling is developed based on a minimal set of essential traits and functions that the network should possess, while yet guided by the observation that the numerosity perception manifests as a global response and an inherent property of the network, robust with respect to space and time randomness and dissipation.In the first column of Table 1 we provide the list of the essential neuronal functions we consider relevant to address numerosity perception.The second column in Table 1 reports instead the mapping onto the corresponding objects or functions of the quantum model.

Quantum Spin model
Based on the mapping in Table 1, we consider a 1D spin-1/2 chain, see Fig 1, with variable coupling ranging from simply nearest-neighbours (n.n.) to all-to-all (a.a.) connectivity.Excitations in the system, that we will model as ↑-polarised spins, can be transferred to connected sites via the exchange coupling.Moreover, the system is subject to an energy offset whenever there are several excitation in a near vicinity.The system Hamiltonian is then given by: where σ are the corresponding raising and lowering operators, J ij are the local exchange amplitudes between connected spins.Here we consider J ij = J = 1 whenever two sites are linked and zero otherwise.This means for nearest neighbours J ij = 1 if |i − j| = 1 and J ij = 1 ∀ i, j for the all-to-all coupling.∆ ij represent the offsite energy offsets defined as: with σ a constant that determines the width of the interaction potential between sites, and ∆ 0 the overall amplitude of such potential.
In the presence of coupling to an external environment, the dynamics of the system is described by its density operator ρ(t), whose evolution is governed by the Gorini-Kossakowski-Sudarshan-Lindblad (GSKL) equation [43]: where J m represents the m-th dissipation channel and γ m its corresponding dissipative rate.In our case, we consider two possible dissipative sources: excitation losses, here corresponding to spin flips and J m = σ − m ; and dephasing, due to collisional processes limiting the quantum coherence of the coarse-grained system model, here J m = σ z m .Note that the Hamiltonian we have introduced in Eq. 1 is a paradigmatic model for quantum magnetism, introduced initially by Heisenberg [44] and first solved by Yang and Yang [45] and Baxter [46].The model has a rich phase diagram exhibiting (anti)ferrogmatism both in the axial and planar axis.Each spin experiences an energy offset given by the state of its neighbours.This energy shift is given by a gaussian profile centered in each spin with amplitude ∆ 0 , (c).Finally, each spin can interact with different dissipative channels, (d) leading to excitation losses and dephasing with a rate γ i .
dissipative scenarios up to these days, including for the simulation of systems unrelated to quantum magnetism as it is our case.
In order to produce the numerical simulations, we take advantage of stochastic unraveling methods, in particular quantum trajectories, allowing to reduce the numerical complexity of the computation at the cost of computing several trajectories.Details on the method can be found in [47].
We compute the time evolution of the system given by (3) for a series of relevant parameters, with the aim of building intuition on the expected dynamics in such a spin system.
In Fig 2, we present the evolution of the magnetization for an example system with M = 7 spins, where at the initial time t = 0 one of the spins is polarised in the ↑ direction while the rest remain in the resting state corresponding to ↓ orientation.As time progresses, the excitation can travel along the system due to the exchange coupling.In the nearest-neighbour (n.n.) case, shown in Fig 2 .(a)-(d), the excitation travels in a well-defined cone before covering the whole system and continues to travel back and forth as time evolves as we observe some revivals where the excitation returns to the original site after spreading across the whole system.The presence of the interaction ∆, Fig 2 .(b),modulates the profile of the evolution but does not change the overall behaviour.This is true for a wide range of interaction parameters (∆ 0 , σ) as seen in Fig 2 .(c)where we present, as an example, a wider interaction profile.The addition of dissipation γ l , Fig 2 .(d), in the form of spontaneous spin decay uniformly reduces the signal in space and time, as predicted.
On the other hand, the all-to-all (a.a.) coupling scenario illustrated in Fig 2 .(e)-(h) is remarkably different.We observe that the dynamics are much simpler.Here, the excitation is evenly spread into all the other sites -as they are all connected -to return back to the initial site at a rate ∝ J, that is the tunneling time.There, we can interpret all the initially ↓ sites as a single "supersite" where the excitation is evenly transferred to each one of them, to subsequently return in this oscillatory manner.In the presence of interaction, Fig 2 .(f)-(g), the rate of tunneling varies between the individual sites and, as a result, some non-uniform spreading is observed while time evolves.The role of dissipation is similar to the n.n.case, reducing the overall excitations in the system uniformly over time.Most of the highlighted features remain unchanged when we consider multiple excitations in the system.For the sake of completeness, we include several examples in the Supporting information, see Fig 7. We have so far focused on the case of adding one single excitation to the system.d) for the all-to-all (a.a.) case.In the n.n., we can observe that the excitation propagates in a light cone until reaching the boundaries, and then oscillates back and forth.The addition of interaction leads to space modulations that build over time changing quantitatively the magnetisation but without affecting the general behaviour.Inclusion of a spin decay rate γ l ̸ = 0 leads to the loss of the excitation over time.In contrast, the a.a.does not display any excitation cone and the spin up evenly spreads to all the neighbours and bounces back and forth with a constant frequency, including interaction we observe again the appearance of space modulation in the propagation profile.
However, the most interesting aspect of the model comes to play when we consider several spin flips along the time evolution.In particular, we observe that the power spectrum of the time signals contains information on the number of spin flips that took place during that evolution.In Fig 3, we consider the frequency spectrum of the magnetisation ⟨σ z i ⟩ in a given site for a chosen time window of length 10 ≤ tJ ≤ 20.In the initial time interval t ≤ 10J excitations in the form of spin flips in sites i = 1, 3, 5 respectively have been added to the system at fixed times.Here, we observe that in the n.n.case the spectrum has little dependence on the number N of spin-↑ in the evolution; finding a set of narrow peaks at low frequencies that do slightly change in width and amplitude with no consistent dependence on N .
When the system is all-to-all coupled instead, we observe the appearance of peaks with equidistant frequencies for every additional spin flip.The temporal evolution of the magnetisation contains information on the numerosity for each site: a global increase of the number of excitations does increase the number of peaks with low-frequency harmonic components.Note that due to the up-down symmetry of the model, we can only distinguish up to N ≤ M/2 excitations, as an N number of spin-↑ higher than M/2 can be regarded as simply M − N spin-↓ particles.Frequency spectrum of the magnetisation.Amplitude spectrum of the magnetisation ⟨σ z i ⟩ on site i = 5 as a function of time in a system with parameters M = 7 sites, J = 1, ∆ 0 = 0.1, σ = 1/ √ 2, γ l = 0 for varying number of spin flips during the evolution N = 1, 2, 3 displayed from left to right.In every panel we compare the results for the case of nearest-neighbours and all-to-all coupling, observing that the number of peaks and the overall behaviour of the spectrum shows small differences in the case of n.n., contrasting the a.a.case, where every time that a spin flip connects to a new magnetisation sector a new peak at a constant distance appears in the spectrum, showing the potential ability for the system to count.In both cases, the time domain used was 10 ≤ tJ ≤ 20 after the events occurring in sites i = 1, 3, 5 respectively at fixed times in the initial window between 0 ≤ tJ ≤ 10.
We have presented here the case with no dissipation.However, the results are comparable if we consider any time window where the dissipation has not yet washed out all of the excitations from the system.We have also verified that the spectrum peaks do not depend on the specific time of, or interval between the measurements, nor on rotation angle, location of the spin flips, or the length of the time signal with the only variation being their relative amplitude, meaning that this is a robust feature.Details on these findings are in the Supporting information, see Fig 8,

Estimation protocol
As we discussed, Fig 3 shows that larger numerosity of inputs introduce lower frequency components in the temporal evolution of the magnetization.Thus, to validate that the information for all numerosity is adequately encoded in the magnetization profile, we applied an ideal observer model based on a supervised classifier.In Fig 4 we show an outline of our estimation protocol.In order to estimate numerosity in our system, we first record the local magnetisation, which is given by the expectation value of the observable ⟨σ z i ⟩ on every site as a function of time, where the profiles will resemble the patterns in Fig 2 .We record the magnetisation in a fixed time window after all the stimuli have been added to the system, e.g. 10 ≤ tJ ≤ 20 in As we deliver stimuli randomly over space and time, we compute the spectrum from the local magnetisation at each site and then produce a space-average spectrum for every single trajectory.
In order to decode the information embedded in the power spectra, we analyze them through an ideal observer approach, that is agnostic to the signal having a quantum or classical origin.In this approach, the decoder assesses the similarity of an input spectrum to that of a library of spectra which have been previously learned, and informs the decoder on the average behaviour of the system in response to one of the possible inputs.This method requires no knowledge of the internal processes that give rise to the specific states from a given input.It simply classifies the current internal state, comparing it to a library of previously learned power spectra that are averaged over a fixed number of simulations of order 10 2 (200 in the case of our results), each associated with a given numerosity, and eventually decodes it as the numerosity which on average produces the most similar internal state [48].See Fig 4 .3.
Once the system has learned the average behaviour for each numerosity, we consider an ideal decoder for the power spectrum of a new sample with a yet-to-be-decoded number of spin flips.The similarity is evaluated by correlating the spectrum of the new input signal with those present in the library representing the average spectrum to each numerosity.Then the template associated with the highest correlation is selected.All correlations are accepted and no threshold is used.

Numerosity classification
In order to measure how the performance of the model varies as a function of the underlying numerosity, we run a virtual psychophysical experiment, as illustrated in Fig 4.4, in which two numerosities are compared: one as a base reference and one as a variable.Here, the ideal observer has to decide which of the two stimuli is more numerous, by applying the classifier illustrated above.
The probability for the decoder to classify the variable stimulus as the more numerous, is a monotonic function of the variable's stimulus numerosity, well approximated by the integral of a cumulative gaussian function, as described in the Probit model [49]: The median of the Probit indicates the point of subjective equality (where the two stimuli are deemed as having the same numerosity).The curve slope indicates instead the noiseness of the classification.Human-observers psychometric functions for numerosity classification are shallower for larger numerosity in linear scale, having the same width in logarithmic scale: a hallmark of Weber's law.Here we observe the same phenomenon in the output of the classifier (see Fig 5).

Results
In Fig 5 we present the results of the estimation protocol applied to the magnetisation signal for a system with M = 18 spins where N = 1 − 9 spin flips occurred with random amplitudes at random times and locations.In Fig 5 .(a)we present an example trajectory of the magnetisation for the case with N = 4 where we can observe how excitations of varying intensity appear in the system at specific times.In contrast, an average over trajectories of the magnetisation renders no spatial features, The error in numerosity estimation is obtained from the fits of the psychometric functions as described in the Estimation Protocol section.The corresponding fits are displayed in Fig 5.(d), from smaller to larger numerosities.In Fig 5 .(e),we provide the associated standard deviations of the estimator for the previous case, corresponding to spin flips of random amplitude (orange, random rotations (RR)), and compare them with the case where the spin flips had random rotations but their summed amplitude was constant and equal to 3π (blue, constant energy (CE)).This comparison is an important test, as many classical systems fail to decode numerosity when the overall excitation amplitude is kept constant.Both cases reproduce the predicted dependence and Weber's law.The case with the constant total amplitude however, is seen to perform worse, due to the small average amplitude of each of the spin flips.Finally, the Weber fraction associated to the results is displayed in the right panel of Fig 5 .(f)observing the expected flat dependence.Given the system-size limitations, we were not able to provide signatures for N > M/2 = 9 elements.Note that the time window during which we store the time signal is not relevant, as demonstrated in the Supporting information, Fig 9 .In this figure, we present the power spectrum for the same system, with varying time windows.We observe no qualitative differences in the spectra.In S1 Appendix, we justify the specific numerical values that we chose to ensure consistency over this time window.
In order to verify that the essential features of this behaviour in Fig 5 .(d)-(f)lies in the evolution of the magnetization of the quantum system, we performed a series of validations of our decoding procedure aimed at demonstrating that the decoder and the data fitting do not introduce significant noise components.This analysis is included in Fig 6.(e) Corresponding standard deviation estimates from the fits of the psychometric functions on the left.Here, we compare the previous case where each event is a spin flip of random amplitude (orange) with a case where the rotations where again random but their sum was constrained to be equal to 3π (blue).(f) Weber fraction associated to the results in the middle panel.
The first test, in Fig 6 .(a),was related to the decoding performance when the libraries were built with a limited number of trajectories.For this we consider the same data set as in Fig 5 in the case of random amplitude of excitations (RR) where we used N t = 200 trajectories.We show that this result is largely independent from the number of trajectories used to construct the templates displaying stably traits of Weber's law using as few as N t = 5 trajectories.This indicates that our ideal decoder performs well with limited samples and that our results are not affected by the specific parameters of the decoder.
Secondly, we test whether the decoder can faithfully capture a pattern of noise present in the signal.To this end, we move away from the data of our quantum simulation and test the decoder with sinusoidal activities computing the spectra from a simple sequence of activations for a noise-free version and one corrupted by 1/f noise, proportional to the inverse of the sinusoid frequency.More specifically we generated a set of 18 different sine gratings, that differ in temporal frequency with simultaneous activity in all the nodes.The spectra for each of the 18 frequencies contain only one October 2, 2023 10/19  5, for varying number of trajectories N t = 3, 5, 10, 40 with which we construct our library templates.We observe that the decoding converges with a very limited number of samples.(b) Weber fraction associated to the frequency decoding for sinusoidal activation maps with frequency ranging from f = 1 − 18, both noiseless and with noise proportional to the inverse of the frequency.We show that the decoder does not incorporate additional noise to the analysis by comparing the performance of both classical signals.
peak and cover nicely the frequency range of the system.We use the decoder to classify the frequency of the sinusoid, in a similar fashion to classifying the number of events, which we did with the quantum system.Fig 6 .(b)shows that in the absence of noise in the activity gratings, we obtain good performance with a very low noise floor.Instead, 1/f noise, which is more disruptive at low frequencies, renders an output with similar behaviour to shot-noise matching the noise characteristics of the signal.This two additional tests confirm that the decoder does not introduce itself specific noise patterns but simply reveals the intrinsic variability in the activity of the system that is being decoded.

Discussion
In this work, we have used a quantum spin model to tackle an open problem in human sensory systems, which is how humans are capable of perceiving the numerosity of events.Our results have shown that the time evolution of a very simple fully-connected spin-1/2 Heisenberg model can encode the number of stimuli that it has been exposed to.Moreover, we have shown that its performance is not driven by the overall input energy, that has been normalised, with the system remaining to encode numerosity also the presence of high input energy noise.
It is important to stress that here we have used quantum physics as a statistical tool for information processing, having no implications about the presence of quantum phenomena in the process of numerosity perception in our brain.We have presented a proof-of-principle model where, by adhering to the statistical rules of quantum mechanics instead than the classical ones, we are able to reproduce the behavior of October 2, 2023 11/19 complex networks with a minimal model which takes advantage of the properties of quantum systems.While we do not claim that quantum microscopic interactions in the brain are relevant for sensory processes, we suggest that the powerful mathematical structures existing in quantum models may be useful to simulate complex brain network dynamics.
From the perspective of quantum modeling, there is a wide range of extensions that would be desirable.This would include the use of larger networks by means of matrix product states [50], the use of heterogenous network topologies, e.g. with several fully-connected systems sparsely connected among themselves, or the use of non-Markovian open quantum systems allowing for information back-flow into our spin system.However, we believe that the current iteration of the model represents the essential ingredients for a successful representation of numerosity perception while adhering to minimal complexity.
Importantly, our model is able to exceed previous models in the field of perception of numerosity in two important aspects.Firstly, to our knowledge, no current model exists of how numerosity can be sensed and integrated both in space and time.Some models for numerosity of simultaneously presented items do exist [13][14][15] and are successful to some degree.However, no models exist for temporal numerosity.This is a notable shortcoming of current literature, as perception of temporal numerosity is strictly linked to spatial numerosity, and both aspects should be conceived as two facets of a single procedure for numerosity processing [51].Current models possibly can be upgraded to process items presented over time, introducing an ad hoc memory component.However this is a specific solution that cannot be generalized.Instead, our model captures both by construction.
The second interesting issue is that numerosity is encoded in the frequency of the magnetization arising after multiple spin flips and only for the all-to-all connectivity.Thus, our model highlights that in order to measure the number of events unfolding over time, collective interactions measured at all nodes and times may be critical.At least, this is the case for our quantum model.This approach is shifting the focus away from the isolated unit excitation to global network dynamics.Interestingly, global network dynamics measured as endogenous oscillations are an active area of research, and demonstrate the strong potential role in selecting salient information.In this respect our model offers a true paradigm shift, indicating that the frequency of the oscillations may encode the complexity of an incoming stimulus.
In addition, our model is not only capable of encoding numerosity, but also reproduces a critical hallmark of human sensory systems: Weber's law.Whereas Weber's law is a ubiquitous trait of sensory systems, it is particularly challenging from a modelling perspective, since neural firing generally follows Poisson statistics.In our system, Weber's law holds both for randomly rotated systems and even for those where the overall energy is constant despite the change in the number of excitations.We also remark that in our system we have no ad hoc noise sources.The noise in our model mainly arises from the randomness in space, time, and intensity of the local excitations.The randomness-driven noise and the all-to-all connectivity seem to be able to capture Weber's law.
We paired the current evolution of magnetizations with a specific decoding scheme borrowed from analysis and modelling of brain activity [48].While this model is appealing for its simplicity and biological plausibility, simulating an ideal observer performance, we stress that it is not an integral part of the quantum model.It constitutes a tool that is used to validate the quantum network model and to demonstrate both its performance and its adherence to Weber's law.Having demonstrated the capability of the network to encode numerosity, any other decoder to extract the correct numerosity may be used, the simplest one being the detection in October 2, 2023 12/19 frequency of peak excitation.Our results have also demonstrated that Weber's Law behaviour is not a consequence of the supervised classifier decoder or the noisiness, but it lies in the magnetization profiles themselves.The present work can be extended in several ways.For instance, human studies show that visual judgments of numerosity can incorporate biases provided by non-numerical features, such as area, density and energy of the input [52,53].While the effects of area and density are often small [6], they can still be important test benches for models of numerosity.Interestingly, in a recent work, Testolin et al [4] have demonstrated that deep neural networks that have not completed the training, simulate the cues induced by non-numerical features of human perception.In the current quantum simulations we eliminate the non-numerical feature, like total energy, by normalizing the input energy or by adding important energy noise.However, the other two important cues, i.e. area and density, could not be benchmarked adequately given the limitation of the maximum number of excitations allowed (half the length of the network).To demonstrate how these non-numerical features influence the quantum model, one would require substantially larger networks that make use of approximate methods for their simulation, see e.g.matrix product state methods [50].
In addition, in the present work we discussed only two extreme quantum architectures, with either local connectivity or all-to-all connectivity.Here, the all-to-all connectivity, which is the one that encodes numerosity, being closer to biological cortical connectivity.We note, however, that in the cortex the weight of the neuronal connectivity is not equal and can vary dynamically.As a result, it would be interesting to test, with a dedicated set of simulations, whether intermediate architectures could capture the input numerosity, and if those were also sensitive to the modulation of the non-numerical features in the numerosity encoding.In this manner, we could establish a comparison with the results of [4] which show that NN are prone to the influence of non-numerical features.

Conclusion
All in all, our quantum spin model hinges on very general and minimal assumptions and, as highlighted in the Supporting information, remains robust against tuning of system parameters while being able to reproduce essential traits of numerosity perception.We have shown how, after appropriate agnostic decoding, the behaviour of global time-dependent signals conveys information of the number of events the system has experience in the recent past.Refinements of the model can be introduced with sustainable efforts, both to probe larger systems and to investigate phenomena different from numerosity perception.Along these lines, we believe that our model opens unexplored avenues in simulating and interpreting the behaviour of complex brain networks and as a new framework to understand information processing in such systems.We observe that if all spin flips occur in the same location without any spatial inhomogeneity, as in (a) and (e), the system cannot discern the number of excitations.However, as soon as the interaction, as shown in (f), modifies the spatial profile, since the energy shift depends on the number of excitations present, the system can discern the number of stimuli and produce the expected number of peaks.The rotation angle of the excitations,(c)-(d),(g)-(h), does not modify the number of peaks or their location, but only the relative amplitude.could lead to the decoder classifying the trajectory as the wrong numerosity.This is, in our system, the ultimate source of noise in the decoder.But these features do not limit the use of the all-to-all coupled network for the model of numerosity perception.
Moreover, in Fig 9, we present the power spectrum for the same system, for varying time windows t max − t 1 .To avoid any correlation between data sets, each of the averages is produced with an individual set of N t = 100 trajectories, each recorded for the indicated time.The time windows were always chosen after the last stimulus presentation at time t 1 .From the analysis of spectra at different system sizes, we observed that the system is producing peaks from temporal frequencies f ∼ 2πJ to f ∼ 2πJ/M that to be well-detected required a window larger than ∼ 2J −1 for M=9 spins (or ∼ 3J −1 for M = 18 as our results in Fig. 5).In the simulation we considered a minimum temporal window of 10J −1 , corresponding to several cycles of the lowest temporal frequency for the largest numerosity and system size to ensure visibility.
We observe that the results depend very weakly on this time window.We do observe a small drift towards the DC component (that we eliminate in our analysis) while the time window increases.However, this only slightly reduces the relative peaks height, that in most cases remains within error bars.This result allows us to confidently perform the analysis illustrated in the main text, with time windows of the order of i ⟩ as a function of the specific time window, averaged over all sites in a system with M = 9, N = 4, J = 1, ∆ 0 = 0.1, σ = 1/ √ 2, γ l = 0 and for varying time integration windows t max − t 1 .The chosen parameters serve as an example and do not qualitatively change the results displayed.Each line corresponds to the average of N t = 100 trajectories.We observe that the time window plays no role for the number of peaks in the spectrum, only the relative amplitude is modified.Longer time windows shift the amplitude towards the continuous (DC) component, which we eliminate in our spectrum analysis.
Continuous developments in both numerical and analytical tools have made the model relevant in both closed and October 2, 2023 4/19 < l a t e x i t s h a 1 _ b a s e 6 4 = " Z W d a E Y A 9 H u x Z P n k g g i n i z 6 0 Y h bY = " > A A A B 4 n i c b Z D N S g M x F I X v 1 L 9 a / 6 o u 3 Q S L 4 K r M S F G X B T f q q g X 7 A + 1 Q M u m d N j Q z G Z K M U I a + g K 5 E 3 f l I v o B vY 1 p n o a 1 n 9 e W e E 7 j n B o n g 2 r j u l 1 N Y W 9 / Y 3 C p u l 3 Z 2 9 / Y P y o d H b S 1 T x b D F p J C q G 1 C N g s f Y M t w I 7 C Y K a R Q I 7 A S T m 7 n f e U S l u Y w f z D R B P 6 K j m I e c U W N H z f t B u e J W 3 Y X I K n g 5 V C B X Y 1 D + 7 A 8 l S y O M D R N U 6 5 7 n J s b P q DK c C Z y V + q n G h L I J H W H P Y k w j 1 H 6 2 W H R G z k K p i B k j W b x / Z z M a a T 2 N A p u J q B n r Z W 8 + / M /r p S a 8 9 j M e J 6 n B m N m I 9 c J U E C P J v C 8 Z c o X M i K k F y h S 3 W x I 2 p o o y Y 6 9 S s v W 9 5 b K r 0 L 6 o e p f V W r N W q d / l h y j C C Z z C O X h w B X W 4 h Q a 0 g A H C M 7 z B u z N 0 n p w X 5 / U n W n D y P 8 f w R 8 7 H N 5 u e i n M = < / l a t e x i t > J < l a t e x i t s h a 1 _ b a s e 6 4 = " 6 r O i C T A q O A 9 M T 5 U f W F i T d h X 9 D 6 s = " > A A A B 6 X i c b Z D N T s J A F I V v 8 Q / x D 3 X p p p G Y u C K t I e q S x I 3 u M J G f B B p y O 1 x g w k z b z E x N S M N D 6 M q o O 1 / H F / B t H L A L B c / q m 3 v O J P f c M B F c G 8 / 7 c g p r 6 x u b W 8 X t 0 s 7 u 3 v 5 B + f C o p e N U M W q y W M S q E 6 I m w S N q G m 4 E d R J F K E N B 7 X B y M / f b j 6 Q 0 j 6 M H M 0 0 o k D i K + J A z N H b U 6 Y 1 Q S u z z f r n i V b 2 F 3 F X w c 6 h A r k a / / N k b x C y V F B k m U O u u 7 y U m y F A Z z g T N S r 1 U U 4 J s g i P q W o x Q k g 6 y x b 4 z 9 2 w Y K 9 e M y V 2 8 f 2 c z l F p P Z W g z E s 1 Y L 3 v z 4 X 9 e N z X D 6 y D j U Z I a i p i N W G + Y C t f E 7 r y 2 O + C K m B F T C 8 g U t 1 u 6 b I w K m b H H K d n 6 / n L Z V W h d V P 3 L a u 2 + V q n f 5 Y c o w g m c w j n 4 c A V 1 u I U G N I G B g G d 4 g 3 d n 4 j w 5 L 8 7 r T 7 T g 5 H + O 4 Y + c j 2 / u 2 o 2 W < / l a t e x i t > i < l a t e x i t s h a 1 _ b a s e 6 4 = " R Z z Z r l w 1 y 6 w T 0 F K y T c j Z l k J F g z k = " > A A A B 5 H i c b Z D N T g I x F I X v + I v 4 h 7 p 0 0 0 h M c E N m D F G X R D c u M c p P A h P S K X e g o T O d t B 0 T M u E N d G X U n U / k C / g 2 F p y F g m f 1 9 Z 7 T 5 J 4 b J I J r 4 7 p f z s r q 2 v r G Z m G r u L 2 z u 7 d f O j h s a Z k q h k 0 m h V S d g G o U P M a m 4 U Z g J 1 F I o 0 B g O x j f z P z 2 I y r N Z f x g J g n 6 E R 3 G P O S M G j u 6 r w R n / V L Z r b p z k W X w c i h D r k a / 9 N k b S J Z n 5 / X q n d 5 Y c o w h E c w y l 4 c A k 1 u I U 6 N E C A g m d 4 g 3 d n 5 D w 5 L 8 7 r T 7 T g 5 H 8 O 4 Y + c j 2 9 z 0 Y 1 E < / l a t e x i t > 0 < l a t e x i t s h a 1 _ b a s e 6 4 = " B + / 8 f e l B V 0

Fig 1 .
Fig 1.Quantum spin model.(a) Diagram of the spin system with variable connectivity, we present the case of nearest-neighbour and all-to-all coupling; (b) Diagramatic representation of the Hamiltonian and dissipative terms: each spin can propagate an excitation to its neighbours through the exchange term with amplitude J.Each spin experiences an energy offset given by the state of its neighbours.This energy shift is given by a gaussian profile centered in each spin with amplitude ∆ 0 , (c).Finally, each spin can interact with different dissipative channels, (d) leading to excitation losses and dephasing with a rate γ i .

Fig 2 .
Fig 2. Magnetisation profiles.(a) Evolution of the local magnetisation σ z i for a system with M = 7 sites, J = 1, ∆ 0 = 0, γ l = 0 starting from a single excitation (spin up) on the middle site at t = 0 and nearest neighbor (n.n.) coupling.The dashed line highlights the magnetisation spreading in a light-cone manner; (b) same as (a) for ∆ 0 = 0.1, σ = 1/ √ 2; (c) same as (a) for ∆ 0 = 0.1, σ = 2/ √ 2; (d) same as (a) for γ l = 0.1; (e)-(h) Same as (a)-(d) for the all-to-all (a.a.) case.In the n.n., we can observe that the excitation propagates in a light cone until reaching the boundaries, and then oscillates back and forth.The addition of interaction leads to space modulations that build over time changing quantitatively the magnetisation but without affecting the general behaviour.Inclusion of a spin decay rate γ l ̸ = 0 leads to the loss of the excitation over time.In contrast, the a.a.does not display any excitation cone and the spin up evenly spreads to all the neighbours and bounces back and forth with a constant frequency, including interaction we observe again the appearance of space modulation in the propagation profile.
Fig 3.  Frequency spectrum of the magnetisation.Amplitude spectrum of the magnetisation ⟨σ z i ⟩ on site i = 5 as a function of time in a system with parameters M = 7 sites, J = 1, ∆ 0 = 0.1, σ = 1/ √ 2, γ l = 0 for varying number of spin flips during the evolution N = 1, 2, 3 displayed from left to right.In every panel we compare the results for the case of nearest-neighbours and all-to-all coupling, observing that the number of peaks and the overall behaviour of the spectrum shows small differences in the case of n.n., contrasting the a.a.case, where every time that a spin flip connects to a new magnetisation sector a new peak at a constant distance appears in the spectrum, showing the potential ability for the system to count.In both cases, the time domain used was 10 ≤ tJ ≤ 20 after the events occurring in sites i = 1, 3, 5 respectively at fixed times in the initial window between 0 ≤ tJ ≤ 10.
Fig 9 and Appendix S1 Appendix.

Fig 3 .FFig 4 .
Fig 4. Agnostic estimation protocol summary.(1) The local time signal of the magnetisation is registered in a chosen time window, after the excitations have entered the system; (2) The spectrum of the signal is computed and then averaged over the number M of sites in the network; (3) Averaging over realisations with excitations at random times, locations, and random angles produces a spectrum template for each numerosity; (4) Sample runs are then compared with the templates, using agnostic decoding;(5) The estimated errors are compared for different numerosities to assert whether the system follows the predicted Weber's law.

Fig 5 .
(b).The average magnetisation simply drifts toward overall larger values as the stimuli are added uniformly distributed on average.This highlights the importance of processing the individual trajectories and not their averages.From the individual time signals, we can compose the average spectrum presented in Fig 5.(c).

Fig 5 .
Fig 5. Numerosity estimation in the quantum spin model.(a) Example magnetisation profile from one of the sampled trajectories for the case of M = 18 spins and N = 4 random spin flips, with ∆ 0 = 0, γ l = 0. (b) Average magnetisation for the same system for a set of N t = 200 trajectories.As the events have random location and intensity, there is no information in the averaged time signal.(c) Average of the amplitude spectrum of the magnetisation signals in the time window between t = (8J, 18 + √ 2J): the spectra were computed over individual trajectories and sites, then spaced averaged, and finally trajectory averaged.Here we display only the positive frequencies.(d) Psychometric function results for the quantum spin model with M = 18, and same parameters as in the top panel, where N spin flips random in location, time, and rotation angle, have occurred before registering the magnetisation.(e)Corresponding standard deviation estimates from the fits of the psychometric functions on the left.Here, we compare the previous case where each event is a spin flip of random amplitude (orange) with a case where the rotations where again random but their sum was constrained to be equal to 3π (blue).(f) Weber fraction associated to the results in the middle panel.

Fig 6 .
Fig 6.Decoder validation.(a) Weber fraction associated to the decoding of numerosity for the magnetisation signals with random amplitude excitations (RR) in Fig.5, for varying number of trajectories N t = 3, 5, 10, 40 with which we construct our library templates.We observe that the decoding converges with a very limited number of samples.(b) Weber fraction associated to the frequency decoding for sinusoidal activation maps with frequency ranging from f = 1 − 18, both noiseless and with noise proportional to the inverse of the frequency.We show that the decoder does not incorporate additional noise to the analysis by comparing the performance of both classical signals.

FundingFig 7 .Fig 8 .
Fig 7. Adapted version of Fig 2, for the case with N = 2 spin flips.(a) Evolution of the local magnetisation σ z i for a system with M = 7, J = 1, ∆ 0 = 0, γ l = 0 starting from a single excitation (spin up) on the middle site at t = 0 and a second one at time t 1 = (11 + √ 3)J and n.n.coupling.We use irrational numbers to prevent any symmetry-based counter-argument.The dashed lines highlight the magnetisation spreading in a light-cone manner; (b) same as (a) for ∆ 0 = 0.1, σ = 1/ √ 2; (c) same as (a) for ∆ 0 = 0.1, σ = 2/ √ 2; (d) same as (a) for γ l = 0.1; (e)-(h) same as (a)-(d)for the a.a.case.In the n.n.case, both excitation cones interplay to modify the evolution profile due to interference with similar behaviour in the presence of interactions, which only shifts the specific shape of the propagation profiles but does not alter the qualitative behaviour.Inclusion of spin decay with rate γ l ̸ = 0, leads to the loss of the excitations over time.The a.a.case does not exhibit light-cone spreading, but instead the excitation propagates evenly to all sites and oscillates back and forth with constant frequency.We observe how the addition of the second spin flip adds a new oscillatory frequency to the time signal, as reported in the power spectrum in Fig 3.The addition of interactions or dissipation, leading to spatial inhomogeneity, does not affect the presence of two distinct oscillation frequencies.

Fig 9 .
Fig 9.  Spectrum dependence on recorded time window.Amplitude spectrum of the magnetisation ⟨σ z i ⟩ as a function of the specific time window, averaged over all sites in a system with M = 9, N = 4, J = 1, ∆ 0 = 0.1, σ = 1/ √ 2, γ l = 0 and for varying time integration windows t max − t 1 .The chosen parameters serve as an example and do not qualitatively change the results displayed.Each line corresponds to the average of N t = 100 trajectories.We observe that the time window plays no role for the number of peaks in the spectrum, only the relative amplitude is modified.Longer time windows shift the amplitude towards the continuous (DC) component, which we eliminate in our spectrum analysis.

Table 1 .
Minimal elements for information processing and their quantum counterpart.