## Correspondent

## Charles in NJ

**Host ID**: 229**email:** __catintp.nospam@nospam.yahoo.com__**episodes: 12**

### hpr1935 :: Quick Bashpodder Fix

Released on 2016-01-01 under a CC-BY-SA license.Bashpodder is a great Bash script for downloading the latest episodes of podcasts and other media from their feeds.

There are a few feeds that are not handled properly by Bashpodder, namely, the TED Talks podcast feed and the NPR digest show called the TED Radio Hour.

The URLs for the audio files have a number of additional fields at the end of the string after the media file name, and Bashpodder picks up the last field as if it were the media file name for the show. So every TED Radio Hour episode is called "510298". If you download more than one episode at a time, only the last episode to be saved will survive. Each new file clobbers the last one, because they all get the same filename.

Charles in NJ made a simple fix to Bashpodder.shell to correct this problem, and he shares it in this episode.

## Links:

- Bashpodder: http://lincgeek.org/bashpodder
- TED Talks: http://blog.ted.com/audio_podcasts/
- TED Radio Hour: http://www.npr.org/podcasts/510298/ted-radio-hour
## Additional Resources:

- Original version of Bashpodder.shell

http://hackerpublicradio.org/eps/hpr1935-bashpodder_original.shell- Revised version with fixes to pick up TED-related podcast files

http://hackerpublicradio.org/eps/hpr1935-bashpodder.shell- Abbreviated example of bp.conf configuration file that tells Bashpodder what resources to fetch

http://hackerpublicradio.org/eps/hpr1935-bp.conf- Abbreviated example of podcast.log that shows how Bashpodder stores its history, including some sample TED links.

http://hackerpublicradio.org/eps/hpr1935-podcast.logHappy New Year from Charles in NJ.

### hpr1786 :: What is MapReduce?

Released on 2015-06-08 under a CC-BY-SA license.Shownotes in pdf format

Shownotes in docx format

## What is MapReduce, Anyway?

MapReduce is inspired by three approaches from functional programming for applying a function to each item of a collection of data, namely, Map, Filter and Reduce. That is pretty abstract, so I will try to bring some of these ideas down to Earth. I'll use lists to represent the “data” in any examples, but the concepts in MapReduce can apply equally well to any data source: multiple streams from the Internet, a number of internal data stores from multiple sites, and even user keystrokes/mouse moves.

If a function (or operation) can be applied to each item in some kind of input data, you may be able to use map, filter and reduce.

## Defining Terms

## Map

When we use the expression Map(function: f, data: [1,2,3,4,5,6]), we are declaring that we want to apply the function "f" to each element in the data. In this case, we have a list of numbers, but the data could be names, employee records, or URLs for Internet documents from the Internet that we would like to parse to extract useful information.

Example: function f is square(x) = x * x, and the data is our list [1..6].

Map( square(x), [1,2,3,4,5,6]) = [square(1),square(2), ..., square(6)], or [1, 4, 9, 16, 25, 36]## Filter

Filtering data is essentially a variation of Map. You could think of it in two stages:

Apply a "test" function to Map each item to either True or False ("In" or "Out")

Use the results of that Map operation to drop any item that fails the test (False)

Having said this, a Filter does not have to be implemented in this way. By declaring that we want to use a Filter operation, we have specified WHAT we want to do. It really does not matter HOW it gets done.

Most functional programming tutorials would illustrate a Filter by selecting prime numbers from a list of integers, or to isolate numbers that are not multiples of 3. A more useful illustration of Filter is a search filter that reviews documents in a repository, or a set of search engine results, and returns only those that pass the "relevance test". The test itself could be defined using a "fuzzy" criterion for relevance (0-20% Not, 20-50% A Little, 50-75% Fairly, > 75% Very -- or what have you), but the end result is that you'll choose some documents to accept, and omit the rest.

In a filter operation on a large number of data items, you might want to drop the items as early as possible. There is no law that requires you to make these decisions in advance when you offer Map or Filter operations on a server.

In a MapReduce context, Map and Filter will often end up lumped together. This is fine, because you don't want to waste processing time to perform potentially expensive transformations on data or documents that you can rule out immediately with a less computationally expensive filter.

## Reduce

A Reduce operation on a collection of data is any kind of aggregate operation that boils down all of the detail items into one or more summary metrics computed on the (filtered) data. The canonical examples of a Reduce operation would be a Sum or a Count, but there are other possibilities.

Reduce is usually defined as an operation:

Reduce(function(accumulator, data item) -> new accumulator value; initial value; data).

Sometimes, you may see the Reduce operation defined recursively:

Reduce( function: f, initial_value, data = {first_item, all_other_items} ) is equal to Reduce ( function: f, new_value = f(initial_value, first_item), data: {all_other_items})If you follow that script, you can just rinse-and-repeat until you've processed all of the items.

## Why is this some kind of technological advance?

If you look at this characterization of Map and Reduce, you'll see that these operations are fairly abstract. The declarations typically state only what needs to be done, and the implementation steps that specify how it is to be done are left open.

For operations on data items that are fairly independent of each other, there are advantages in defining things in this way. If there are no dependencies between data items, in the sense of the two rules listed below, you can use distributed processing across several "servers" to get to the result for the entire data collection much faster.

Basic ground rules for the simplest case (Exceptions and additional constraints will apply in real projects):

Computations for each data item do not depend on those for other data items, so no communication, coordination or shared memory is needed between "worker" machines.

The order of the computations does not matter.

Under these conditions, Map and Reduce operations could be outsourced from a MapReduce server installation to a fleet of "worker" computers that can take on pieces of the overall computation, and send their results back to the Aggregation Server (or "Boss" machine). That could give you a tremendous speed-up over the alternative of running on a single computing cluster. So there can be speed advantages that come from MapReduce.

With the right infrastructure, you can relax these constraints and still get many of the same benefits on data that needs to be ordered or preprocessed into some kind of table structure.

Another advantage of the Boss/Workers paradigm for MapReduce operations, which may be less obvious, is fault tolerance. Computers sometimes fail to complete their assigned tasks. Network connections can be lost. In a Boss/Workers setup, a Worker could send a status report back to the Boss machine (or a Supervisor, since even the Boss role can be shared) that either contains a SUCCESS status flag and the results of its assignment, or a FAILED flag.

If a Boss receives a FAILED message, that piece of the overall computation could be re-assigned to other Worker(s). In the case of a network outage, the Boss could respond to a Timeout event for the Worker, flush that assignment to that Worker, and re-assign the unfinished task to other resources with a new unique ID. Any homework that is turned in after the Timeout event can then be ignored.

Note: This is just one way to build in parallelism and fault tolerance.

An additional advantage to this sort of vague definition of MapReduce tasks is the ability to work with distributed data in a way that allows greater use of local processing. A central server (Hub) processing model forces remote sites to transmit all the original data to the Hub, wait for the Hub to do the processing, and then possibly transfer the processed results back from the Hub to the remote data repository. That's a lot of network traffic, any part of which could be lost, corrupted or even intercepted by third parties.

In a Reduce operation, where everything is boiled down to some [set of] summary measures, the local site could do much of the processing work, and transmit only the needed intermediate results to the Boss back at the Hub for inclusion in the final totals over all Worker machines.

Summary: Leaving the implementation details out of the MapReduce specification allows for flexibility and some degree of optimization in getting these operations done in the most beneficial way.

You can optimize to save time, even if that means spending more on hardware and communications.

You can design to save money (local processing, servers that are easier to replace, etc.).

Whatever your objectives, you can adjust your implementation to get the best result for your application.

## Enter Hadoop.

Hadoop is an open source project from the Apache Foundation that lets you set up massively parallel distributed processing schemes for computations that can be fit into the MapReduce paradigm. The best part is that you can make Hadoop work on varying types of hardware, so you don't need to run the pieces of computational work solely on high-end, expensive supercomputers or complex computing cluster installations.

Hadoop makes it possible to farm out the bits of computational "homework" to "commodity hardware" – whatever that may mean for your installation. Commodity hardware is also an abstract term. In practice, you can match the level of computing power for Workers to meet the requirements of the assigned work. The worker machines could be set up on computers that are easy to provision and replace, so you won't have to buy special-purpose servers that require extended periods for setup and configuration.

MapReduce does NOT refer to the process of splitting up a large data processing job into assignments. The concepts behind MapReduce help us to think about and plan classes of processing tasks that are frequently applied to large datasets, or to a lot of data streams that are coming in from many sources and locations.

So far, it sounds like MapReduce and Hadoop are a kind of silver bullet that can eliminate the time and expense required to solve “Big Data” problems. As helpful as these ideas and their supporting technologies may be, not every potential MapReduce job can be optimized as much as we might like. Hadoop will not offer a cure-all for every problem.

We still have to understand the problem, determine what is needed, and work hard to do the right thing.

But when there is a good fit between the problem and this approach toward providing a solution, Hadoop and MapReduce can be very helpful.

### hpr1510 :: What's in My Bag?

Released on 2014-05-16 under a CC-BY-SA license.This episode is a just-for-fun show in which I walk systematically through the bags I was carrying to work on a particular day, and describe what I have found inside.

### hpr1508 :: In Defense of Play

Released on 2014-05-14 under a CC-BY-SA license.This episode is a just-for-fun show in which I make a few observations in defense of just playing around. We need to stop worrying about work and to-do lists every once in a while in order to just get up off our chairs and do something that is fun. It doesn't have to have a structure at first, but it should involve a challenge or exposure to at least one new thing, or place, or person, or idea. I think it is the best way to learn, because the knowledge and acquisition of skills sneak up on you while you are having fun. It may be the only way to make learning really stick, and to stick with the learning process.

## Links

Dr. Peter Gray on the Play Deficit: http://aeon.co/magazine/being-human/children-today-are-suffering-a-severe-deficit-of-play/

Articles from the Journal of Play: http://www.ecswe.org/wren/researchpapers_theimportanceofplay.html

### hpr1502 :: Practical Math - Units - Distances and Area, Part 2

Released on 2014-05-06 under a CC-BY-SA license.HPR Episode: Using and Converting Between Units of Distance Intro: Last time, we talked in general terms about units, numbers and how they might be useful in practice. In this episode, we address some specific measurement units that apply to distance and area, and how we might convert from one system to another to better understand both. Entire point of this episode is this: Carry units in calculations on distances and areas, and you'll have more success in using them in your life. Segment 1: Review of Distance and Area conversions in the English system 1. Links from last time Table of Units: http://www.csgnetwork.com/converttable.html To see why the story is tremendously more complicated than my account http://en.wikipedia.com/wiki/Mile Fun article on the mile. http://www.sizes.com/units/mile.htm High school student theme on the furlong. http://www.writework.com/essay/history-furlong by silverAlex2000 Brief dictionary article on the mile, referenced by Dr. Math http://www.unc.edu/~rowlett/units/dictM.html#mile Referred by http://mathforum.org/library/drmath/view/61126.html Resource: StackExchange Physics and Maths sections ("mile" question) http://physics.stackexchange.com/questions/57785/difference-between-nautical-and-terrestrial-miles 2. Converting between units a. Units of distance usually defined as multiples of each other - 1 mile = 5,280 feet - 1 hand = 4 inches - 1 foot = 12 inches - 1 yard = 36 inches Skipping ahead to look at the metric system, we now have: - 1 inch = 2.54 centimeters (exact). Regularized in recent years. b. This works because there's consensus on Zero distance, so we don't have to adjust for differing origins, as we do with the non-absolute temperature scales like Fahrenheit and Celsius. - We'll get to temperature, non-absolute scales in a later show. c. For absolute scales, we can convert from one unit to another using a "conversion factor". That is, we can convert a measurement expressed in one unit to its equivalent in another unit by multiplying or dividing by some number to stretch or compress the original unit to match the target unit. - Example: I know that 1 foot is 12 inches, so how many inches are there in 10 feet? How feet are there in 660 inches? - It is clear that a factor of 12 ought to be involved, but how do I know when to multiply or divide by 12 in the conversion? - Wait! I'm serious. When you see this problem for the first time, you have to think this through to get it right. * Without a system in place, you always have to think about it. - Answers in naive setup: (i) 10 feet = (12 * 10) inches = 120 inches (ii) 660 inches = (660 / 12) feet = 55 feet 3. Having a system. Or units conversion as "multiplying by One" a. In each of the solutions I wrote down above, I start with an equation that looks like this: X inches = Y feet. b. Inches are not feet, and this way of writing down the calculation does NOT help you figure you how the conversions should work, or whether you should multiply or divide to get the right answers. c. Here's a system for creating conversion factors that tell you what to do at each step in the units conversion process. It is based on the very obvious fact that when I multiply any number by '1', its value remains unchanged. - Start with one of the identities we wrote down at the beginning. In this case, let's use: 12 inches = 1 foot - If I divide equals by equals, the results are equal. So I can write: 12 inches 1 foot 12 inches = 1 foot implies that --------- = --------- = 1 1 foot 12 inches - Get the first term by dividing my original identity by (1 foot). - Get the second term by dividing my original identity by (12 in). d. To make a conversion from feet to inches, I use: 12 in 10 ft 10 ft * 1 = 10 ft * ------- = ------ * 12 in = 10 * 12 in = 120 in 1 ft 1 ft - Note: In the fraction (10 ft) / (1 ft), the units "cancel out", which leaves a unitless number. - Suppose we start with the other form for the conversion factor: 1 ft 10 square feet 10 feet * 1 = 10 feet * ------ = -------------- = ??? 12 in 12 inches - See? When I use the form where the units don't cancel each other, I get a resulting equation that is still correct. It just doesn't make much sense to me as a reader. - This is what you get when you "divide by 12" to convert feet to inches, but the difference is that you KNOW something's wrong. - You do not have to even look at the numbers to know that this could not possibly be the right number of inches in 10 feet. Brilliant Insight #2: When you use unit conversion factors, you help your cause by carrying along both sets of units in the form of a fraction as you go through your calculation. - If the units on the right-hand side of your final equation don't match the units you want (after everything else cancels out), your numerical answer is almost certainly WRONG. - The implication here? To convert units of distance, you need to multiply or divide by a conversion factor = (X New_Units) / (Y Old_Units). When you do this, write the conversion factor in its full fractional form, and carry out all of the multiplications and cancellations. - If you do the conversion this way, and the units match, you only have to check your arithmetic to be sure you've got it right. - If the units you want do not match those on the right side of the equal sign, you are solving the wrong problem. The equation may be correct, but it is not expressed in the units you wanted. 6. Let's use the system to solve the second example: 1 ft 660 in * 1 ft 660 in * 1 = 660 in * ------- = --------------- = 55 feet 12 in 12 in Why? The "inches" units cancel out because they appear in both numerator and denominator (top/bottom, upstairs/downstairs) of the fraction in the next to last term, leaving only "feet". Why people hate units and conversion problems: http://www.regentsprep.org/regents/math/algebra/am2/leseng.htm Comment: The "algebraic" approach suggested here is ugly, ad hoc in nature, and unnecessarily complicated. Forget about setting up equations and going through formal operations to solve them. Choose your conversion factors so that the units work out properly as a straight multiplication problem with cancellation of all the units you don't want. You may have to "divide" numbers, but you can use your calculator for working through the numbers. Cranky Summary: You should not have to solve equations to convert between units. Phooey on anyone who says otherwise. :-) Segment 2: Conversions using compound conversion factors. 1. Suppose I want to find the number of inches in a furlong, or the number of acres (or hectares) in a square mile? - My almanac doesn't carry these conversion factors, so I start with what I do have and work my way through it. 4 rods 16.5 ft 12 in 1 furlong = 10 chains = 10 chains * ------- * ------- * ------- 1 chain 1 rod 1 ft = 10 * 4 * 16.5 * 12 inches = ... = 7920 inches 2. For acres in a square mile (1 mi^2), we have a bit more to do. Abbreviations used: miles = mi, furlong = fur, chain = ch Area means that we are dealing in two dimensions, so we have to convert the lengths in each dimension. An acre is already a measure of area, so we're good. 1 acre 10 ch 8 fur 10 ch 8 fur 1 sq mi = 1 mi^2 * -------- * ------ * ----- * ----- * ----- 10 ch^2 1 fur 1 mi 1 fur 1 mi = (1 mi * 1 mi) * 1 acre * 10 ch * 10 ch 8 fur * 8 fur ------------- * ------------- 10 ch * ch 1 mi * 1 mi Units cancel, leaving this: 1 sq mi = 1 acre * (100/10) * (8 * 8) = 10 * 64 acres = 640 acres Segment 3: Hey! Ready to try metric? 1. Metric system never caught on in the US, although most of English- speaking world has adopted it. Units conversion is easy in the metric system, because everything is in powers of 10. - But you still need to carry along units in calculations! 2. Area and distance units in the metric system - Basics of distance: Centimeter is easy for us to see, and now the factor to convert centimeters to inches is exact. 1 inch = 2.54 centimeters (cm) exactly 1 inch 1 meter = 100 cm = 100 cm * --------- = 39.37 in (approximate) 2.54 cm 1 kilometer = 1,000 meters - Basics of area: 1 are = 100 sq meters (area of a square that's 10m on each side) 100 sq m 1 hectare = 100 ares = 100 ares * ---------- = 10,000 sq meters 1 are 3. For short distances, we should do our conversions fairly precisely. - There's usually a higher relative error from rounding off too soon. - If you measure wood for a small project, you want to be "close". 2.54 cm So 1 foot = 12 in * --------- = 30.48 cm exactly. Cut carefully! 1 in 4. For larger distances, like distances covered in track and field, or the length of a football pitch (to a spectator), approximations can give you a nice intuition for comparing units you know and a new set of units that you don't know as well. - 1 meter is around 39.37 inches. Suppose I call it about 1.10 yards as a kind of approximate benchmark (39.60 in), so each meter in my reckoning is about a quarter of an inch too long? - If I'm planning a space mission, I could be in trouble. But how bad would this be for getting an intuitive feel of the distances covered by the athletes in the Olympic Games? - Error at 100 meters is about 0.23 in (0.6 cm) * 100 = 60 cm over at 200 meters, it's 1.1 m over. at 1 kilometer, it's 5.6 m over. Unless you're a long-range sharpshooter, 5.6m off in 1 km seems OK. 5. Bonus: The news talked about a wildfire that burned 100,000 hectares. What kind of area are we talking about? - Let's use our approxmation of 1 meter is about 1.1 yards. - Acres are defined in terms of "square chains", so let's look at meters vs chains to see what we get. 1 m 1 chain = 4 linear rods = 22 yds = 22 yds * -------- = about 20m 1.1 yd 20m 20m 1 acre = 10 square chains = 10 ch * 1 ch * ----- * ------ 1 ch 1 ch = 10 * 1 * 20m * 20m = 4,000 square meters, or 0.4 hectares - Wow! An acre's about 0.4 hectares, or 1 hectare's about 2.5 acres. So what's the answer? 2.5 acres a) 100,000 hectares = 100,000 hectares * --------- = 250,000 acres 1 hectare 1 sq. mi 250,000 b) 100,000 hectares = 250,000 acres * --------- = ------- sq. mi 640 acres 640 = 391 sq. miles (about 400 sq miles) Note: This suggests a shortcut conversion (hectares to square miles). 640 acres 1 hectare 1 square mile = 1 sq. mile * --------- * --------- = 256 hectares 1 sq. mi. 2.5 acres 6. Final check: Error analysis on this approximate conversion from hectares to acres or square miles. - Using Google or 'units' in the shell, we have: 1 sq mi = 259 hectares to 6 significant digits, versus 256 (1%) Note: If we used 250 hectares per square mile, the relative error is 3.5%. That's less than the error in the news report. 1 hectare = 2.47105 acres, versus 2.5 (1% error) Units shell command: Dann Washko did a really nice job on 'units' for HPR. * Linux in the Shell #26: http://www.linuxintheshell.org/ * HPR Episode #1213: http://hackerpublicradio.org/eps.php?id=1213 Final word: Unless you are buying, selling or cultivating land, use the cruder approximations here to understand the relationships between acres, hectares and square miles. It will make you seem smarter. - If someone calls you out and says it's wrong, blame "that guy on HPR." Next Topic? Volumes and recipes, other than medicines (separate topic) - Volumes are the bottom line in cooking, unless they aren't. - Hint: You should weigh some items, like some kinds of flour.

### hpr1499 :: How I Got Into Computers

Released on 2014-05-01 under a CC-BY-SA license.HPR Episode: How I Got Into Computers 1. Got into computers in 1974 in high school. - School had a DEC PDP-11/20 minicomputer * Two ASR-33 Teletype terminals, keypunch, line printer, card sorter * Ran older operating system RSTS-11 v4a - Too low-end to run anything more recent. - 16K words of core memory: point-to-point wired "cores" - The system was somewhat rudimentary. It's idea of a prompt was: READY - A Teletype terminal does not have a screen, so the print head was the only "cursor" to let you know where you are. Hardware: PDP-11/20: Computer Museum http://www.computerhistory.org/revolution/minicomputers/11/366/1946 PDP-11/20: Retro Technology http://www.retrotechnology.com/pdp11/exhibit/PDP_11_infoage_1.htm ASR Model 33 Teletype with PDP-11 model computers http://www.retrotechnology.com/pdp11/ Operating System: RSTS-11 System Managers Guide http://bitsavers.trailing-edge.com/pdf/dec/pdp11/rsts/V04/DEC-11-ORSMA-B-D_RSTSmgr_73.pdf RSTS-11 System Users Guide http://bitsavers.trailing-edge.com/pdf/dec/pdp11/rsts/V06/DEC-11-ORSUA-D-D_RSTS_SystemUserGuide_Jul75.pdf 2. Learned BASIC-Plus to get anywhere, starting with 1/2-year course DEC BASIC Plus Language Manual http://bitsavers.trailing-edge.com/pdf/dec/pdp11/rsts/V04/DEC-11-ORBPA-A-D_BASIC-PLUS_LangMan_Oct72.pdf * Course was taught by a math teacher who was not an amazing programmer, but he was a great teacher. He enabled us to get going with BASIC. * Anticipated pairs programming by working on programs with a friend as "Chuck and Duck Enterprises", but we were mainly having fun. - Started by necessity (1 TTY), but we got satisfying results faster - Both of us could write code, but we learned about using complementary strengths to get cool stuff done. Pairs programming: Pairs Programming, from XP http://www.extremeprogramming.org/rules/pair.html Laurie Williams (Her other stuff is good, too) http://collaboration.csc.ncsu.edu/laurie/publications.html * Small memory --> innovation - ASCII Art "Poster" Program: Create banner with block letters on LP based on terminal input. - Developed a mini-language to encode characters, white space, newlines for each supported character. - This was a special-purpose language used to compress data, rather than a cool Domain-Specific Language (DSL). - We just wanted to make cool banners to come off the line printer. Domain Specific Languages: Why ours wasn't a DSL Martin Fowler on DSLs http://martinfowler.com/tags/domain%20specific%20language.html 3. Did a math major in college, after switching away from Comp. Sci. * Math had advantages for me - More flexible curriculum - Abstractions of the time were more fun to play with * I used the University computers on jobs as research assistant, tutor, typist - Used them in course work, too. - Planning my code carefully let me use my excess CPU seconds for fun - Rule of Thumb: 1 hour in library is worth 12 hours at the terminal. 4. Branching out in hardware, systems and programming languages * We learned FORTRAN in the programming courses - I resisted the temptation to "think in FORTRAN" - More general approach felt slower for getting individual jobs done. - Working from first principles seemed more reliable - Often gave me better solutions than following my nose in FORTRAN Quirky FORTRAN Preprocessor for Structured Programming (SF/K) http://www.worldcat.org/title/fundamentals-of-structured-programming-using-fortran-with-sfk-and-watfiv-s/oclc/301094243 * Later, I picked up Pascal and TOPS-20 Assembly Language Pascal: From the source Pascal User Manual and Report (Springer) Trade paperback (1975) by Kathleen Jensen, K Jensen, N Wirth Trade paperback, Springer, 1975. English 2nd ed. 167 pages ISBN: 0387901442 ISBN-13: 9780387901442 5. Gear and software rundown: * Xerox/Honeywell Sigma Six (descended from Scientific Data Systems) (1977 to 1979) http://en.wikipedia.org/wiki/CP-V_operating_system http://en.wikipedia.org/wiki/SDS_Sigma_series * DEC System 2060 (relabeled PDP-10) running TOPS-20 on a 36-bit machine (1979 to 1981) http://bitsavers.trailing-edge.com/pdf/dec/pdp10/TOPS20/DECnet-20/AA-5091B-TM_TOPS-20_DECnet-20_Programmers_Guide_Jan80.pdf http://pdp10.nocrew.org/docs/ad-h391at1.pdf DECsystem-10 and -20 Processor Ref. 6. Summer and Night Job * The Duration Caper: Friend fixing a Fortran program to compute bond duration on a large portfolio. - Answers weren't coming out, so he printed out several subtotals in his calculation. - "Extend the line" to include the last term in the numerator of one big fraction "and you'll have it" Found a typo in the Jack Clark Francis "bible" of investments theory - Throwaway question: "What's this duration stuff, anyway?" - Question got me hired as a research assistant by Finance department in Business school Investments: Analysis and Management, First Edition Hardcover(1972) by Jack Clark Francis. McGraw-Hill Book Company ISBN: 0070217858 ISBN-13: 9780070217850 * The "Sure! I Know Assembly Language" Caper Offered a job with Finance, conditional on first assignment. - Take over maintenance of a Fortran program with inline Assembly Language - Original developer was a senior Computer Science major I knew. - Gambled that his code was solid. And won in the end. Got paid 3 times minimum wage ($7.50/hour versus $2.30) to look up and read research papers. - I'd have done it for free, so this was a sweet gig. * Other jobs: - Tutoring math, computer science for food or cash - Programming jobs - Teaching assistant jobs for statistics, finance courses - Security and management of student-run darkroom in Summer months == "reading" - Typing papers on a typewriter 7. After college, started working in non-life insurance. * End user computing in actuarial group was in BASIC-Plus on PDP-11s - Word processing was in DECword or the WPS-8 dedicated machine. - After first year, moved to department-level PDP-11/44 - For heavy-duty jobs, we also had timesharing access to VAX-11/780 * First project was building a database from mainframe data dump - EBCDIC data conversion to ASCII led to my education about signed data fields in COBOL. - I knew hexadecimal math from my assembly language course - I'd seen EBCDIC in dumps while writing FORTRAN on CP-V Data dumps from 9-track to PDP-11/70 led to Overpunch field conversion http://www.3480-3590-data-conversion.com/article-signed-fields.html * Note: When you have curly braces at the end of a signed number field, the brace opens in the direction of the positive or negative end of the number line. - Open brace ({): Value ends in zero and has positive sign. Zero < X - Closing brace (}): Value ends in zero and is negative. Zero > X * If field ends in A, the value's final digit is 1, and it's positive - B means positive value that ends with a 2, C is 3, ... I is 9. - So "00003757D" is $ +375.74. * If the field ends in J-R, the value is negative and ends in 1-9. - So "00000255R" is the value $ -25.59. 8. Irony: I was asked to help troubleshoot a program that was crashing as it was automatically converting the rates and rules manuals away from Unix with 'nroff' to DECword on RSTS in 1982. - This may have delayed my adoption of Linux - Used Unix (Ultrix) in early 1990s to preprocess data for use in OS/2 - Had to move to Win 95 and Win NT for work ****** Skipping the Dark Period of DOS/Windows and OS/2 Computing ****** - Turbo Pascal, APL, PICK, QuickBasic, Visual Basic, Excel with VBA - Learned SQL dialects, COM, .Net, and scripting languages More from Dark Period: Less Slackware 8. Gave Linux a try with Quantian Live CD in 2006 (Thanks, Dirk!) http://dirk.eddelbuettel.com/quantian.html http://dirk.eddelbuettel.com/quantian-tmp.pdf (PDF description) http://dirk.eddelbuettel.com/quantian/quantian_0.7.9.2.quantian.packages.txt * Used Live CDs to try Debian packages, repair PCs, and do math stuff - Liked Gnumeric, Python, R, and educational software - Wiped my Vista laptop in April, 2008 to install Ubuntu full-time - Music, checking, and photo editing kept me from switching other PCs 9. Tried Ubuntu "Feisty" using WUBI on Windows XP on Racing Cow * Trouble-free install, mainly because I was on an Ethernet cable - Tried out Linux software in a risk-free environment to find what I liked - GNOME 2 was close enough to Windows and Mac, so no problems with UI - Command line was similar to Ultrix and even to DOS, so not so bad. * WUBI let me try Ubuntu without having to dual boot or use Live CDs - Easy to install and remove, like a Windows application - No messy virtualization setup - Linux could see and use files on my Windows partition seamlessly * Ubuntu "Hardy" on "Titanic" (retired Dell Latitude D820 laptop) - Install was easy, except for wireless networking - Had to use NDISWRAPPER at first, but everything worked. * Switched my main home desktop (Racing Cow) in April, 2011 - Just in time for Unity, which would not run on my gear. - Gnome 2 ran well on my computers, and they choked on Unity and Gnome 3. - Taste and older machines led me to go distro hopping. - Dan Lynch of Linux Outlaws pointed me to CrunchBang. Try it. http://crunchbang.org 9. Other distros I've tried: * Gentoo (June 2011): http://www.gentoo.org Note: It is not as super-hard as you've been told. Installed it in three 4-hour sessions after reading docs on train - Compiled kernel on first shot - Added modules for devices I liked, and that recompile worked - Got X working enough to use a browser and a window manager - Gave up only because I had not decided on my workflows - Was afraid to mix GTK and QT or KDE packages at that stage - Unsure about reversing wrong choices - Unfamiliar toolkits scared me, although I had no real problems Conclusion: My problem with Gentoo? Between keyboard and chair. * Slackware (several times): http://www.slackware.org Always installs on first try for me, with huge kernel - Knowing what to do after initial install was the problem here, too - To remove fear, I updated my 13.37 with all patches by hand - Manual updates after install took 2 hours, including learning pkgtool - Using generic or custom kernels is only hard when I'm stupid * Be sure the drivers to operate your boot disk are compiled in Conclusion: After hating older versions, it's KDE 4 for the win! * SlackerMedia book: http://slackermedia.info Helpful tips on designing workstation around workflows - Uses SlackBuilds and SlackBuild queues for repeatable configuration - Gave me idea for groups working on math software-in-progress - Slackware package format is simple, easy to grasp (for binaries) - SlackBuilds: close to a universal format for sharing program source Why Slackware? - There are SlackBuild scripts for Sage and other packages I like - Slackware comes with support for TeX for math writing - SlackerMedia has queues for audio, video, web editing, publishing Conclusion: SlackerMath is born. Still needs to be fleshed out. - Slackware distribution-from-scratch based on SlackBuilds - Set it up as you wish using your own custom queues - Suggested packages would include Sage, R, Octave, GSL, QuantLib, Grass GIS, kile, gretl, Tux Racer, euler, gnucap, and others - Languages: Python with NumPy/SciPy/matplotlib and bindings to other languages/libraries, Scheme, Perl, Lua, C and Fortran * Also tried the following, but didn't stay with them - Slax (www.slax.org) - 11. Right now: * Five of our six former Windows computers have switched to Linux. - "Surfing Cow" decommissioned with CrunchBang as its final O/S. - "Racing Cow" still going strong with CrunchBang - Sony FE laptop "White Cloud" running Ubuntu 13.04 - Derringer is my audio editing machine, because it's under 3 lbs. - Laptop "Titanic" died after a baptism in red wine Back to life with new keyboard, disk, and name -- "Lazarus" * Number six ("Dawn Pixie") about to go to a Linux "granny" distro - Linux Mint or PCLinuxOS (KDE version) - Need a "granny" distros for generic use by all comers

### hpr1497 :: Practical Math - Units - Distances and Area, Part 1

Released on 2014-04-29 under a CC-BY-SA license.HPR Episode: Using and Converting Between Units of Distance Intro: Last time, we talked in general terms about units, numbers and how they might be useful in practice. In this episode, we address some specific measurement units that apply to distance and area, and how we might convert from one system to another to better understand both. Entire point of this episode is this: Carry units in calculations on distances and areas, and you'll have more success in using them in your life. Segment 1: Distance and Area in the English system 1. Series will focus on English and Metric systems. a. Basic units of distance: inch, foot, yard, mile b. Basic units of area: square inch, square foot, acre, square mile 2. Other units of distance and area do exist a. Barleycorn for shoe sizes (1/3") b. Hand for describing horses (4") c. Rod for surveying (16-1/2 feet) d. Chain, also for surveying (4 linear rods, 66 feet, 22 yards) e. Furlong from horse racing and agriculture (220 yards, 10 chains) f. League (about an hour's walk) usually assumed to be 3 miles - Nautical: technical unit that's exactly 3 knots g. Square yard may be used in quotes for carpet installations Table of Units: http://www.csgnetwork.com/converttable.html Brilliant Insight #1: Units of distance were originally arbitrary. We did not standardize on inches, feet, miles, and so on because these are magical units with special merits. They were convenient at the time and place where they were invented. Standards let us talk to each other about distance without having to be in the same place at the same time. We'd have trouble if builders builders had to ask for boards "as long as my arm", or a plank that's "Yea long". 3. Bizarre properties of some English units explained: a. Rod/Chain: Used in measuring farmland and building plots - Rod is 5-1/2 yards, or 16-1/2 feet. - Chain is 4 linear rods, or the length of a surveyor's chain - Could have been longer or shorter. Standard emerged from usage. b. Furlong: Longest row you can plow without resting the animals - Defined as 10 chains (220 yards) c. Acre: If you are on a quiz show, it's 43,560 square feet. Huh? - Defined as the area of a plot that's 1 chain wide by a furlong - Putting definitions together, we peek ahead to make sense of it. 1 acre = 1 chain x 1 furlong x 10 chains <--- multiply by 1 ---------- (1 furlong is 1 furlong 10 chains) Cancelling out furlongs upstairs and downstairs, we get 1 acre = 1 chain x 10 chains = 10 "square chains" - So the square feet in an acre is not (completely) arbitrary - It's just mostly arbitrary, but consistent with shorter units. d. Mile: Why is it 5,280 feet? Similar story [Simplified version!] - Roman occupation brought in a 5,000 foot mile ("mille passus") Warning! The Roman mile was defined in Roman feet, so it was a bit shorter than I've painted it. - Originated as 1,000 double-steps or "paces" - Since 1,000 was "mille", unit naturally became "mile" in English - Elizabeth I (1603, or was it 1593?): * Statute mile set to 8 furlongs (1,760 yds; 5,280 ft) * Why 8 furlongs? Why not 10 furlongs? * Goal: Set new mile close to existing mile, but as N furlongs. * New "statute mile" only about 5% longer than Roman mile Note: Similar analysis could be used with other "miles". * Setting a mile to a even multiple of a furlong had practical benefits, and keeping it close to the old unit reduced conversion costs for "legacy users". - That's why we've inherited a mile that measures 5,280 feet. To see why the story is tremendously more complicated than my account http://en.wikipedia.com/wiki/Mile Fun article on the mile. http://www.sizes.com/units/mile.htm High school student theme on the furlong. http://www.writework.com/essay/history-furlong by silverAlex2000 Brief dictionary article on the mile, referenced by Dr. Math http://www.unc.edu/~rowlett/units/dictM.html#mile Referred by http://mathforum.org/library/drmath/view/61126.html Resource: StackExchange Physics and Maths sections ("mile" question) http://physics.stackexchange.com/questions/57785/difference-between-nautical-and-terrestrial-miles 4. Converting between units a. Units of distance usually defined as multiples of each other - 1 mile = 5,280 feet - 1 hand = 4 inches - 1 foot = 12 inches - 1 yard = 36 inches Skipping ahead to look at the metric system, we now have: - 1 inch = 2.54 centimeters (exact). Regularized in recent years. b. This works because there's consensus on Zero distance, so we don't have to adjust for differing origins, as we do with the non-absolute temperature scales like Fahrenheit and Celsius. - We'll get to temperature, non-absolute scales in a later show. c. For absolute scales, we can convert from one unit to another using a "conversion factor". That is, we can convert a measurement expressed in one unit to its equivalent in another unit by multiplying or dividing by some number to stretch or compress the original unit to match the target unit. - Example: I know that 1 foot is 12 inches, so how many inches are there in 10 feet? How feet are there in 660 inches? - It is clear that a factor of 12 ought to be involved, but how do I know when to multiply or divide by 12 in the conversion? - Wait! I'm serious. When you see this problem for the first time, you have to think this through to get it right. * Without a system in place, you always have to think about it. - Answers in naive setup: (i) 10 feet = (12 * 10) inches = 120 inches (ii) 660 inches = (660 / 12) feet = 55 feet 5. Having a system. Or units conversion as "multiplying by One" a. In each of the solutions I wrote down above, I start with an equation that looks like this: X inches = Y feet. b. Inches are not feet, and this way of writing down the calculation does NOT help you figure you how the conversions should work, or whether you should multiply or divide to get the right answers. c. Here's a system for creating conversion factors that tell you what to do at each step in the units conversion process. It is based on the very obvious fact that when I multiply any number by '1', its value remains unchanged. - Start with one of the identities we wrote down at the beginning. In this case, let's use: 12 inches = 1 foot - If I divide equals by equals, the results are equal. So I can write: 12 inches 1 foot 12 inches = 1 foot implies that --------- = --------- = 1 1 foot 12 inches - Get the first term by dividing my original identity by (1 foot). - Get the second term by dividing my original identity by (12 in). d. To make a conversion from feet to inches, I use: 12 in 10 ft 10 ft * 1 = 10 ft * ------- = ------ * 12 in = 10 * 12 in = 120 in 1 ft 1 ft - Note: In the fraction (10 ft) / (1 ft), the units "cancel out", which leaves a unitless number. - Suppose we start with the other form for the conversion factor: 1 ft 10 square feet 10 feet * 1 = 10 feet * ------ = -------------- = ??? 12 in 12 inches - See? When I use the form where the units don't cancel each other, I get a resulting equation that is still correct. It just doesn't make much sense to me as a reader. - This is what you get when you "divide by 12" to convert feet to inches, but the difference is that you KNOW something's wrong. - You do not have to even look at the numbers to know that this could not possibly be the right number of inches in 10 feet. Brilliant Insight #2: When you use unit conversion factors, you help your cause by carrying along both sets of units in the form of a fraction as you go through your calculation. - If the units on the right-hand side of your final equation don't match the units you want (after everything else cancels out), your numerical answer is almost certainly WRONG. - The implication here? To convert units of distance, you need to multiply or divide by a conversion factor = (X New_Units) / (Y Old_Units). When you do this, write the conversion factor in its full fractional form, and carry out all of the multiplications and cancellations. - If you do the conversion this way, and the units match, you only have to check your arithmetic to be sure you've got it right. - If the units you want do not match those on the right side of the equal sign, you are solving the wrong problem. The equation may be correct, but it is not expressed in the units you wanted. 6. Let's use the system to solve the second example: 1 ft 660 in * 1 ft 660 in * 1 = 660 in * ------- = --------------- = 55 feet 12 in 12 in Why? The "inches" units cancel out because they appear in both numerator and denominator (top/bottom, upstairs/downstairs) of the fraction in the next to last term, leaving only "feet". Why people hate units and conversion problems: http://www.regentsprep.org/regents/math/algebra/am2/leseng.htm Comment: The "algebraic" approach suggested here is ugly, ad hoc in nature, and unnecessarily complicated. Forget about setting up equations and going through formal operations to solve them. Choose your conversion factors so that the units work out properly as a straight multiplication problem with cancellation of all the units you don't want. You may have to "divide" numbers, but you can use your calculator for working through the numbers. Cranky Summary: You should not have to solve equations to convert between units. Phooey on anyone who says otherwise. :-) Segment 2: Conversions using compound conversion factors. 1. Suppose I want to find the number of inches in a furlong, or the number of acres (or hectares) in a square mile? - My almanac doesn't carry these conversion factors, so I start with what I do have and work my way through it. 4 rods 16.5 ft 12 in 1 furlong = 10 chains = 10 chains * ------- * ------- * ------- 1 chain 1 rod 1 ft = 10 * 4 * 16.5 * 12 inches = ... = 7920 inches 2. For acres in a square mile (1 mi^2), we have a bit more to do. Abbreviations used: miles = mi, furlong = fur, chain = ch Area means that we are dealing in two dimensions, so we have to convert the lengths in each dimension. An acre is already a measure of area, so we're good. 1 acre 10 ch 8 fur 10 ch 8 fur 1 sq mi = 1 mi^2 * -------- * ------ * ----- * ----- * ----- 10 ch^2 1 fur 1 mi 1 fur 1 mi = (1 mi * 1 mi) * 1 acre * 10 ch * 10 ch 8 fur * 8 fur ------------- * ------------- 10 ch * ch 1 mi * 1 mi Units cancel, leaving this: 1 sq mi = 1 acre * (100/10) * (8 * 8) = 10 * 64 acres = 640 acres Next time: "Hey! Ready to try metric?"

### hpr1353 :: Practical Math - Introduction to Units

Released on 2013-10-09 under a CC-BY-SA license.Introduction: Units are the bridge from learning abstract arithmetic operations on numbers to actually using maths to navigate the world of objects, distance, time, rates, volume, temperature, heat, current, voltage, and even cooking using recipes. Goal for the series: Embracing units, and carrying them along as you go, can help you work with confidence in using maths in your life. When you start to use maths to solve real problems, you are going to run into units. This series is intended to show you that units are your friends, and that they're here to help you. Goal for this episode: We want to look at what units are, what they do, types of units, and how to mix unitless numbers with units. Resource for the series: * Khan Academy pages on Rates, Ratios and Units https://www.khanacademy.org/math/arithmetic/rates-and-ratios Most articles that would be relevant to this introductory episode were about teaching physics and chemistry, or discussions of philosophical implications of doing what we will be doing at every turn in this series. All of the formal operations that we will learn to do with units are done every day in real life by experts in their respective fields. I am not worried about what it means to say, "There are 12 inches in a foot." Later shows will have more links and resources. Segment 1: What do we mean by units? 1. Definition: Two types of units are useful in practical maths: a. Counting units: An individual thing treated as single or complete. Units can also apply to an individual component of a larger or more complex system. E.g., mufflers can become part of a car. - Think of objects that you would keep in an inventory in your pantry or in a warehouse. b. Measurement units: A quantity chosen as a standard that you can use as a common benchmark for comparing other quantities (of the same kind). - "Same kind": Don't try to compare distances to times or volumes. - "Standards": Communication tool for talking about quantities without being face-to-face. If you have standard units, you avoid expressions like "yea long", "kind of tall", etc. - Probably invented by buyers and sellers, or by the spouse of an avid fisherman. c. Composite units: Units can be multiplied together (or divided) to create new types of units. Some people call these "derived quantities", but that may sound too much like programming talk. I use composite units because of the mental picture it creates of putting things together, or doing one operation after another. - Dimensionality changes: * 1 ft * 1 ft = 1 square foot: distance^2 --> area * 1 ft * 1 ft * 1 ft = 1 cubic foot: distance^3 --> volume - Rates: * Speed: distance / time = average speed, as in kilometers/hour * Flow rates: volume / time, as in liters/minute * Pressure: force / area, as in pounds / square foot * Density: mass / volume, as in kilograms / liter * Rationing: (1 period) counting units / time, as in apples/day (longer time) apples / family_member / day - We will run more of these types of units in later shows. 2. Other kinds of numbers: Not every quantity has units attached a. Numbers can be unitless. Unitless numbers help you make sense of quantities with units through comparisons, extrapolations, etc. - Example: Percent changes are unitless floating point numbers, unless it is tied to an elapsed time. That's a "rate", which has units of "% per year" (say). - Example: Percentage of Total values are unitless fractions, too. - Example: Any unit can be multiplied by a unitless integer. * 2 feet, 3 apples, 4 quarts, 10 meters, etc. * "Twice as many", "ten times as far", "double a recipe" - Counting units can be multiplied by a unitless fraction, but the result will be rounded off to the nearest integer value. * "Mary has 2-1/2 times as many apples as John," is fine if John has 4 apples, and Mary has 10 apples. - Example: Measurement units can be multiplied by any arbitrary scale factor. * How big: "A land area 3.6 times the size of New Jersey..." * How far: "I'll meet you halfway..." * How much: "If using white flour, you'll need 30% more..." b. When values with units are divided by other values with the very same units, the result is a unitless number. - Percent of Total and Percent Change are prime examples - Comparison of distances: * "St. Johnsbury is 45 miles away, and Barton is only 15 miles. So you have to drive 3 times as far to get to St. J." c. Conversion factors between units work in this way. They are given as ratios of some number of new_units divided by some other number of original_units. * The original_unit quantities cancel in multiplication, just as numbers do, so you get an answer with the correct units! * You could call conversion factors "derived quantities", because you create them from something called an identity, or a statement of equality that you know to be true. d. Conversion factors will be covered next time. 3. Why bother with "counting units"? Aren't these just names? a. Counting units are labels or names applied to individual items in a total count, but they are still useful. b. Using counting units helps us to make distinctions between items that are not interchangeable, so we can keep track of the counts for each individual kind of item. - If you need 2 apples, having 10 onions does not help you. - Thinking with units will help you keep inventories and to start setting up accounting systems for your business. It will also help you manage your kitchen and your budget at home. Segment 2: Counting Units? Are you serious? 1. Counting units give context to the numbers that you are using in any calculations that arise when you are buying, selling, trading or just using up items in a beginning inventory. Here's what happens when you don't track units in counting problems. - Example: "John has 9 apples in his basket. If he gives 2 apples to Mary, how many does he have left?" - Speed test preparation textbooks seem to teach you to parse the problem as if you were a word problem "compiler": a. Fish out the numbers and their roles. --> Notice that 9 is near "in his basket", and "how many does he have left?", It must be the source. --> Notice that 2 is next to "gives away". It must be the change in quantity. b. Parse out the operation: "gives away" is code for subtraction. c. Do the calculation and supply a numerical answer: 9 - 2 = 7 2. Re-work the problem by tracking units. a. Read the problem. I'll wait. We will parse it together. b. John has a basket with 9 apples in it --> beginning inventory c. John gives away two (2) apples to Mary. - John's inventory of 9 apples is reduced by 2 apples, - John now has 7 apples in his basket. d. Mary now has 2 additional apples in her inventory. - The apples were neither created out of nothing nor destroyed. - They came from somewhere (John), and they went somewhere (Mary). - If "apples out" does not equal "apples in", something's wrong. e. Having this information lets you answer questions with confidence. f. Answer the question: "John now has 7 apples." - John does not have '7'. John has '7 apples'. 3. Ho hum. That solution is exactly the same. You're picking nits. a. For a trivial problem, this looks the same. But there are some benefits of using units, even if they appear to be "just labels". b. If the problem had said that "John gave 2 oranges to Mary", we would have spotted the discrepancy immediately. - Giving away oranges does not affect John's apple inventory - The oranges must have come from another supply (account) - We can still talk about an increase in Mary's oranges count, and the decrease in John's oranges -- even though we don't know the beginning or ending balances. c. What if the problem had said, "Mary has three times as many apples as John. How many apples would Mary have to give to John to leave each of them with the same number of apples?" d. Better yet, what if the problem read: "John has 19 apples, and Mary has 14 oranges. Now John likes oranges twice as much as he likes apples, but Mary likes apples three times as much as she likes oranges. How can John and Mary exchange apples and oranges to get the best (equal) gain in happiness?" - This problem involves not only the tracking of apples and oranges, but probably some type of "happiness" function that gives a value that carries some kind of units. Warning: There's not enough information to really solve this problem without further assumptions. It is meant as an illustration of how complicated a setup can become when you get into real life situations. - Problems like this are what make people hate economics. One way to solve it is to define utility functions for each party. - Their preferences are so different from their inventories, that simply trading baskets is pretty close to an optimal solution. e. If the problem had involved trading some of John's apples for some of Mary's oranges, and possibly an offsetting cash payment to correct an imbalance, we would make the best use of our information about the sources and uses of resources by tracking the units of each object or currency involved in the exchange. Point: Problems can become complicated. Units can help with the bookkeeping needed to work through to the answers. If someone poses a problem like this one to a group at a dinner party, it is time to remember that you forgot to iron your curtains. 4. Final properties of counting units a. Compatible counting units can be added and subtracted. - Example: 6 apples + 4 apples = (6 + 4) apples, or 10 apples. - Example: 6 apples + 2 oranges is a mixed expression. They cannot be added, except as part of a fruit salad. b. An amount that's given in counting units can be multiplied by an integer, since that is like repeated additions. They can also be multiplied by a fractional amount, but we would want to interpret the result as a whole number. c. Any multiplication by a floating point number would have to be defined, and it's usually not worth the effort. d. Counting units have weaknesses, especially in classification: - Organic items are usually not identical. Apples can vary. * Size: A recipe calls for "3 large apples". Are these large? * Varieties: "Apples" in the US can include Macintosh, Rome, Gala, Granny Smith, etc. These can be quite different. - Animals also vary within categories: * Cats: Lions, lynxes and Little Puff can all qualify * House cats: Siamese, Persians, Tabby cats are all just cats, until you have them living in your home. - Some living things are hard to pin down: sponges, paramecia - Other items can also create classification issues, depending on your purpose. * Units are just tools. Let them work for you, and not the other way round. Segment 3: Units of measurement 1. Measurement units are often continuous (or just about), so they can be divided conceptually into smaller and smaller subunits as many times as we like. - They can also be lumped together into larger and larger wholes. - Physical limitations place practical limits on how finely we can actually chop things up, and still get a measurement. - There are real world limitations on how much we can lump together. - But you get the idea. 2. Measurement units can be applied to distance, time, area, volume, weight or mass, energy, frequencies of light or radio waves, voltages, current, heat, temperature, and a host of other things. - We can measure these quantities with differing levels of precision, based on the instruments and abilities that we have. - For all practical purposes, we measure within tolerances that we can meet without spending our whole lives measuring. 3. Applications of measurement units a. Understanding the news: hectares of forest endangered by a fire, square miles of arable farmland in South Africa, temperatures given in unfamiliar scales such as Fahrenheit, snowfall measurements in Canada versus neighboring Montana, etc. b. Following recipes to make bread, cookies, beer and other items that promote World Peace c. Mixing chemicals for an old-school darkroom, or for a very cool low-tech electronics home "fab lab" d. Buying gasoline (petrol) in other countries, and understanding their speed limits in foreign units. - Can't help you with driving on the wrong side of the road e. Helping your kids with their maths homework, and understanding it for once! f. Checking the dosages of your medications against your prescription to find out if this is my medicine or my child's. You just have to be able to get this one right. We'll get to all of this and more in future episodes in this series.

### hpr1292 :: Doomsday Remainders

Released on 2013-07-16 under a CC-BY-SA license.Last Episode on Conway's Doomsday Rule ends with teaser on MOD(), a "remainder" function defined for integer values (whole numbers): MOD(K, m) = remainder when K is divided by "modulus" m. Examples: a. MOD(207, 7) = MOD(207 - 140, 7) = MOD(67, 7) = 4 b. MOD(1234567, 2) = 1 because the number is odd MOD() function found in most spreadsheet programs, but it also shows up as an operator in some programming languages: (a % b), or (a mod b). Other functions referenced: DIV(K, m) = quotient in integer division where K = m * quotient + remainder (not returned) 0 <= remainder < m DIVMOD(K, m) = (quotient, remainder) when K is divided by m where remainder = MOD(K, m) quotient = DIV(K, m) K = m * quotient + remainder## Full Show Notes

http://hackerpublicradio.org/eps/hpr1292.txt

## Links

- https://en.wikipedia.org/wiki/Modular_arithmetic
- https://www.khanacademy.org/math/applied-math/cryptography/modarithmetic/a/what-is-modular-arithmetic
- http://betterexplained.com/articles/fun-with-modular-arithmetic/
- http://mathworld.wolfram.com/Congruence.html
- https://en.wikipedia.org/wiki/ALGOL_60
- http://www.conservapedia.com/Pascal_%28programming_language%29
- http://www.gnu.org/software/libc/manual/html_node/Integer-Division.html#Integer-Division
- http://www.haskell.org/tutorial/numbers.html
- http://www.standardml.org/Basis/integer.html
- http://docs.python.org/2/library/functions.html#divmod
- http://docs.python.org/3/library/functions.html#divmod
- http://ruby-doc.org/core-2.0/Numeric.html
- http://en.wikipedia.org/wiki/Doomsday_rule
- http://en.wikipedia.org/wiki/Modulus_operation
- http://zetcode.com/lang/python/lists/
- http://docs.python.org/2/tutorial/introduction.html

### hpr1240 :: Doomsday Rule

Released on 2013-05-03 under a CC-BY-SA license.HPR Episode: Doomsday Perpetual Calendar Method What is it? http://en.wikipedia.org/wiki/Doomsday_rule (due to John H. Conway, a mathematician born in Liverpool) * He's done other research that hackers might like to check out. * Look up the "Game of Life" and "cellular automata". * There may be episodes on these topics, but those should come with visualization software. John H. Conway http://en.wikipedia.org/wiki/John_Horton_Conway Game of Life http://en.wikipedia.org/wiki/Conway%27s_Game_of_Life Doomsday Rule lets you find the day of the week for any date * Dates in history, in immediate past or in future are all good. * Works for both the Gregorian and Julian calendar. - I'll only be looking at Gregorian dates for now. - Method should work well for dates from 1800 onward. - If dates for non-Gregorian calendars are converted to their (extrapolated) Gregorian equivalents, this method works. Wikipedia entry (includes recent optimization): http://en.wikipedia.org/wiki/Doomsday_algorithm Why do this? It came up in Episode Zero of my "N Days" show on calendar counting, where I used it without explanation. http://hackerpublicradio.org/eps.php?id=1143 Demos: Check these answers at www.day-calculator.com * Some listeners may now adjourn to the latest Linux Outlaws episode. Method: Get Century Anchor Day, calculate offset for the year to find Doomsday's reference location for current year, find closest reference date to target date, and count off to the answer. a) Isaac Newton's date of birth: - 25 December 1642 - 1600's Tuesday. Year 42 = 3*12 + 6 and (6/4) = 1. Hence 3 + 6 + 1 = 10 for an offset of 3. Tuesday + 3 = Friday. 12/12 is Friday, so 12/26 is Friday Newton was born 12/25, so that was a Thursday b) My grandfather's date of birth: - 20 January 1898 - 1800's anchor is Friday. Year 98 = 8*12 + 2, (2/4) = 0. So 8 + 2 + 0 = 10 gives an offset of 3. - 1898 wasn't a leap year, so 10 January was Monday - That means 17 January was a Monday, too. - So 20 January 1898 was a Thursday. c) A wedding anniversary that I like to remember: 15 May 2000 - 2000 has anchor day on Tuesday, and no offset. - Rule: "I work 9 to 5 at 7-11", so 9 May (16 May) are on Tuesday. - 15 May 2000 was a Monday. True. 'Twas the day after Mother's Day. d) My parent's wedding day: 19 May 1957 - 1900 has anchor day Wednesday. 57 = 4*12 + 9 and (9/4) = 2. - So 4 + 9 + 2 = 15 or an offset of 1. - 9 May is Thursday, as is 16 May. The 19th is 3 days later. - So 19 May 1957 was a Sunday. Plan: I'm going to reveal the magic behind this, and introduce some mental shortcuts to help you learn to do this in your head. If you can master the 12's row in your times tables up to 8 times 12, and the 4's row up the 20s or 30s, and you can tell time on a 12-hour clock, you should be able to do this. We're not in school, so paper and pencil to track the numbers, and finger-counting offsets to days of the week are all allowed. Explanation: 1. Certain memorable dates fall on the same day of the week as "Doomsday" = last day of February, whatever that is. 2. Dates recycle every 400 years, and Doomsday Anchor dates by Century are 1600: Tuesday, 1700: Sunday, 1800: Friday, 1900: Wednesday. 3. That's enough, but to simplify mental math notice 12-year cycles. - Every completed 12 years pushes the days of the week ahead by +1 - Each year within the current incomplete cycle adds +1 - Each leap year in current cycle adds +1 (including current year) 4. Doomsday dates are: a. January 10 and Doomsday (last day of February) b. Odd months: Add +4 through July, then subtract 4. 7 March, 9 May, 11 July 5 September, 7 November c. Even months are reflexive: 4/4, 6/6, 8/8, 10/10, 12/12 See the attached spreadsheets for examples and annotated calculations. - LibreOffice Calc: 229-Charles-in-NJ-Doomsday-Rule-v1.ods - Excel 5/95 'xls' for LibreOffice or Gnumeric: 229-Charles-in-NJ-Doomsday-Rule.xls - Gnumeric: 229-Charles-in-NJ-Doomsday-Rule-v1.gnumeric Bonus Content: - Excel VBA module: 229-Charles-in-NJ-Doomsday-Rule.vbaxl.bas * Import the .bas module * Input is an Excel "Date" object * Very proprietary formats and code, but some people use it. - Python: doomsday.py * Contains two functions: Each returns a string value for the day of the week, e.g., "Sunday" dayOfWeek(year, month, day): Doomsday is last day of February, and the (month, day) are converted to relative ordinal dates. For leap years, we have to push both Doomsday and any target date after 28 February up by one for the leap day. dayOfWeek2(year, month, day): Doomsday date anchors are computed for each month, so leap years require adjustments to the anchors for January and February to account for the shift in the February ending date. Later months are fine. - Script for GNU 'bc': doomsday.bc is a bc 'port' of the Python code * Differences: Return value is a number from 0-6 that represents the day of the week by its relative position. 0 = Sunday, 1 = Monday, 2 = Tuesday, 3 = Wednesday, 4 = Thursday, 5 = Friday, 6 = Saturday * In a shell, run 'bc' with the filename as an argument: catintp@Derringer:~$ bc doomsday.bc - This loads the two functions in the file. You can invoke them within 'bc' like any other function: dayofweek(1981, 5, 15) dayofweek2(1642, 12, 25) dayofweek(2013, 11, 22) dayofweek2(2059, 5, 19) - Alternate Script for GNU 'bc': doomsday2.bc * Return value is still a number from 0-6 that represents the day of the week by its relative position. * Uses a side effect to print a human-friendly answer. * English only, but localisation should be easy.## Links

- http://hackerpublicradio.org/eps/hpr1240/20130401T171122Z_229_Charles_in_NJ_Doomsday_Rule.zip
- http://en.wikipedia.org/wiki/Doomsday_rule
- http://en.wikipedia.org/wiki/John_Horton_Conway
- http://en.wikipedia.org/wiki/Conway%27s_Game_of_Life
- http://en.wikipedia.org/wiki/Doomsday_algorithm
- http://hackerpublicradio.org/eps.php?id=1143
- http://www.day-calculator.com
- http://hackerpublicradio.org/eps/hpr1240/229-Charles-in-NJ-Doomsday-Rule-v1.ods
- http://hackerpublicradio.org/eps/hpr1240/229-Charles-in-NJ-Doomsday-Rule-v1.xls
- http://hackerpublicradio.org/eps/hpr1240/229-Charles-in-NJ-Doomsday-Rule-v1.gnumeric
- http://hackerpublicradio.org/eps/hpr1240/229-Charles-in-NJ-Doomsday-Rule.vbaxl.bas
- http://hackerpublicradio.org/eps/hpr1240/doomsday.py
- http://hackerpublicradio.org/eps/hpr1240/doomsday.bc
- http://hackerpublicradio.org/eps/hpr1240/doomsday.bc
- http://hackerpublicradio.org/eps/hpr1240/doomsday2.bc

### hpr1189 :: Part One: Counting Partridges and Gold Rings

Released on 2013-02-21 under a CC-BY-SA license.## Edited version - re sent

The Sonar Project has $9,838 raised with 256 people contributing. A big thanks to all the !HPR Listeners who helped out.

It's not too late to contribute to the ACF. See http://accessiblecomputingfoundation.org/ for more information.Tomorrow The Eleventh Annual Southern California Linux Expo starts. Running from February 22 to the 24, 2013 in the Hilton Los Angeles International Airport. Speakers include Kyle Rankin, Joe Brockmeier and Matthew Garrett.

See http://www.socallinuxexpo.org/scale11x for more information## The N Days of Christmas? Intro to Recreational Math Part One: Counting Partridges and Gold Rings

The complete shownotes can be found here:

- http://hackerpublicradio.org/eps/hpr1189/hpr1189.txt
- http://hackerpublicradio.org/eps/hpr1189/Pascal_Calcs_Gnumeric.gnumeric
- http://hackerpublicradio.org/eps/hpr1189/Pascal_Calcs_non-free.xls
- http://hackerpublicradio.org/eps/hpr1189/hpr1189_Charles_in_NJ-N-Days-of-Xmas-Ep-One.zip
Pascal's Triangle:

Background on Pascal's Triangle and the Binomial Theorem, see the excellent videos by Sal Khan at http://KhanAcademy.org

Contact: Charles in NJ Email: catintp@yahoo.com

Charlie + Alpha + Tango + India + November + Tango + Papa.

### hpr1143 :: The N Days of Christmas? Intro to Recreational Math

Released on 2012-12-19 under a CC-BY-SA license.Hacker Public Radio: 206 203 5729 The N Days of Christmas? Intro to Recreational Math Part Zero: Calendar Counting First episode of HPR that contains a direct discussion of a math topic. - Episode 479 Ohio Linux Fest, Klaatu interviews DWick about math software for Linux - Episode 523 Using Petunia software to teach math Inspired by a traditional song that is proof that some songs do not need to be recorded by William Shatner to be annoying. - Repetitive and formulaic - Involves a lot of counting, and that's our focus here. What is the 12 Days of Christmas? - Starts on Christmas Day, runs through the day before the next Season - Hint: That's 'Epiphany', which starts January 6. - Counting calendar days comes hard, so we tend to use our fingers - Turns out that using our fingers is quite mathematical. Here's why. Finger Counting: How do I count Twelve Days? - Let's start easy, with the fingers on one hand. My hands have five. - To name the Five Days of New Years is easy: January 1-5