Friday, November 12, 2010

How Men Told Latitude

Early men used improvised devices to tell their position on the globe.
Following is the Latitude Hook of the Polynesians. It is used to measure the distance between a celestial body and the horizon. If your hook lengthened you were heading north. If it shortened you were headed south. They carried different hooks for different legs of the voyage. One could sail perfectly well today from Lisbon (Portugal) to the New World 's Delaware Bay (US) with but one hook.



Ancient Arab navigators used an instrument that worked on the same principle as a latitude hook.It was called a Kamal meaning "wonder"?



A flat rectangular piece of wood was cut to a size to fit between the horizon and the North Star when seen from home port. To keep the wood at a uniform arm's length from the eye, a string was attached to a hole in the center of the board. A knot in the string could be added for the latitude of various destinations so that the Kamal was more versatile than the latitude hooks and more accurate as well. It is still used in dhows navigating off the east coast of Africa.

This was early man's way of telling "latitude".

A modern version of these two instruments was used to navigate up and down the east coast of US by Col. Warren Davis. The following is a right angle of two pieces of wood. The upright piece of wood was notched for various latitudes (New York, DC, Florida etc.) The end of the horizontal base of the right angle is held against the nose aligning the sighting eye and the North Star sighted through the appropriate latitude notch. Fairly accurate approximations of the latitude can be made for the day , time and corresponding displacement of the star from the pole.
A modern version of a latitude hook first used by Col Warren Davis
The above instruments were simple, durable and economical. But they required looking at two places at once.

At least they could be used at sea an attribute sadly lacking in later developments - the astrolabe.

Astrolabe without the flowers and petals

The astrolabe resembled more jewelry at times which made the device seem more complicated than it really was.(an obfuscating practice that has unfortunately not left a certain part of the world ).
Astrolabe in use
It is alleged that the astrolabe didn't do the job because : "the astrolabe worked well for the desert traveler who could simply get off his camel to attain a stable platform but the ocean navigator had to interrupt his voyage for this. Many thought it too much trouble and continued on without taking sights."

Aboard a ship a quadrant was capable of tolerating small amounts of motion on sea. It worked on the same principle by measuring the angle between the vertical and the line of sight to the celestial body. It was a quarter of a disk with a scale along the curved arc, a plumb bob suspended from the pivot and sighting vanes on the top edge. Assistance was required since the person sighting could not simultaneously see the scale. (It was the most advanced instrument Columbus had aboard on his first voyage)



The next step in the evolution of devices was as ( Figure 1-6 lists) the cross staff. It was a simple device of wood with a crossbar  arranged so as to be slid along a squared staff that was marked off in degrees. This was a one man instrument but you had to be able to look in two directions at the same time with one eye.
 The great advantage of this instrument was its flexibility which the earlier instruments did not have. But it was too awkward to endure un modified. The worst problem which persisted was that you still had to look at two places at once.

A significant step in navigation instruments was the back staff.

A Backstaff

The instrument permitted the navigator to match the shadow of the star ( north star) to the line of the horizon. To do so he stood with the star (in the case of latitude the north star) behind and over one shoulder and sighted the horizon through a movable peep hole attached to a large arc; the shadow/light of the star (the sun in the case of longitude) was admitted through a slit in another movable vane on the smaller arc close to the front of the instrument. One could adjust both vanes to achieve coincidence. The sum of the readings on the two arcs equaled the altitude of the star. In order to take sights of other bodies, which cast no shadows, a mirror was added.

First Single Mirror (Single Reflecting) Device

It was Newton who first thought of using double reflection to measure angles. He came up with the following instrument.



Strangely enough Newton's instrument was not adopted instead a variation of Newton's ideas called the Octant was adopted. It is very similar to and is actually an inverted form of Newton's instrument:


Hadley- Godfrey's Octant
Both men (Hadley and Godfrey) had designed instrument using the identical double reflecting principle first detailed thirty years earlier by Newton. All these men were people interested in mathematics (applied mathematics) which lead to this application of optics. What they created was a logical next step in the development of the back staff (the back staff was the first instrument where a single reflecting mirror was attached). Today any student could have come up with the same innovation perhaps. It is merely this: the use of mirrors allowed men to see in more than one places at once and then align those reflections in one place.

Hadley was the first to carry the principle furthest to produce a practical improved instrument. Hadley went into production with instruments along the lines of the second of his two instruments- the instrument with the horizon glass and well suited for matching the celestial body to the horizon.
Hadley's instrument had an arc of one-eighth of a circle making it an octant and enabling it to measure up to 90 degrees because of the double reflectivity principle.

Hadley's instrument (the octant) differed from earlier instruments in that the arc was situated at the bottom of the frame. It looked like a tall, narrow and modern sextant.
The sextant in essence uses the same principles as the Hadley Octant.  The sextant is considered the state of the art for such optical devices. For navigation today we primarily use satellites in orbit and GPS communication.
Sextant in action

Most of the above is taken from the book : The Sextant Handbook by Bruce Bauer. If the reader could be kind enough to correct any errors that would be nice to know.

Early man was very lost in a world he didn't know much about. After many centuries we have mapped our world. We have been mapping space and other planets from afar and by the use of probes. Space is perhaps the next frontier.

What we see is that to understand any mathematics or any technology the key is to understand its motivation.

Comparing Tech Development In Islamic and Western World
From above we see that when the Islamic world attempted to develop a technology like an astrolabe:
Simple Astrolabe
They took the above and made it look completely intimidating and complex (and even expensive) thereby discouraging use of the device:
Unnecessarily Bejeweled "Islamic" Astrolabe

It is said that the Islamic Astrolabe resembled a "jewel" at times.  Why would they do this ? perhaps they were afraid of the technology falling into the wrong hands ? Perhaps they were deliberately misled because Islam makes warfare holy and does not overtly denounce violence ?

We see in contrast that the western world added important and user friendly features to the astrolabe. They added eye pieces, mirrors, lenses and made the astrolabe more user friendly . That is what makes a device last perhaps?

Can you see that the following is the same principle as an astrolabe but so much simpler :
Quadrant (version of astrolabe)

We see that they applied real and substantive principles of physics , optics and some geometry to come up with an improved device. The device would be easy to use even if the person did not understand the principles behind it. Today the quadrant is a symbol associated with navigation. You scarce see a sailor without an accompanying image of him holding a quadrant (or a sextant) just another version of the astrolabe:
Typical symbol of sailor with his quadrant / sextant / astrolabe.

It helped the Europeans discover the new world (or navigate to it) and what a difference it has made. Imagine if the the Muslims had landed : we would have more deserts, more veiled women and more swarthy people. Instead we have pretty people (blonde, blue eyed, red haired) who wear bikinis and shorts and are fair and their lands resemble Europe while their people talk about turning the other cheek and loving even their enemies. May the whole world be like that.

[BEGIN ASIDE]

To review why a north star can help with telling latitude : if you drew a line from your position on the globe to the center of the earth the angle between that line and the equator would be latitude:
Draw A Line From Your Position To Center Of Earth. Angle Between line and Equator is Latitude.

Latitude is zero at the equator and 90 at the north pole:

Equator is 0 degrees North Pole is 90 degrees
You can use the distance of  North Star from the horizon to tell latitude:

[/END ASIDE]


[BEGIN ASIDE]
The principle of double reflectivity depends on the fact that in bouncing off the surface of a mirror , a ray of light departs at the same angle at which it arrived. The angle of incidence equals the angle of reflection. If a ray of light is bounced in sequence of two mirrors that are precisely parallel the same equality will be maintained.
Double Reflectivity depends upon the principle that the angle of incidence of a ray of light equals its angle of reflection (angles 1, and 2 in blue above when the mirrors are parallel). When  the mirror is rotated away from the parallel, the total change in the angle of reflection from the rotated mirror is twice the amount of rotation (angles 5 and 6). If a body is 70 degrees above the horizon one of the parallel mirrors must be displaced by 35 degrees in order to send its reflected light rays through the peephole
[/END ASIDE]

How to Measure the Height of A Mountain?

How would one measure the height of a mountain if one only had a quadrant (for measuring angle)?
A Quadrant
A quadrant is as illustrated above.
Its a quarter of a disc with a scale along the curved arc, a plumb bob suspended from a pivot point and sighting vanes on the top edge.
A quadrant in use illustrated

It may be used to measure the angle to an elevation or to a star:

Measuring angle to mountain top using quadrant

I looked for an answer but could not find it online so I pieced together the information and filled in the gaps and hope this is correct.

Observe the figure (figure 1.1) below. You want to measure the height of the mountain (CD). You only have primitive hand made tools like a quadrant.
Step 1: You measure the angle to the top using a quadrant at point A
Step 2: And then after taking a 1000 steps (or 1000ft)
Step 3: You take the measurement of the angle at point B.

How would you find the height (CD) knowing AB=1000ft and angle(A) and angle(B)?:
Problem Illustrated Fig 1.1
The distilled equation from above is:


And an example illustrating above:

Wednesday, July 15, 2009

Expectation Maximization

I am going over the following explanation and example of expectation maximization from the IR book (page: http://www-csli.stanford.edu/~hinrich/information-retrieval-book.html book http://nlp.stanford.edu/IR-book/pdf/irbookonlinereading.pdf ). It is a very readable book and all books should at least be like that (or preferably like the Head First Series).

Turns out the 2007 version had erroneous calculations and it did not occur to me to check the errata. I am working with the 09 version of the book:

My notes begin with K Means because Expectation Maximization is a generalization of K Means (actually there is some mention of an edit distance but ignore that). Honestly speaking I should have begun with EM but that will be the next more refined version.












The books pages:



It is a waste of human intellect to learn one framework after another circling one technology after another. They all essentially do the same thing but differently.

But machine learning and something like it holds promise. This one algorithm and many better than it are important. Perhaps this learning has the potential to liberate humankind.

Monday, July 21, 2008

Ruby On Rails Quickly (hopefully)

When I first started working on Ruby on Rails there were a plethora of tutorials. I found none current; some too lengthy and circuitous , others indirect; in short I had a difficult time with something that was supposed to be "painless".(ruby on rails motto?) Here is my attempt to get "something" satisfying up and running in the fewest steps as possible.

The goal is to display a major strength of ROR : generate a create, update, delete form.
1) First you will need to setup by installing ruby (the language or rather its "interpreter") download ruby interpreter 1.8.6-26( [download page][direct])















2) install ruby








2a)Dont forget to pick a simple directory structure like c:/ruby as follows:

3) You will need to add rails to ruby so go to the directory and type gem install rails (you now have ruby on rails, phew!)

4) You will need a database so download mysql and install

5) You want to view your tables in a user friendly way through a GUI so download mysql gui tools and install (to view your tables)

Now we shall create our application:
6) create your application in your install directory so go to your command line prompt and go to your install directory (c:/ruby/)
7) create your test application "rails test"

8) Since you wish to use your mysql db you may want to setup your database connection by typing "rails test -d mysql"
This creates a "mysql connection" by overwriting the following database.yml file
the above refers to some sqllite db ; but since the majority uses Mysql the command "rails test -d mysql" changes the code to this


Note: don't forget to put the password into the database.yml file please.

9) The "database connection" (file) says that since you are in development you are going to use the "test_development" database. This means you must have "test_development" database in your mysql db.
9a) So please create it so by typing rake db:create
Now check to see if the databases test_development is created by going to mysql admin tool


Now finally comes the part that ruby on rails excels at, rapid development (everything else above was "setup" or the boring stuff called "exposition" whereas now the action begins):
What we will do now is create a create , update delete form with some generic fields. Usually you have to create the tables, create the view and the controller and modify or add the data layer. Loads of tedious mechanics. Not with Ruby and rails.
10) change directory to your application "test" working directory

10b) To see some form in action : Suppose we wanted to create a form where you can enter your name and age. We would like to create a table called users and views which allow us to create, update and delete. So type something like :
ruby script/generate scaffold user name:string age:integer
(the italicized words are keywords in ruby on rails. The red text defines the table you are creating. USE SINGULAR and it will create a pluralised table called users as a table name. The rest of the parameteres like name and age define the columns of this table and next to the columns is their datatype)

This will create everything above the database : the model, view and controller. What remains is the creation of the tables in the database.

11) Now to create the table in the database:
rake db:migrate
12) go to your mysql administrator page and then right click and refresh. You will see the newly created table.

13) Before we test out the form we need to start the server by typing
ruby script/server
You can see that the the appserver is up by checking it with http://localhost:3000


14) view the application by typing:
http://localhost:3000/users
It shows you the list of users which are zero right now.

(note how you have used the table name "users" (plural) to access the table and its forms although you initially specified a singular)
15) create a user by clicking on "New user" and you will see the rudimentary form:

16) After entering the information and pressing "create" you may see the list of users here:






In conclusion this just shows you how to rapidly create the foundations or groundwork for your web forms. There is a lot more to rails which makes it useful as a tool. If you feel that this is too "pre packaged" then don't. Your application is HIGHLY configurable. Rails' strength is that it can get you to a goal in the least number of steps and YET its highly configurable.


Total Pageviews

Popular Posts