Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/multithreading/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Multithreading 使用peach时,随机状态如何传播到不同的线程?_Multithreading_Kdb - Fatal编程技术网

Multithreading 使用peach时,随机状态如何传播到不同的线程?

Multithreading 使用peach时,随机状态如何传播到不同的线程?,multithreading,kdb,Multithreading,Kdb,我试图理解在使用peach时随机状态是如何传播到线程的,但是找不到太多关于它的文档 从经验上看,从下面的测试来看,线程最终似乎有不同的种子,但这些种子可能与主线程的随机种子无关 q) \S 123 q) {[x] show 20?10} peach til 10 但第二次运行这两行并不能重现这个答案 因此,我的问题是: 线程中的种子与主线程的随机状态之间是否存在关系 我们保证在每个线程上得到不同的种子吗 关于在每个线程设置种子的最佳实践或获得可复制结果的其他方法,有什么建议吗 谢谢情况并非总

我试图理解在使用peach时随机状态是如何传播到线程的,但是找不到太多关于它的文档

从经验上看,从下面的测试来看,线程最终似乎有不同的种子,但这些种子可能与主线程的随机种子无关

q) \S 123 
q) {[x] show 20?10} peach til 10
但第二次运行这两行并不能重现这个答案

因此,我的问题是:

  • 线程中的种子与主线程的随机状态之间是否存在关系
  • 我们保证在每个线程上得到不同的种子吗
  • 关于在每个线程设置种子的最佳实践或获得可复制结果的其他方法,有什么建议吗

  • 谢谢

    情况并非总是如此,它在v3.1中得到了修复

    q).z.K
    3f
    q)count distinct {10?10}peach til 1000
    931
    
    q).z.K
    4f
    q)count distinct {10?10}peach til 1000
    1000
    
    从发行说明中

    2013.08.19
    FIX
    the random number generator was not thread-safe. Now the behaviour is as follows
     rng is thread local.
     \S 1234 sets the seed for the rng for the main thread only.
     the rng in a slave thread is assigned a seed based on the slave thread number.
     in multithreaded input mode, the seed is based on socket descriptor.
     instances started on ports 20000 thru 20099 (slave procs, used with e.g. q -s -4) have the main thread's default seed based on the port number.
    

    情况并非总是如此,它在v3.1中得到了修复

    q).z.K
    3f
    q)count distinct {10?10}peach til 1000
    931
    
    q).z.K
    4f
    q)count distinct {10?10}peach til 1000
    1000
    
    从发行说明中

    2013.08.19
    FIX
    the random number generator was not thread-safe. Now the behaviour is as follows
     rng is thread local.
     \S 1234 sets the seed for the rng for the main thread only.
     the rng in a slave thread is assigned a seed based on the slave thread number.
     in multithreaded input mode, the seed is based on socket descriptor.
     instances started on ports 20000 thru 20099 (slave procs, used with e.g. q -s -4) have the main thread's default seed based on the port number.
    

    谢谢你的澄清。幸运的是,我只使用了v3.5、3.6。我不明白“基于端口号拥有主线程的默认种子”是什么意思,尤其是“基于端口号”是什么意思?q是否接受主线程的种子并根据端口#对其进行修改?我不知道细节,但似乎是这样-我已经在我的原始博文中添加了关于此行为的说明,他们已经在文档中添加了说明(或者可能它以前在那里,我没有看到),谢谢您的说明。幸运的是,我只使用了v3.5、3.6。我不明白“基于端口号拥有主线程的默认种子”是什么意思,尤其是“基于端口号”是什么意思?q是否接受主线程的种子并根据端口#对其进行修改?我不知道细节,但似乎是这样-我已经在我的原始帖子中添加了,他们已经在文档中添加了关于此行为的说明(或者可能它以前就在那里,我没有看到它)