Showing posts with label BYUH. Show all posts
Showing posts with label BYUH. Show all posts

Thursday, August 1, 2013

Nested Loops and Counting Time in Perl

I'm teaching an introductory programming class this semester.  On Monday, we're going to be exploring the concept of nested loops. In programming, loops are repeated sets of action steps.

Counting Seconds

For example, counting is a repeated set of action steps.  A loop for counting seconds might have the following repeated set of action steps:
  1. Start with a number, 0.
  2. Say or write down the number. 
  3. Add one to your number.
  4. Wait one second. 
  5. Repeat steps 2, 3, and 4 until you say or write down the number you want to get to. 
In Perl, these steps would look like this: 

for ( $seconds = 0; $seconds <= 10; $seconds++) { 
 print ( "$seconds " ); 
 sleep ( 1 ); }

If I were reading the above code out loud, I might say
  1. Create a for loop
  2. Start with a number seconds, that equals one.  
  3. Perform the following steps as long as seconds is less than or equal to 10. Each time you finish these steps, add one to seconds
    1. Print the value of seconds out to the screen. 
    2. Wait one second.

Counting Minutes and Seconds

Sometimes we want to have two counters going at the same time.  If I want to count minutes and seconds, I need to add some instructions.  A loop for counting minutes and seconds might have the following repeated set of action steps: 
  1. Start with the minutes number 0. 
  2. Start with the seconds number, 0.
  3. Say or write down the minutes & seconds numbers. 
  4. Add one to your seconds number. 
  5. Wait one second. 
  6. Repeat steps 3, 4, and 5 until you say or write down the number 59. 
  7. Once you get to 59, wait one second, it's time to start the 59-second counting loop over. 
  8. Each time we start over in counting seconds (going from 59-back to 0), add one to the minutes number. 
  9. Repeat steps 2-8 until you say or write down the number of minutes & seconds you want to get to. 
In Perl, these steps would look like this: 
for ( $minutes = 0; $minutes < 60; $minutes++ )
  for ( $seconds = 0; $seconds < 60; $seconds++ ) {
    print ( "$minutes : $seconds" );

    sleep ( 1 );
 }}


If I were reading the above code out loud, I might say

  1. Create a for loop.
  2. Start with a number, minutes, that equals zero.
  3. Perform the following steps as long as minutes is less than 60. Each time you finish these steps, add one the the value of minutes
    1. Create a for loop.
    2. Start with a number, seconds, that equals zero. 
    3. Perform the following steps as long as seconds is less than 60. Each time you finish these steps, add one to the value of seconds. 
      1. Print the value of minutes and seconds out to the screen. 
      2. Wait one second. 

Counting Hours, Minutes, and Seconds

Sometimes we want to have three counters going at the same time. If I want to count hours, minutes, and seconds, I need to add some instructions.  A loop for counting hours, minutes, and seconds might have the following repeated set of action steps: 
  1. Start with the hours number, 0.
  2. Start with the minutes number, 0.
  3. Start with the seconds number, 0. 
  4. Say or write down the hours, minutes, and seconds numbers. 
  5. Add one to your seconds number. 
  6. Wait one second. 
  7. Repeat steps 4, 5, and 6 until you say or write down the number 59. 
  8. Once you get to 59, wait one second. It's time to start the 59-second counting loop over. 
  9. Each time we start over in counting seconds (going from 59 back to 0), add one to the minutes number. 
  10. Repeat the steps in counting from zero to 59 and adding 1 to the minutes number until the number of minutes is 59. 
  11. The next time you complete the counting seconds loop, set the value of minutes to zero and add one to the value of hours. 
  12. Repeat steps 2-11 until you say or write down the number of hours, minutes, and seconds you want to get to. 
In Perl, these steps would look like this: 
for ( $hours = 0; $hours < 24; $hours++ ) {
  for ( $minutes = 0; $minutes < 60; $minutes++ ) {
    for ( $seconds = 0; $seconds < 60; $seconds++ ) {
      print ( "$hours : $minutes : $seconds " );
      sleep ( 1 ); }}}

If I were reading the above code out loud, I might say
  1. Create a for loop
  2. Start with the number of hours, that equals zero. 
  3. Perform the following steps as long as hours is less than 24. Each time you finish these steps, add one to the value of hours.
    1.  Create a for loop
    2. Start with the number of minutes, that equals zero. 
    3. Perform the following steps as long as minutes is less than 60. Each time you finish these steps, add one to the value of minutes.
      1. Create a for loop.
      2. Start with the number of seconds, that equals zero. 
      3. Perform the following steps as long as seconds is less than 60.  Each time you finish these steps, add one to the value of seconds
        1. Print the value of hours, minutes, and seconds out to the screen. 
        2. Wait one second.

Formatting Numbers

Now that our counting loops are properly nested, we should format the numbers. If you've tried running these programs, you may have noticed that the single digit numbers do not have padded zeros: 
0
1
2
3
4
5
6
7
8
9
10

On a digital clock, we usually pad the numbers so that each number takes up two digits. 

00
01
02
03
04
05
06
07
08
09
10

To accomplish this in Perl, we need to use a function called printf ( )  instead of print ( ). We need to replace this line of code: 
      print ( "$hours : $minutes : $seconds " );
with this 
               printf ( "%02d:%02d:%02d", $hours, $minutes, $seconds );

If I were reading the above code out loud, I might say: "Print three values in the following format: I want three signed integers (positive or negative whole numbers or zero), each number will be formatted as a two digit number and will be separated by a colon.  The three numbers (in order of their presentation) are hours, minutes, and seconds. 

Our final code for our nested loops clock counter is as follows: 

for ( $hours = 0; $hours < 24; $hours++ ) {
  for ( $minutes = 0; $minutes < 60; $minutes++ ) {
    for ( $seconds = 0; $seconds < 60; $seconds++ ) {
       printf ( "%02d:%02d:%02d\n", $hours, $minutes, $seconds );
  sleep ( 1 );
  }}}

References

  1. This tutorial is based on an exercies found in Dr. Don Colton's Introduction to Programming Using Perl and CGI, available as a free download at http://ipup.doncolton.com
  2. More information about formatting using the printf ( ) function is available from the online Perl documentation at http://perldoc.perl.org/functions/sprintf.html

Friday, July 26, 2013

Social Media and the LDS Church


I've been preparing a class lesson on social media, and given that I teach at Brigham Young University - Hawaii, I've been reflecting on how the LDS (Mormon) Church has used social media (i.e., blogs, social networks, wikis, etc.)  over the last few years.


I think it's safe to recognize that one of the founding events in the Church's push into the social media space occurred at BYU Hawaii. Elder M. Russell Ballard of the Quorum of the Twelve Apostles (one of the governing bodies of the church), was speaking at the BYU Hawaii December 2007 Commencement exercises. His talk was titled Using New Media to Support the Work of the Church. In the talk, Elder Ballard spoke of a conversation going on about the Church. At the time a combination of events, including the candidacy of Mitt Romney in the US presidential election, had generated a lot of interest in the church.  News stories, blogs, and other media outlets were publishing stories about the church at an unprecedented rate. Within this context, Elder Ballard issued the following invitation:




                           Now, to you who are graduating today, and all other faithful members of the Church, and as you graduate from this wonderful university, may I ask you to join the conversation by participating on the Internet, particularly the New Media, to share the gospel and explain in simple, clear terms the message of Restoration. Most of you already know that if you have access to the Internet you can start a blog in minutes and begin sharing what you know to be true. You can download videos from the Church and other appropriate sites, including Newsroom at LDS-dot-org, and send them to your friends. You can write to media sites on the Internet that report on the Church, and voice your views as to the accuracy of the reports. This, of course, requires that you, all members of the Church, understand the basic, fundamental principles of the gospel. 
We are living in a world saturated with all kinds of voices, because now, more than ever, we have a major responsibility as Latter-day Saints to define ourselves instead of letting others define us. Far too many people have a poor understanding of the Church because most of the information they hear about us is from the news media reports that are often driven by controversies. Too much attention to controversy has a negative impact on peoples' perceptions of what The Church of Jesus Christ of Latter-day Saints really is.
 Following that talk, a number of member-driven initiatives arose around the web.  But in this post, I'd like to review what the official social media efforts of the church have included.

Social Networks

Facebook

On April 24, 2008, the Church established it's first official page on Facebook (https://www.facebook.com/LDS).

The Church would go on to develop over thirty official Facebook pages publishing in areas of inspirational messages, news of the Church, family history support, church magazine articles, aids for sharing the gospel, Church history, and much more. These don't include the 100+ Facebook communities created to help people connect and collaborate around family history work in different regions around the world.

The latest addition to these Facebook pages is a set of pages created for the members of The First Presidency and The Quorum of the Twelve Apostles, the two highest governing bodies of the church.  These general authority pages have been recently established (within the last few weeks) so it remains to be seen how actively they will be updated, hopefully frequently. 

Twitter

Although the Church's Facebook presence has been the most extensive, ongoing efforts are underway on additional platforms. The Church established an official Twitter profile https://twitter.com/LDSchurch. Over one dozen official Twitter accounts publish news of the Church, inspirational messages, technology updates, and media resources. 

Google+

The Church has a growing presence on Google+ including pages for official, inspirational messages from the Church, news media announcements, multimedia programming from the Mormon Channel, and missionary updates from mormon.org. Unique to the Google+ list of pages is a Church Employment page, which shares general job tips as well as links to Church employment opportunities. Also unique to the Google+ effort is the creation of a Church of Jesus Christ of Latter-day Saints community, created / administered by the official Google+ LDS Church account.  There are probably more active communities of church members on Google+, but I find in interesting that they're experimenting with this as well.

LinkedIn

While we're on the subject of employment resources, the Church has also devoted a lot of resources to developing presence on LinkedIn. These sites help in recruiting individuals for church employment and providing career planning and job search tips.  The Church's official linkedin.com page shares updates that mirror the postings on the Google+ employment opportunities account. Various departments within the Church sponsor their own linkedin.com pages or groups.

YouTube

Next, we should probably review the official Church efforts on YouTube. The Church has a number of channels on YouTube, but the most popular is arguably the Mormon Channel, featuring content from www.mormonchannel.org. Other popular channels include the mormon.org channel, featuring videos from the I am a Mormon campaign, music from the Mormon Tabernacle Choir and family history helps from FamilySearch 

Pinterest

One recent addition to the handful of large social networks, at least in English speaking nations, is Pinterest.  The Church has a modest official presence on Pinterest, populated largely with images from the lds.org Media Library and videos from the Mormon Channel on YouTube. I have also noticed that the LDS Church Facebook account has started to share poster graphics with linked invitations to "Pin this image to Pinterest." 
Perhaps more significantly on Pinterest, the recently called General Young Women's President, Bonnie Oscarson, has a significant presence on Pinterest, with over 2500 pins, 47 boards, and 6,800 followers. 

Mormon.org

Recently, the Church has begun to add a social component to the www.mormon.org missionary website as well. In addition to providing standard content and multimedia that parallels the topics featured in the Preach My Gospel missionary lessons, the mormon.org staff now invite all members to create social profiles on mormon.org at www.mormon.org/create. Members can post brief descriptive profile pages of themselves along with their personal answers to frequently asked questions about the church. Their profiles can be searched by investigators and their answers can be read on their profile pages.  Selected answers are also embedded in related content across the www.mormon.org website.


lds.org/youth

In addition to these efforts, it appears the Church may be considering the development of more social interaction features among church members as well. The www.lds.org/youth website includes social features in which users with an lds account can "like" content and share their experiences or thoughts about articles and have their comments directly published at www.lds.org/youth. 

Blogs

The Church does not have a large official presence on the blogosphere. The official Church Public Affairs site, maintains its own blog (http://www.mormonnewsroom.org/blog/), featuring noteworthy events / activities by church members, messages from Church leaders that may be of interested to watchers of the Church, and occasional commentary. Managing Director of Public Affairs for the Church, Michael Otterson, regularly contributes, in his official capacity, to the OnFaith blog at the Washington Post. Another blog exists at http://tech.lds.org/, featuring updates and commentary about issues relating to Church sponsored efforts with technology.  I will review the LDS Tech website in more detail tomorrow in a post discussing the Church's use of wikis, crowdsourcing, etc. 







Friday, March 23, 2012

An Introduction to Linear Programming

Motivation for Today's Class

During my previous MIS course on Wednesday, we had a discussion about business process modeling based on students' experience playing IBM's Innov8 game (http://www.ibm.com/innov8).  During that class, we reviewed the basics of Business Process Modeling Notation and discussed some ways business process improvement can build on emerging technologies in supply chain management, call center management, and traffic control.  In the Innov8 simulation game, students were asked to revise business models and then to allocate resources to various paths within that model (e.g., determine the number of expensive high-skill call-center employees versus less expensive low-skill call-center employees. I asked the students how they approached this resource allocation problem, and they said they just kept playing with the numbers in the simulator, making random guesses until they got the desired results.  

I told the students there was a more systematic way of addressing these kinds of problems and asked if any of them had learned about linear programming in their other classes. They had not. So I decided to give them a linear programming introduction tutorial today. 

I had prepared a number of slides with pictures and some example problems, along with a graphing calculator utility on my macbook. However, I had problems getting my laptop to work with the in-room projector.  Thankfully, I understood the material well enough to work through the problems on the board without my slides.  

Linear Programming

I first went to the article, "Linear Programming: Managing with Constraints" from the Marriott Magazine that the students had been assigned to review prior to coming to class. The article is part of a larger set of tutorials to introduce math tools to managers.  The article's author states that linear programming is "arguably the most widely used mathematical tool in business management." I tried to underscore this principle with my students hoping to motivate them to learn this topic for more than just their grade in an IS course. 

Happy Trails

The tutorial begins with a profile of a company Happy Trails that produces a classic trail mix. They're weighing the option to launch a second line of trail mix with a larger proportion of dried fruit than their classic mix.  They need to figure out if it would be profitable to offer the two lines of trail mix and, if so, what proportion of classic mix vs. fruitylicious mix they should produce to maximize their profit. 

I told the students that this and the other example problems we would be looking at today all had the same structure: we are trying to optimize one function while working within a given set of constraints. I said it was like trying to go buy ice cream at Foodland for what seems like $12 a quart when you only have two dollars in your pocket. You need to know what you can and can't do with the resources you have available. 

That's all linear programming is: identifying the equations for the lines (hence the term linear in linear programming) and optimizing (finding the maximum or minimum value depending on the context) of a separate function using the points where the constraint lines intersect / overlap.  

We first set up the variables we'll use in this problem. 

Setup

Let x equal the number of classic packages produced. 
Let y equal the number of fruitilicious packages produced. 

Identify Constraint Equations

In the happy trails example, the constraints we have are the maximum ounces of peanuts we can use to produce trail mix (8x + 4y <= 20,000), the maximum ounces of dried fruit we can use to produce trail mix (6x + 10y <= 30,000), and the fact that we cannot produce a negative packet of either type of trail mix ( x >= 0, y >= 0). We could manually graph each of these lines and then determine the intersection points.  And that's just what I did on the white board.  But, I wanted to help my students see their responsibility is to understand the equations, not to spend all their time performing arithmetic.  On next Wednesday, we'll discuss how to use functions like SOLVER in spreadsheet programs to address these problems.  

Today, I showed the students how they could use Wolfram Alpha to solve these inequality constraints.  By typing in the following into the Wolfram Alpha search box, the students can graph the shape made by overlapping these functions: 

8x + 4y <= 20000, 6x + 10y <= 30000, x >= 0, y >= 0

Adding the profit optimization function to the Wolfram Alpha query, we can generate the coordinates at which we can maximize profit. We know from the article that each bag of classic mix (x) generates $1.50 profit and each back of fruitylicious (y) generates $1.00 of profit. Therefore, P = 1.5x + 1.0y. We, thus, enter the following into the Wolfram Alpha search box: 

8x + 4y <= 20000, 6x + 10y <= 30000, x >= 0, y >= 0, P = 1.5x + 1.0y

Wolfram Alpha generates the following solution: 



We see here three solutions to our inequalities. It's a little hard to read with the Re or the Im preceding each of the P's, but this is just Wolfram Alpha's way of dealing with complex numbers (made up of real and imaginary components).  I'm not sure where in the linear programming algorithm, things turn into complex numbers, but we'll gloss over that in this introduction.  In comparing this output with the solution in the Marriott Magazine article, we can see in this output the numbers included in the solute: 
  • On the first line, we see that P <= 3000.  3,000 is the value of P assuming we produce 0 classic mixes and 3,000 fruitilicious mixes. 
  • On the second line, we see that P <= 3750. This is the value of P assuming we produce 2,500 classic mixes and no fruitilicious mixes.  
  • On the third line, we see that P < 30000 / 7 ( approx 4285). This is the value of P assuming we produce 1428.6 classic mixes and and 2142 fruitiliciouls 
Therefore, our solution is that we should produce 1428.6 classic mixes and 2142 fruitilicious mixes. 

Additional Practice Problems

We worked through additional linear programming exercises from www.purplemath.com.  We also discussed some of the assumptions related to linear programming and it's uses, business principles related to pricing products, selling products at a loss, and disruptive innovation. 

Friday, March 16, 2012

Business Process Modeling - An Introduction


IS 330 Class Reflection
March 16, 2011

Today in my management information systems class, we discussed business process improvement. Most of the students in my class are new to the concepts of business processes, so today's class focused on understanding what processes are, the difference between as-is and to-be processes, ideas for improving business processes, managerial considerations related to automation, and the role of information systems in business process improvement.

I started out with a brief discussion of what a process is (typically a sequence of steps for getting something done). I invited students to share some of their basic processes. We talked about different routines for getting started in the morning, cooking, getting products out of a vending machine, etc.

To illustrate the concept of business process improvement, I shared two different processes for preparing oatmeal for my family breakfast. One process followed a "one-piece flow" model -- each bowl was prepared individually in the microwave.  With eight people in our family, making breakfast was a rather drawn out process.  The second process was a batch flow process with a large batch of oatmeal being prepared in a pot and either distributed to a waiting row of bowls or stored as work-in-process inventory in a plastic container in the fridge.  I haven't timed it, but I tend to like the batch process better, since I usually finish getting the batch of breakfast prepared before the children have finished coming into the kitchen in the morning.  With the one-piece flow model, I feel like I'm stuck preparing food even while the first children have already finished eating. There's less time to sit over breakfast as a family that way.

We moved on from that topic to identifying problems in business processes, focusing on inefficiencies and inconsistencies in the process. Inefficient processes are those that are not completed in a timely manner.  Excessive delays, impatient customers, long lines, and long hold times are all indicators of inefficient processes.  Inconsistent or unreliable processes are those that have variable results due to variations in the process.  In today's economy customers often expect a uniform product or service experience.  I don't expect a cheeseburger at McDonald's in Laie to taste any different from a cheeseburger at McDonald's in Honolulu. Inconsistent quality leaves customers guessing whether they'll receive appropriate service at any given time.

We can look to improve business processes by identifying bottlenecks / choke points, evaluating the order in which activities are carried out, and minimizing task switching.

We also discussed ways that information systems can help improve business processes. Simply automating processes can dramatically improve efficiency. In addition to automating repetitive portions of a process, computer software and hardware can also enforce a well-defined process by constraining the user behavior. Innovative uses of information systems frequently involve transforming or improving business processes in ways that improve the quality of the product / service along with improving the efficiency or reliability of a business process.

During our class discussion, we also gave some consideration to ethical issues regarding automation, trying to balance the benefits of increased efficiency (i.e., lower costs, more customers served) with the same or better levels of quality.  We drew on business scenarios at the Polynesian Cultural Center, Amazon.com, various manufacturing facilities, and fast-food restaurants, and BYU-Hawaii to bring context into this discussion.

Thursday, March 8, 2012

The Price of Free in the Internet Age

I've been reading an intriguing book, Free: The Future at a Radical Price, by Chris Anderson.  In the book, Mr. Anderson explores the economic and social history of offering things for free and paying for one's work in different ways.  In our information age, the marginal distribution costs of bits representing products and services has begun to approach zero. These changes will have profound effects on our models of business and society in the coming years.

To introduce my CIS 470 students to this topic, I asked them to prepare for class by reviewing an earlier (and more condensed) version of Mr. Anderson's thoughts in his Wired article "Free: Why $0.00 is the Future of Business and to share what they learned.  A wide variety of lessons came from students readings. Some focused on business opportunities identified in the article. Others pointed out the difference between free and nearly free.  A third group of students focused on the ways that free and nearly free resources can change our behaviors.  During our class discussion time, I focused mostly on this last group of ideas.

Free Food
We started by talking about free food. Everyone in the class likes free food (these are struggling undergraduate students). Of course the class recognized that often free food comes with a price. I recalled the old English saying "There's no such thing as a free lunch."  Everything has a cost; some costs are just hidden or passed on to others.  In the case of free food, I asked "What's the catch?" Often food is given out as free refreshments after an event (a church fireside presentation,  a guest lecture for a university club,  or a pushy marketing presentation). The free food is subsidized by others who are using the food to further motivate your participation.

I then lead the students through a thought experiment. "What if," I asked, "we could really make food free? What if there really were no strings attached, and I didn't ask for anything in return?" What would happen?  One student pointed out he probably wouldn't have to work anymore.  I shared my experience visiting American Samoa in 1989 and my memories of hearing my parents describe the different attitudes some islanders had about work in an environment where land is owned by the family / community, and food is abundantly available growing on breadfruit trees or as available fish.

I said if we could provide free food for everyone (like the food replicators in Star Trek: The Next Generation), we could solve a lot of problems. Hungry people on this planet tend to do one of two things: either they suffer and die, or they get angry and start a war.  Providing free food would eliminate lots of these types of problems.

Source: http://blogs.hardindd.com/?p=348


But taken to an extreme, we can envision some negative consequences of limitless free food (and presumably shelter).  With food abundantly available at zero or near zero cost, some people would find themselves over-consuming--spending their entire day eating food and watching YouTube videos. Over time, my stereotypically skinny student from Japan starts taking on the appearance of a sumo wrestler.  Thus, by removing the cost and scarcity of food, I change behavior and create different costs (in the form of health problems and potential idleness.

The relationship between food and work in our culture goes back thousands of years. In the Book of Moses, we read
 25 By the sweat of thy face shalt thou eat bread, until thou shalt return unto the ground—for thou shalt surely die—for out of it wast thou taken: for dust thou wast, and unto dust shalt thou return.
Thankfully, we don't have any societies on earth wherein food is both abundant and cheap (at least for certain segments of the population.) We won't dwell on the fact that in the United States over 35% of adults and 17% of children and adolescents are obese. (Note: these number are from the United States Center for Disease Control and Prevention and are more accurate than the figures I reported in class). Thus, when we make one resource free, we create a cost somewhere else in the system. In operations management, this is like fixing one process bottleneck only to move the bottleneck downstream.

Free Gifts
An important insight came out of one student's bringing up the role of free in gift giving.  Although gifts are free to the recipient, they normally require sacrifice on the part of the gift giver.  In many ways, the meaning of  gift is tied to the sacrifice required for it.  You can imagine a man asking a woman to marry him and giving her a priceless ring. She says "You shouldn't have!" His response: "Don't worry. It was free." would change the meaning of the exchange.  If nothing required sacrifice either on our part or the part of others, the meaning of its worth would be harder to convey.



Frictionless Purchasing
 I then directed the discussion toward another way in which products or services can be free--in terms of time.  I shared my experience yesterday of viewing a book recommendation from my friend Jesse Stay. Between Jesse's recommendation and the great title and book blurb, and the nearly free price, I thought I'd like it.  Within two minutes, I had clicked over to Amazon, and purchased the kindle version of the book.  Within less than 30 seconds from my purchase, I was reading the book in my web browser. (I really enjoyed it by the way, and it it did take about 90 minutes).  Looking back on it, I'm amazed at how little time was spent actually evaluating and buying the product.



Amazon has stated they're trying to make this entire purchase process frictionless, that means they want to make the steps from attention to impuse to buying decision to completing the purchase as quick and simple as possible.  That's why they patented their 1-click purchasing process.


Think about this for a minute. Between the 1-click purchase process and the instant availability of electronic goods through devices like the kindle, that means I have very little time between the time I decide to buy something and my completion of the purchase. There's little opportunity for me to get my cortex involved to rationally deliberate whether I really want this book or not. It's frictionless. It's free of time costs, and it's increasingly free of thought. And for Amazon the marginal cost of distributing one more electronic book (as compared with one more physical book) is near-zero.

Free Processing
I told my students their job as Information Science professionals is to find ways to make things free. To illustrate, we discussed Moore's Law. Gordon Moore, working at Intel discovered the trend that the number of transistors they were able to fit onto a single chip was doubling approximately 18 months. In very loose terms, that means the processing power of a microprocessor had been doubling every 18 months.  Interestingly, that trend continued for about 40 years.  (Today's advances in CPUs from companies like AMD are using other techniques like multiple cores to keep the performance improvements coming even as we're reaching physical limits as to how small we can make the transistors).

As an analogy for what Moore's Law means for computing, I set up a fictitious scenario in which I bought the nearby Turtle Bay Resort and hired a single student to mow all the grass on the golf course at the resort.  Pulling numbers out of the air, I suggested it would take him about 8 hours of hard work to get all the lawns mowed. But James, our student, is a fast learner because of this great education he got at BYU Hawaii, and he's figured out some process improvements. So when I check up on his work in about a year and a half, I discover that he's now getting the whole job done in 4 hours instead of 8. Since I pay James 7 dollars per hour, my cost for getting the grass mowed has dropped from 56 dollars to 28 dollars.  A year and a half later, I discover that James is now getting the grass mowed in just 2 hours, bringing my costs down to 14 dollars. In another year and a half, my costs are down to 7 dollars for the entire lawn.  My cost to mow the lawn is quickly approaching zero.

James is such a fast and low cost worker, I start finding other jobs around the resort for him to do.  In each case, the pattern is the same, in a small number of years, his productivity begins to grow exponentially and the cost per job that I ask him to do approaches zero. Meanwhile he's putting many of my other employees out of work.  Thus, the next lesson for my students: in making more things digital and marginally free, your job is to put people out of work. 


I told my students that we're rapidly approaching a time--at least in some parts of the world--where a lot of people are going to be unemployed. We're going to have to figure out as a society what we should do about that. With increased productivity, do we make everyone work only four hours a day. Or do we only employ half as many people?  What else are people going to do with their time? What other bottlenecks will we create as computers become more productive and jobs become scarce. Will our ability to create work be able to keep up with our ability to destroy work by making it digital and nearly free?

Free Education
I raised the question about my own employment prospects.  Knowledge industries (including entertainment and education) are increasingly becoming digitized.  Movie studios can duplicate video footage thereby converting 20 extras dressed up as orcs into an army of thousands. (Incidentally, I just read that the Orcs in the Two Towers film were entirely computer generated).  Studios are also experimenting with synthespian technology in which actors' words and facial expressions can be digitized and remixed to create new scenes. In education, lectures and exams can be digitized allowing a single educator to oversee potentially thousands of students. Where does that leave the future of my career? Will I be educating thousands? Or will I be unemployed?

Of course, making educational materials free doesn't make education free.  We've just shifted the cost. You may be able to access all of the information contained in an undergraduate education for free over the internet, but now the cost is your time. Will you have the self discipline and to take that time without the structure of a classroom environment? As educational content becomes free, how do we ensure that students and faculty perform the necessary cognitive exercises so that our minds continue to be active and our educational efforts yield lasting benefits.  These are questions we need to consider as we move into the future.

Tuesday, March 6, 2012

Neuroscience and internet addiction


This morning, I taught my CIS 470 class about the neuroscience of addiction.  Brain scientists divide the brain up into three sections for evolutionary / classification purposes: the brain stem (i.e., lizard brain), the limbic system (i.e., the mammalian brain), and the cerebral cortex (i.e., the ape brain). Please note, this is not an endorsement of the evolutionary theory of species development, but we do need to understand how the academic world works with our developing understanding.  Update: This model is apparently out of date with current models of thinking (http://en.wikipedia.org/wiki/Lizard_brain).
The brain stem is responsible for keeping us alive, regulating breathing, blood flow, sensitivity to light and dark, etc.  The limbic system holds the keys to much of our emotional response to things.  The prefrontal cortex manages the functions of rational thinking and decision making.  For a basic understanding of the neuroscience of addiction, we need to begin our discussion with the limbic system.

The limbic system is responsible for our basic emotional drives to things that keep us as individuals and as a species alive: food, safety, and reproduction.  When your hungry and you start craving food, that’s  the limbic system working.  When you have a new member of the opposite sex move into the ward, and that person attracts your attention (along with the attention of many of the other members of your sex in the ward) that’s the limbic system at work. If you’re driving down the road, and an animal or car unexpectedly darts out in front of you and grabs your attention, that’s your limbic system again.  Your limbic system helps motivate you to act in ways that will get you the food, safety from physical threats, and reproductive opportunities you need to survive.  
In basic terms, your limbic system (and much of your brain) works by sending signals through specialized regions of the brain, which are connected by neurons (or nerve cells) shown below.  


These neurons are like sprawling highways across your brain.  However, the neurons are not physically connected.  At the ends of the neuron, there is a small (very small) gap, called a synapse. Within the neuron, signals are passed electrically.  But between the neurons, signals are passed chemically.  
The activated neuron releases a chemical, known as a neurotransmitter, which passes across the synapse and attaches to receptors.  The more receptors that bond with the neurotransmitter chemical, the stronger the signal / activation in the connected neuron.  That activation travels across the neuron to other connection points between neurons and the process continues through the system.  
One of the key neurotransmitters used in the limbic system is dopamine. Certain cues in our environment trigger activation of the neurons in our limbic system sending dopamine and the resultant electrical activations across the nerve cells in the limbic system.  The result is we experience an “orienting response” that directs our attention and actions toward whatever was stimulating us.   
One of the challenges of the limbic system is that it wasn’t engineered for our modern society.  To illustrate, let’s look at the following: 

I showed a photo like this to a classroom full of students today and asked what they saw.  By and large, the answer was “apples.” I told them they were all wrong. What they actually saw was an image of a set of apples.  These aren’t real apples. You cannot eat them.  (I tried to eat them in front of the class, but was clearly unsuccessful).  When we stop to think about it, this makes perfect sense. No one would rationally think they could eat food that appears on a projection screen.  The trick is, our limbic system doesn’t know that. Our mammalian brains have no way of knowing the difference between a picture of an apple and a real apple. That’s because, for thousands of years, if we saw something that looked edible, it likely meant (if we could catch / harvest it) we were going to eat soon. 

It reminds me of a passage from Isaiah
And the multitude of all the nations that fight against Ariel, even all that fight against her and her munition, and that distress her, shall be as a dream of a night vision. Yea, it shall be unto them even as unto a hungry man who dreameth, and behold, he eateth, but he awaketh and his soul is empty; or like unto a thirsty man who dreameth, and behold, he drinketh, but he awaketh, and behold, he is faint, and his soul hath appetite. Yea, even so shall the multitude of all the nations be that fight against mount Zion.http://www.lds.org/scriptures/jst/jst-isa/29.7?lang=eng#6

Thus looking at pictures of food, particularly when we’re hungry, starts activating the neural circuits that lead to craving / anticipating the reward we’re going to feel when we eat it.  The impression on our brain is even stronger with images of high calorie / high-fat foods. (Such foods used to be really scarce). From what I’ve read, video is even more realistic for our limbic system.  
The limbic system also responds to cues for novelty.  If something shows up in the environment and is new, we need to determine quickly if it’s 1) a threat to our safety, 2) edible, or 3) a potential companion / mate. So new stuff gets our attention quickly.  Food gets our attention quickly.  Violence / physical threats get our attention quickly, and sex gets our attention quickly.  
So when you go to the grocery store, and stand in the checkout line, look around. What do you see.  A bunch of stimuli designed to get the attention of the limbic system. Magazines advertising the latest gossip (new stuff).  Other magazines with enormous pictures of desserts (along with headlines advertising the secrets for how to lose 10 pounds in 2 days). Rows and rows of candy bars (high fat, high calorie foods). More magazines with sexualized (and digitally enhanced) images and titles designed to entice your limbic system. Toss in refrigerators full of ice cream, sodas, and energy drinks, and you’ve created a literal dopamine gauntlet for the tired shopper who often lacks enough blood sugar to use his / her cortex to process any of this stimuli rationally.  The end result is you’ve spent more money than you anticipated.  Marketers have a very good understanding of how the brain works. I believe that consumers need to understand this as well to protect themselves. 
Drugs and the Limbic System
In the previous section, I talked about how dopamine crosses the synapse to activate certain receptors of a neighboring neuron. After a certain amount of time, dopamine that is still in the synapse is reabsorbed by the transmitting neuron. This process is known as reuptake. Certain drugs can increase the amount of dopamine in the synapse. For example, when cocaine enters the system, it can block the dopamine transporter, thereby preventing reuptake of the dopamine within the synapse.  The flooded synapse results in an excessive activation of the receiving neuron, which produces a feeling of euphoria.  
  
Source: http://upload.wikimedia.org/wikipedia/commons/thumb/e/e0/Synapse_Illustration2_tweaked.svg/300px-Synapse_Illustration2_tweaked.svg.png

When too much dopamine is available, the neuron will discard some of the dopamine receptors. When this happens, and the drug chemicals leave the body, normal life experiences generate a normal level of dopamine, but it’s not enough to cause a normal activation response, because now there are fewer neurotransmitter receptors.  This leads to feelings of withdrawal and anticipation / cravings for the drug again.  As this cycle occurs repeatedly, drug addicts often report having to take drugs just to feel normal.  These addictive chemical reaction cycles occur with drugs, pornography, certain foods, and other addictive stimuli. 
One good piece of news in all this is that after an individual “stays clean” / abstains long enough from drugs, the body will begin to restore the levels of needed neurotransmitter receptors. But this takes weeks / months / years. The challenge is that, in addition to dealing with the addictive effects of the drug, individuals have to create new habits, to replace the existing behaviors that have developed around the drug use.  During this period of detoxification, it’s very important to take part in activities that naturally increase your dopamine levels. These activities include exercising, interacting at a social level with members of both sexes, learning a new skill, taking part and progressing on a significant project, sleeping well, and participating in family activities.  
Internet Addiction
Now, this is an information sciences class, and one of the things we’re trying to figure out is how all this knowledge can inform our understanding of Internet addiction.  The Internet is a tremendous transportation and replication network--making access to novel and intensive stimuli in virtually any form (images of indulgent food, pornography, violent games) immediately available in a virtually limitless variety.  Unlike actual food consumption, we have little in the way of a physical off switch (like feelings of fullness or physical sickness after eating too much) to get us to stop stimulating ourselves with the Internet.  We can thus get stuck in a vicious cycle of checking one more YouTube video, one more status update, one more web page, one more email, etc. in a search for something to increase the level of dopamine in our limbic system synapses. 

This hyperstimulation also erodes our ability to concentrate on one thing long enough to give our cortex time to thoroughly process it.  Several minutes into a long book chapter or lecture, we start feeling restless, distracted, or sleepy. We start using the Internet not just as a tool for gathering and communicating needed information, but as a vehicle for waking ourselves up, for stimulating our brains.  Left unchecked, this behavior makes us really good at responding to immediate stimuli--and in many ways dependent on them--while making us weaklings in terms of our ability to critically think about and ponder on a given issue.  
It’s challenging for us in the computer and information sciences to avoid the Internet while recovering from these addictions, because we need it for our careers.  Furthermore our society is increasingly reliant on the network for our personal and business activities.  But an awareness of what’s happening will, hopefully, make us more mindful of our online behaviors. And as we live more fully enriching lives in the real world we will find ourselves seeking less stimulation in the virtual world.   

Friday, September 16, 2011

Transformations and Trend Lines


I'm teaching a Management Information Systems course for business students this semester, and we're starting a discussion tomorrow about technology trends including the famous Moore's Law -- the observation by an Intel engineer that the number of transistors on a microcontroller chip was effectively doubling every 18 months.  I want my students to understand what that kind of a growth function means, so I put together a spreadsheet tutorial for them. In it, I walk them through a simple example of linear regression using the LINEST function with some linear data.  

I then have them use some data from Intel to plot out the nearly exponential trend in their transistor density growth.  I show them how to use the LN function to perform a natural log transformation on the exponential data to make it more linear so that we can use LINEST to calculate a linear model. I then compare the results of that linear model with the output of the LOGEST function. The emphasis here is to show that the slope of the linear model is the same as the natural log of the growth factor b in the equation y = a * b^x.  I then discuss how we can approximate the doubling rate by dividing 70 by the growth rate. In this example, the growth rate is about 34% per year, which results in a doubling every 2.05 years. 

UPDATE: The link I had previously somehow was missing a page of instructions. The revised materials are available at http://public.iwork.com/document/?a=p50683115&d=Transformations_and_TrendLines_Tutorial.pages