From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: from zero.zsh.org (zero.zsh.org [IPv6:2a02:898:31:0:48:4558:7a:7368]) by inbox.vuxu.org (Postfix) with ESMTP id 29CE821BE5 for ; Mon, 17 Jun 2024 16:44:29 +0200 (CEST) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1718635469; b=nziBhGQFu495G+xJIt80GiqJd/csRnmkvmPRA9JohMx0GtrTexp/EsdNmPQzXlIO9W2tOogiCZ Y+sI1rKocAxjCQtOgsYhi7wTqOQtlAR+IjS45Y3ApzxJG5RZr7FVyDMhIo/ebGgpJogidL3Jdw aM8SKMTzM4KN+RWw5NRgK0MeiTMXss5BYvxgMUy3LM8hkb/8DGbiOTOvJycmECAKKN9RsiRUIV CI/Kp0mUgDzxwhTwfiYpObGGIJUV23ukS3C1kKgSUudbn8YaebN1xpPRzlTglPdXXKZ9VtosSX Ld7YiKzPCI9JKLMbWvo9onWdUbPUnk3xVBejcIRTfNSQmQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mta-snd-w03.biglobe.ne.jp) smtp.remote-ip=27.86.113.19; dkim=pass header.d=kba.biglobe.ne.jp header.s=default-1th84yt82rvi header.a=rsa-sha256; dmarc=none header.from=kba.biglobe.ne.jp; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1718635469; bh=b2G+f33h+NqaoqURDuRzMqSxj5rkcZd4hCLlCw42YLc=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:DKIM-Signature:Message-ID:In-Reply-To:To:References:Date: Subject:MIME-Version:Content-Transfer-Encoding:Content-Type:From: DKIM-Signature; b=VnuKKEzCLR0DsZTPZZlrgLx3iBjqcS8DQqtWNUyWPdlJB+/ruN/HfV1/SZrx5RbCSs1l6NE6Xd wLT1UjEjwZUFiATKfIZgbOleK7lR/H8v2yiLwz+f60pLs9lYbOWMXf02+e2LdFg8fVzYKlGkJw cR7+X8M6So5xF8MFGQDOBCRPaBDuQdq4iXoHrqHYBJNKpwrWV+MPRA/WYUKluFYZwzEuapEFsN 21pnU9ZHYePStmuPH7K+6iazY+wwE+KKL/dIatNfd8Pup7QMQH0jU/ZvTl+iEZYpmHh7klvdSO yEu0jCefLEIuoq6eq2uCqTs8Ilcqm94a2ThAgldZ23JuZA==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Message-Id:In-Reply-To:To:References: Date:Subject:Mime-Version:Content-Transfer-Encoding:Content-Type:From: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=cFUIknMNIfSCYhxIt6z5T/7i9ddLLvCypoC1EvXgqXk=; b=lDgnKdnwY5q5VM9SbWc5AVnhu5 1YOQPVzdIqKE+ECu8SObQ//EMpvESyxjcBmfLuuGLftZA37gwf7Lyeylwi3IazCz3NYjp4JTdWDry PqqDIIWY4OWmOG9pjR4/sEtuFZlDf6jRs2aUEb8ae1p9vZJ+cd7EkZhHNIT3gOzIOflbH73e+ifzg C2NsgBpIzHnaIAsqAtIX8fNwqyWZaiEUmqx0UQynyiavrbfSK7iXnYsLiqXIl58zuOWouURdSTtbJ AeC089xFSs0zDNw+S41HYbWH5cutGK3ROEZSJn+ucI+/9w4kWs6lOzdnboF6HREEPBZsKmqSgpCQu afJEX5Hw==; Received: by zero.zsh.org with local id 1sJDat-0002ev-TI; Mon, 17 Jun 2024 14:44:27 +0000 Authentication-Results: zsh.org; iprev=pass (mta-snd-w03.biglobe.ne.jp) smtp.remote-ip=27.86.113.19; dkim=pass header.d=kba.biglobe.ne.jp header.s=default-1th84yt82rvi header.a=rsa-sha256; dmarc=none header.from=kba.biglobe.ne.jp; arc=none Received: from mta-snd-w03.biglobe.ne.jp ([27.86.113.19]:4065) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1sJDZv-0002JT-PB; Mon, 17 Jun 2024 14:43:31 +0000 Received: from mail.biglobe.ne.jp by mta-snd-w03.biglobe.ne.jp with ESMTP id <20240617144317764.OEBA.998.mail.biglobe.ne.jp@biglobe.ne.jp> for ; Mon, 17 Jun 2024 23:43:17 +0900 From: "Jun. T" Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.4\)) Subject: Re: [PATCH 1/1] zsh/random Date: Mon, 17 Jun 2024 23:43:16 +0900 References: <5be719d0-15b7-44ed-ac3c-61cb06357d51@zentaur.org> To: zsh-workers@zsh.org In-Reply-To: <5be719d0-15b7-44ed-ac3c-61cb06357d51@zentaur.org> Message-Id: X-Mailer: Apple Mail (2.3696.120.41.1.4) X-Biglobe-Sender: takimoto-j@kba.biglobe.ne.jp DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kba.biglobe.ne.jp; s=default-1th84yt82rvi; t=1718635398; bh=cFUIknMNIfSCYhxIt6z5T/7i9ddLLvCypoC1EvXgqXk=; h=From:Subject:Date:References:To:In-Reply-To; b=aLUK08wVyrHJnIXk4ttRCHll1e09WL7kFTVYHuZd7K3CUc+fBmOBIpugaYrgvR3bRvOnABPc qyXNa22RiGj0rCr/aIiOMMhsr/oQoPzhrbIe12Y0T26uaLj42BtqTWZGP6ss2IBsiGL17Q3F1j PnwjTZ143lJuyb08roEJLhO0/d3GkzVQUGOcyvgLi0YcQ98ze0iwr86oF/JJgWc+mixp9amm9U 3mDwFR6xUPu7VEPHoKzo/nqqymVoxVO/ZyCoszwpzfnhonT/COkX0ZXf61Nqelkib2J6IKf/gS DfqeSljWX2QMbc456jgsmP0fCQ5bpvtpUaoa2uPXDPbMfqnw== X-Seq: 52956 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: # Please do not separate a patch into [0/1] and [1/1]. # Some people reply to [0/1], others to [1/1]. What is the current status of this patch? Here are my comments: > 2024/04/28 4:31, Clinton Bunch wrote: > Doc/Zsh/mod_random.yo > +item(tt(SRANDOM)) ( > +A random positive 32-bit integer between 0 and 4,294,967,295. 'between 0 and 4,294,967,295' I think $SRAND can be 0; can it be 4,294,967,295, or only to 4,294,967,295-1? > +item(tt(zrand_float+LPAR()RPAR())) ( > +Returns a random floating point number between 0 and 1. 'between 0 and 1' Is this inclusive? Can zrand_float() return 1? =20 > +item(tt(zrand_int)+LPAR()tt(upper), tt(lower), tt(inclusive)RPAR()) ( > +Returns a random integer between tt(lower) and tt(upper). All = parameters are > +optional. If none are specified it is equivalent to > +tt(SRANDOM). > +tt(inclusive) is a flag that controls whether the result is ever = equal to > +tt(upper). By default it is not. If 'inclusive' is 0 (off) by default, then 0 <=3D zrand_int() < 4,294,967,295 by default. Is this equivalent to $SRANDOM? > Src/Modules/random.c > +#include > +#include I guess stdbool.h is not used? I think including stdint.h (new in C99 but may exist in earlier compilers) without #ifdef HAVE_STDINT_H is OK now, since we are now using C99 as the C language standard, right? > +/* buffer to pre-load integers for SRANDOM to lessen the context = switches */ > +uint32_t rand_buff[8]; static uint32_t rand_buff[8]; > +int > +boot_(Module m) UNUSED(m) > Src/Modules/random.mdd > +load=3Dyes Does this module really need be autoloadable? I don't know what are the criteria that a module should be autoloadable. > Test/V15random.ztst I don't know whether zsh need to check the "quality" of the random number. I guess the simple $RANDOM would also pass these tests. Maybe better to check that $SRANDOM is 'non-repeatable'? If we will do the quality check, then: > + print -ru $ZTST_fd 'This test may take two seconds...' Why two seconds? A few seconds, or something like that? > + function calc_chi2() { > +# Calculate Chi Squared (snip) > + #echo > + } Please remove several '#echo' (for debugging?). You can convert the functions calc_chi2(), ligf() etc. into math-functions by using 'functions -M'. Then you can call them as, for example (( p =3D 1 - ligf(s, z)/gamma(s) )) > +0q:random integer $samples samples between 1-$n The flag 'q' works only for the lines starting with < > or ?. $samples and $n are not expanded. -- Jun=