links for 2009-06-29
Tuesday, 2009.06.30
-
Earlier this week a fossil Darwinus masillae (nick-named “Ida”) created a bit of a stir and sent creationist websites into deny-everything-about-everything mode. The media has also been pretty unhelpful with it’s “missing-link” labeling and over-hyped rhetoric [...] Ida is NOT: * THE missing link. (Every fossil is transitional in some way; Ida is one link in a very long evolutionary chain.)
* The only example we have of a transitional fossil. (There are so many … to store and categorise)
* An example of scientists trying to deceive you.
* A much needed piece of evidence for the theory. (There’s a mountain of evidence that overwhelmingly supports evolution by natural selection. We don’t even need fossils due to: vestigial organs, embryology, morphological similarities, genomic similarities, observable evolution of micro-organisms and virtually every other discovery in biology over the 150 years.)
* The work of Satan (!)
links for 2009-06-26
Saturday, 2009.06.27
-
Wall Street is bankrupt. Instead of trying to save it, we can build a new economy that puts money and business in the service of people and the planet—not the other way around. [...]The world of our shared human dream is one where people live happy, productive lives in balance with one another and Earth. It is democratic and middle class without extremes of wealth or poverty. It is characterized by strong, stable families and communities in which relationships are defined primarily by mutual trust and caring. Every able adult is both a worker and an owner. Most families own their own home and have an ownership stake in their local economy. Everyone has productive work and is respected for his or her contribution to the well-being of the community.
links for 2009-06-23
Wednesday, 2009.06.24
-
Watch as Professor Richard Wolff breaks down the root causes of today's economic crisis, showing how it was decades in the making and in fact reflects seismic failures within the structures of American-style capitalism itself. Wolff traces the source of the economic crisis to the 1970s, when wages began to stagnate and American workers were forced into a dysfunctional spiral of borrowing and debt that ultimately exploded in the mortgage meltdown. By placing the crisis within this larger historical and systemic frame, Wolff argues convincingly that the proposed government "bailouts," stimulus packages, and calls for increased market regulation will not be enough to address the real causes of the crisis, in the end suggesting that far more fundamental change will be necessary to avoid future catastrophes. Richly illustrated with motion graphics, this is a superb introduction designed to help ordinary citizens understand, and react to, the unraveling economic crisis.
-
This can be especially hard for Christians to grasp, since a very deep part of our moral formation has been the belief that human identity is ultimately wrapped up in the suburban bliss of family life. (On which, see the TV series Mad Men…) This is also why our churches are often so strangely inhospitable to “single” (read: pre-married) people. We simply can’t really believe that these people are fully formed human beings. And so we treat them with all the sympathy or suspicion or indifference that their estate demands; our charity might even compel us to subject them to the peculiar indignity of a “singles” social event, all in the hope that the bright truth of sex will at last dawn in their dark lives.
Money and the Crisis of Civilization
Friday, 2009.06.12
-
In the face of the impending crisis, people ask what they can do to protect themselves. "Buy gold?" "Stockpile canned goods?" I would like to suggest a different kind of question: "What is the most beautiful thing I can do?"
Convert Unix timestamp to Date-time format
Tuesday, 2009.05.26
Working with log files in linux/unix, you’ll inevitably come across the weirdness of a unix timestamp. It’s not intuitive working with the number of seconds since Jan 1 1970, so I rolled a little conversion utility in bash, called “utime2ymd”.
#!/bin/sh
u1="Usage: utime2ymd <timestamp> [local|gmt]"
u2="\n\nConvert 10-digit Unix timestamp to yyyymmdd.hhmmss format"
u3="\n use local time zone (default) or UTC/GMT"
[ $1 ] || { echo -e $u1$u2$u3; exit 1 ; }
unixtime=`echo $1|cut -c -10`
if [ $2 ]
then qual2=`echo $2|awk '{print tolower($1)}'`
if [ "$qual2" = "gmt" ]
then thetime=`perl -e "print scalar(gmtime($unixtime))"`
fi
else
qual2="local"
thetime=`perl -e "print scalar(localtime($unixtime))"`
fi
YYYYMM=`echo $thetime | awk '{print $5 $2}' \
| sed 's/Jan/01/;s/Feb/02/;s/Mar/03/;s/Apr/04/;s/May/05/;s/Jun/06/;
s/Jul/07/;s/Aug/08/;s/Sep/09/;s/Oct/10/;s/Nov/11/;s/Dec/12/'`
DD=`echo $thetime | awk '{printf("%02d",$3)}'`
hhmmss=`echo $thetime | awk '{print $4}' | sed 's/://g'`
echo "$YYYYMM$DD.$hhmmss $qual2"
NOTE: There’s a similar script for the Windows environment, called ‘timetool‘. Wonder if I should write a linux version??
Proof that 1=2
Tuesday, 2009.05.26
Assume and
.
Then
QED.
RIP Stanley Jaki ~ Scholar and Gentleman
Tuesday, 2009.04.21
Stanley L. Jaki, OSB was a Benedictine priest and Distinguished Professor of Physics at Seton Hall University, New Jersey since 1975.
Jaki has been an intellectual hero of mine for a long time, I have owned “Science and Creation” for 10 years and explored its riches numerous times. It’s a revelatory book, which gives the reader a feel for the great sweep of religious traditions around the world, and is a brilliant introduction to the development of human thought since history began..
-
The Rev. Stanley L. Jaki, a physicist and theologian whose prolific writings parsed the histories of science and religion and the intertwining of faith and reason, died on Tuesday in Madrid, where he had traveled from Rome after delivering a lecture. He was 84 and lived in Princeton, N.J.
Father Jaki held doctoral degrees in physics and theology. A relentless scholar, he wrote more than 40 books, including studies of the religious thinking of G. K. Chesterton, the works of the French physicist and historian of science Pierre Duhem and the life of Cardinal John Henry Newman, the 19th-century theologian who famously converted from Anglicanism to Roman Catholicism.
He is probably best known, however, for works like “Science and Creation” (1974), in which he argued that the scientific enterprise did not become viable and self-sustaining until its incarnation in Christian medieval Europe, and that the advancement of science was indebted to the Christian understanding of creation.
RE: John Minto | Democracy only for the wealthy in Auckland
Sunday, 2009.04.12
-
Around the developed world there is growing disenchantment with what passes for democracy. The drivers have been the same in each country. For at least five elections from 1984 New Zealanders voted for one set of policies and got another. Despite consistently voting for governments expected to put curbs on corporate control of our economy and keep ownership of community assets in public hands we were betrayed each time by political parties under the effective control of the very corporate sector who benefited from undemocratic decisions.
Psalm 23: English to Maori
Wednesday, 2009.03.04
Taming a Beast called UNIX
Wednesday, 2009.03.04
The year was 1988. Voices hushed in trepidation, the apprentices gathered in a dingy corner of the Engineering building. In the undergraduate computer lab we assembled to offer sacrifices to the mainframe, hunched over the fading amber or green glow of hesitant dumb terminals, all connected to the mighty UNIX (VAX/VMS) mainframe. Poor first year acolytes we were, learning various complex incantations to extract data from the Beast. We learned to navigate the perils of UNIX: using ed, vi, man, fortran, and other strange spells to tame the Beast. For some of those innocent souls, the Beast caused them to cringe in fear and retreat to a “lesser” academic career, or flee gibbering and drooling in fear. Alas, I was an overconfident youth whose world was shattered by the Beast. So it was that I gave up my dream of conquest and glory.
But fate is fickle, and the world ever turns. So it was that seven years later, after a journeyman’s life, I wandered accidentally back into the nether realms of UNIX. However this time, I was different — stronger in body and mind from years of hard labour — and was wary of the nature of the Beast. Also, Unix itself was a different creature, somewhat mellowed with age, more tractable, less hostile: even unto supporting lower-case symbols and X-windows. So it was that an uneasy truce was forged between Unix and I. We learned to work together. Thus it was that I saw the Beast in a different light: a creature of mankind designed to serve, but only those who prove themselves worthy by mastering its secrets.
One of my greatest masterpieces was written in g77, the GNU port of Fortran. This program applies the Revised Simplex Method in two phases to find the optimal solution to a set of linear equations. I can’t remember all the mathematical theory and strategies involved, but the code still looks cool. For posterity I now give it to the world.
program main
implicit none ! Set up variables..
integer o,p
parameter(o=20,p=100)
integer i,j,m,n,r,s
integer apos(o),bpos(o)
real A(o,p),Bi(o,o),b(o),xb(o),cost(p),ca(o+p)
! Read data..
open(unit=8,file='lp.dat',status='old')
open(unit=9,file='lp.out',status='new')
read(8,*) m,n
if (m.gt.o.or.n.gt.p) then
write(9,*)'Exceeded variable/constraint limits'
endif
read(8,*) (cost(j),j=1,n)
write(9,*) 'm ',m
write(9,*) 'n ',n
write(9,*) 'c'' ',(cost(j),j=1,n)
write(9,*)
write(9,*) 'A.x = b'
do i=1,m
read(8,*) (A(i,j),j=1,n),b(i)
write(9,*) (A(i,j),j=1,n),' =',b(i)
enddo
c ------------------extra bit..-----------------
do i=1,m
read(8,*) (Bi(i,j),j=1,m)
write(9,*) (Bi(i,j),j=1,m)
enddo
read(8,*) (bpos(i),i=1,m)
write(9,*) (bpos(i),i=1,m)
read(8,*) (apos(i),i=1,n)
write(9,*) (apos(i),i=1,n)
do i=1,m
do j=1,m
xb(i)=xb(i)+Bi(i,j)*b(j)
enddo
enddo
goto 5
c -----------------------miss out for now------------------------
write(9,*)
write(9,*) 'Phase 1'
do i=1,n ! Phase 1
ca(i)=0 ! Prepare artificial cost,basis,variables
apos(i)=0 ! all original variables are nonbasic
enddo
do i=1,m
do j=1,m
Bi(i,j)=0 ! initially Bi = identity matrix, I
enddo
Bi(i,i)=1
ca(n+i)=1 ! artificial cost vector now constructed
bpos(i)=n+i ! artificial variables fill the basis
xb(i)=b(i) ! initially xb = b (because xb=Bi.b, Bi=I)
enddo
call rsm(m,n,A,Bi,b,xb,ca,bpos,apos,1)
c ---------------------------------------------------------------
5 write(9,*)
write(9,*) 'Phase 2'
! Phase 2
! Now do RSM with the new basis
call rsm(m,n,A,Bi,b,xb,cost,bpos,apos,2)
end
C--------------------------------------------------
subroutine rsm(m,n,A,Bi,b,xb,c,bpos,apos,phase)
parameter(o=20,p=100)
integer apos(n),bpos(m),phase ! variables passed to rsm
real A(o,p),Bi(o,o),b(m),c(n+m) ! "
integer i,j,imax,r,s,note ! introducing new variables
real bestrc,bias(m),pi(m),xb(m),z ! "
character retval
imax=2*(m+n)
tiny=1E-10
i=0
call currentsoln(Bi,b,bpos,c,m,xb,z)
1 if (i.lt.imax) then ! Iterate Revised Simplex Method..
i=i+1
call computedual(Bi,c,bpos,m,n,pi) ! find pi (initially pi=e)
call reducedcost(A,c,pi,apos,m,n,s,bestrc)
if(s.eq.0) then
if(z.gt.tiny.and.phase.eq.1) then
write(9,*) ' Infeasibility detected.'
note=-2
else
write(9,*) ' Optimality reached.'
note=1
endif
goto 3
endif
call mivitwwbias(A,Bi,m,s,bias)
call lvratiotest(xb,bias,m,n,r,phase,bpos)
if (r.eq.0) then
write(9,*) ' Unboundedness detected.'
note=-1
goto 3
endif
write(9,*) 'basisupdate:'
write(9,*) ' bpos',(bpos(j),j=1,m),' apos',(apos(j),j=1,n)
call basisupdate(Bi,bias,c,pi,xb,bpos,apos,m,n,r,s)
write(9,*) ' ->',(bpos(j),j=1,m),' ->',(apos(j),j=1,n)
call currentsoln(Bi,b,bpos,c,m,xb,z)
else
goto 3
endif
2 goto 1
3 write(9,*) ' RSM iterations executed: ',i
end
C-----------------------------------------------------
subroutine currentsoln(Bi,b,bpos,c,m,xb,z)
parameter(o=20)
integer bpos(*) ! old
real Bi(o,o),b(*),c(*),xb(*),z ! old
integer i,j ! new
z=0
do i=1,m
z=z+c(bpos(i))*xb(i)
enddo
write(9,*) 'currentsoln: Bi, xb'
do i=1,m
write(9,*) ' ',(Bi(i,j),j=1,m),' x',bpos(i),' =',xb(i)
enddo
write(9,*)
write(9,*) ' --------------------------- Objective value z =',z
write(9,*)
end
C-----------------------------------------------------
subroutine computedual(Bi,c,bpos,m,n,pi)
parameter(o=20)
integer bpos(*) ! old
real Bi(o,o),c(*),pi(*) ! old
integer i,j,k ! new
do i=1,m
pi(i)=0
do j=1,m
k=bpos(j)
pi(i)=pi(i)+c(k)*Bi(j,i)
enddo
enddo
write(9,*) 'computedual: pi ',(pi(i),i=1,m)
end
C----------------------------------------------------
subroutine reducedcost(A,c,pi,apos,m,n,s,bestrc)
parameter(o=20,p=100)
integer apos(*),s ! old
real A(o,p),c(*),pi(*),bestrc ! old
integer i,j ! new
real rc,pian,tiny ! new
rc=0
bestrc=0
tiny=-1E-10
do i=1,n ! determine entering var x(s)
if(apos(i).eq.0) then !< look at nonbasic columns
pian=0 ! (never price artificials)
do j=1,m
pian=pian+pi(j)*A(j,i)
enddo
rc=c(i)-pian !< red. cost for nonbasic x(i)
if(rc.lt.bestrc) then
bestrc=rc
s=i
endif
endif
enddo
if(bestrc.ge.tiny) then !< This means no ev was found,
s=0 ! optimality has been reached,
endif ! so flag s to 0
write(9,*) 'reducedcost: x',s,' enters with rc',bestrc
end
C----------------------------------------------------
subroutine mivitwwbias(A,Bi,m,s,bias)
parameter(o=20,p=100)
real A(o,p),Bi(o,o),bias(*)
integer i,j,s
do i=1,m ! a quick calculation of bias,
bias(i)=0 ! aka. the most important vector
do j=1,m ! in the whole world.
bias(i)=bias(i)+Bi(i,j)*A(j,s)
enddo
enddo
write(9,*) 'mivitwwbias: bias',(bias(j),j=1,m)
end
C----------------------------------------------------
subroutine lvratiotest(xb,bias,m,n,r,phase,bpos)
integer bpos(*),r,phase ! old
real xb(*),bias(*) ! old
integer i ! new
real ratio,rmin,tiny ! new
r=0 ! r=0 returned if no lv can be found
tiny=1E-10
teeny=-1E-10
rmin=10E+10
do i=1,m
if(bpos(i).gt.n.and.phase.eq.2) then
! Artificial present in phase2 basis:
! Extended lv routine to force out
! artificial variables..
if(bias(i).lt.teeny.or.bias(i).gt.tiny) then
rmin=0
r=i
endif
else ! Usual lv routine..
if(bias(i).gt.tiny) then ! ratio = rate of change of xb(i), as
ratio=xb(i)/bias(i) ! xs increases from 0 (enters)
if(ratio.lt.rmin) then
rmin=ratio ! the leaving variable is xb(r), the
r=i ! basic variable which decreases most
endif ! rapidly as xs enters.
endif
endif
enddo
write(9,*) 'lvratiotest: xb',r,' leaves.'
end
C----------------------------------------------------
subroutine basisupdate(Bi,bias,c,pi,xb,bpos,apos,m,n,r,s)
parameter(o=20)
integer apos(*),bpos(*),m,n,r,s ! old
real Bi(o,o),bias(*),c(*),pi(*),xb(*) ! old
integer i,j ! new
do i=1,m ! do gauss-jordan pivot on rth element
if(i.eq.r) then ! of bias, and thus also on Bi and xb
do j=1,m
Bi(r,j)=Bi(r,j)/bias(r)
enddo
xb(r)=xb(r)/bias(r)
else
do j=1,m
Bi(i,j)=Bi(i,j)-bias(i)/bias(r)*Bi(r,j)
enddo
xb(i)=xb(i)-bias(i)/bias(r)*xb(r)
endif
enddo
if(bpos(r).le.n) then
apos(bpos(r))=0 ! xb(r) now nonbasic; 0 in apos
endif
bpos(r)=s ! xb(r) replaced by xs in bpos
apos(s)=r ! xs located in rth basic position
end
simplex.f
Note: the above code has not been compiled or executed since sometime around 1998.
Here are some problems solved using this glorious program.
Read the rest of this entry »