Anthony Palomba | 1 Nov 2011 16:12
Picon
Gravatar

Re: SciPy for Computational Geometry

I am very interested in finding a good python package that does
computational geometry.

I was looking at CGAL for a while, but they python bindings do
not seem to work and examples are pretty limited.

If you do find something that works, please be sure to inform
us as well.




Thanks,
Anthony




On Mon, Oct 31, 2011 at 4:58 PM, <hayne <at> sympatico.ca> wrote:
Maybe have a look at "microsphere interpolation":
http://www.dudziak.com/how_microsphere_projection_works.php
(Perhaps just looking at the diagram at the bottom of that page would
suffice for a start.)
This is not a Python implementation, but it might give you some ideas.

--
Cameron Hayne
macdev <at> hayne.net

On 31-Oct-11, at 5:14 PM, Lorenzo Isella wrote:
> This is admittedly a bit off topic, but I wonder if anybody on the
> list
> is familiar with this problem (which should belong to computational
> geometry) and is able to point me to an implementation (possibly
> relying
> on scipy).
> Imagine that you are sitting at the origin (0,0,0) of a 3D coordinate
> system and that you are looking at a set of (non-overlapping) spheres
> (all the spheres are identical and with radius R=1).
> You ask yourself how many spheres you can see overall.
> The result is in general a (positive) real number as one sphere may
> partially eclipse another sphere for an observer in the origin (e.g.
> if
> one sphere is located at (0,0,5) and the other (0,0.3,10)).
> Does anybody know an algorithm to calculate this quantity efficiently?
> I have in mind (for now at least) configurations of less that 100
> spheres, so hopefully this should not be too demanding.
> I had a look at
> http://www.qhull.org/
> but I am not 100% sure that this is the way to go.




_______________________________________________
SciPy-User mailing list
SciPy-User <at> scipy.org
http://mail.scipy.org/mailman/listinfo/scipy-user

_______________________________________________
SciPy-User mailing list
SciPy-User <at> scipy.org
http://mail.scipy.org/mailman/listinfo/scipy-user
josef.pktd | 1 Nov 2011 16:28
Picon

Lerch transcendent function

Is the Lerch transcendent function available in scipy or python?

http://en.wikipedia.org/wiki/Lerch_zeta_function#Definition  capital phi
http://mathworld.wolfram.com/LerchTranscendent.html

(used for moments of Weibull-geometric distribution)

Josef
Friedrich Romstedt | 1 Nov 2011 16:32
Picon

Re: applications for tukeylambda distribution ?

2011/10/30  <josef.pktd <at> gmail.com>:
> Are there any applications for the Tukey Lambda distribution
> http://en.wikipedia.org/wiki/Tukey_lambda_distribution ?
>
> I just stumbled over it looking at PPCC plots (
> http://www.itl.nist.gov/div898/handbook/eda/section3/ppccplot.htm and
> scipy.stats.morestats) and it looks quite useful covering or
> approximating a large range of distributions.

Hi Josef,

"The most common use of this distribution is to generate a Tukey
lambda PPCC plot of a data set."
(http://en.wikipedia.org/wiki/Tukey_lambda_distribution#Comments)

"It is typically used to identify an appropriate distribution (see the
comments below) and not used in statistical models directly."
(http://en.wikipedia.org/wiki/Tukey_lambda_distribution)

So I guess the mighty Wikipedia suggests explicitly that there are no
applications in the sense of a statistical model?

Your second reference agrees on this: "The Tukey-Lambda PPCC plot is
used to suggest an appropriate distribution. You should follow-up with
PPCC and probability plots of the appropriate alternatives."

I would guess the "most common use" and "typically used" formulations
are just backdoors to not claim what we're not sure about.

Furthermore, "The probability density function (pdf) and cumulative
distribution function (cdf) are both computed numerically, as the
Tukey lambda distribution does not have a simple, closed form for any
values of the parameters except λ = 0 (see Logistic function).
However, the pdf can be expressed in parametric form, for all values
of λ, in terms of the quantile function and the reciprocal of the
quantile density function."
(http://en.wikipedia.org/wiki/Tukey_lambda_distribution again); I have
no idea off the cuff if it is useful to fit the quantile directly or
not.  At least it does not look like the common (aside of PPCC).

I guess the reason why one would not like to model with this Tukey
quantile is, that it is just a parametric model, and does not have a
physical reason (at least there is none such given in what you gave).

A quick googling "tukey modeling" gives this here:
http://andrewgelman.com/2011/01/tukeys_philosop/ - but I find what's
written there rather unclear and don't really understand what're the
associations related to "model" and "method" in that post.  It looks
like if it comes down to "do we need a physical derivation of our
distribution or not".

To my belief, a pdf or cdf without a reason is missing something.  It
just feels wrong - it's not satisfying.  The problem might be: Where
does the endless circle of deriving and deriving stop?  Maybe it never
does.  Maybe it's just a game we play and we pretend that it's of
objective importance but it isn't - it's just about satisfaction and
fun in the end. :-)

AISI,
Friedrich
_______________________________________________
SciPy-User mailing list
SciPy-User <at> scipy.org
http://mail.scipy.org/mailman/listinfo/scipy-user
Fredrik Johansson | 1 Nov 2011 16:57
Picon

Re: Lerch transcendent function

On Tue, Nov 1, 2011 at 4:28 PM,  <josef.pktd <at> gmail.com> wrote:
> Is the Lerch transcendent function available in scipy or python?
>
> http://en.wikipedia.org/wiki/Lerch_zeta_function#Definition  capital phi
> http://mathworld.wolfram.com/LerchTranscendent.html
>
> (used for moments of Weibull-geometric distribution)
>
> Josef

mpmath has it: http://mpmath.googlecode.com/svn/trunk/doc/build/functions/zeta.html#lerch-transcendent

Fredrik
josef.pktd | 1 Nov 2011 17:11
Picon

Re: applications for tukeylambda distribution ?

On Tue, Nov 1, 2011 at 11:32 AM, Friedrich Romstedt
<friedrichromstedt <at> gmail.com> wrote:
> 2011/10/30  <josef.pktd <at> gmail.com>:
>> Are there any applications for the Tukey Lambda distribution
>> http://en.wikipedia.org/wiki/Tukey_lambda_distribution ?
>>
>> I just stumbled over it looking at PPCC plots (
>> http://www.itl.nist.gov/div898/handbook/eda/section3/ppccplot.htm and
>> scipy.stats.morestats) and it looks quite useful covering or
>> approximating a large range of distributions.
>
> Hi Josef,
>
> "The most common use of this distribution is to generate a Tukey
> lambda PPCC plot of a data set."
> (http://en.wikipedia.org/wiki/Tukey_lambda_distribution#Comments)
>
> "It is typically used to identify an appropriate distribution (see the
> comments below) and not used in statistical models directly."
> (http://en.wikipedia.org/wiki/Tukey_lambda_distribution)
>
> So I guess the mighty Wikipedia suggests explicitly that there are no
> applications in the sense of a statistical model?
>
> Your second reference agrees on this: "The Tukey-Lambda PPCC plot is
> used to suggest an appropriate distribution. You should follow-up with
> PPCC and probability plots of the appropriate alternatives."
>
> I would guess the "most common use" and "typically used" formulations
> are just backdoors to not claim what we're not sure about.
>
> Furthermore, "The probability density function (pdf) and cumulative
> distribution function (cdf) are both computed numerically, as the
> Tukey lambda distribution does not have a simple, closed form for any
> values of the parameters except λ = 0 (see Logistic function).
> However, the pdf can be expressed in parametric form, for all values
> of λ, in terms of the quantile function and the reciprocal of the
> quantile density function."
> (http://en.wikipedia.org/wiki/Tukey_lambda_distribution again); I have
> no idea off the cuff if it is useful to fit the quantile directly or
> not.  At least it does not look like the common (aside of PPCC).
>
> I guess the reason why one would not like to model with this Tukey
> quantile is, that it is just a parametric model, and does not have a
> physical reason (at least there is none such given in what you gave).

That's pretty much the impression that I also got. However, we do have
the cdf and indirectly the pdf in scipy.special. It also has a section
in Johnson, Kotz and Balakrishnan. So, I was wondering whether it's
used in any field.

>
> A quick googling "tukey modeling" gives this here:
> http://andrewgelman.com/2011/01/tukeys_philosop/ - but I find what's
> written there rather unclear and don't really understand what're the
> associations related to "model" and "method" in that post.  It looks
> like if it comes down to "do we need a physical derivation of our
> distribution or not".
>
> To my belief, a pdf or cdf without a reason is missing something.  It
> just feels wrong - it's not satisfying.  The problem might be: Where
> does the endless circle of deriving and deriving stop?  Maybe it never
> does.  Maybe it's just a game we play and we pretend that it's of
> objective importance but it isn't - it's just about satisfaction and
> fun in the end. :-)

The Gellman page is a bit too philosophical for my taste, especially
the comments.

To some extend I'm just a collector (of statistical functions instead
of coins or movies or powertools), but I'd rather collect useful
things (you never know when they come in handy).

My impression is that in reliability they invent about ten
(underestimate) new distributions a year that all have a motivating
introduction (that doesn't tell me much but looks relevant) (bath-tub
shapes, anyone?:)

Thanks for looking into it.

Josef
too many brackets

>
> AISI,
> Friedrich
> _______________________________________________
> SciPy-User mailing list
> SciPy-User <at> scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
_______________________________________________
SciPy-User mailing list
SciPy-User <at> scipy.org
http://mail.scipy.org/mailman/listinfo/scipy-user
Ralf Gommers | 1 Nov 2011 17:51
Gravatar

Re: Error in Numpy 1.6 timedelta()



On Mon, Oct 31, 2011 at 11:24 PM, Charles R Harris <charlesr.harris <at> gmail.com> wrote:


On Mon, Oct 31, 2011 at 3:45 PM, Fernando Paolo <fspaolo <at> gmail.com> wrote:
Hello,

I receive the following error when trying:

>>> import numpy as np
>>> np.timedelta64(10, 's')

TypeError: function takes at most 1 argument (2 given)

I know this is probably fully implemented in Numpy 1.7, but what about 1.6.1?


Yep, it's working in current master. I'll have to check 1.6.1 later unless someone who is running it can comment.

Doesn't work in 1.6.1. Datetime is not in very good shape in that release, if you want to use it for real work it's best to run master.

Ralf
 

_______________________________________________
SciPy-User mailing list
SciPy-User <at> scipy.org
http://mail.scipy.org/mailman/listinfo/scipy-user
Fernando Paolo | 1 Nov 2011 18:09
Picon

Re: Error in Numpy 1.6 timedelta()

Okay thanks. Will use the python `datetime.timedelta` for now.


-Fernando

On Tue, Nov 1, 2011 at 9:51 AM, Ralf Gommers <ralf.gommers <at> googlemail.com> wrote:


On Mon, Oct 31, 2011 at 11:24 PM, Charles R Harris <charlesr.harris <at> gmail.com> wrote:


On Mon, Oct 31, 2011 at 3:45 PM, Fernando Paolo <fspaolo <at> gmail.com> wrote:
Hello,

I receive the following error when trying:

>>> import numpy as np
>>> np.timedelta64(10, 's')

TypeError: function takes at most 1 argument (2 given)

I know this is probably fully implemented in Numpy 1.7, but what about 1.6.1?


Yep, it's working in current master. I'll have to check 1.6.1 later unless someone who is running it can comment.

Doesn't work in 1.6.1. Datetime is not in very good shape in that release, if you want to use it for real work it's best to run master.

Ralf
 


_______________________________________________
SciPy-User mailing list
SciPy-User <at> scipy.org
http://mail.scipy.org/mailman/listinfo/scipy-user




--
Fernando Paolo
Institute of Geophysics & Planetary Physics
Scripps Institution of Oceanography
University of California, San Diego
9500 Gilman Drive
La Jolla, CA 92093-0225
_______________________________________________
SciPy-User mailing list
SciPy-User <at> scipy.org
http://mail.scipy.org/mailman/listinfo/scipy-user

Re: SciPy for Computational Geometry

Lorenzo,

There is a very substantial body of research dedicated to your topic,
since it is essential for real-time rendering of 3D environments:
http://en.wikipedia.org/wiki/Binary_space_partitioning

You can certainly adapt existing code for your need, although
depending on your efficiency needs, it's probably easiest to just
write something from scratch.

1. For each sphere, determine a plane perpendicular to the line-of-sight.
2. For each sphere, calculate a set of points on the radius.
Granularity can be as fine as you need.
3. For each circumference point, find the intersection between the
line (circumference to origin) and each plane.
3. Calculate whether the line/plane intersection point is within the
radius for that circle (one circle per plane).
4. If the intersection is within the radius, that circumference point
is occluded.  Break out of plane calculations if you find an
occlusion.
5. Break out of sphere point testing if you find a circumference point
that is not occluded: that sphere is visible.

It's naive and not terribly efficient, but it is simple.

Jonathan

On Tue, Nov 1, 2011 at 9:12 AM, Anthony Palomba <apalomba <at> austin.rr.com> wrote:
> I am very interested in finding a good python package that does
> computational geometry.
>
> I was looking at CGAL for a while, but they python bindings do
> not seem to work and examples are pretty limited.
>
> If you do find something that works, please be sure to inform
> us as well.
>
>
>
>
> Thanks,
> Anthony
>
>
>
>
> On Mon, Oct 31, 2011 at 4:58 PM, <hayne <at> sympatico.ca> wrote:
>>
>> Maybe have a look at "microsphere interpolation":
>> http://www.dudziak.com/how_microsphere_projection_works.php
>> (Perhaps just looking at the diagram at the bottom of that page would
>> suffice for a start.)
>> This is not a Python implementation, but it might give you some ideas.
>>
>> --
>> Cameron Hayne
>> macdev <at> hayne.net
>>
>> On 31-Oct-11, at 5:14 PM, Lorenzo Isella wrote:
>> > This is admittedly a bit off topic, but I wonder if anybody on the
>> > list
>> > is familiar with this problem (which should belong to computational
>> > geometry) and is able to point me to an implementation (possibly
>> > relying
>> > on scipy).
>> > Imagine that you are sitting at the origin (0,0,0) of a 3D coordinate
>> > system and that you are looking at a set of (non-overlapping) spheres
>> > (all the spheres are identical and with radius R=1).
>> > You ask yourself how many spheres you can see overall.
>> > The result is in general a (positive) real number as one sphere may
>> > partially eclipse another sphere for an observer in the origin (e.g.
>> > if
>> > one sphere is located at (0,0,5) and the other (0,0.3,10)).
>> > Does anybody know an algorithm to calculate this quantity efficiently?
>> > I have in mind (for now at least) configurations of less that 100
>> > spheres, so hopefully this should not be too demanding.
>> > I had a look at
>> > http://www.qhull.org/
>> > but I am not 100% sure that this is the way to go.
>>
>>
>>
>>
>> _______________________________________________
>> SciPy-User mailing list
>> SciPy-User <at> scipy.org
>> http://mail.scipy.org/mailman/listinfo/scipy-user
>
>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User <at> scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
>
Johann Cohen-Tanugi | 1 Nov 2011 19:10
Picon

Re: Lerch transcendent function

Hi Josef, I was planning to work on something related (polylog), and I 
started some groundwork : https://github.com/johannct/scipy/tree/polylog
But it recently stalled, due to overburden. Also I would like to start 
with a complete implementation of the zeta function (analytic 
continuation) as in mpmath.....

best,
Johann

On 11/01/2011 04:28 PM, josef.pktd <at> gmail.com wrote:
> Is the Lerch transcendent function available in scipy or python?
>
> http://en.wikipedia.org/wiki/Lerch_zeta_function#Definition  capital phi
> http://mathworld.wolfram.com/LerchTranscendent.html
>
> (used for moments of Weibull-geometric distribution)
>
> Josef
> _______________________________________________
> SciPy-User mailing list
> SciPy-User <at> scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
David Baddeley | 1 Nov 2011 22:04
Picon

Re: SciPy for Computational Geometry

How about using OpenGL to render the problem, giving each sphere a different colour. You can then grab the rendered image (or potentially images from different camera angles) and count the number of discrete colours you have. It's probably not the most elegant of solutions, and would only be approximate (due to the pixelation), but python has good OpenGL bindings and it ought to be fast to compute. 

It would probably also be pretty easy to code something up from scratch which did this, along these lines:

- generate an 2D array which is going to contain the index of the nearest sphere for any given angle (theta, phi) (initialised to zero)
- create a similar array which holds the distance to the nearest sphere in for each of the pixels above (analagous to a zBuffer in normal 3D rendering) and initialise this to a very large number
- iterate over your spheres and draw a circle in your index and z buffer arrays where you change the index and z value if (and only if) the new z value is going to be smaller than the one currently in the z buffer (mapping the sphere to a circle in theta, phi space should be pretty simple).

Again this is only going to be approximate (due to the pixelation).

cheers,
David

From: Lorenzo Isella <lorenzo.isella <at> gmail.com>
To: scipy-user <at> scipy.org
Sent: Tuesday, 1 November 2011 10:14 AM
Subject: [SciPy-User] SciPy for Computational Geometry

Dear All,
This is admittedly a bit off topic, but I wonder if anybody on the list
is familiar with this problem (which should belong to computational
geometry) and is able to point me to an implementation (possibly relying
on scipy).
Imagine that you are sitting at the origin (0,0,0) of a 3D coordinate
system and that you are looking at a set of (non-overlapping) spheres
(all the spheres are identical and with radius R=1).
You ask yourself how many spheres you can see overall.
The result is in general a (positive) real number as one sphere may
partially eclipse another sphere for an observer in the origin (e.g. if
one sphere is located at (0,0,5) and the other (0,0.3,10)).
Does anybody know an algorithm to calculate this quantity efficiently?
I have in mind (for now at least) configurations of less that 100
spheres, so hopefully this should not be too demanding.
I had a look at

http://www.qhull.org/

but I am not 100% sure that this is the way to go.
Any suggestion is appreciated.
Many thanks

Lorenzo
_______________________________________________
SciPy-User mailing list
SciPy-User <at> scipy.org
http://mail.scipy.org/mailman/listinfo/scipy-user


_______________________________________________
SciPy-User mailing list
SciPy-User <at> scipy.org
http://mail.scipy.org/mailman/listinfo/scipy-user

Gmane