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 9327323A95 for ; Tue, 18 Jun 2024 01:53:36 +0200 (CEST) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1718668416; b=V6RMkJoYLshe1hkGI5GVWC7GRZcEEsur5lGFI5AEw8ItUsCFQoEKUqlVCC3CAIJXYtxjQ9Ucum glZcZkdb79abDcBoGXFJjZ9Z/Y/IZK7ogAwfqEb0YD4JxQ4kgcA1MgbGY3JdLAYfvNWEVpGihg NZcs9YeM1W+i1N+C2S6F3dDstrloJdl9POvV926kJvk4RHst/tbLRFP71pZHdi0gcAhaWAYIey yzqnpYyeY8tNZnfPDanxC3h6j4Qfpefu7i1FoE6SsQ7gh304tlILIqg0mwhBS8vaVic+0b13cu eu/iJ2e1U0g7sGL0p3MSAj4HBWurjKL7r3PPT0eAs3H//A==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (iris.zentaur.org) smtp.remote-ip=198.58.127.206; dkim=pass header.d=zentaur.org header.s=dkim20200120 header.a=rsa-sha256; dmarc=pass header.from=zentaur.org; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1718668416; bh=E+WlVEEBCNfLZtcPNeLojjLvY/fcRPCSoNMzAcfg6wM=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:In-Reply-To:From: References:To:Subject:MIME-Version:Date:Message-ID:DKIM-Signature: DKIM-Signature; b=k80p2EVcXeucky0kCte2MGoYP9qD1ahLxsuUSQn8aDoaQUywxwxgs0cTJ2UWHM65Q4zcz51xwY WXlOimdJprZyr7s2Mrq7sQlDoQY8uKPO2YdmzZe/8L5wAFmuijEkgK5eQ9aGnlQW7DkuHm7b3i HtJhJLPfze8Sa/Ksds4IWqUbL0QmezeCyghpJ+5718Opa9AVMtyllVGKIpXTQxVlzgl1ylMaK5 mtbGpMNFkv7aC/UeihATfNCZ+el4eJLd88fpzXBzv5PNhyjPQHNeSt5JePvR9XA5Jltsn2Hy63 McK15qUSmmkRVN5NQ17cHDpCn/CEkk7/0swvDTcTq5ciyA==; 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:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=nXDMHwFWH0VNaMyAtWETFS/duN3cSe5W1HKY80+8H/E=; b=jWm3F0S4vJHbLHbJqeGXpyXeMD D6KG8eBRsOoZFVV95Jsrlp0WNFXIQgY7XSnOTxTuK/ube5ni7rFDwGfAIEddWllEwkD3f596JON/n ae1g5V+Da5RQY0XB+rdTI9mBb5HgKUyftZJpcQIYSK+KhnVJxpSCwSHIyYtscdXhqCAul5AO1PCa+ O6Jf4vaUZt9xAG96XLVwpY+2++Ai7h6xVvM7ZlHk6c4WlcN/tN0jAgd9Or88cBZ3EsYt/XWTocIH2 ls62/nSp3tm+kuam6FlGfrgnMcHxfCNKBzjeqbZQIafdFlCKqDbxQVymgQEoPIWw+25wkJJkxusJd 4whCQwRA==; Received: by zero.zsh.org with local id 1sJMAJ-000JIa-Jf; Mon, 17 Jun 2024 23:53:35 +0000 Authentication-Results: zsh.org; iprev=pass (iris.zentaur.org) smtp.remote-ip=198.58.127.206; dkim=pass header.d=zentaur.org header.s=dkim20200120 header.a=rsa-sha256; dmarc=pass header.from=zentaur.org; arc=none Received: from iris.zentaur.org ([198.58.127.206]:47546) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1sJM9b-000Iyd-1p; Mon, 17 Jun 2024 23:52:52 +0000 Received: from iris.zentaur.org (localhost [127.0.0.1]) by iris.zentaur.org (Postfix) with ESMTP id 4W36Bn5fwjz3wZv for ; Mon, 17 Jun 2024 23:52:49 +0000 (UTC) Authentication-Results: iris.zentaur.org (amavis); dkim=pass (2048-bit key) reason="pass (just generated, assumed good)" header.d=zentaur.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=zentaur.org; h= content-transfer-encoding:content-type:in-reply-to:from :content-language:references:to:subject:user-agent:mime-version :date:message-id; s=dkim20200120; t=1718668369; x=1718671970; bh=E+WlVEEBCNfLZtcPNeLojjLvY/fcRPCSoNMzAcfg6wM=; b=Iv+xcKri/Ws7 5KncA7jG5sen8lQUNNEE6TT3WCJUTukCawxsP7V4egZCv2MTwqt+a8KHy/GLTYI1 CIV+QmC3mPF9FuaO82HU/Q+jsqgGTKMpXL5qURcWztDjpgGOjokfhkxeE+MzJ0Im px+6BkS+KWhsS9B20eb7ux+h2ziL6nEhaaEyjCvX6h0xgbP66AByLA3i7LZHOTzq n7WxQy4yEa61j9a2XNFDA5V4l8dMdBgqtR4vlq9UkcgVpzg06e5mKAc9a3TwJVvJ 8uKb6tMwOaGpdzz1l9bfvSV802YCrKHAneEXLTJbxWWRTbfN27hEodsXWD6Z/f8m zGaduh+u8w== X-Virus-Scanned: amavis at iris.zentaur.org Received: from iris.zentaur.org ([127.0.0.1]) by iris.zentaur.org (iris.zentaur.org [127.0.0.1]) (amavis, port 10026) with ESMTP id 4KaacJvouwK3 for ; Mon, 17 Jun 2024 23:52:49 +0000 (UTC) Received: from [IPV6:2605:a601:a57c:ee00::4000] (unknown [IPv6:2605:a601:a57c:ee00::4000]) by iris.zentaur.org (Postfix) with ESMTPSA id 4W36Bn0mnvz3wZt for ; Mon, 17 Jun 2024 23:52:49 +0000 (UTC) Message-ID: <8d1c4112-a099-4a3c-9d34-c16dc761ac82@zentaur.org> Date: Mon, 17 Jun 2024 18:52:48 -0500 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/1] zsh/random To: zsh-workers@zsh.org References: <5be719d0-15b7-44ed-ac3c-61cb06357d51@zentaur.org> Content-Language: en-US From: Clinton Bunch In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Seq: 52960 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: On 6/17/2024 09:43, Jun. T wrote: > # 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? It's been waiting on feedback > > 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? 4,294,967,295 is 2**32-1 (odd number) > >> +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? Yes. it can return both 0 and 1.=C2=A0 I've specified inclusive in the=20 documentation. > =20 >> +item(tt(zrand_int)+LPAR()tt(upper), tt(lower), tt(inclusive)RPAR()) ( >> +Returns a random integer between tt(lower) and tt(upper). All paramet= ers are >> +optional. If none are specified it is equivalent to >> +tt(SRANDOM). >> +tt(inclusive) is a flag that controls whether the result is ever equa= l 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? In the code it calls the same function as SRANDOM when no arguments are=20 given. > >> Src/Modules/random.c >> +#include >> +#include > I guess stdbool.h is not used? Apparently I removed all places where I used a bool type > > 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 swit= ches */ >> +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. I would think we'd want at least the SRANDOM parameter autoloaded > > >> 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. RANDOM would not pass these tests.=C2=A0 They test the difference between= the=20 distribution of the generated values against the ideal equal distribution= . > > Maybe better to check that $SRANDOM is 'non-repeatable'? Since SRANDOM can't be set how would you prove 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? I believe that was the result of timings during testing.=C2=A0 As I recal= l=20 the other tests were more specific than a few. > >> + function calc_chi2() { >> +# Calculate Chi Squared > (snip) >> + #echo >> + } > Please remove several '#echo' (for debugging?). Yes, they were 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. Okay explicit values used in messages. > > -- > Jun