Sunday, May 21, 2017

Circular Reasoning in Python

When people restate their conclusion as the argument for that same conclusion, it's logical fallacy called circular reasoning. There are some pretty good examples of this on Bo Bennet's blog "Logically Fallacious" including the logical form of it.
Logical Form:
X is true because of Y.
Y is true because of X.,
As someone who tries to be a rational human being, I avoid circular reasoning as often as I can. Yet, I ended up finding it two of the most logically consistent fields: computer science and math. In computer science language, it's called recursion while math's version of circular reasoning is called induction. During my computer science course "CS For All: Introduction to Computer Science and Python Programming" on by Harvey Mudd, I learned that these two forms of circular reasoning are actually useful problem solving methods even though they seem counter-intuitive at first. An example of recursion from the course's e-book CS For All is this factorial function:

What's going on

This is a function that gives you the factorial of n (aka n!=n*(n-1)*(n-2)...*1). The way this function works is that if n=1, it's obvious that 1! = 1*1 =1 and factorial(1)=1. The tricky part is the 
factorial(n-1) on line 8 which means that in order to get the factorial of a number greater than 1, the factorial function has to use the factorial function. Although it seems that using the factorial function while trying to find the factorial brings you to the same place that you started, it actually helps you solve the problem. At a closer look, you'll see that the inner factorial takes the value of (n-1) which means that the input of inner factorial  is sent back to the first part of the function where it goes through the "if" and "else" clauses and the input decreases by one each time. This loop continues until the input equals one and obviously factorial(1) = 1, so the loop ends and the function returns the value of the variable result after however many loops.

The While Loop 

This method of recursion is actually very similar to a more intuitive concept called the while loop. For example, this is the while loop that I coded to do the exact same thing as the previous function:
Basically, I always start off with a result that equals 1 and the result is multiplied by n until n is no longer greater than 1. With each loop, the n value decreases by 1 so that the function gets the right answer and doesn't continue into infinity. 

Underlying Concepts of Recursion

According to the CS For All textbook, recursion starts with the base case which is the answer to the simplest form of the problem. For the factorial example, the base case is 1!=1 or factorial(1) = 1. From there, the function can solve more complex problems like factorial(34) by putting it through the loop with the input of factorial(n-1) decreasing each time and thus simplifying problem until (n-1)=1. Notice how (n-1) actually gets stored as n with each loop, yet all of the past incarnations of n are multiplied together when it's time to calculate the final result. In a language like Python, variables like n can change value during the course of a program. However, all the values that n ever took are stored in "stacks" which you can think of as these boxes in this figure from CS For All :
As you can see, none of the past versions of n are forgotten and they all enter into the equation for the result. 


Although I still prefer the "while loop", learning recursion has given me a new way to think about solving problems which could be useful in case other methods do not work as well. In addition, seeing the limits of my intuition is a valuable experience for me because I tend to rely on intuition too heavily like many other people. CS For All by Christine Alvarado (UC San Diego), Zachary Dodds (Harvey Mudd), Geoff Kuenning (Harvey Mudd), and Ran Libeskind-Hadas (Harvey Mudd) has been a great guide that helped me understand this strange concept and I would definitely recommend it to anyone else interested in learning more about recursion(see Chapter 2: Function programming) or any other computer science concept. Circular logic can actually be logically valid problem solving method and is definitely not always as bad as this Dilbert cartoon makes it out to be.

Saturday, July 9, 2016

Understanding Scientific Papers (Part 2)

My revenge on bad scientific writers
Image is from
I described the basics to reading a scientific paper in Understanding a Scientific Paper Part 1, but there are still more tricks to understanding a scientific paper. They are clearly not written for the general public, and academese is an unavoidable hurdle. Once you unravel this arcane language, you'll soon see that most of the babble on paper is a euphemism for things in the vulgar, material world. After reading one paper, I spent weeks wondering what was the "background, ultraviolet radiation" that interfered with photometers during the day. Then, my professor pointed out that it was sunlight. Learning to understand scientific papers requires you to think in a new way, and I have found some tips helpful for making this process easier.

Some Useful Tips

  • Have a Research Goal
  • The usual research goal is conducting a similar experiment. But it could also be writing a book, writing a blog post, inventing an instrument, make a lifestyle change, or learning about cutting edge technology. Whatever the goal is, this will help inspire interest and give you focus while you are reading. The research goal also gives you an application for your newly acquired knowledge, making you an active learner with better retention. Because you are taking knowledge from the abstract context of the paper to the practical level, your comprehension will improve.

  • Print Hard Copies and Annotate
  • The research goal should dictate what notes you will take. I prefer to use something conspicuous like a red pen.

  • Highlight Spelled-out Abbreviations
  • This will help you keep track of the countless abbreviations that follow. Scientists love to abbreviate, and they do it very often.

  • Read Multiple papers in the same area of research
  • Some papers explain different parts of the research better than others, which is helpful when you can not understand one paper at all. In addition, scientific papers often reference and compare their methods to other researcher's methods. Sometimes they use a theory from other researchers, but they barely explain it. So, reading the other papers will help you follow those discussions. A good source of further reading material is the References at the end of the paper.

  • Make Mnemonics to remember basic scientific facts
  • Knowing your basic scientific concepts can make it easier to visualize and understand what's happening in the experiment. For instance, the aeronomy papers I'm reading often talk about instruments taking measurements in the upper-mesosphere and thermosphere. To imagine where these instruments are, I made up a mnemonic for the atmospheric layers in order of descending altitude: "Emus Train My Scarlet Tiger". This stands for Exosphere, Thermosphere, Mesosphere, Stratosphere, Troposphere. Now, I know that the instruments are flying in the second and third highest layers of the atmosphere. That's higher than airplane and weather balloon flights, so you'd need a rocket to get that high! Just by knowing this little mnemonic, I can imagine where the experiment is taking place.

  • Reread and persist
  • Sometimes, you make new connections after the second or third time. This happens especially after you read other sources or look up new definitions.

  • Try to explain it to others
  • Just like having a research goal, having to teach others forces you to bring all those abstract ideas down to a practical level. There's also that cliche that you remember 90% of what you teach. You can do this by having conversations, writing blog posts, making an infographic, or making your own Dummy's guide. Just be sure that you don't end up over-simplifying concepts or "dumbing down" the information. From my experience, the most complex concepts and still be accurately communicated to the average person as long as you elaborate enough and include appropriate comparisons. There may be technical details that you omit because they aren't relevant to understanding the purpose and implications of the research.


    For me, reading scientific papers has been an intellectually humbling experience. It also made me more capable of independent thinking. Because of this, I think that proponents of scientific literacy should encourage students to read scientific papers from the databases instead of second-hand from scientific articles or pop science books. Students can benefit by overcoming their intimidation of science, and they can make more informed decisions about their health, environmental policies, and scientific funding. At the very least, it's one way to show off your education to friends and family members.

    Thursday, June 30, 2016

    Understanding a Scientific Paper (Part 1)

    This image is from The Scientific Cartoonist
    Scientific papers are the most arcane pieces of literature I've ever encountered. They make Nietzsche and Rousseau look like child's play. I had to read more than ten different papers over the course of three months before I understood any of them. Now, I think everyone should go through this trial, so they challenge their minds to understand new and abstract concepts. Scientific literature, unlike liberal education, makes you understand the objective world on a deeper level, and I would argue that it's more intellectually rigorous. Besides that, I also believe that we have a civic duty to become scientifically literate. We need to be responsible consumers and voters. Reading articles from scientific news outlets isn't enough for me because most articles lack enough detail for me learn about the theory and methodology. Also, some outlets such as Yahoo! Science are ad-ridden and poorly edited. And, the studies can be misrepresented or fraudulent. This isn't an article about judging the validity of a paper, which is a useful skill for reading papers from open access journals. Nor is it an article on finding scientific papers; getting around the steep paywall is a topic for another post. This is about learning how to think like a researcher.

    Recommended Prerequisites

    • Natural Science:University Physics and Calculus
    • This is especially important if you are interested in astronomy, aeronomy, or even chemistry. It will allow you to have some understanding of the formulas and graphs. In addition, you will frequently see some basic terms such as "vector", "momentum", "derivative", etc. If you haven't taken the AP or college classes yet, Khan Academy and other online courses are a great resource. Just make sure you are taking University Physics which is calculus-based, not algebra-based "College Physics". Make sure you have learned differential, integral, and multi-variable calculus. If you want to read some of the more advanced literature, mechanics will also be useful.
    • Life Science: Biology, Chemistry, Anatomy and Physiology
    • This applies to medical, as well as biology papers. I've been able to understand most of the biology papers with only a high school education in those three subjects.
    • Social Sciences: Statistics and Probability
    • These prerequisites are not necessary for comprehension, but they're vital for judging the validity of the paper. The social sciences have a reputation for producing studies with less reproducible results and are more prone to researcher bias, so you will need to be aware of any statistical manipulation. Economics is more rigorous, so I would recommend learning Differential and Integral Calculus as well.

    Parts of Research Paper

    The outline described here is based on the papers I've read in the natural sciences. Other studies studies might have a different format. After reading each section, you should have learned about a certain aspect of the research. I've including some questions that can act as comprehension checkpoints.
    • Abstract
    • This is similar to the blurb on the cover of a novel. It's supposed to give you a brief idea of what the paper is about, and this is where you decide if the article is worth reading.
      Ask yourself, "What are these researchers studying? What contribution have they made to their field? Is this paper relevant to me?".
    • Introduction
    • This is where you can learn the background information about the paper's field of research. It may include an explanation for the phenomena, examples of past experiments done, and the typical instruments used. If you are entirely unfamiliar with this field, you should read the introductions of multiple papers before proceeding into the next section.
      Ask yourself, "What do the experts currently know about this topic? What is the phenomena? What causes the phenomena?
    • Observations/Data
    • This is where you'll see most of the graphs and tables for this experiment. Besides the figures, the paragraphs will tell you under what conditions this data was collected. The paragraphs often describe interesting events that affect the shape of the graphs, so look out for that. There may also be separate sections devoted to the instrument used, the method of data analysis, and the model chosen for comparing the experimental data.
      Ask yourself, "What's the dependent and independent variable? Why did the researchers study these variables? Did the researchers find a correlation? Where in the graph is the event described in the paragraphs?
    • Discussions
    • Here, the researchers interpret their results. Researchers will identify prominent trends and relationships. They may also compare their results to previous experiments or speculate about the causes behind their findings.
      Ask yourself, "What did the researchers discover? What were the likely causes behind their findings?"
    • Conclusion
    • This is the summary of the study. In addition, the researchers discuss the significance of their findings and how it would impact their field. They may also give suggestions for future studies in this field.
      Ask yourself, "What impact does this study have on its field? this How will future researchers build top of their work? References This is the list of all the sources cited in the paper. You should use to learn more about a theory or past experiment that's briefly mentioned. On online versions, you can click the doi number which is linked to where the source is published. Ask yourself, "Is there anything in the paper that the author barely explained, but I need to learn more? Does it have a citation?

    Looking up Unknown Terms

    Throughout your reading, you will definitely encounter a lot of jargon that can't easily be clarified with a Google search. While Wikipedia is likely to have an article on most of these terms, it has a weak editing system and it can be inaccurate. So, it should only be a last resort. Here are the best references I've found. Each one addresses a particular need, and I listed them in order from most general to most specialized.
    • The Free Dictionary
    • This site is best for getting a quick definition on basic concepts e.g gravity waves, ordinate, tidal force, etc. I prefer this dictionary over others such as Merriam-Webster because it includes graphics and it has the widest range of scientific terms in my experience.
    • The Encyclopedia Britannica
    • This source will give you a good background on the paper's subject matter or the instruments used. It has many factual, well-organized, and easily understandable articles with plenty of graphics. It's a good place to become familiar with the scientific concepts before getting exposed to the academic language. Searchable topics include nuclear fission, Fabry-Perot interferometer, and chaos theory.
    • Wolfram's Mathworld
    • This is the go-to place for mathematical equations and definitions. It will give you the formal definition, properties, explanations for variables, derivations, and applications.You can look up series, knots, theorems, etc. It's difficult to understand for people with a limited background in math, but at least each article included links to each concept that the topic is built upon.
    • Scholarpedia
    • This online encyclopedia has peer-reviewed articles by the scientific community. So, it's the scientists' attempt to make highly specialized knowledge accessible to the public. It's not so good for looking up general terms used in science that you can look-up using The Free Dictionary. However, it's the best source for finding esoteric theories and phenomena such as the Kelvin-Helmholtz instability or Hydromagnetic-Dynamo Theory. If the term is named after a scientist or will probably never be mentioned in a pop science discussion, you are more likely to find it in this source. Strangely, it doesn't bother to include articles about widely known scientific ideas such as climate change or string theory.
    By now, you should know how to fill any gaps of knowledge when reading a scientific paper. This post covered what background knowledge you need, what you are supposed to learn from each section of the paper, and what resource materials you can use to further your understanding. This post turned out much longer than I expected, so I will have to continue on in the next post. In Part 2, I will give additional advice that will help make this process easier.

    Friday, September 18, 2015

    Online Textbook Shopping Guide For College Students

           I am one of the students that made the mistake of ordering all of my textbooks online the day before the start of the fall semester, and I lost 2 weeks for studying the material. Poor preparation can lead to falling behind in class and making the transition to college much more difficult than it has to be. Online shopping can be a miraculous cost-cutting and time saving tool for textbooks, but it requires planning in advance. By following the basic tips and choose the right sites, you will be able to use online shopping to your best advantage.

    Dos & Don'ts:

    • DON'T wait until the last minute
    • Online shipping typically takes about 1-2 weeks. In addition to that, getting your textbooks early will allow you to look over the first few chapters before class starts. That way, you will at least have some familiarity with the concepts and better understand the lectures. Some of these lectures can include bizarre, new information that would make unprepared students feel lost. For instance, my first few chemistry lectures discussed quantum physics which is far from what I expected.
    • DO check the class syllabus beforehand:
    • You do not need to wait until the professors tell you what books you need in the first lectures.The syllabi are typically mailed to each student within 3-5 weeks before the semester starts. Otherwise, they might be on your student login accounts. If the class does not provide a syllabus or mention a required text, it's safe to assume that the class does not have a required text.
    • DON'T buy the wrong translations of books for literature classes
    • Because the translation will affect your interpretation of the text and these types of books will be referenced frequently by page number, having the right version will affect how well you can participate in class discussions and persuade your professors in the critical analysis essays.
    • DO buy previous editions of textbooks by the same author
    • These editions of the textbook provide the same material at a fraction of the cost. According to Debt-Free U by Zac Bissonnette, college textbook companies often make small changes to new editions in order to generate more profit. In my experience, the old edition of the textbook slightly differs in the order of the chapters. However, the content almost exactly matches that of the lecture.
    • DO search by ISBN number
    • By copying and pasting this number from your class syllabus into the website search engine, you will be directed to the exact product you need and save time. You can look for previous editions in the sidebar as needed.
    • DO buy used:
    • On the websites I've visited, the description of the book quality is accurate. If you buy a "fair" copy at worst, you do not have to worry about the book falling apart or being damaged. You'll probably find highlighted text and other people's notes in the margins, but the text itself remains legible.
    • DO Rent
    • This is the best option for non-literature books that have no previous editions and you need it for a core course that you don't particularly care for. The rent lasts for one semester and some sites will even cut the shipping costs.
    • DO buy from multiple sites
    • Some sites have better deals or a better selection than others.
    • DO group as many books as possible in each purchase
    • This will often qualify you for coupon discounts and free shipping for qualified products.
    • DO remember shipping costs
    • Sites have differing shipping costs and policies. In general, avoid the expensive expedited shipping options and look out for free shipping deals.
    • DO sign up for site accounts and newsletters
    • The budget book sites often send coupons to their subscribers. These mails don't come more than once a week and they come just in time for you to buy the next set of textbook. The savings usually amount to less than 10-15% and the coupons only apply if you spend over a certain amount of money, but it's a simple move to save a few bucks. Plus, having a site account will help you keep track of your purchases and get access to deals.
    • DO leave customer feedback
    • It's an easy way to show gratitude to these sites and help them improve their service.

    Quick Site Reviews

         This is the first place I go for textbooks because purchases over $10 get free-shipping, the prices are the cheapest I've encountered, and the deals are the most generous. The shipping (listed as 4-14 business days) is also faster than the other sites I've used. However, the selection is more limited and items go out of stock fast. You will probably find only a small portion of the textbooks you need here.
    On the other hand, this site is has a wider selection and is better stocked. I have had success in finding all of the textbooks I need at great prices. If you have an account, that also saves you the extra hassle of of having to fill in your shipping address every time. Shipping is typically $3.99 per book, so I do tend to see my final costs double. Very few books have free shipping options. Also, I've been experiencing a time-consuming technical difficulty on the site: the website frequently logs out of my account when I go to a different page on the website. by eBay: Buy and Sell new and used books, music, movies, games and more...
    This site also has a wide selection and the same shipping prices as alibris. Both sites have the same price range, too. The rent options are cheaper and you can find more alternative editions than you would on alibris. One downside is that you need an eBay account to make the purchase and I've had trouble signing into my account on this site.
    While shopping for the spring semester, I found that Amazon offers a better deal on literary books than alibris and The lowest prices for the latter two is $0.99 while Amazon's is $0.01 with all three having the same standard shipping costs. Amazon has the free shipping option for slightly higher priced books, but it only applies if you are buying enough eligible items that cost at least $35 together. Also, you may want to pay attention to the estimated tax and ideally get the books with $0.00 estimated tax. Generally, the textbooks aren't good deals compared to the others, but the handbooks can be cheaper. The site is a lot easier to use than some of the others. If you have an account, you can save your credit card information in addition to your shipping address. This is a great time-saver, though it does pose a security concern.
    Image result for barnes and noble banner

    Barnes and Noble runs my campus bookstore, and I assume that other colleges have their own Barnes and Noble. Even with the online option, this is my least favorite place to buy textbooks. Instead of a search engine, the website has a form that you have to fill out with the semester, class subject, class number, and class section. Then, the computer algorithm fetches all of the books you need. This is a much more tedious process than pasting in the ISBN number and it makes the site harder to navigate. In addition, the prices are much higher than the other sites and you do not get the option of choosing different editions. Whether you purchase in-store or pick-up in store, you will also have to wait in long lines especially at the beginning of the semester. The only good reason to buy from your campus bookstore is if you have to purchase an access code for a particular class.

    From my university bookstore, I would have to spend $383.70 for one semester of textbooks that included used copies. For the same books, I paid $83.67 on the other websites I listed. In addition, I did not have to wait for hours in university bookstore lines. With planned online shopping, you can eliminate textbook cost concerns and focus more on actually learning the material.

    Tuesday, August 4, 2015

    123D Circuits

    The Lab View

    For people like me who can't afford electronics kits and are worried about getting electrocuted during a project, 123D Circuits is a wonderful, free online resource that will allow you to learn the basics of electronics with online simulations and helpful guides. This website is run by AutoDesk which also creates 3D modeling applications such as Tinkercad and 123D design.


    • Three views in 123D Circuits: Lab View, Schematics View, PCB view.
    • Design Modes: Electronics Lab, PCB, and Circuit Scribe 
    • basic components such as LEDs, capacitors, diodes, breadboards, etc
    • everything from the Arduino basic kit and a code editor
    • Video Tutorials for Newbies
    • No download
    • Gallery of everyone's designs
    • A Shop for ordering any of the designs in the gallery
    The Schematics View

    The Educational Impact:

    There are currently many free and accessible online resources for people to learn about computer science and programming, but online resources to learn about the hardware side of technology is not as readily available. For instance, the MOOC (Massive Open Online Course website edX has 66 computer science courses and only 8 electronics courses as of today. Hopefully with websites like 123D Circuits, the number of tutorials and MOOCs for electronics based on building circuits will grow. Similar to how online coding tutorials allow many programmers to become professionals without formal schooling, these new resources for electronics can open non-degree opportunities such as becoming a chip designer, an inventor, or even an electrical engineer. 
    The PCB View