Re: Searching variables with regex?
- 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
^!If ^%i%<^%max% Rand
I increased the iterations to improve the accuracy, but the error I got was still in the +/- 2% range.
--- In email@example.com, "diodeom" <diomir@...> wrote:
> I wrote:
> > ^!Set %n%=^$Calc(FLOOR(RND(^%ar0%)+1))$
> If of interest to anyone, I utilized the following makeshift clip to better test "fairness" of various randomizing takes:
> ;Number of random numbers to generate +1
> ^!Set %i%=1001
> ;Number of alternatives (array elements), min 2/max 8
> ^!Set %alt%=3
> ^!Dec %i%
> ^!If ^%i%=0 Count
> ;Variants of getting random numbers
> ^!Set %method%=^$Calc(FLOOR(RND(^%alt%)+1))$
> ;^!Set %method%=^$Calc(RND(^$Calc(^%alt%-1)$)+1;0)$
> ;^!Set %method%=^$Calc(CEIL(RND(^%alt%)))$
> ^!Append %rnd%=^%method%
> ^!Goto Rand
> ^!Inc %i%
> ^!If ^%i%>^%alt% Done
> ^!Set %h%=^$StrCount(^%i%;^%rnd%;0;0)$
> ^!Append %res%=Alt ^%i%: ^%h% hits
> ^!Append %res%=, ^$Calc(^%h%/^$StrSize(^%rnd%)$*100;2)$%^%nl%
> ^!Goto Count
> ^!Info [L]^%res%
> ^!Set %i%=; %alt%=; %method%=; %rnd%=; %h%; %res%=
> For a more accurate illustration, this obviously could be furthered to average data collected from multiple runs.
- 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 firstname.lastname@example.org, 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.