Loading ...
Sorry, an error occurred while loading the content.

Re: Searching variables with regex?

Expand Messages
  • diodeom
    Cool; I wish I had thought of it here, Eb -- directly incrementing results in an array. And it shaves a respectable half a second of almost three consumed by
    Message 1 of 35 , Oct 7, 2010
    • 0 Attachment
      Cool; I wish I had thought of it here, Eb -- directly incrementing results in an array. And it shaves a respectable half a second of almost three consumed by the original on my comp. Another advantage (even though it evidently wasn't my concern when putting together this impromptu clip) is that your approach is not limited to just a few alternatives. The variable %count% could be made universal for any %alt% value with e.g.:

      ^!SetArray %count%=0^$StrFill(^%nl%0;^$Calc(^%alt%-1)$)$

      For me a ten-cycle set of 10,000 generated random numbers (after running their averages) gave between either of the three %alt% alternatives a maximum average variance of 78.5 "hits" or 0.785%. The same done for just 100 numbers produced -- as expected -- a much larger max spread of 3.6%. Fair by me. I'd probably freak and question *randomness* if the statistical expectations anchored in infinity were met on the dot at low quantities/iterations.

      Anyway, this (I'd suggest: overkill, to say the least) tester was only meant to help me illustrate more radical favoritism (or lack thereof) of different takes. I appreciate your contribution regardless of this context.


      --- In ntb-clips@yahoogroups.com, "Eb" <ebbtidalflats@...> wrote:
      >
      > Hi Diodem,
      > That's a nifty utility, but I couldn't resist changing it a bit, to make the counting more efficient:
      >
      > ;loop counter, Num random numbers to generate, range of numbers
      > ^!Set %i%=0; %max%=5001; %alt%=3
      > ^!SetListDelimiter ^%nl%
      > ^!SetArray %count%=0^%nl%0^%nl%0
      > :Rand
      > ^!Inc %i%
      > ^!Set %method%=^$Calc(INT(RND(^%alt%)+1))$
      > ^!Inc %count^%method%%
      > ^!If ^%i%<^%max% Rand
      > :Done
      > ^!Info [L]^%count%
      > ^!ClearVariables
      >
      >
      > I increased the iterations to improve the accuracy, but the error I got was still in the +/- 2% range.
      >
      > Cheers
      >
      >
      > Eb
      >
    • Paul
      See? There s always someone ready to apply the rules even when I thought I was doing something harmless?!! sry bout that.. point taken. will visit
      Message 35 of 35 , Oct 11, 2010
      • 0 Attachment
        See? There's always someone ready to apply the rules even when I thought I was doing something harmless?!! <ahem> sry 'bout that.. point taken. will visit over there.....

        --- In ntb-clips@yahoogroups.com, Axel Berger <Axel-Berger@...> wrote:
        >
        > Paul wrote:
        > > I only stiffly object to copied work when it is purported to be
        > > ones own work. In the early stages of professional development
        > > I advocate reprimand and retraining.
        >
        > This is beginning to drift off the topic od clips, My answer certainly
        > is, which is why I just posted it to the off-topic list.
        >
        > Axel
        >
      Your message has been successfully submitted and would be delivered to recipients shortly.