Draw synaptic weights from distribution

14 views
Skip to first unread message

Wilhelm Braun

unread,
Oct 15, 2019, 1:05:20 PM10/15/19
to Brian Development
Dear all,

I am not sure whether this question has already been asked (I could not find an answer here), but what I am trying to do seems to be quite generic and hence I wonder whether there is a simple solution in 'brian2'.

Basically, I would like to draw synaptic weights independently and identically distributed from a certain distribution, so doing something like:

S = Synapses(group_pre, group_post, 'w : volt', on_pre='V_post += w')
S
.connect(p = 0.1)
S
.w[:, :] = 'rand()*mV' #How to use general, e.g. from numpy.random.normal(), distribution here?

Thank you very much for your answer.

Best, Wilhelm

Marcel Stimberg

unread,
Oct 16, 2019, 12:50:20 PM10/16/19
to brian-de...@googlegroups.com
Hi Wilhelm,

in code strings, you can only use functions that we prepared for use
with Brian (since they get translated into C++ code, etc.). For random
numbers that means "rand()" for uniformly distributed, and "randn()" for
normally distributed numbers (Brian's development version also has
support for discrete numbers from a Poisson distribution). If that is
not enough, you can also generate numbers in Python and provide them as
values (instead of specifying the distribution as strings). This works
in principle both in runtime and standalone mode, but not in your case
where the number of synapses is random. In runtime mode you can do, say,

S.w = np.random.negative_binomial(1, 0.1, len(S))

but in standalone mode, "len(S)" will raise an error since the synapses
will only be generated as part of the standalone code, and we therefore
do not know yet how many values we need.

Best,

  Marcel


Reply all
Reply to author
Forward
0 new messages