[SciPy-User] Scipy and information theory

Robert Lucente - Pipeline.Com rlucente at pipeline.com
Fri Nov 8 12:13:32 EST 2019


> 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.log2

math.log2(x)

    Return the base-2 logarithm of x. This is usually more accurate than
log(x, 2).

    New in version 3.3.

-----Original Message-----
From: Robert Lucente - Pipeline.Com <rlucente at pipeline.com> 
Sent: Friday, November 8, 2019 12:11 PM
To: 'scipy-user at python.org' <scipy-user at python.org>
Cc: Robert Gmail Backup 2 Lucente (robert.backup.2.lucente at gmail.com)
<robert.backup.2.lucente at gmail.com>
Subject: Re: Scipy and information theory 

> 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 <scipy-user-bounces+rlucente=pipeline.com at python.org> On
Behalf Of scipy-user-request at python.org
Sent: Friday, November 8, 2019 12:00 PM
To: scipy-user at python.org
Subject: SciPy-User Digest, Vol 195, Issue 2

Send SciPy-User mailing list submissions to
	scipy-user at python.org

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
	scipy-user-request at python.org

You can reach the person managing the list at
	scipy-user-owner at python.org

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 <me at iyanmv.com>
To: scipy-user at python.org
Subject: [SciPy-User] Scipy and information theory
Message-ID: <20976252.W2eyRVhfPJ at 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 <ralf.gommers at gmail.com>
To: SciPy Users List <scipy-user at python.org>
Subject: Re: [SciPy-User] Scipy and information theory
Message-ID:
	<CABL7CQh=LDNJfH+P7tJQz2wB8SyeY3uRKRK5NFYs4eWHxYnYTg at 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 <me at iyanmv.com> 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
> SciPy-User at python.org
> 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
SciPy-User at python.org
https://mail.python.org/mailman/listinfo/scipy-user


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

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



More information about the SciPy-User mailing list