Tuesday, June 7, 2016

Ada Lovelace and the Analytical Engine: First Female Computer Programmer

The 19th century mathematician Ada Lovelace is considered “the prophet of the computer age” not only because she wrote the first computer program, but because she also recognized the far-ranging applications of the nascent computing technology. Even before her major accomplishments, Ada showed great mathematical skill at a young age. Through her work with Charles Babbage, the first person to describe a computer-- or, as he called it, the Analytical Engine--,  Ada led to the invention and development of the computer.
          Born in 1815 to the legendary poet Lord Byron, Ada Byron showed herself to be a mathematical prodigy at an early age. She always pursued her mathematical interests, despite the discouragement her family showed because she was a girl.  She was fascinated by equations and numbers, and found solving a math problem extremely rewarding. She once described that solving a problem “made a lovely shape in her head”. However, in 1827, Ada’s mother interrupted her plans, insisting that she pursue ‘useful’ and ‘moral’ interests, because fascination with science was considered improper for a girl. Undeterred, Ada continued her studies and met William Turner, who introduced her to Charles Babbage's ideas and inventions.
Charles Babbage

           At a banquet, Ada heard an intriguing snatch of conversation. William was discussing Babbage’s newly invented Difference Engine, a machine that performed basic mathematical operations. Babbage’s Difference Engine was an application of the rules of finite differences, capable of adding and storing numbers. She watched intently as he turned a dial on the tangle of cogs and wires, numbers beginning to appear on the machine’s brass wheels. With each turn of the dial, the numbers increased by two. When the machine reached 178, the crowd was beginning to fall asleep...until the machine displayed an entirely different number. He had programmed the machine to add 201 to the number obtained after 89 rotations. Ada visited Babbage many times after this, and learned of his new plan for an improved Difference Engine-- the Analytical Engine. This was to be the first computer. Even though it was never constructed, detailed plans existed on paper. These plans led to the construction of the computer. Although the Difference Engine seems like nothing but an elaborate calculator to people today, it laid the foundation for future computer technology.

The Difference Engine
    The Analytical Engine was to have more applications than the Difference Engine, and have a far more complicated structure. How exactly was the Analytical Engine different? Unlike the Difference Engine, which required numbers to be entered by a human, the Analytical Engine used punched cards to do this job. It was also capable of performing more complicated mathematical operations, and needed to be much larger to accommodate all its components. One set of cards determined the operations for the adding and multiplying states of the Analytical Engine. Another set of cards distributed the operations according to a particular function, providing the engine with data and obtainable results. The machine was comprised of four components: the mill, the store, the reader, and the printer. These components are the essential elements of every computer today. The mill was the calculating unit, the equivalent to the central processing unit (CPU) in a modern computer. The store was where data was held, analogous to memory and storage in today’s computers. The reader and printer were the input and output devices. Although today’s computers are more complex, the planned Analytical Engine laid the foundation for the development of computer technology.

Part of the plans for the Analytical Engine
              Not only did Ada contribute to the invention of the Analytical Engine, but she also paved the way for computer programming with the code she wrote for the Analytical Engine. At a presentation of his ideas, Babbage met the Italian mathematician Luigi Menabrea, who was interested in writing a book about the Analytical Engine. However, there was only one problem when the book was published: it was written in French. Due to her voluminous education, Ada was fluent in French. Thus, Babbage referred to Ada to translate the book into English. As well as translating the book, Ada added intricately detailed notes further describing the machine, and its possible applications. 
                In fact, Ada realized something about the Analytical Engine that even Babbage did not see. She saw that, just because one was using numbers in their device, they did not need to be thinking just about numbers. Every computer is doing arithmetic underneath due to its binary code, whether someone is listening to music or programming it to add. Ada was the first to observe possible uses for the computer outside of mathematics, such as composing music. Ada also understood the potential power this machine had, because it could make choices and repeat instructions. In translating and adding to Menabrea’s writing, Ada emphasized the machine’s versatility, explaining how it could solve trigonometric functions including variables, and how it could solve challenging math problems.
Ada’s work with Babbage led to the development of the Analytical Engine, which laid the foundation for the computers we use today. In her honor, the first computer programming language was named ‘Ada’.
   

Monday, June 6, 2016

Computer Science Project: Helping Solve a Problem in Bioinformatics

 
If you have ever been prescribed a drug, or seen an advertisement for one, you have probably noticed the list of potential side effects ranging from dizziness to death. A drug might cure one person, and poison another. I wondered why people respond differently to the same drugs, and decided to pursue a project in bioinformatics -- the science of analyzing genetic data --  to explore this question. I found that genetic mutations affect a person’s response, and coded an algorithm to locate these mutations in a genome. Research in this area could lead to groundbreaking medical innovations that would alleviate suffering by enabling personalized medicine, allowing doctors to create tailor-made treatments based on an individual’s unique genetic composition.
People responding differently to the same drug is a problem of increasing concern. For example, a CDC study found that 120,000 people are hospitalized per year for severe drug reactions. With over 70% of Americans on at least one prescription drug, the possibility of experiencing severe side effects is an imminent and potentially fatal risk. According to a study from the Journals of the American Medical Association, prescription drugs are the fourth leading cause of death in the USA, causing 106,000 deaths per year. This means that severe responses to drugs are a critical health concern.
Could there be a way to predict what drugs an individual will respond to? To help address this problem, I researched what could cause variable responses to some of the most common drugs Lipitor, Plavix, and Tegretol, and found that genetic mutations influence a person’s response. 
However, knowing the mutations only solves half the problem. Doctors need to know if their patients have particular mutations. They need to locate a single base swap in a genome of millions of bases by using a string searching algorithm. String searching algorithms are computer programs that locate a string of characters within a text. In this case, the genome is the text and the mutation, a sequence of base letters, is the string. It is important for the algorithm to produce a result quickly so that doctors can test a large volume of patients conveniently and easily. In addition, a fast algorithm is vital in emergency situations such as seizure or allergic shock when the correct drug must be prescribed immediately.
To help determine an optimal algorithm, I selected two of the most widely used string searching algorithms: Naive Exact Matching and Boyer-Moore, as well as the Boyer-Moore modification Apostolico-Giancarlo, and compared their efficiencies.
Efficiencies are determined by the number of character comparisons and string alignments each algorithm performs. The fewer comparisons and alignments it performs, the faster an algorithm runs. Character comparisons compare a letter in pattern P to a letter in text T, while the alignments compare the whole P to a small segment of T.  Since Boyer-Moore uses an efficient algorithm to skip certain alignments, it takes less time to run than Naive Exact Matching. Apostolico-Giancarlo is more efficient than Boyer-Moore because it stores each compared character in an array. For this reason, I parallelized it, or coded it to run simultaneously on multiple processors, to make it even faster.
    How does parallelism make an algorithm faster?
A parallel program divides the task of searching through a genome by making multiple processors work together on a problem. This reduces the time needed to obtain the solution.

    Structure of a parallel program
parallel_giancarlo.jpg
My results lead me to conclude that a parallelized algorithm is essential to feasible personalized medicine. Further research is needed, as this study only addresses several mutations specific to several drugs, and the Apostolico-Giancarlo algorithm is only one out of hundreds of possibly more efficient algorithms. However, these results suggest that bioinformatics research has the potential to save lives by allowing doctors to make the pill fit the ill.

I also made a video describing my project, which you can find here: https://www.youtube.com/watch?v=Vw3QYrqA99U
 

Getting Started!

Just start coding! The best way to learn how to code is to start coding! Do it now! Wondering how? I started coding when I was 10, beginning with Scratch. 

My first experience with Scratch was through a course taught by my awesome teacher, Mrs. Meryl van der Merwe. Now she has the class online so anybody anywhere can take it! Her site is called FundaFunda, and has a beginner, intermediate, and advanced Scratch class.
 
 I also used tutorials from MIT's scratch page to gain very basic knowledge. Here is the tutorial:  https://scratch.mit.edu/projects/31407152/ 

Now that you know some Scratch, it's time to start coding! If you are dreading following obscure instructions to download Scratch on your computer, never fear! You can open a complete Scratch platform here: https://scratch.mit.edu/projects/editor/?tip_bar=home  There are suggested projects and tutorials on the side.

I suggest starting small. Before you attempt a full game or animation, just experiment with the different blocks. Make the cat sprite move across the blank screen. Once you've tested the individual blocks, try making them interact! Make the cat dance in a whole chunk of code! You can also experiment with the 'looks' and 'sound' tabs by making the cat 'say' something, or drawing a hat on it. Try incorporating time into your program with the 'control' bar, making it wait several seconds before meowing, or making it repeat a motion 10 times.

Once you have experimented with the Scratch cat, you can follow a tutorial to make a game or animation. You can use the tutorials from MIT on your coding page, or use this video to make a platform game: https://www.youtube.com/watch?v=ooPPlj4jFjc

When you've made something based on a tutorial, try elaborating on it or creating your own game or animation! I animated some of Aesop's fables such as the Crow and the Pitcher and the Lion and the Mouse. I advise making a short animation of a simple fable or fairy tale because it is extremely easy to become overwhelmed in a complicated story. 

Once you've made something, share your fabulous project! You can create an account on the site https://scratch.mit.edu/, post your project, and explore what others have done!