Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace ACG with Random123 #5

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions arm.hoc
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ proc initArmCB () { local i
LearnON()
} else LearnOFF()
APHASE=AMOVE
if(DoRDM) ardm.ACG(aseed)
if(DoRDM) ardm.Random123(aseed)
if(DoLearn==1) cvode.event(MoveDur,"resetPhase()")
SUBPHASE=0
if(syDT>0) {nqsdel(nqsy) nqsy=new NQS("id1","id2","wg","t") cvode.event(syDT,"svsywts()")}
Expand Down Expand Up @@ -857,7 +857,7 @@ proc NRTrain () { local i,j,dur,noisemax,noisemin,noisedec
// performs training with random starting positions
proc RandTrain () { local nlocs,i,j,dur,niter,se localobj rdm
nlocs=$1 niter=$2 dur=$3 if(numarg()>2)se=$3 else se=213951 resetplast_INTF6=0
rdm=new Random() rdm.ACG(se)
rdm=new Random() rdm.Random123(se)
tstop = dur
for i=0,nlocs-1 {
print "location number " , i
Expand Down
24 changes: 13 additions & 11 deletions col.hoc
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ proc setspks () { local cd,se,ndx localobj rdm,ce,intf
printf("CSTIM: no cells to stim!\n")
return
}
intf=ce.o(0) rdm=new Random() rdm.ACG(iseed) //initialize Random object
intf=ce.o(0) rdm=new Random() rdm.Random123(iseed) //initialize Random object
if(vq==nil) vq=new NQS("ind","time","wt","sy") else vq.clear() //NQS storing INTF6 spike times
intf.clrvspks() //clear INTF6 spike times
if(sgrdur>0) {
Expand Down Expand Up @@ -107,7 +107,7 @@ proc jitterspks () { local a,jmin,jmax,seed localobj v1,rdm
if(numarg()>1) jmax=$2 else jmax=1e-6
if(numarg()>2) seed=$3 else seed=1234
rdm=new Random()
rdm.ACG(seed)
rdm.Random123(seed)
rdm.uniform(jmin,jmax)
v1.resize(vq.v.size)
v1.setrand(rdm)
Expand Down Expand Up @@ -146,7 +146,7 @@ proc pulsestim () { local nspk,tt,i,j,nrate,ti,maxt localobj rdp,vqtmp
if(numarg()>2) {
if($3) vq.clear()
} else vq.clear()
if(numarg()>3) rdp.ACG($4) else rdp.ACG(1234)
if(numarg()>3) rdp.Random123($4) else rdp.Random123(1234)
vqtmp=new NQS()
tt=1 rdp.poisson(1000/nrate)
while(tt<=maxt) {
Expand All @@ -170,7 +170,7 @@ proc initrands () { local i,se localobj rds
for i=0,vrse.size-1 {
rds = rsl.o(i) // go thru Random objects
se = vrse.x(i) // seed previously used
rds.MCellRan4(se,se) // initialize MCellRan4 Random # generator
rds.Random123(se,se) // initialize random # generator
rds.negexp(1) // must be called this way
}
}
Expand All @@ -195,10 +195,12 @@ proc nsstim () { local a,sy,sdx,idx,sglo,sghi,hzlo,hzhi,ct,se localobj rdm,vsy,v
ns.noise = 1 // make it fully random
ns.interval = 1e3 / vhz.x(idx-col.ix[ct]) // avg interval btwn the inputs

rsl.append( rds = new Random() )
rds = new Random()
rds.Random123(se,se) // seeds are in order, shouldn't matter
rsl.append( rds)
rds.negexp(1) // set random # generator using negexp(1) - avg interval in NetStim.interval
rds.MCellRan4(se,se) // seeds are in order, shouldn't matter
ns.noiseFromRandom(rds) // use random # generator for this NetStim
// ns.noiseFromRandom(rds) // use random # generator for this NetStim
ns.noiseFromRandom123(se, se, 0) // compatible back to 2016
vrse.append(se) // save random # seed

ncl.append( nc = new NetCon(ns,col.ce.o(idx)) ) // set the connection (netstim->postsynaptic INTF6 cell)
Expand Down Expand Up @@ -541,7 +543,7 @@ proc init () { local skipwire
//** initdivrnd(seed) - initializes random object for wiring
obfunc initdivrnd () { local s localobj rd
s=$1
if(setdviPT==PARETO) rd=new rdmpareto(1,PARETOSH,s) else {rd=new Random() rd.ACG(s)}
if(setdviPT==PARETO) rd=new rdmpareto(1,PARETOSH,s) else {rd=new Random() rd.Random123(s)}
return rd
}

Expand Down Expand Up @@ -652,7 +654,7 @@ proc wire () { local x,y,z,ii,jj,a,del,prid,prty,poty,dv,dvt,lseed,dvrand,szo\
if (argtype(1)==0) lseed=$1 else lseed=1234
vrsz(1e4,vidx,vdel,vdist,vtmp)
vrsz(ce.count*CTYPi,vdvd)
{rdm=new Random() rdm.MCellRan4(lseed,lseed)}
{rdm=new Random() rdm.Random123(lseed,lseed)}
if(dgcor){dvrand=0.2 rdm.uniform(.8,1.2) vdvd.setrand(rdm)}// div variability of 20% when dgcor==1
rdmDV=initdivrnd(lseed)//initialize random # generator for use when dgcor==0
// Create the connectivity NQS table.
Expand Down Expand Up @@ -703,7 +705,7 @@ func wire2col () { local d,from,to,sz,dvm,dv,pij,dlym,dlyd,w1,w2,sy1,sy2,loc,i,i
{vpij=nq.getcol("pij") vloc=nq.getcol("loc")}
if(verbose) print "tcol.wseed = ",tcol.wseed, " vfrom.size = ",vfrom.size
rdmDV=initdivrnd(tcol.wseed)//initialize random # generator
{rdm=new Random() rdm.MCellRan4(tcol.wseed,tcol.wseed)}
{rdm=new Random() rdm.Random123(tcol.wseed,tcol.wseed)}
if (mknetnqss && xcolconnsnq==nil) xcolconnsnq=new NQS("id1","col2","id2","del","wt1","wt2")
i=0
while(i<vfrom.size) {
Expand Down Expand Up @@ -766,7 +768,7 @@ proc setcellpos () { local i,z,x,y,zvar,c localobj rdm,vz
if(numarg()>1) zvar=$2
if(numarg()>2) pseed=$3
if(numarg()>3) cside=$4
{rdm=new Random() rdm.ACG(pseed)}
{rdm=new Random() rdm.Random123(pseed)}
c=-1
if(cellsnq!=nil) c=cellsnq.fi("xloc")
for i=0,allcells-1 {
Expand Down
4 changes: 2 additions & 2 deletions decvec.hoc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ vrtmp = new Vector(10)
veclist = new List()
veccollect = new List()
rdm = new Random()
rdm.MCellRan4()
rdm.Random123()

if (!(xwindows && name_declared("xwindows"))) {
xwindows=0
Expand Down Expand Up @@ -1535,7 +1535,7 @@ proc rdmuniq () { local i,max,min,n,a3,a,see localobj ro,v1,v2,vin,l
}
if (!rdmuniqm4) {
if (ro==nil) ro=new Random()
if (see) ro.ACG($5) // seed it
if (see) ro.Random123($5) // seed it
ro.discunif(min,max)
}
vin.resize(0)
Expand Down
2 changes: 1 addition & 1 deletion infot.hoc
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ proc mkspks () { local tmax,rate,t,dt,intt,off,i,alpha localobj rdp
if(numarg()>3)alpha=$4 else alpha=1
intt=1e3/rate
rdp=new Random()
rdp.ACG(1234)
rdp.Random123(1234)
rdp.poisson(intt)
for i=0,1 vs[i].resize(0)
vs[0]=mkspktrain(rdp,rate,tmax)
Expand Down
2 changes: 1 addition & 1 deletion intf6_.mod
Original file line number Diff line number Diff line change
Expand Up @@ -1256,7 +1256,7 @@ VERBATIM {
clk=clock()-savclock; savclock=clock();
if (cbsv) hoc_call_func(cbsv,0);
if (tf) fprintf(tf,"t=%.02f;%ld(%g) ",t,pg->jri,clk/1e6); else {
printf("t=%.02f;%ld(%g) ",t,pg->jri,clk/1e6); }
printf("t=%.02f;%ld ",t,pg->jri); }
for (i=0;i<CTYN;i++) {
ix=cty[i];
pg->spktot+=spikes[ix];
Expand Down
14 changes: 7 additions & 7 deletions network.hoc
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ proc swirecut () { local x,y,z,ii,jj,a,del,prid,poid,prty,poty,dv,lseed,h,prob,s
}
slambdasq = slambda^2 // using squared distance
vrsz(1e4,vidx,vdel,vdist,vtmp)
rdm=new Random() rdm.ACG(lseed) // initdivrnd(lseed)//initialize random # generator
rdm=new Random() rdm.Random123(lseed) // initdivrnd(lseed)//initialize random # generator
rdm.uniform(0,1) vprob.resize(ce.count^2) vprob.setrand(rdm) pdx=0
// Create the connectivity NQS table.
if(col.mknetnqss) {nqsdel(col.connsnq) col.connsnq=new NQS("id1","id2","del","dist","wt1","wt2")}
Expand Down Expand Up @@ -640,7 +640,7 @@ proc swirecutfl () { local x,y,z,ii,jj,a,del,prid,poid,prty,poty,dv,lseed,h,\
col=$o1 ce=col.ce EEsq=$2 EIsq=$3 IEsq=$4 IIsq=$5
if (argtype(6)==0) lseed=$6 else lseed=1234
vrsz(1e4,vidx,vdel,vdist,vtmp,vpre)
rdm=new Random() rdm.ACG(lseed) // initdivrnd(lseed)//initialize random # generator
rdm=new Random() rdm.Random123(lseed) // initdivrnd(lseed)//initialize random # generator
rdm.uniform(0,1) rsz=ce.count^2 vprob.resize(rsz) vprob.setrand(rdm) pdx=0
{mmaxd.x(0,0)=sqrt(EEsq) mmaxd.x(0,1)=sqrt(EIsq) mmaxd.x(1,0)=sqrt(IEsq) mmaxd.x(1,1)=sqrt(IIsq)}
// Create the connectivity NQS table.
Expand Down Expand Up @@ -701,7 +701,7 @@ proc swireDPs () { local x,y,z,ii,jj,a,n,del,prid,poid,prty,poty,dv,lseed,prob,i
cdx=0
cl=col[cdx] lce=cl.ce
if (argtype(1)==0) lseed=$1 else lseed=1234
rdm=new Random() rdm.ACG(lseed) // initdivrnd(lseed)//initialize random # generator
rdm=new Random() rdm.Random123(lseed) // initdivrnd(lseed)//initialize random # generator
rdm.uniform(0,1) vprob.resize(rsz=lce.count^2) vprob.setrand(rdm) pdx=0
vpoty.append(ES)
//** wire in the DPs
Expand Down Expand Up @@ -753,7 +753,7 @@ proc wireDPs () { local x,y,z,ii,jj,a,n,del,prid,poid,prty,poty,dv,lseed,cdx,cv,
cdx=0
cl=col[cdx] lce=cl.ce
if (argtype(1)==0) lseed=$1 else lseed=1234
rdm=new Random() rdm.ACG(lseed) // initdivrnd(lseed)//initialize random # generator
rdm=new Random() rdm.Random123(lseed) // initdivrnd(lseed)//initialize random # generator
rdm.uniform(0,1)
vpoty.append(ES)
//** wire in the DPs
Expand Down Expand Up @@ -793,7 +793,7 @@ proc wireDPs () { local x,y,z,ii,jj,a,n,del,prid,poid,prty,poty,dv,lseed,cdx,cv,
//* checkerpos(col,rad,xinc,yinc,seed) - arrange cells in checkerboard pattern
proc checkerpos () { local i,j,x,y,csz,xinc,yinc,seed,rad,a localobj col,ce,rdm,xo,nqc
col=$o1 csz=col.cside rad=$2 xinc=$3 yinc=$4 rdm=new Random()
if(numarg()>4) seed=$5 else seed=1234 rdm.ACG(seed) ce=col.ce nqc=new NQS("x","y")
if(numarg()>4) seed=$5 else seed=1234 rdm.Random123(seed) ce=col.ce nqc=new NQS("x","y")
for(y=0;y<csz;y+=yinc) {
if(y%2==0) {
for(x=0;x<csz;x+=xinc) nqc.append(x,y)
Expand Down Expand Up @@ -864,7 +864,7 @@ proc convwire () { local x,y,z,ii,jj,a,del,prid,prty,poid,poty,cv,cvt,dv,dvt,lse
col=$o1 ce=col.ce
if (numarg()>1) lseed=$2 else lseed=1234
vrsz(1e4,vidx,vdel,vdist,vtmp)
{rdm=new Random() rdm.MCellRan4(lseed,lseed)}
{rdm=new Random() rdm.Random123(lseed,lseed)}
// Create the connectivity NQS table.
nqsdel(col.connsnq)
col.connsnq=new NQS("id1","id2","del","dist","wt1","wt2")
Expand Down Expand Up @@ -969,7 +969,7 @@ proc mkDPs () { local ii,x,y,c,ndp,suty,rw,cl,rs,cs,pad,cdx,xinc,yinc\
ce=col[cdx].ce gid=0
if(NMUSCLES==4) rs=cs=2 else {rs=1 cs=2} // # rows and columns for DP spatial layout
for ii=0,col[cdx].numc[DP]-1 cedp.append(new DPC()) // create the DPs
rdm=new Random() rdm.ACG(pseed+DP)
rdm=new Random() rdm.Random123(pseed+DP)
if(DPpad) pad=colside/cs/8 else pad=0
if (col[cdx].cellsnq==nil) c=-1 else {
cellsnq=col[cdx].cellsnq cellsnq.tog("DB") c=cellsnq.fi("xloc")
Expand Down
2 changes: 1 addition & 1 deletion params.hoc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ if(!autotune) if(useSTDP) seadsetting_INTF6 = 3 // plasticity on

declare("fih","o[1]","nstim","o[1]")
vseed_stats(223481)
rdm.MCellRan4(seed_stats)
rdm.Random123(seed_stats)

//* IREparams - setup IRE cells
proc IREparams () { local ii,jj localobj xo,co
Expand Down
2 changes: 1 addition & 1 deletion samutils.hoc
Original file line number Diff line number Diff line change
Expand Up @@ -1063,7 +1063,7 @@ objref r_uniform

proc InitRand(){
r_uniform = new Random(1234567891011121314)
my_ran_ind = r_uniform.MCellRan4()
my_ran_ind = r_uniform.Random123()
r_uniform.uniform(0,1)
}

Expand Down
6 changes: 3 additions & 3 deletions sense.hoc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ rdmthresh_DRSPK = 1
proc mkstimnq () { local ii,se,a localobj xo,rdm,ind,vr
if(numarg()>0) se=$1 else se=9658
{nqsdel(stimnq) stimnq=new NQS("eflex","eext","wflex","wext")}
rdm=new Random() rdm.ACG(se) a=allocvecs(ind,vr)
rdm=new Random() rdm.Random123(se) a=allocvecs(ind,vr)
ind.indgen(0,PI/2,0.01)
for ii=0,10 {stimnq.v[0].append(ind) stimnq.v[0].append(ind.c.reverse)}
stimnq.v[1].copy(stimnq.v[0])
Expand All @@ -34,8 +34,8 @@ proc mkstimnq () { local ii,se,a localobj xo,rdm,ind,vr
proc setDPrand () { local ii,se,a localobj xo,rdm,vr,vec
if(numarg()>0) se=$1 else se=9658
if(rdmthresh_DRSPK) {
ldp=new List() rdm=new Random() rdm.ACG(se) rdm.poisson(8)
} else {rdm=new Random() rdm.ACG(se)}
ldp=new List() rdm=new Random() rdm.Random123(se) rdm.poisson(8)
} else {rdm=new Random() rdm.Random123(se)}
for ltr(xo,cedp,&ii) {
if(rdmthresh_DRSPK) {
rdm.normal(25,10)
Expand Down
6 changes: 3 additions & 3 deletions stats.hoc
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ proc init () {
avg=$1 shape=$2
if(numarg()>2)seed=$3 else seed=1234
rd=new Random()
rd.ACG(seed)
rd.Random123(seed)
}
proc reset () {
rd.ACG(seed)
rd.Random123(seed)
}
func paretoc () { local scale,shape,U
scale=$1 shape=$2 U = rd.uniform(0,1)
Expand Down Expand Up @@ -131,7 +131,7 @@ obfunc nhppvec () { local i,dt,tt,maxt,maxi,se,tidx localobj tvec,ivec,rdm
ivec=$o1 dt=$2 maxt=$3
if(numarg()>3)se=$4 else se=1234
rdm=new Random()
rdm.ACG(se)
rdm.Random123(se)
tt=0
maxi=ivec.max
while(tt<maxt) {
Expand Down
2 changes: 1 addition & 1 deletion syncode.hoc
Original file line number Diff line number Diff line change
Expand Up @@ -1570,7 +1570,7 @@ func nrstim () { local a,tt,i,j,ti,maxt,ct localobj rdp,vr,vt,vi,nq
if(numarg()>2) {
if($3) nq.clear()
} else nq.clear()
if(numarg()>3) rdp.ACG($4) else rdp.ACG(1234)
if(numarg()>3) rdp.Random123($4) else rdp.Random123(1234)
rdp.normal(pwght,pvar)
vt.indgen(0,maxt,1000/prate) vi.resize(vt.size) vr.resize(vt.size)
for i=ix[$1],ixe[$1] {
Expand Down