MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Problem with BinCounts

  • To: mathgroup at smc.vnet.net
  • Subject: [mg90927] Re: Problem with BinCounts
  • From: Valeri Astanoff <astanoff at gmail.com>
  • Date: Wed, 30 Jul 2008 03:51:39 -0400 (EDT)
  • References: <g6mas3$i0d$1@smc.vnet.net>

On 29 juil, 07:46, Mark Teagarden <Mark.Teagar... at UTSA.EDU> wrote:
> Hi,
>
> I'm trying to do an autocorrelation analysis on an artificially generated
> neuronal spike train, but BinCounts is behaving strangely.
>
> I first generate a list of spike times for an oscillator with a mean
> frequency of 1 Hz, plus some gaussian jitter:
>
> st = NestList[(1 + RandomReal[NormalDistribution[0, 0.1]] + # &), 0,100=
0];
>
> Then I do the autocorrelation like this:
>
> BinCounts[st, {# - 2.00, # + 2.00, 0.01}] & /@ st;
>
> ac = Last[Accumulate[%]]/Length[%];
>
> The output of BinCounts ought to be a list of length st, with each list
> element having a fixed length of 400.  And yet I get error messages lik=
e so:
>
> Thread::tdlen: Objects of unequal length in
> \
> {13,11,15,9,12,13,14,13,9,6,<<390>>}+{0,1,0,0,0,0,0,0,0,0,<<389>>}
> \
> cannot be combined. >>
>
> And sure enough, if I run Dimensions/@ the output of the BinCounts line, =
I
> get one or two elements with a length of 399.  This happens completely =
at
> random, and I don't understand why.  It seems to me that BinCounts ough=
t to
> give me a fixed output length, regardless of what the results of the
> operation actually were.  These shorter elements do not occur near the
> beginning or end, either, so it's not an edge effect.  Furthermore, the
> values of st corresponding to the shorter elements of ac don't have any
> unusual properties like being whole numbers or anything.  I will add th=
at
> sometimes the code works correctly, and it's not obvious why.
>
> Has anyone else encountered such behavior before?  What did you do abou=
t it?
>

Good day,

All I can say is that if you rationalize 'st'
and all parameters then it doesn't occur :

st=NestList[(1+RandomReal[NormalDistribution[0,0.1]]+#&),
0,1000]//Rationalize[#,10^-6]&;

BinCounts[st, {# - 2, # + 2, 1/100}] & /@ st;


V.Astanoff



  • Prev by Date: Re: remove higher orders terms from mathemtica's result
  • Next by Date: Re: Re: Method Option
  • Previous by thread: Problem with BinCounts
  • Next by thread: Re: Re: Problem with BinCounts