Hi everyone,
is it able to set the seed in kdb to reproduce same random numbers?
Which algorithms to simulate random numbers are used in kdb?
How to simulate a weighted coin in kdb?
I am not lazy. Here is my way to do it. Perhaps there is a more
smarter way.
(count[r where r=O];count[r where r=
E]) % count r:100000?raze (10 2)
{[x;y] x#y}’ O
E
Thanks for any comments
Regards,
Kim
On 23 Jul., 14:11, kuentang <kuent…> wrote:
> Hi everyone,
>
> is it able to set the seed in kdb to reproduce same random numbers?
> Which algorithms to simulate random numbers are used in kdb?
>
> How to simulate a weighted coin in kdb?
>
> I am not lazy. Here is my way to do it. Perhaps there is a more
> smarter way.
This looks better :
select p:count[i]% count s by sample from s:( sample:100000?raze (2
10) {[x;y] x#y}’ O
E)
>
> (count[r where r=O];count[r where r=
E]) % count r:100000?raze (10 2)
> {[x;y] x#y}’ O
E
>
> Thanks for any comments
>
> Regards,
>
> Kim
</kuent…>
To: personal-kdbplus@googlegroups.com
X-Mailer: Apple Mail (2.1084)
>> How to simulate a weighted coin in kdb?
>
> select p:count[i]% count s by sample from s:( sample:100000?raze (2 =
10) {[x;y] x#y}’ O
E)
setting the seed is \S int
the default is -100000*=CF=80
simplifying,
q)select p:count[i]%count s by sample from s:(sample:100000?raze 2 =
10#'O
E)
sample |
p |
E |
0.83371 |
O |
0.16629 |
the core is most simply
q)count each group(1%6)>100000?1.
0| 83522
1| 16478
everything else is labeling :)=
Hi Aaron,On 24 Jul., 05:21, Aaron Davies <aaron.dav…> wrote:> >> How to simulate a weighted coin in kdb?>> > select p:count[i]% count s by sample from s:( sample:100000?raze (2 10) {[x;y] x#y}’ O
E)>> setting the seed is \S intThanks.>> the default is -100000*?>> simplifying,>> q)select p:count[i]%count s by sample from s:(sample:100000?raze 2 10#‘O
E)very nice> sample| p > ------| -------> E | 0.83371> O | 0.16629>> the core is most simplyi tested your approach against my approach. Your approach seems totake longer. Since it needs to simulate random numbers on the wholeinterval wereas my approach needs only to simulate on the twooutcomes.\t value “count each group (1%6) > 10000000?1.0”\t value "select p:count[i]% count s by sample from s:( sample:10000000?raze (2 10) {[x;y] x#y}’ O
E)"Thanks for the comments.>> q)count each group(1%6)>100000?1.> 0| 83522> 1| 16478>> everything else is labeling :)</aaron.dav…>
> i tested your approach against my approach. Your approach seems to> take longer. Since it needs to simulate random numbers on the whole> interval wereas my approach needs only to simulate on the two> outcomes.>> \t value “count each group (1%6) > 10000000?1.0”> \t value “select p:count[i]% count s by sample from s:( sample:> 10000000?raze (2 10) {[x;y] x#y}’ O
E)”?q)\t count each group (1%6) > 10000000?1.0148q)\t select p:count[i]% count s by sample from s:(sample:10000000?raze (2 10) {[x;y] x#y}’ O
E)192
On 25 Jul., 05:50, Aaron Davies <aaron.dav…> wrote:> > i tested your approach against my approach. Your approach seems to> > take longer. Since it needs to simulate random numbers on the whole> > interval wereas my approach needs only to simulate on the two> > outcomes.>> > \t value “count each group (1%6) > 10000000?1.0”> > \t value “select p:count[i]% count s by sample from s:( sample:> > 10000000?raze (2 10) {[x;y] x#y}’ O
E)”>> ?Hmmm,:q) avg { value “\t (int$1e7)?1" } each til 10073.99q) avg { value "\\t (
int$1e7)?1.0” } each til 100104.04q) avg { value “\t count each group (1%6) > 10000000?1.0” } each til100273.14q) avg { value "\t select p:count[i]% count s by sample from s:(sample:(int$1e7)?raze
OE where 2 10 )" } each til 100250.36>> q)\t count each group (1%6) > 10000000?1.0> 148> q)\t select p:count[i]% count s by sample from s:([]> sample:10000000?raze (2 10) {[x;y] x#y}'
O`E)> 192</aaron.dav…>
On 25 Jul., 09:22, Attila Vrabecz <attila.vrab…> wrote:> > raze 2 10#'O
E>Cool> O
E where 2 10>> Regards,> ? Attila</attila.vrab…>