R T*_*mar 5 plot r histogram neuroscience exponential-distribution
所以我的问题跟随我上一次的发展.我一直在尝试将尖峰时间作为尖峰列车的rastor情节.我的射击率为100,并获得20次试验的加速训练:代码为:
fr = 100
dt = 1/1000 #dt in milisecond
duration = 2 #no of duration in s
nBins = 2000 #SpikeTrain
nTrials = 20 #NumberOfSimulations
MyPoissonSpikeTrain = function(p, fr= 100) {
p = runif(nBins)
q = ifelse(p < fr*dt, 1, 0)
return(q)
}
set.seed(1)
SpikeMat <- t(replicate(nTrials, MyPoissonSpikeTrain()))
plot(x=-1,y=-1, xlab="time (s)", ylab="Trial",
main="Spike trains",
ylim=c(0.5, nTrials+1), xlim=c(0, duration))
for (i in 1: nTrials)
{
clip(x1 = 0, x2= duration, y1= (i-0.2), y2= (i+0.4))
abline(h=i, lwd= 1/4)
abline(v= dt*which( SpikeMat[i,]== 1))
}
Run Code Online (Sandbox Code Playgroud)
完成所有这些之后,我的下一个任务是获得Inter-Spike间隔的向量并获得它们的直方图.由于ISI的分布遵循指数分布,如果我绘制具有相同数据的ISI的指数分布,它将匹配由直方图的高度产生的曲线.因此,为了首先获得interpike时间,我使用了:
spike_times <- c(dt*which( SpikeMat[i, ]==1))
Run Code Online (Sandbox Code Playgroud)
然后,为了得到一个interpike间隔的矢量及其直方图,我使用了以下命令行,
ISI <- diff(spike_times)
hist(ISI, density= 10, col= 'blue', xlab='ISI(ms)', ylab='number of occurences')
Run Code Online (Sandbox Code Playgroud)
它给了我这个情节:
现在,我想要的是绘制直方图中的指数分布,证明了峰值间隔的指数分布特性.我对使用什么参数以及使用哪种速率感到困惑.如果有人使用Interspike间隔绘图,请帮忙.如果我的数据看起来不完整,我很抱歉,如果我错过了什么,请告诉我.
我的研究员同事刚刚告诉我一行简单的代码:
x <- seq(0, 0.05, length=1000)
y <- dexp(x, rate=100)
lines(x,y)
Run Code Online (Sandbox Code Playgroud)
如果有人有任何方法可以提高此过程的效率,请帮助我。
| 归档时间: |
|
| 查看次数: |
309 次 |
| 最近记录: |