Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Save the whales. Collect the whole set.


devel / comp.lang.awk / Re: What is the Poisson "function" ??? (Was: Using math functions in Awk)

SubjectAuthor
* Using math functions in AwkJanis Papanagnou
`* What is the Poisson "function" ??? (Was: Using math functions in Awk)Kenny McCormack
 +- Re: What is the Poisson "function" ??? (Was: Using math functionsKaz Kylheku
 `* Re: What is the Poisson "function" ??? (Was: Using math functions inJanis Papanagnou
  +- Re: What is the Poisson "function" ??? (Was: Using math functions inKenny McCormack
  +- Re: What is the Poisson "function" ???Ben Bacarisse
  `- Re: What is the Poisson "function" ??? (Was: Using math functions inBruce Horrocks

1
Using math functions in Awk

<sgvueo$s73$1@gioia.aioe.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=885&group=comp.lang.awk#885

  copy link   Newsgroups: comp.lang.awk
Path: i2pn2.org!i2pn.org!aioe.org!I4G2pI/TjSgw9iO3pv/WTg.user.46.165.242.75.POSTED!not-for-mail
From: janis_papanagnou@hotmail.com (Janis Papanagnou)
Newsgroups: comp.lang.awk
Subject: Using math functions in Awk
Date: Sat, 4 Sep 2021 16:05:12 +0200
Organization: Aioe.org NNTP Server
Message-ID: <sgvueo$s73$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="28899"; posting-host="I4G2pI/TjSgw9iO3pv/WTg.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
X-Notice: Filtered by postfilter v. 0.9.2
X-Mozilla-News-Host: news://nntp.aioe.org:119
X-Enigmail-Draft-Status: N1110
 by: Janis Papanagnou - Sat, 4 Sep 2021 14:05 UTC

I want to use math functions in Awk that are not available by default.
What are the typical (or best) methods to do so. Is there an Awk math
library (awk source code), ideally a standard or a de facto standard?
Should such functions be better accessed from the shell environment
(using standard Unix tools for example)? Any opinions or suggestions?
Specifically I'm looking for the Poisson function.

Janis

What is the Poisson "function" ??? (Was: Using math functions in Awk)

<sgvvr4$1lqhh$1@news.xmission.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=886&group=comp.lang.awk#886

  copy link   Newsgroups: comp.lang.awk
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gazelle@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.lang.awk
Subject: What is the Poisson "function" ??? (Was: Using math functions in Awk)
Date: Sat, 4 Sep 2021 14:28:52 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <sgvvr4$1lqhh$1@news.xmission.com>
References: <sgvueo$s73$1@gioia.aioe.org>
Injection-Date: Sat, 4 Sep 2021 14:28:52 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="1763889"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Sat, 4 Sep 2021 14:28 UTC

In article <sgvueo$s73$1@gioia.aioe.org>,
Janis Papanagnou <janis_papanagnou@hotmail.com> wrote:
>I want to use math functions in Awk that are not available by default.
>What are the typical (or best) methods to do so. Is there an Awk math
>library (awk source code), ideally a standard or a de facto standard?
>Should such functions be better accessed from the shell environment
>(using standard Unix tools for example)? Any opinions or suggestions?
>Specifically I'm looking for the Poisson function.

I don't know what you mean by "Poisson function". It doesn't seem to show
up in this list:

https://en.wikipedia.org/wiki/List_of_things_named_after_Siméon_Denis_Poisson

--
The plural of "anecdote" is _not_ "data".

Re: What is the Poisson "function" ??? (Was: Using math functions in Awk)

<20210904074601.243@kylheku.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=887&group=comp.lang.awk#887

  copy link   Newsgroups: comp.lang.awk
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: 563-365-8930@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.awk
Subject: Re: What is the Poisson "function" ??? (Was: Using math functions
in Awk)
Date: Sat, 4 Sep 2021 14:50:31 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 28
Message-ID: <20210904074601.243@kylheku.com>
References: <sgvueo$s73$1@gioia.aioe.org> <sgvvr4$1lqhh$1@news.xmission.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 4 Sep 2021 14:50:31 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="b7f2c83bcb8c994f19c129cb44388da9";
logging-data="9326"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19LY8j5F5hHQldmBt+UBu8VTNnx7jJDHO4="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:j8uiG1XFd+cMsY3KtICuEe9SPe4=
 by: Kaz Kylheku - Sat, 4 Sep 2021 14:50 UTC

On 2021-09-04, Kenny McCormack <gazelle@shell.xmission.com> wrote:
> In article <sgvueo$s73$1@gioia.aioe.org>,
> Janis Papanagnou <janis_papanagnou@hotmail.com> wrote:
>>I want to use math functions in Awk that are not available by default.
>>What are the typical (or best) methods to do so. Is there an Awk math
>>library (awk source code), ideally a standard or a de facto standard?
>>Should such functions be better accessed from the shell environment
>>(using standard Unix tools for example)? Any opinions or suggestions?
>>Specifically I'm looking for the Poisson function.
>
> I don't know what you mean by "Poisson function". It doesn't seem to show
> up in this list:
>
> https://en.wikipedia.org/wiki/List_of_things_named_after_Siméon_Denis_Poisson

Likely, the Poisson PDF (probability distribution function) for
modelling processes that conform to the Poisson model.

Poisson models situations in which events occur at a certain average rate,
but in a random way, independent of each other. An event having occurred
or not doesn't affect the probability of a subsequent occurrence.

Rare errors happening in bit stream are likely Poisson, as are flat
tires, requests hammering on a server, etc.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal

Re: What is the Poisson "function" ??? (Was: Using math functions in Awk)

<sh01r2$frq$1@gioia.aioe.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=888&group=comp.lang.awk#888

  copy link   Newsgroups: comp.lang.awk
Path: i2pn2.org!i2pn.org!aioe.org!I4G2pI/TjSgw9iO3pv/WTg.user.46.165.242.75.POSTED!not-for-mail
From: janis_papanagnou@hotmail.com (Janis Papanagnou)
Newsgroups: comp.lang.awk
Subject: Re: What is the Poisson "function" ??? (Was: Using math functions in
Awk)
Date: Sat, 4 Sep 2021 17:02:57 +0200
Organization: Aioe.org NNTP Server
Message-ID: <sh01r2$frq$1@gioia.aioe.org>
References: <sgvueo$s73$1@gioia.aioe.org> <sgvvr4$1lqhh$1@news.xmission.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="16250"; posting-host="I4G2pI/TjSgw9iO3pv/WTg.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
X-Enigmail-Draft-Status: N1110
X-Notice: Filtered by postfilter v. 0.9.2
 by: Janis Papanagnou - Sat, 4 Sep 2021 15:02 UTC

On 04.09.2021 16:28, Kenny McCormack wrote:
> In article <sgvueo$s73$1@gioia.aioe.org>,
> Janis Papanagnou <janis_papanagnou@hotmail.com> wrote:
>> I want to use math functions in Awk that are not available by default.
>> What are the typical (or best) methods to do so. Is there an Awk math
>> library (awk source code), ideally a standard or a de facto standard?
>> Should such functions be better accessed from the shell environment
>> (using standard Unix tools for example)? Any opinions or suggestions?
>> Specifically I'm looking for the Poisson function.
>
> I don't know what you mean by "Poisson function". It doesn't seem to show
> up in this list:
>
> https://en.wikipedia.org/wiki/List_of_things_named_after_Siméon_Denis_Poisson
>

I mean the parameterized function describing the Poisson distribution:
https://en.wikipedia.org/wiki/Poisson_distribution
or maybe also this ("probability mass function") for larger values of r
https://en.wikipedia.org/wiki/Negative_binomial_distribution
(As far as I had been told, sometimes also know as Pareto.)
Not a discrete but continuous function; in ASCII graphics something like

**
* *
* *
* * _____> asymptotically towards 0
^____starting at (0,0)

Although this is the function I want to examine the questions can be
taken more generally for any function that is not available in Awk.
General Awk solutions/suggestions or GNU Awk specific are both welcome.

Janis

Re: What is the Poisson "function" ??? (Was: Using math functions in Awk)

<sh056i$1lsnq$1@news.xmission.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=889&group=comp.lang.awk#889

  copy link   Newsgroups: comp.lang.awk
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gazelle@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.lang.awk
Subject: Re: What is the Poisson "function" ??? (Was: Using math functions in
Awk)
Date: Sat, 4 Sep 2021 16:00:18 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <sh056i$1lsnq$1@news.xmission.com>
References: <sgvueo$s73$1@gioia.aioe.org> <sgvvr4$1lqhh$1@news.xmission.com> <sh01r2$frq$1@gioia.aioe.org>
Injection-Date: Sat, 4 Sep 2021 16:00:18 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="1766138"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Sat, 4 Sep 2021 16:00 UTC

In article <sh01r2$frq$1@gioia.aioe.org>,
Janis Papanagnou <janis_papanagnou@hotmail.com> wrote:
....
>I mean the parameterized function describing the Poisson distribution:
>https://en.wikipedia.org/wiki/Poisson_distribution
>or maybe also this ("probability mass function") for larger values of r
>https://en.wikipedia.org/wiki/Negative_binomial_distribution
>(As far as I had been told, sometimes also know as Pareto.)
....
>Although this is the function I want to examine the questions can be
>taken more generally for any function that is not available in Awk.
>General Awk solutions/suggestions or GNU Awk specific are both welcome.

Well, there are really two parts to your question, then:

1) How do I get access to functions that aren't provided directly in GAWK?

2) What exactly is the "Poisson distribution/function" and how to I
convert the mathematical notation that I see for it in Wikipedia
into computer source code in some language?

The first is on-topic and probably something that I and others on this
newsgroup can help you with. The second, not so much. Note that if

For the first, there are (at least) 3 routes I could see as reasonable
paths to pursue (presented in no particular order):

1) Find a library of AWK code somewhere that has what you need.
(This seems unlikely to me, but stranger things have happened...)
2) Write your own AWK code to what what you need to do. I assume this
is what you are trying to avoid.
3) Find a library written in C (or similar) and then figure out how to
link to it via writing a GAWK extension library yourself. This
option is pretty easy once you've done it a few times, but
represents a sizable hurdle for first-timers. As far as I know,
you've not yet done one of these.

Note that if the function you were looking for was something simple, that
is in the C library but not in GAWK - such as acos() - then it would be
straightforward to write an extension lib to get to it (*), but I don't
think your Poisson function is in the standard library - hence the need to
find a (third party) lib that does have it.

Note, BTW, that acos() really is in the C math lib, but not in GAWK.
Purists will point out that (I think this is true - haven't verified it
100%) that it is unnecessary, since it can be derived from atan2(), which
*is* in GAWK. Again, I'm not sure about all this, but I think it is true.

(*) I, of course, would just use my call_any() library and I'd be done, but
that may not be available to you at the present time.

--
This is the GOP's problem. When you're at the beginning of the year
and you've got nine Democrats running for the nomination, maybe one or
two of them are Dennis Kucinich. When you have nine Republicans, seven
or eight of them are Michelle Bachmann.

Re: What is the Poisson "function" ???

<87ilzgqize.fsf@bsb.me.uk>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=890&group=comp.lang.awk#890

  copy link   Newsgroups: comp.lang.awk
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ben.usenet@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.awk
Subject: Re: What is the Poisson "function" ???
Date: Sat, 04 Sep 2021 19:43:49 +0100
Organization: A noiseless patient Spider
Lines: 53
Message-ID: <87ilzgqize.fsf@bsb.me.uk>
References: <sgvueo$s73$1@gioia.aioe.org> <sgvvr4$1lqhh$1@news.xmission.com>
<sh01r2$frq$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
Injection-Info: reader02.eternal-september.org; posting-host="8bde6983c04a47403b42bfb18eb15cac";
logging-data="11043"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+bD61ZD8ErZRsgYoLIvM+SiHThtJphG/k="
Cancel-Lock: sha1:/XRa+XNDKV9xgqg42AjWfQ6lum8=
sha1:J2jQ/WL/aLIYlUa/h7Y71e3v0Ac=
X-BSB-Auth: 1.ed6c3fd253f9f09f55fe.20210904194349BST.87ilzgqize.fsf@bsb.me.uk
 by: Ben Bacarisse - Sat, 4 Sep 2021 18:43 UTC

Janis Papanagnou <janis_papanagnou@hotmail.com> writes:

> On 04.09.2021 16:28, Kenny McCormack wrote:
>> In article <sgvueo$s73$1@gioia.aioe.org>,
>> Janis Papanagnou <janis_papanagnou@hotmail.com> wrote:
>>> I want to use math functions in Awk that are not available by default.
>>> What are the typical (or best) methods to do so. Is there an Awk math
>>> library (awk source code), ideally a standard or a de facto standard?
>>> Should such functions be better accessed from the shell environment
>>> (using standard Unix tools for example)? Any opinions or suggestions?
>>> Specifically I'm looking for the Poisson function.
>>
>> I don't know what you mean by "Poisson function". It doesn't seem to show
>> up in this list:
>>
>> https://en.wikipedia.org/wiki/List_of_things_named_after_Siméon_Denis_Poisson
>>
>
> I mean the parameterized function describing the Poisson distribution:
> https://en.wikipedia.org/wiki/Poisson_distribution

This one is easy, provided you don't have extreme values. So much so,
it's probably fastest just to code it yourself. Do you need
Poisson-distributed whole numbers k, the probability of getting some k?

> or maybe also this ("probability mass function") for larger values of r
> https://en.wikipedia.org/wiki/Negative_binomial_distribution

Also quite easy for non-troublesome parameters. I think the usual
method of generating values is just to "do the trials".

> (As far as I had been told, sometimes also know as Pareto.)
> Not a discrete but continuous function; in ASCII graphics something
> like

I am not sure how the extension to the reals would be implemented as
I've not use that before.

> **
> * *
> * *
> * * _____> asymptotically towards 0
> ^____starting at (0,0)
>
> Although this is the function I want to examine the questions can be
> taken more generally for any function that is not available in Awk.
> General Awk solutions/suggestions or GNU Awk specific are both
> welcome.

This part of outside of my wheelhouse.

--
Ben.

Re: What is the Poisson "function" ??? (Was: Using math functions in Awk)

<67bd447b-a6f8-4e9f-a420-95264393ecb0@scorecrow.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=891&group=comp.lang.awk#891

  copy link   Newsgroups: comp.lang.awk
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: 07.013@scorecrow.com (Bruce Horrocks)
Newsgroups: comp.lang.awk
Subject: Re: What is the Poisson "function" ??? (Was: Using math functions in
Awk)
Date: Sun, 5 Sep 2021 01:22:13 +0100
Lines: 53
Message-ID: <67bd447b-a6f8-4e9f-a420-95264393ecb0@scorecrow.com>
References: <sgvueo$s73$1@gioia.aioe.org> <sgvvr4$1lqhh$1@news.xmission.com>
<sh01r2$frq$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: individual.net pK/ZENB59FndX1GVXNNaYQDgtEmASQHP/xZwc3W0eT+tAjswUB
Cancel-Lock: sha1:SEH18XBS1mSjLjDU7hDLt9/Sh40=
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0)
Gecko/20100101 Thunderbird/78.13.0
In-Reply-To: <sh01r2$frq$1@gioia.aioe.org>
Content-Language: en-GB
 by: Bruce Horrocks - Sun, 5 Sep 2021 00:22 UTC

On 04/09/2021 16:02, Janis Papanagnou wrote:
> On 04.09.2021 16:28, Kenny McCormack wrote:
>> In article <sgvueo$s73$1@gioia.aioe.org>,
>> Janis Papanagnou <janis_papanagnou@hotmail.com> wrote:
>>> I want to use math functions in Awk that are not available by default.
>>> What are the typical (or best) methods to do so. Is there an Awk math
>>> library (awk source code), ideally a standard or a de facto standard?
>>> Should such functions be better accessed from the shell environment
>>> (using standard Unix tools for example)? Any opinions or suggestions?
>>> Specifically I'm looking for the Poisson function.
>>
>> I don't know what you mean by "Poisson function". It doesn't seem to show
>> up in this list:
>>
>> https://en.wikipedia.org/wiki/List_of_things_named_after_Siméon_Denis_Poisson
>>
>
> I mean the parameterized function describing the Poisson distribution:
> https://en.wikipedia.org/wiki/Poisson_distribution
> or maybe also this ("probability mass function") for larger values of r
> https://en.wikipedia.org/wiki/Negative_binomial_distribution
> (As far as I had been told, sometimes also know as Pareto.)
> Not a discrete but continuous function; in ASCII graphics something like
>
> **
> * *
> * *
> * * _____> asymptotically towards 0
> ^____starting at (0,0)
>
> Although this is the function I want to examine the questions can be
> taken more generally for any function that is not available in Awk.
> General Awk solutions/suggestions or GNU Awk specific are both welcome.

The Poisson distribution Wikipedia link you give tells you how to
calculate the Poisson distribution in section 6.1, either directly or
using the gamma function for better stability.

There is no gamma function by default in gawk, of course, but it is
available in the GNU MPFR library <https://www.mpfr.org>

And there is a gawkextlib for MPFR that provides access to the
additional functions, including gamma.
<http://gawkextlib.sourceforge.net/mpfr/gawk-mpfr.html>

So I think your best bet would be to install the mpfr extension library.
<http://gawkextlib.sourceforge.net>
<http://gawkextlib.sourceforge.net/mpfr/mpfr.html>

--
Bruce Horrocks
Surrey, England

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor