Re: Searching variables with regex?
- 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.:
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 firstname.lastname@example.org, "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
> ^!Inc %i%
> ^!Set %method%=^$Calc(INT(RND(^%alt%)+1))$
> ^!Inc %count^%method%%
> ^!If ^%i%<^%max% Rand
> ^!Info [L]^%count%
> I increased the iterations to improve the accuracy, but the error I got was still in the +/- 2% range.
- 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 email@example.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.