Re: [Numpy-discussion] Porting numpy to Python3

2011-02-25 Thread Algis Kabaila
On Friday 25 February 2011 18:54:13 Scott Sinclair wrote:
 On 25 February 2011 06:22, Algis Kabaila 
akaba...@pcug.org.au wrote:
  On Friday 25 February 2011 14:44:07 Algis Kabaila wrote:
  PS: a little investigation shows that my version of numpy
  is 1.3.0 and scipy is 0.7.2 - so ubuntu binaries are way
  behind the bleeding edge...
 
 ... and built for the system Python (2.6), so even if the
 Ubuntu binaries were more up to date you'd need to build
 your own Numpy for Python 3.
 
 Cheers,
 Scott
 ___
Scott,

Good point!  Thanks.

Al.
-- 
Algis
http://akabaila.pcug.org.au/StructuralAnalysis.pdf
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Porting numpy to Python3

2011-02-25 Thread Algis Kabaila
On Saturday 26 February 2011 02:58:19 Bruce Southey wrote:
 On 02/25/2011 02:01 AM, Algis Kabaila wrote:
 
 I just build numpy and scipy from source so I do not know how
 you get Python 3 or which Ubuntu versions include recent
 numpy versions (there is a upcoming release that will
 probably contain a more recent numpy). It is very easy to
 install numpy and scipy from source on Linux although it is
 important that Blas/Lapack/Altas are built and installed
 correctly (I just use my distro's package).
 
 Please see the following link for more details:
 http://www.scipy.org/Installing_SciPy/Linux
 There was also a recent post on the list as well.
 
 Bruce
 
Bruce,

Thank you for the information.  I had a look at the URL that you 
gave (Actually, I had already seen it in my wanderings  on 
internet.)   For me it is very important to hear from the users' 
perspective how easy or hard the installation was.

Python 3 is readily available in most distros, certainly in 
ubuntu, so that is not a problem.  In fact in ubuntu Python 2.6 
happily coexists with Python 3.1 for one and the same user. 

Thank you for your help - greatly appreciated.

OldAl.

-- 
Algis
http://akabaila.pcug.org.au/StructuralAnalysis.pdf
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


[Numpy-discussion] Porting numpy to Python3

2011-02-24 Thread Algis Kabaila
Are there plans to port numpy to Python3? In particular, when 
will the packages of Linear Algebra (viz matrix inversion) be 
available in Python 3 compatible modules.

Because of the importance of numpy in many scientific endeavours 
is so great, information of the availability in Python 3 mode is 
very important and will be greatly appreciated.

OldAl.

-- 
Algis
http://akabaila.pcug.org.au/StructuralAnalysis.pdf
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Porting numpy to Python3

2011-02-24 Thread Algis Kabaila
If there is, then its great news (for me).  Where can I check it 
out?

Thanks for responding -

Al.

On Friday 25 February 2011 13:14:31 Shao Hong wrote:
 Hi correct me if I am wrong, I thought there is package
 ported for python 3.1 already?
 
-- 
Algis
http://akabaila.pcug.org.au/StructuralAnalysis.pdf
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Porting numpy to Python3

2011-02-24 Thread Algis Kabaila
On Friday 25 February 2011 14:22:04 Bruce Southey wrote:
 
 Python 3.1+ support occurred with numpy 1.5 that was released
 last year (2010-08-31)  - 1.5.1 is the current release.
 scipy 0.9 due very soon (release candidates are available at
 http://sourceforge.net/projects/scipy/) also supports Python
 3 except for weave module.
 
 Bruce

Bruce,

The link
http://sourceforge.net/projects/scipy/ 
responds with
Whoops, we can't find that page.  
I use Linux kubuntu 10.10 (Maverick Meerkat) OS and installed 
numpy with lapac from the ubuntu binaries.  As ubuntu 10.10 was 
released on 2010-10-10 10:x the version on numpy is probably 
earlier than 1.5, so presumably I have to either wait a couple 
of months for the next ubuntu release or install from source. 

Bruce, can you tell me how can I check the version of installed 
numpy?  There probably is a __version__ or something like that 
which would enable to verify.

Thanks for the answer - I unsuccessfully googled for the answer; 
I also recall my much earlier enquiries when the replies did not 
shed much light on the possible release date. 

Your reply is very much appreciated - thank you!

Al.

-- 
Algis
http://akabaila.pcug.org.au/StructuralAnalysis.pdf
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Porting numpy to Python3

2011-02-24 Thread Algis Kabaila
On Friday 25 February 2011 14:44:07 Algis Kabaila wrote:
 On Friday 25 February 2011 14:22:04 Bruce Southey wrote:
  Python 3.1+ support occurred with numpy 1.5 that was
  released last year (2010-08-31)  - 1.5.1 is the current
  release. scipy 0.9 due very soon (release candidates are
  available at http://sourceforge.net/projects/scipy/) also
  supports Python 3 except for weave module.
  
  Bruce
 
 Bruce,
 
 The link
 http://sourceforge.net/projects/scipy/
 responds with
 Whoops, we can't find that page.
 I use Linux kubuntu 10.10 (Maverick Meerkat) OS and
 installed numpy with lapac from the ubuntu binaries.  As
 ubuntu 10.10 was released on 2010-10-10 10:x the version on
 numpy is probably earlier than 1.5, so presumably I have to
 either wait a couple of months for the next ubuntu release
 or install from source.
 
 Bruce, can you tell me how can I check the version of
 installed numpy?  There probably is a __version__ or
 something like that which would enable to verify.
 
 Thanks for the answer - I unsuccessfully googled for the
 answer; I also recall my much earlier enquiries when the
 replies did not shed much light on the possible release
 date.
 
 Your reply is very much appreciated - thank you!
 
 Al.
PS: a little investigation shows that my version of numpy is 
1.3.0 and scipy is 0.7.2 - so ubuntu binaries are way behind the 
bleeding edge...
Al.
-- 
Algis
http://akabaila.pcug.org.au/StructuralAnalysis.pdf
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Inversion of near singular matrices.

2011-01-31 Thread Algis Kabaila
On Tuesday 01 February 2011 03:27:22 Sturla Molden wrote:
 Den 31.01.2011 03:05, skrev Algis Kabaila:
  Actually, the structural engineer
  has no interest in trying to invert a singular matrix.
  However he/she is interested (or should be interested :) 
  )  when the square response matrix might approach
  singularity for this would signal instability.
 
 I am sorry for having confused the issue by mentioning
 statistics. The mathematics (linear algebra) is of course
 the same. A singular matrix cannot be inverted by
 definition. The methods mentioned (SVD, Tikohonov
 regularization), as well as the transforms mentioned by
 Paul, will let you avoid numerical instability when matrices
 approach singularity (i.e. are very ill-conditioned).
 
 OT: I think I know what structural engineering is. Back in
 1994 I had to take a class in statikk (not sure what that
 translates to in English), with a textbook by Fritjof
 Irgens. From what I remember we did vector calculus to
 ensure the forces in a construction summed to 0, so that
 Newton's first law of motion would apply. It's unhealthy to
 be inside a building otherwise ;-)
 
 Sturla Molden
 
I would guess that statikk is statics, the subject of 
conditions of equilibrium.  

Yes, teaching is not for the faint hearted... Particularly in 
foreign areas.  Just to put your mind at ese - it is important 
to have some idea of statistics even in simplest engineering 
structures, such as those made up of statically determinate 
trusses.  (A truss is made up of members that are pin jointed, 
or are imagined to be pin jointed.  Because of the pin joints, 
each member can only be subjected to an axial force. My next 
code snippet will show the vagaries of analisis of statically 
determinate trusses).

Before I can really ask my next question, I should know what 
matrix norms are used for the calculation of matrix condition 
number in numpy.linalg.  You see, I tried to compare it with a 
condition number found in an undergraduate text book and got a 
totally different number. 

So if you know that and are able to explain it in simple terms 
so that even engineers can understand it, it will be greatly 
appreciated. 

Al.

-- 
Algis
http://akabaila.pcug.org.au/StructuralAnalysis.pdf
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Inversion of near singular matrices.

2011-01-30 Thread Algis Kabaila
 
 And if you are trying to solve a least-squares, I think that
 you should be using a ridge (or Tikhonov) regularisation:
 http://en.wikipedia.org/wiki/Tikhonov_regularization
 read in particular the paragraph above the table of content:
 you are most likely interested in Gamma = alpha identity,
 where you set alpha to be say 1% (or .1%) of the largest
 eigenvalue of A^t A.
 
 Gael

First of all I want to thank all who have contributed to this 
discussion.  It has been nothing less than inspiring! However, 
it has drifted to areas in which I lack expertese and interest.  
My interest is in structural analysis of engineering structures. 
The structure response is generally characterised by a square 
matrix with real elements.  Actually,  the structural engineer 
has no interest in trying to invert a singular matrix. However 
he/she is interested (or should be interested :)  )  when the 
square response matrix might approach singularity for this would 
signal instability.  He/She knows what the result of instability 
would be - a disaster!

It is my fault not to have stated the problem with adequate 
clarity and I intend to do that as soon as I can.

Thank you again for all your valuable contributions.

Al.
-- 
Algis
http://akabaila.pcug.org.au/StructuralAnalysis.pdf
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


[Numpy-discussion] Inversion of near singular matrices.

2011-01-29 Thread Algis Kabaila
Hi,

I am interested in determining if a matrix is singular or 
nearly singular - very ill conditioned.  The problem occurs in 
structural engineering applications.

My OS is kubuntu 10.10 (32 bit)
Python 2.6.6
numpy and numpy.linalg  binaries from ubuntu repositories.

The attached tar ball has a little CLI script that generates 
singular or near singular matrices (because of the inevitable 
roundoffs) for matrices with elements from sequence 1, 2, 3, 4 
etc.

The dimension of matrix nn can be passed as command line 
parameter via sys.argv[1] .  If argv[1] does not exist, the 5x5 
default matrix is used.
for nn = 3 and 4 numpy does not raise an exception
for nn = 5 it does raise an exception
for nn = 6, 7 np not raises exception
for nn = 8 np does raise exception
for nn = 9 np does not raise exception
for higher nn values np mostly raises the exception, but for nn 
= 23 and nn=120 it does NOT raise the exception.

It is worht noting that in practical problems of engineering 
analyisis the ill conditioned matrix is not exact - there 
always are approximations and roundoff errors.

So my question is: how can one reliably detect singularity (or 
near singularity) and raise an exception?

Many thanks for your attention,

Al.

-- 
Algis
http://akabaila.pcug.org.au/StructuralAnalysis.pdf


inversion.tar.gz
Description: application/compressed-tar
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Inversion of near singular matrices.

2011-01-29 Thread Algis Kabaila
On Saturday 29 January 2011 22:47:23 Stuart Brorson wrote:
  So my question is: how can one reliably detect singularity
  (or near singularity) and raise an exception?
 
 Matrix condition number:
 
 http://docs.scipy.org/doc/numpy/reference/generated/numpy.lin
 alg.cond.html http://en.wikipedia.org/wiki/Condition_number
 
 Stuart

Stuart,

Thank you for the wonderful pointer to good information. When I 
was writing my PhD in 1966,  there was little if anything known 
about the condition mumbers. Your judiciously chosen references 
put me on the track to search some information about it. 
Internet is wonderful - there are some well written material 
there to keep me quietly reading for a while...

Thank you,

Al. (aka OldAl)
-- 
Algis
http://akabaila.pcug.org.au/StructuralAnalysis.pdf
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Inversion of near singular matrices.

2011-01-29 Thread Algis Kabaila
On Sunday 30 January 2011 09:10:30 Sturla Molden wrote:
 Den 29.01.2011 12:40, skrev Algis Kabaila:
  So my question is: how can one reliably detect singularity
  (or near singularity) and raise an exception?
 
 Use an SVD, examine the singular values. 
I gather that SVD is the Singular Value Decomposition, but I 
have no idea how to perform such decomposition. Would you care 
to refer me to some simple source material?  I have been advised 
to watch the condition numbers. No doubt, SVD and condition 
numbers are related.  The references about condition numbers are 
very interesting and I intend to follow them in the first 
instance.

 In statistics we sometimes see ill-conditioning of covariance
 matrices. Another way to deal with multicollinearity besides
 SVD/PCA is regularisation. Simply adding a small bias k*I to
 the diagonal might fix the problem (cf. ridge regression).
 In the Levenberg-Marquardt algorithm used to fit non-linear
 least squares models (cf.
 scipy.optimize.leastsq), the bias k to the diagonal of the
 Jacobian is changed adaptively. One might also know in
 advance if a covariance matrix could be ill-conditioned (the
 number of samples is small compared to the number of
 dimensions) or singular (less data than parameters). That
 is, sometimes we don't even need to look at the matrix to
 give the correct diagnosis. Another widely used strategy is
 to use Cholesky factorization on covariance matrices. It is
 always stable unless there is a singularity, for which it
 will fail (NumPy will raise a LinAlgError exception).
 Cholesky is therefore safer to use for inverting covariance
 matrices than LU (as well as faster). If Cholesky fails one
 might fallback to SVD or regularisation to correct the
 problem.

 Sturla

My knowledge of statistics is rather limited, though our son Dr. 
Paul Kabaila is a specialist in that area.  My interests lie in 
the area of Analysis of Engineering Structures - it saves my 
brain from falling to a permafrost like sleep   :)

Thank you for your reply - greatly appreciated.

Al.

PS: Paul, I thought there is a minuscule chance that this is of 
some interest to you.
Tete.
-- 
Algis
http://akabaila.pcug.org.au/StructuralAnalysis.pdf
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Inversion of near singular matrices.

2011-01-29 Thread Algis Kabaila
On Sunday 30 January 2011 16:35:15 Charles R Harris wrote:
 On Sat, Jan 29, 2011 at 10:11 PM, Algis Kabaila 
akaba...@pcug.org.auwrote:
  On Sunday 30 January 2011 09:10:30 Sturla Molden wrote:
   Den 29.01.2011 12:40, skrev Algis Kabaila:
So my question is: how can one reliably detect
singularity (or near singularity) and raise an
exception?
   
   Use an SVD, examine the singular values.
  
  I gather that SVD is the Singular Value Decomposition, but
  I have no idea how to perform such decomposition. 
snip 
 Use numpy.linalg.svd. The condition number is the ratio of
 the largest singular value to the smallest.
 
 snip
 
 Chuck
Why not simply numply.linalg.cond? This gives the condition 
number directly (and presumably performs the inspection of 
sv's). Or do you think that sv's give more useful information? 

Thanks for writing - I find it all rather fascinating...

Gratefully,
Al.
-- 
Algis
http://akabaila.pcug.org.au/StructuralAnalysis.pdf
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion