Recording data and generating distinct integers
Posted: Tue Dec 21, 2010 4:15 pm
Hi, Ted,
I got two questions for you. The first one is about recording simulation time. I used a time step of dt = 0.05 ms (fixed) in simulation and I want to record the simulation time in every 10 steps. My code is as follows:
If everything is corret, the data in the file "tt" should be: 0 0.5 1 1.5 2... However, the actual data I got is somewhat different:
0
0.475
1
1.5
2
2.475
2.975
3.475
3.975
.
.
So sometimes it recorded correctly, but sometimes it was off a little bit (e.g., 0.475 instead of 0.5). That means the data was not recorded in an uniform interval. Why?
The second question is how I can generate a number of distinct integers in NEURON? I used the code to generate N integers:
But this code would generate repeated integers. Is there an efficient way to generate distinct integers?
Thank you very much!
Best,
GL
I got two questions for you. The first one is about recording simulation time. I used a time step of dt = 0.05 ms (fixed) in simulation and I want to record the simulation time in every 10 steps. My code is as follows:
Code: Select all
N = 10
objref f1
f1 = new File()
objref time
time = new Vector()
// Record time
time.record(&t, N*dt)
// Save time into a file
f1.wopen("/Model/NET/data/tt")
time.printf(f1)
f1.close()
If everything is corret, the data in the file "tt" should be: 0 0.5 1 1.5 2... However, the actual data I got is somewhat different:
0
0.475
1
1.5
2
2.475
2.975
3.475
3.975
.
.
So sometimes it recorded correctly, but sometimes it was off a little bit (e.g., 0.475 instead of 0.5). That means the data was not recorded in an uniform interval. Why?
The second question is how I can generate a number of distinct integers in NEURON? I used the code to generate N integers:
Code: Select all
objref random
random = new Random(seed)
for k=0, N {
gi = random.uniform(0, 100)
gi = nint(gi)
}
func nint() {
if ( abs($1 - int($1)) <= 0.5) {
return int($1)
} else {
if ($1 < 0) { return int($1)-1 }
if ($1 >= 0) { return int($1)+1 }
}
}
Thank you very much!
Best,
GL