Re: Scipy and information theory

"Robert Lucente - Pipeline.Com" <[email protected]> Fri, 8 Nov 2019 12:10:48 -0500
Newsgroups gmane.comp.python.scientific.user
Message-ID <[email protected]>
> interested in using log2 instead of natural logarithm. I was expecting to
be able to choose the base with this functions but it is not possible
Why not use Python's built in fcn?

https://docs.python.org/3/library/math.html#math.log

math.log(x[, base])

    With one argument, return the natural logarithm of x (to base e).

    With two arguments, return the logarithm of x to the given base,
calculated as log(x)/log(base).



-----Original Message-----
From: SciPy-User <[email protected]> On
Behalf Of [email protected]
Sent: Friday, November 8, 2019 12:00 PM
To: [email protected]
Subject: SciPy-User Digest, Vol 195, Issue 2

Send SciPy-User mailing list submissions to
	[email protected]

To subscribe or unsubscribe via the World Wide Web, visit
	https://mail.python.org/mailman/listinfo/scipy-user
or, via email, send a message with subject or body 'help' to
	[email protected]

You can reach the person managing the list at
	[email protected]

When replying, please edit your Subject line so it is more specific than
"Re: Contents of SciPy-User digest..."


Today's Topics:

   1. Scipy and information theory (Iy?n M?ndez Veiga)
   2. Re: Scipy and information theory (Ralf Gommers)


----------------------------------------------------------------------

Message: 1
Date: Thu, 07 Nov 2019 13:11:55 +0100
From: Iy?n M?ndez Veiga <[email protected]>
To: [email protected]
Subject: [SciPy-User] Scipy and information theory
Message-ID: <20976252.W2eyRVhfPJ@theotp40>
Content-Type: text/plain; charset="iso-8859-1"

Hi,

I discovered recently some interesting functions in scipy that are useful in
the context of information theory. In particular, xlogy, entr and rel_entr. 
However, for the calculations I want to do I am interested in using log2
instead of natural logarithm. I was expecting to be able to choose the base
with this functions but it is not possible.

Do you think it would be a nice feature to add to scipy? Maybe not for a
general base, but at least the bases that are available in numpy (log2,
log10). 

The workaround I am using with xlogy(x,y) (and similar functions) is
multiplying x array by log2(e).

Best wishes,
Iy?n




------------------------------

Message: 2
Date: Fri, 8 Nov 2019 10:54:32 -0500
From: Ralf Gommers <[email protected]>
To: SciPy Users List <[email protected]>
Subject: Re: [SciPy-User] Scipy and information theory
Message-ID:
	<CABL7CQh=LDNJfH+P7tJQz2wB8SyeY3uRKRK5NFYs4eWHxYnYTg@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Hi Iy?n,


On Thu, Nov 7, 2019 at 12:21 PM Iy?n M?ndez Veiga <[email protected]> wrote:

> Hi,
>
> I discovered recently some interesting functions in scipy that are 
> useful in the context of information theory. In particular, xlogy, 
> entr and rel_entr.
> However, for the calculations I want to do I am interested in using 
> log2 instead of natural logarithm. I was expecting to be able to 
> choose the base with this functions but it is not possible.
>
> Do you think it would be a nice feature to add to scipy? Maybe not for 
> a general base, but at least the bases that are available in numpy 
> (log2, log10).
>

This does sound like a useful feature to add to these functions. I'm not
sure how easy it is to add a keyword to those functions though, since the
ufunc machinery may be limited in flexibility. Maybe someone else can say
straight away. If you want to start looking into implementing this, here are
some notes of where to start:
http://scipy.github.io/devdocs/dev/core-dev/index.html#scipy-special

Cheers,
Ralf


> The workaround I am using with xlogy(x,y) (and similar functions) is 
> multiplying x array by log2(e).
>
> Best wishes,
> Iy?n
>
>
> _______________________________________________
> SciPy-User mailing list
> [email protected]
> https://mail.python.org/mailman/listinfo/scipy-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.python.org/pipermail/scipy-user/attachments/20191108/f06b5c12/a
ttachment-0001.html>

------------------------------

Subject: Digest Footer

_______________________________________________
SciPy-User mailing list
[email protected]
https://mail.python.org/mailman/listinfo/scipy-user


------------------------------

End of SciPy-User Digest, Vol 195, Issue 2
******************************************