Functions - Mapping from Sets to Sets Functions are defined by an input and an output. The input refers to what you areputting into the function, and the output is what comes out of it. Functions can alsobe described as mapping from one set to another set. The set being mapped from iscalled the domain, and the set being mapped to is called the range. We will not begin our discussion of functions by examining the most commonapproach, in which one draws a graph. That method is familiar to you. Instead, wewill begin with an approach that's less well-known – one that emphasizes a keyproperty of functions: their ability to transform inputs into outputs.So here is a picture to keep in mind. Suppose we have a set A, represented by thelittle bubble on the left, and a set B, represented by the little bubble on the left. Thegeneral definition of a function f from A to B is a rule or formula that takes everyelement from A and produces some element from B. For example, we can imagine amachine that takes an apple from A and spits out an orange from B. Here's A, a little walking along, gets fed into the machine. Lord knows what happenshere, we're sort of covering it up, censoring it with these blue dots. And at the end ofthe day, out comes an f(a), that's an output over here. Thus, it is a mechanisticprocess in which the input a is transformed into an output f(a). The function of amachine is not simply a graph or a list of inputs and outputs. It is the rule thattransforms one thing into another.
Suppose you have a set A that consists of 1, 2 and 10. Suppose your set B has theelements Apple, DE, and Monkey. Given that information, you might define afunction f from A to B such that f(1) = Apple, f(2) = Apple and f(10) = Monkey. That iswhat we mean by a function. To illustrate visually: 1, 2 and 10 are in A; Apple, DEand Monkey are in B; f maps 1 to Apple, 2 to Apple and 10 to Monkey. Suchmappings are important in mathematics. They can be used for many purposesincluding finding patterns and organizing data. Let's recast one of the things. For example, suppose x equals all the people from theVBS study. That's the third time we've mentioned it. It may actually be a real disease,see if we can get a patent on the treatment. All people from the VBS study. Let'sdefine a function called test from x to y; this function is the medical test that we takewhen we want to tell whether or not you have VBS. We're going to say that a test fora person equals plus if that person tested positive and minus if that person testednegative. And so it's just a way of operationalizing the idea; it's that function.
The concept of defining a function is simple. Suppose you're running a business.And let's say that capital Y stands for all the years. So this might be going from 2010,2011, 2012, on forever, and over here on the other side we have the real numberline. Define a function called Profit. From Y to R where profit of a particular year isequal to the profit in that year, profit / loss in that year. It should be noted that thetarget of this function—the real line—is the real line because it's possible that profit in2011 was $1,007 and it might be so that profit in 2012 was -10,000. This might betypical of a thesis on running a business or not doing so well. The main concept wesee here is really not much more than defining a function from one set to anotherset. We can get a bit more advanced here, and tie into something you see a lot inmachine learning. The truth is that you don't always have functions in life—you oftendon't know what every input to output is. So in what's called supervised learning, youfigure out functions from a little bit of examples of input and output. For example: theprofit function. From years to the real line, you understood how every output relatedto every input. If you know what profit of the year was for every year, you'd be inbusiness, as they say. If you knew what the result of the test was on every person,you wouldn't have to give them the test.What you do in supervised learning is often given some examples. So for example ifyou're trying to figure out you have a set A and a set B and you have a mysteryfunction f and you're trying to figure out. You're often given some examples of a andA and outputs f(a) and B. You try to figure out the function that predicts their profit.This is called pattern analysis.