# Description of problem

Hi,
Consider you have a network of two layers. the first layer contains N_e excitatory neurons and N_i inhibitory ones, fully connected to the second layer having N_o neurons. (ex. 6 exc and 4 inh neurons and 2 output neurons → 20 synapses )
I have the number of 5 runs and want to set random values (for weights) after each run for the number of randomely chosen synapses with a fixed probability , connected to second layer. For example,if I had 30 synapses,the weights of 0.2 of them( the number of 4) would be changed to a new random value after each run.

Hi @Rihana . There are two ways to change the weights, the first would look like this:

``````synapses.w['rand() < 0.2'] = 'min_weight + rand()*(max_weight - min_weight)'
``````

This would set the random weight for each synapse with a probability of 20% – in the case of 20 synapses, this would change the weights for 4 synapses on average, but it will sometimes change the weight for 3 or 5 of them (Bernoulli trials → Binomial distribution).

If you want to change the weights of exactly 4 synapses, you can use:

``````random_indices = np.random.choice(len(synapses), size=4, replace=False)
synapses.w[random_indices] = 'min_weight + rand()*(max_weight - min_weight)'
``````
1 Like