Vector vol. 23 Nos. 1&2 Contents Editorial Stephen Taylor 2 Sustaining Members News



Download 0.53 Mb.
Page14/31
Date28.01.2017
Size0.53 Mb.
#9422
1   ...   10   11   12   13   14   15   16   17   ...   31

An Example




Suppose the vector Ages contains the ages of 400 respondents to an opinion poll. We want to establish how many people there are in each of the following categories.

0 – 25 – 30 – 35 – 45 – 50 – 55 – 65 or above.

In addition we decide that those who are on a borderline will be assigned to the lower category.

Here is an extract of the data:

Ages ← 32 19 50 33 23 65 46 26 31 58 51 23 51 36 28 42
Category ← 0 25 30 35 45 50 55 65

We are going to invoke the outer product Category ∘.< Ages, and here are the first items calculated as shown above:



<

32

19

50

33

23

65

46

26

31

58

51

23

51

36

28…

0

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

25

1

0

1

1

0

1

1

1

1

1

1

0

1

1

1

30

1

0

1

1

0

1

1

0

1

1

1

0

1

1

0

35

0

0

1

0

0

1

1

0

0

1

1

0

1

1

0















































If one adds up this binary table, one obtains for each row the number of people who are older than 0 years, 25 years, 30 years, etc. This is the expression:

cum ← +/Category∘.

The example above is reduced to the value cum which is: 17 14 12 8 6 4. In other words there are 12 people older than 30. But among them there are 8 older than 35. In order to know how many people are between 30 and 35, it is necessary to perform 12-8, to give 4.

If one wants to reproduce this calculation for all categories, it is necessary to perform a series of subtractions as here:

cum
17 14 12 8 6 4

1↓cum,0
14 12 8 6 4 0

cum-1↓cum,0
3 2 4 2 2 4

So, as we shall have occasion to notice again, we find that the comma joins variables together. This is a function called catenation.

If one no longer works with a small extract of data but with the 400 people, this is what one has:

cum←+/Category∘.
cum-1↓cum,0
83 65 79 79 32 17 36 9

All that without proper programming, and it works whatever the number of people or categories… what luck!

The outer product allows us to find typical solutions to some very classical problems.

I Have not Told you Everything


In the course of these pages we have flown over APL country and glimpsed certain bold ideas which explain the attraction of the language. A thousand other things remain to be seen!

It would be possible to talk about inner product, which is an extensive generalisation of matrix multiplication, of which our students retain only some formulae, learned by heart as a never-well-understood rigmarole, to reinforce “sigma of Aij Bjk”. But realistically, among life’s continuing problems, WHAT PURPOSE is served by stuffing our brains this way?

Having used APL as a teaching tool, I can assure you that one can teach linear algebra in a fast and realistic way, and show students that one can use it for comparing the management accounts of two companies. After that they will never forget it!

We ought to talk about generalised arrays, about the execute function, about… and it would take 400 pages… that is not our intention here.

Allow me to give you a quick illustration of a very unusual use: for files of data in an inverted form.


Directory: issues
issues -> Protecting the rights of the child in the context of migration
issues -> Submission for the Office of the High Commissioner for Human Rights (ohchr) report to the General Assembly on the protection of migrants (res 68/179) June 2014
issues -> Human rights and access to water
issues -> October/November 2015 Teacher's Guide Table of Contents
issues -> Suhakam’s input for the office of the high commissioner for human rights (ohchr)’s study on children’s right to health – human rights council resolution 19/37
issues -> Office of the United Nations High Commissioner
issues -> The right of persons with disabilities to social protection
issues -> Human rights of persons with disabilities
issues -> Study related to discrimination against women in law and in practice in political and public life, including during times of political transitions
issues -> Super bowl boosts tv set sales millennials most likely to buy

Download 0.53 Mb.

Share with your friends:
1   ...   10   11   12   13   14   15   16   17   ...   31




The database is protected by copyright ©ininet.org 2024
send message

    Main page