AN ENROLMENT PROJECTION PROBLEM

achrist at easystreet.com achrist at easystreet.com
Sun Jun 29 20:32:40 EDT 2003


For help with a problem like this, try posting a questioon here:

http://boards.eesite.com/board.cgi?boardset=Actuary

You should find some APL fans there and some people who do and know
demography and population problems.

Al

Ajith Prasad wrote:
> 
> Donald 'Paddy' McCarthy <paddy3118 at blueyonder.co.ukNOTthisBIT> wrote in message news:<3EFF0B14.4090307 at blueyonder.co.ukNOTthisBIT>...
> > Ajith Prasad wrote:
> > > I would appreciate advice on how best to formulate the following
> > > problem in Python. I have originally posted the problem to the J
> > > Programming forum and received a one-line formulation ((#s)
> > > (|.s)&(+/@:*)\ I)! I was wondering what the equivalent Python
> > > formulation would be.
> >
> > Wow! that one line formulation is dense.
> > Why do you *want* a compact answer?
> > I'm curious, if you put it down, do you have problems undestanding the
> > above program in a weeks time?
> > Or in a days time?
> >
> > Cheers, Pad.
> >
> >
> > >
> > > The Problem:
> > >
> > > The enrolment E(n) of an institution at the beginning of year n is the
> > > sum of the intake for year n, I(n), and the survivors from the intakes
> > > of previous r years. Thus, if s(1) is the 1-year intake survival rate,
> > > s(2) is the 2-year survival rate, etc, we have:
> > >
> > > E(n)= I(n)+I(n-1)*s(1)+ I(n-2)*s(2)+...+I(n-r)*s(r)
> > > E(n+1)= I(n+1)+I(n)*s(1)+I(n-1)*s(2)+... +I(n-r-1)*s(r)
> > > .
> > > .
> > > .
> > > E(n+k)= I(n+k)+I(n+k-1)*s(1)+I(n+k-2)*s(2)+...+I(n+k-r)*s(r)
> > >
> > > Given:
> > > (a) the actual intakes for the current and previous r years, I(n),
> > > I(n-1),I(n-2),..,I(n-r), and the planned intakes for the next n+k
> > > years: I(n+1), I(n+2),..., I(n+k), we have the intake vector I =
> > > (I(n-r), I(n-r-1),...,I(n),I(n+1),..., I(n+k)); and
> > > (b) the survival rate vector, s = (1,s(1), s(2),...,s(r))
> > > Find:
> > > The  k*1 enrolment projection column vector, E =
> > > (E(n+1),E(n+2),...,E(n+k)) in terms of a k*(r+1) matrix P (derived
> > > from
> > > I) and the (r+1)*1 column vector, s.
> > >
> > > I = P*s
> > >
> > > Is there a compact Python representation of the relevant matrix P
> > > where:
> > >
> > > P = [I(n+1) I(n) I(n-1).. . I(n-r)
> > >      I(n+2) I(n+1) I(n)...  I(n-r-1)
> > >      .
> > >      .
> > >      I(n+k) I(n+k-1) I(n+k-2)... I(n+k-r)]
> > >
> > > Alternatively, a non-matrix formulation of the problem would be
> > > acceptable. Thanks in advance for any suggestions on how to proceeed.
> I do not require an equally compact Python formulation - any solution
> that works will do. The J solution works but I do not why! It was
> formulated by a J expert and if one is very competent in J, I suppose
> one could follow the logic. In Python, I look forward to a readable
> and comprehensible solution. Thanks.




More information about the Python-list mailing list