1
A Brief Introduction to R
It is recommended that you install R on your own personal computer. However, if that is not an
option, R is available in most (if not all) computer labs on campus.
Installing R
To install R, go to the UCSC Information Technology Services (ITS) website:
http://its.ucsc.edu/software/list.html
Scroll down to the “R – Statistics” tab, and follow the show link. Next follow the R Project Site
link. Under the “Getting Started” section follow the link CRAN mirror then scroll down to
“USA” and select one of the sites listed – the first one listed is http://cran.cnr.Berkeley.edu/ and
is a good choice. Whichever site you choose, follow the instructions found there for the
operating system you that are using (i.e. Mac OS, Windows, etc).
Using R
It is recommended that you create a new folder for each of the required assignments and
exercises for this class.
To begin a session in R, simply click on the R-icon that has appeared on your computer. In many
cases this icon will be on your desktop, but if not go to the usual folder on your computer where
you normally find your other applications.
The first thing you will want to do is to go to the folder that you created for your work (e.g. let’s
suppose that you are working on assignment #1, and you created a directory called HW1 for this
purpose). To change folders (or directories) you just need to use the “change directory” menu
item – for Windows this is under the “File” or “Misc” tab near the top left-hand corner of the R
window.
To exit R simply type q() or close the R window. You may be asked if you want to “Save the
workspace image” – for now you can answer No.
An Example
1. Create a new folder called R_INTRO
2. Go to the canvas website for the class and in the module “Information about R” module,
download into R_INTRO the file brownian_motion.R which you will find on the page
called “R Introduction”.
3. Startup R as described above
4. Within R change to the folder R_INTRO using the appropriate tab as described above.
2
5. The folder R_INTRO should contain the sample R program called brownian_motion.R.
To run this program simply type source(“brownian_motion.R”) after the prompt in the R
window.
6. If everything is working correctly, an image should appear in a separate window that
looks something like this:
7. In addition, a copy of this image will have been created in the directory R_INTRO as a
jpeg file called brownian_plot.jpg. You can open this image by clicking on it.
8. In this simple example, R is used to create a sequence of one million random numbers
that mimic the motion of a pollen grain under the influence of Brownian motion. We will
discuss this example further in class. The image created when you run the program shows
the histogram of the pollen grain displacements – more on this is class too! The sequence
(or time series) of pollen grain displacements in this example is referred to simpl.
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45
1 A Brief Introduction to R It is recommended tha.docx
1. 1
A Brief Introduction to R
It is recommended that you install R on your own personal
computer. However, if that is not an
option, R is available in most (if not all) computer labs on
campus.
Installing R
To install R, go to the UCSC Information Technology Services
(ITS) website:
http://its.ucsc.edu/software/list.html
Scroll down to the “R – Statistics” tab, and follow the show
link. Next follow the R Project Site
link. Under the “Getting Started” section follow the link CRAN
mirror then scroll down to
“USA” and select one of the sites listed – the first one listed is
http://cran.cnr.Berkeley.edu/ and
is a good choice. Whichever site you choose, follow the
instructions found there for the
operating system you that are using (i.e. Mac OS, Windows,
etc).
Using R
It is recommended that you create a new folder for each of the
2. required assignments and
exercises for this class.
To begin a session in R, simply click on the R-icon that has
appeared on your computer. In many
cases this icon will be on your desktop, but if not go to the
usual folder on your computer where
you normally find your other applications.
The first thing you will want to do is to go to the folder that you
created for your work (e.g. let’s
suppose that you are working on assignment #1, and you created
a directory called HW1 for this
purpose). To change folders (or directories) you just need to use
the “change directory” menu
item – for Windows this is under the “File” or “Misc” tab near
the top left-hand corner of the R
window.
To exit R simply type q() or close the R window. You may be
asked if you want to “Save the
workspace image” – for now you can answer No.
An Example
1. Create a new folder called R_INTRO
2. Go to the canvas website for the class and in the module
“Information about R” module,
download into R_INTRO the file brownian_motion.R which you
will find on the page
called “R Introduction”.
3. Startup R as described above
4. Within R change to the folder R_INTRO using the
appropriate tab as described above.
3. 2
5. The folder R_INTRO should contain the sample R program
called brownian_motion.R.
To run this program simply type source(“brownian_motion.R”)
after the prompt in the R
window.
6. If everything is working correctly, an image should appear in
a separate window that
looks something like this:
7. In addition, a copy of this image will have been created in the
directory R_INTRO as a
jpeg file called brownian_plot.jpg. You can open this image by
clicking on it.
8. In this simple example, R is used to create a sequence of one
million random numbers
that mimic the motion of a pollen grain under the influence of
Brownian motion. We will
discuss this example further in class. The image created when
you run the program shows
the histogram of the pollen grain displacements – more on this
is class too! The sequence
(or time series) of pollen grain displacements in this example is
referred to simply as x. If
you simply type x after the R prompt the entire time series of
numbers will be listed – all
one million of them! Try this for yourself.
4. 9. R is a very powerful statistical analysis tool, and many of its
features are beyond the
scope of what we will cover in this class. However, we will
make extensive use of many
of the features of R to analysis time series of observations from
the earth climate system.
As an illustration try the following:
(a) Compute the mean of x by typing mean(x) after the R
prompt. The answer should be
very close to zero.
(b) Compute the variance of x by typing var(x). The answer
should be very close to one.
(c) Compute the standard deviation of x by typing sd(x). The
answer should also be very
close to one.
(d) Pick a number between one and one million (e.g. 123456)
and find this element in the
time series by typing x[123456].
(e) Now find the square root of the absolute value of the
element you identified in (d)
using the command sqrt(abs(x[123456])).
3
(f) You can use R to do simple arithmetic also, just as you
might on a pocket calculator.
For example, to compute the square root of 26.51 simply use the
command
sqrt(26.51). To find the natural log of the same number type
5. log(26.51), or to find the
log to base 10 you can use log10(26.51). This can be very handy
if you need to do
some quick calculations as part of your assignments.
10. When you are done with R, simple close the R window or
type q() at the prompt. You can
answer “No” if asked whether you want to save the workspace.
Getting Help
R has an excellent web browser for providing help. After
starting R simply type help.start() to
open the help menu in your web browser. You can also find help
about a specific command. For
example, to find more about the mean command you used in
9(a) above, simple type help(mean)
after the R prompt.
Summary
This should be enough information for now to get you started.
Each homework assignment will
provide you with further specific information as required.
Page ?
Page ?
1.
In what might be the earliest example of media synergy, some
of the first magazines in France were collections of works taken
mostly from newspapers.
A)
True
6. B)
False
2.
The word magazine comes from the French term magasin,
meaning “storehouse.”
A)
True
B)
False
3.
The first magazines in America were edited for the working
classes.
A)
True
B)
False
4.
The first colonial magazines published by Andrew Bradford and
Benjamin Franklin enjoyed instant success and continued for
several years.
A)
True
B)
False
5.
The first magazines primarily offered entertainment news and
gossip.
A)
7. True
B)
False
6.
Specialized magazines were published in America throughout
the nineteenth century.
A)
True
B)
False
7.
Some of the most influential magazines of the nineteenth
century were targeted at women.
A)
True
B)
False
8.
By the end of the nineteenth century, some magazine prices
actually went down—from thirty-five cents to ten cents.
A)
True
B)
False
9.
Production costs and reduced distribution forced magazine
publishers to raise magazine prices.
A)
8. True
B)
False
10.
President Theodore Roosevelt criticized magazine journalists
who exposed corruption in government and business by calling
them muckrakers.
A)
True
B)
False
11.
Muckraking journalists exposed corruption and abuses in the
oil, meatpacking, and patent medicine industries.
A)
True
B)
False
12.
The Saturday Evening Post continued the muckraking
tradition—especially by criticizing business corruption—into
the 1920s.
A)
True
B)
False
13.
For many years Reader'sDigest was the most popular magazine
9. in the world.
A)
True
B)
False
14.
Life magazine was able to compete with the popular radio
programs of the 1930s and 1940s by running popular fiction,
first-person news reports, and other text-based features.
A)
True
B)
False
15.
Collier's and Woman's Home Companion failed in the 1950s
because of poor management.
A)
True
B)
False
16.
TV Guide succeeded, in part, because it was readily available at
the nation's supermarket checkout lines.
A)
True
B)
False
17.
10. In a desperate attempt to compete with television in the late
1960s, the Saturday Evening Post and Life cut their cover prices
and thereby increased circulation by millions of copies.
A)
True
B)
False
18.
Women's magazines, such as Good Housekeeping and Woman's
Day,survived the competition for ad dollars better than
magazines like Life and Look.
A)
True
B)
False
19.
The magazine industry continues to shun the Internet because of
its threat to printed journals.
A)
True
B)
False
20.
Webzines such as Salon and Slate have opened new doors for
online journalism.
A)
True
B)
False
11. 21.
Specialized magazines outside the mainstream publish
information and viewpoints for readers not served by other
media channels.
A)
True
B)
False
22.
Until Playboy entered the marketplace, most large-circulation
magazines were targeted at women.
A)
True
B)
False
23.
To avoid offending readers, Sports Illustrated does not publish
investigative articles.
A)
True
B)
False
24.
To create new interest in the magazine, Playboy announced it
would no longer publish nude photos beginning in 2016.
A)
True
B)
False
12. 25.
The AARP Bulletin and AARP The Magazine have the largest
circulations of any U.S. magazines.
A)
True
B)
False
26.
The New Yorker was the first city magazine aimed at a national
upscale audience.
A)
True
B)
False
27.
Though they resemble newspapers, supermarket tabloids are
considered to be a type of magazine.
A)
True
B)
False
28.
The circulation of tabloid newspapers such as the National
Enquirer declined after their peak in the 1980s.
A)
True
B)
False
13. 29.
The average magazine contains about 45 percent ad copy and 55
percent editorial material.
A)
True
B)
False
30.
The Web and App formats give magazines unlimited space and
the ability to do things that are impossible in the print versions.
A)
True
B)
False
31.
Magazines survived the coming of television in part by
developing demographic and regional editions.
A)
True
B)
False
32.
Demographic editions of national magazines are able to charge
higher rates for advertising.
A)
True
B)
False
14. 33.
Split-run editions allow national magazines to tailor ads to
different geographic areas.
A)
True
B)
False
34.
Demographic editions of national magazines are tailored to the
interests of different geographic areas.
A)
True
B)
False
35.
Almost all magazines offer 25 to 50 percent discounts from
their rate cards to advertisers.
A)
True
B)
False
36.
The typical consumer magazine distributes far more copies
through newsstand sales than through subscriptions.
A)
True
B)
False
15. 37.
Evergreen magazine subscriptions are those that are
automatically renewed on the subscriber's credit card.
A)
True
B)
False
38.
By 2015, digital distribution accounted for about 60 percent of
the magazine audience.
A)
True
B)
False
39.
Large companies are increasingly beginning to dominate the
magazine business.
A)
True
B)
False
40.
Alternative magazines such as the Progressive and the National
Review have historically defined themselves in terms of gender
and race.
A)
True
B)
16. False
41.
Zines are usually noncommercial, small-circulation magazine
projects self-published by individuals.
A)
True
B)
False
42.
With so many specialized magazines appealing to distinct
groups, magazines today don't have as strong a role in creating
a sense of national identity.
A)
True
B)
False
43.
Early European magazines were oriented toward _____.
A)
broad political commentary
B)
discussions of women's issues
C)
medical and health advice
D)
hunting and fishing tips
E)
recent news
17. 44.
Which of the following statements about colonial American
magazines is true?
A)
George Washington, Alexander Hamilton, John Hancock, Paul
Revere, and Benjamin Franklin all had work published in these
magazines.
B)
Circulation was relatively small and typically limited to
politicians, the educated, and merchant classes.
C)
Some magazines helped rally the colonies against British rule.
D)
The very first colonial magazines had difficulty catching on.
E)
Athe options are correct.
45.
In 1828, Sarah Josepha Hale started the first magazine directed
exclusively to a female audience, called _____.
A)
Godey's Ladies Book
B)
Harper's
C)
Youth's Companion
D)
Ladies' Magazine
E)
Ladies' Home Journal
46.
What factor had an effect on the dramatic growth in magazine
circulation around the end of the nineteenth century?
18. A)
Cheaper postal rates
B)
Advances in mass-production printing
C)
Lower cover price
D)
Dramatic growth of drugstores and dime stores
E)
All of the options are correct.
47.
Who wrote History of the Standard Oil Company, first
serialized in McClure's magazine?
A)
Ida Tarbell
B)
Upton Sinclair
C)
Joseph Pulitzer
D)
Nellie Bly
E)
Frederick Douglass
48.
The term muckraker _____.
A)
was coined by President Theodore Roosevelt because he was
angry with negative reporting
B)
described investigative reporters who only wrote about
American institutions in a positive light
C)
19. was seen as an insult by leading investigative reporters
D)
described reporters who wanted to write in the simplistic and
conventional style of newspaper journalism
E)
None of the options are correct.
49.
Who wrote The Jungle, a fictional account of Chicago's
meatpacking industry?
A)
Lincoln Steffens
B)
Ida Tarbell
C)
Tim Allen
D)
Upton Sinclair
E)
Frank Norris
50.
Which of the following is not a result of muckraking journalism
in magazines around the start of the twentieth century?
A)
Antitrust laws for increased government oversight of business
B)
The creation of government oversight of food and drugs
C)
A progressive income tax
D)
The direct election of U.S. senators
E)
A drop in attention paid to the plight of immigrants in big cities
20. 51.
One of Cyrus Curtis's strategies for reinvigorating the Saturday
Evening Post was to _____.
A)
appeal to farmers
B)
romanticize American virtues through images like Norman
Rockwell paintings
C)
denigrate American values
D)
continue the muckraking tradition
E)
publish risqué pictures
52.
Which magazine was the foremost outlet for photojournalism in
the mid-twentieth century?
A)
Life
B)
The North American Review
C)
The Nation
D)
The Saturday Evening Post
E)
Harper's
53.
Which of the following statements about general-interest
magazines is false?
21. A)
They became popular starting in the mid-to-late-nineteenth
century.
B)
With one or two exceptions, they had mostly gone out of
business by about 1910.
C)
Television played a big role in signaling the demise of general-
interest magazines.
D)
Photojournalism was a key aspect of general-interest magazines.
E)
None of the options are correct.
54.
One of the reasons for TV Guide's popularity was that _____.
A)
its first issue featured Elvis
B)
it offered lurid commentary about TV stars
C)
it was initially free
D)
many newspapers hadn't yet started publishing TV listings
E)
All of the options are correct.
55.
Media baron Rupert Murdoch bought TV Guide in 1988 because
_____.
A)
it was one of the world's most profitable magazines
B)
he wanted to ensure that programs for his Fox network would be
22. listed
C)
he wanted to change the magazine's liberal editorial policy
D)
he enjoyed reading the magazine
E)
he was afraid it would go out of business without him
56.
Which of the following is not a reason Life and Look magazines
went out of business in the early 1970s?
A)
Their paid circulation had plummeted, with the magazines
falling out of the Top 10 magazines in the nation.
B)
Advertisers were shifting their money toward television.
C)
Postage rates had increased for oversized magazines.
D)
They had relatively small supermarket sales.
E)
They were being sold for far less than the cost of production.
57.
Which of the following was designed as a general-interest or
mass audience magazine?
A)
The Saturday Evening Post
B)
Reader's Digest
C)
Time
D)
People
23. E)
All of the options are correct.
58.
Which popular magazine was launched in 1974 by Time Inc.?
A)
Sports Illustrated
B)
The Saturday Evening Post
C)
People
D)
Life
E)
TV Guide
59.
An example of a magazine that was conceived as online-only is
_____.
A)
Time
B)
TV Guide
C)
Wired
D)
Entertainment Weekly
E)
Slate
60.
Launched in 2009 by MSN and BermanBraun, _____ is a
leading online entertainment magazine.
24. A)
Entertainment Weekly
B)
Wired
C)
Wonderwall
D)
Salon
E)
Slate
61.
Claiming over 25 million unique monthly visitors, _____ is
currently the leading online magazine.
A)
Salon
B)
Slate
C)
Wonderwall
D)
Wired.com
E)
Elle Girl
62.
Which of the following statements about the relationship
between magazines and the Internet is false?
A)
The Internet was initially seen as a medium that would kill print
magazines.
B)
Some print magazines that have folded are finding new life on
the Internet.
25. C)
Online-only magazines have gained journalistic credibility.
D)
The Internet gives magazines the ability to do things that they
couldn't do in print.
E)
The Internet is still widely considered to be putting the final
nails into the coffin of print magazines.
63.
An example of the way in which an online magazine might be
different from a print magazine is to _____.
A)
feature interactive 3-D models
B)
allow readers to click on an item on a digital page and be taken
to an online store where they can purchase it
C)
feature video and audio
D)
use an innovative layout that is only possible online
E)
All of the options are correct.
64.
Online-only and online versions of magazines are _____.
A)
having trouble attracting an audience
B)
more expensive to produce and distribute compared to printed
versions
C)
able to add interactive components to their articles
D)
26. struggling with space limitations in the online format
E)
All of the options are correct.
65.
Which of the following is an example of a consumer magazine?
A)
Progressive Grocer
B)
Dakota Farmer
C)
Dairy Herd Management
D)
Advertising Age
E)
O: The Oprah Magazine
66.
Hugh Hefner's Playboy magazine became an instant success in
1953, thanks in part to _____.
A)
an expensive TV ad campaign
B)
sending free copies to one million male college students
C)
articles that criticized divorced and working women
D)
a nude calendar foldout of Marilyn Monroe
E)
insightful feminist articles
67.
Which of the following is true about the magazine Sports
27. Illustrated?
A)
It is an example of a general-interest magazine.
B)
It is never criticized for its annual swimsuit edition.
C)
It is never credited with major investigative reporting.
D)
It was originally aimed at well-educated, middle-class men.
E)
It originally promoted its content as “humanized geography.”
68.
The top children's magazine in 2014 was _____.
A)
Ranger Rick
B)
Maxim
C)
Boy's Life
D)
Highlights for Children
E)
Youth's Companion
69.
Of the following magazines, which has the largest circulation in
the United States?
A)
Maxim
B)
AARP The Magazine
C)
Time
28. D)
Reader's Digest
E)
TV Guide
70.
Among magazines that target audiences by age, the most
dramatic recent success has come from those aimed at _____.
A)
children
B)
tweens
C)
young adults
D)
adults over fifty
E)
thirty- to forty-year-olds
71.
Which of the following is true about minority-targeted
magazines?
A)
They have a history dating back to before the Civil War, with
titles like Emancipator and Reformer.
B)
They have a history dating back to the first half of the twentieth
century, with titles like Negro Digest and Ebony.
C)
Minority-targeted magazines cover only racial minorities.
D)
They were popular during the Civil Rights movement of the
1950s and 1960s, but have mostly gone out of business since
then.
29. E)
Most of them started up as Webzines in the last ten years.
72.
The bilingual magazine _____ is the most successful English-
language publication for Hispanic women.
A)
Latina
B)
Essence
C)
Vanidades
D)
ESPN Deportes
E)
None of the options are correct.
73.
Within the magazine publishing industry, the department that
usually produces the nonadvertising content of a magazine is
known as the _____.
A)
advertising and sales department
B)
production and technology department
C)
editorial department
D)
circulation and distribution department
E)
table of contents department
74.
30. A magazine's rate card lists _____.
A)
what it costs to advertise in the magazine
B)
how often the magazine is published
C)
the price of a one-, two-, or three-year subscription
D)
how much the magazine pays its freelance writers
E)
None of the options are correct.
75.
Advertisers frequently pressure magazines to publish _____.
A)
gatefold covers
B)
more complimentary copy
C)
investigative stories
D)
color photos
E)
more often
76.
A national magazine with regional editions _____.
A)
tailors ads to different age groups
B)
contains different stories for different geographic regions
C)
relies solely on subscription sales
D)
31. relies solely on newsstand sales
E)
sends special editorial content to readers with high incomes
77.
Split-run editions are _____.
A)
magazines that publish two issues a month
B)
a new ownership strategy—such as when Bertelsmann bought
Random House
C)
magazines that have ads that are tailored for geographic areas
D)
national magazines that tailor their content for specific groups
of readers
E)
None of the options are correct.
78.
A main purpose of split-run and demographic editions of
magazines is to _____.
A)
move the magazine industry back to more general-interest
publications
B)
make sure that local and regional companies are cut off from
advertising in nationally distributed magazines
C)
create fewer places for advertisers to spend their money
D)
attract more targeted advertisers and compete with television
advertising
E)
32. None of the options are correct.
79.
Within the magazine publishing industry, the department that
typically monitors single-copy and subscription sales is known
as the _____.
A)
advertising and sales department
B)
circulation and distribution department
C)
table of contents department
D)
editorial department
E)
production and technology department
80.
In terms of ownership structure and business models, the
magazine industry has the most in common with which other
form of mass media?
A)
Book publishing
B)
The recording industry
C)
The Internet
D)
Movies
E)
Cable television
81.
33. Which of the following statements about Linux software is true?
A)
Exposing government corruption
B)
Transforming the United States from a producer society to a
consumer society
C)
Forcing change in powerful institutions
D)
Giving a voice to ordinary American citizens
E)
None of the options are correct.
82.
A style of early-twentieth-century investigative journalism,
______________________ refers to reporters crawling around
in society's muck to uncover a story.
83.
A type of magazine that addresses a wide variety of topics,
______________________ magazines are aimed at a broad
national audience.
84.
Salon is an example of a ______________________, a magazine
that appears exclusively online.
85.
______________________ typically publish human-interest
stories, celebrity gossip, and crime stories that push the limits
of decency and credibility.
34. 86.
Editions of national magazines whose advertising is tailored to
subscribers and readers according to occupation, class, and zip-
code address are ______________________ editions.
87.
______________________ subscriptions automatically renew
on a credit card account unless subscribers request that the
automatic renewal be stopped.
88.
The ____ championed women's property rights.
89.
____ published the work of writers such as Emerson, Thoreau,
and Twain.
90.
____ is the longest-running magazine in U.S. history.
91.
____ pioneered the national political magazine format.
92.
_____ took on the Standard Oil Company.
93.
_____ investigated patent medicines.
35. 94.
_____ investigated Chicago's meatpacking industry in The
Jungle.
95.
_____ targeted urban problems.
96.
In _____, ads in national magazines are tailored for geographic
areas.
97.
In _____, unique versions of magazines can be sent to specific
subscriber groups.
98.
_____ are magazines created exclusively for online readers.
99.
Explain the role of early magazines in America's political and
social shift from British colony to independent nation.
100.
What are the typical characteristics of a general-interest
magazine? What types of content would you expect to see in
such a magazine?
36. 101.
What role did magazines play in social reform in the late
nineteenth and early twentieth centuries?
102.
When and why did some of the major general-interest magazines
fail?
103.
What are some of the advantages that online versions of
magazines have over print versions?
104.
How are some online-only magazines trying to reinvent the idea
of a magazine?
105.
In what ways do magazines serve democratic ideals?
106.
Why is the muckraking spirit—so important at the turn of the
twentieth century in popular magazines—generally missing
from magazines today?
107.
Imagine you are the marketing director of your favorite
magazine. What would you do to increase circulation?
108.
37. Do your favorite magazines define you primarily as a consumer
or as a citizen? Do you think magazines have a responsibility to
educate their readers as both? Why or why not?
Answer Key
1.
A
2.
A
3.
B
4.
B
5.
B
6.
A
7.
A
8.
A
9.
B
10.
A
11.
A
12.
B
13.
A
14.
B
15.
42. Evergreen
88.
Godey's Lady Book
89.
The North American Review
90.
The Saturday Evening Post
91.
The Nation
92.
Ida Tarbell
93.
Colliers
94.
Upton Sinclair
95.
Lincoln Steffens
96.
split-run editions
97.
demographic editions
98.
Webzines
99.
100.
101.
102.
103.
104.
105.
43. 106.
107.
108.
Extra_Credit_folder/extra_credit_P2.R
#
# Enter name here.
#
#name<-"John Doe"
#
# Read the AAO principal component amplitude time series.
#
aao<-read.table("aao_amp_1979-2013.dat")
attach(aao)
aao_data<-V1
time<-seq(1979,2013,len=length(aao_data))
#
# Plot the PDF with normal distribution.
#
x<-seq(-4,3,0.01)
y<-exp(-(x-
mean(aao_data))^2/(2*var(aao_data)))/(sd(aao_data)*sqrt(2*pi)
)
jpeg("extra_credit_plot4.jpg")
hist(aao_data,seq(-4,3,0.5),prob=TRUE,main="Probability
Density Function of AAO Amplitude",xlab="AAO
Amplitude",sub=name,ylim=c(0,0.5))
lines(x,y,col="red",lwd=2)
dev.off()
#
56. OCEA 90: Extra Credit Answer Sheet
Name:
Section:
TA:
Yang Xiang
Henry Houskeeper
Assignment Instructions:
1. Put your name and section at the top of
this sheetand check the appropriate TA box.
2. Download the assignment from the class website.
Follow all instructions carefully and
execute all R scripts as prescribed.
3. Answer all HW questions in the spaces provided
below. (Please note:each answer does not
need to fill the entire space provided. The
accuracy of your answer is valued, not its
length.)
4. All Figures must be printed out and stapled to
the back of this answer sheet. (Please print
figures on as few pages as possible, but ensure
that all figures are still readable.)
5. Remember the following requirements:
a. Submit your assignment on this answer sheet
b. Submit your assignment on time (10% grade
reduction per calendar day late)
c. Submit all necessary figures
d. Submit all figures with your name printed on
them (no credit for the entire
57. assignment if your name is not on the figures)
6. Also:
a. A hard copy of this answer sheetis required.
Electroniccopies will not be accepted.
b. Do not share answers with your classmates
(we follow UCSC procedures in cases of
academic misconduct).
7. You are welcome to attend office hours
for any TA (and of course the professor)!
1A(iii).
1B.
OCEA 90 Fundamentals of Climate Fall 2019
1C.
1D(i)
58. 1D(ii)
1E
2i. The probability of the AAOamplitude being at
or below -1 is
2ii. The probability of the AAOamplitude being at
or below +1 is .
Therefore,
the probability of the AAOamplitude being greater
than -1 and less than or equal to
+1 is .
2iii. The probability of the AAOamplitude being
above +1 is .
__MACOSX/Extra_Credit_folder/._AnswerSheet_ExtraCredit.p
df
Extra_Credit_folder/extra_credit_P1.R
#
# Enter name here.
#
#name<-"John Doe"
#
# Read the AAO principal component amplitude time series.
#
59. aao<-read.table("aao_amp_1979-2013.dat")
attach(aao)
aao_data<-V1
time<-seq(1979,2013,len=length(aao_data))
#
# Plot time series
#
jpeg("extra_credit_plot1.jpg")
plot(time,aao_data,"l",xlab="Time in years",ylab="AAO
Amplitude",main="Time Series of AAO Amplitude",sub=name)
dev.off()
#
# Plot the histogram.
#
jpeg("extra_credit_plot2.jpg")
hist(aao_data,seq(-4,3,0.5),ylim=c(0,100),main="Histogram of
AAO Amplitude",xlab="AAO Amplitude",sub=name)
dev.off()
#
# Plot the PDF
#
jpeg("extra_credit_plot3.jpg")
hist(aao_data,seq(-
4,3,0.5),ylim=c(0,0.5),prob=TRUE,main="Probability Density
Function of AAO Amplitude",xlab="AAO
Amplitude",sub=name)
dev.off()
#
detach()
Extra_Credit_folder/AnswerSheet_ExtraCredit.docx
OCEA 90 Fundamentals of Climate Fall 2019
60. OCEA 90: Extra Credit Answer Sheet
Name:
Section:
TA: Yang Xiang |_| Henry
Houskeeper |_|
Assignment Instructions:
1. Put your name and section at the top of this sheet and check
the appropriate TA box.
2. Download the assignment from the class website. Follow all
instructions carefully and execute all R scripts as prescribed.
3. Answer all HW questions in the spaces provided below.
(Please note: each answer does not need to fill the entire space
provided. The accuracy of your answer is valued, not its
length.)
4. All Figures must be printed out and stapled to the back of
this answer sheet. (Please print figures on as few pages as
possible, but ensure that all figures are still readable.)
5. Remember the following requirements:
a. Submit your assignment on this answer sheet
b. Submit your assignment on time (10% grade reduction per
calendar day late)
c. Submit all necessary figures
d. Submit all figures with your name printed on them (no credit
for the entire assignment if your name is not on the figures)
6. Also:
a. A hard copy of this answer sheet is required. Electronic
copies will not be accepted.
b. Do not share answers with your classmates (we follow UCSC
procedures in cases of academic misconduct).
7. You are welcome to attend office hours for any TA (and of
course the professor)!
1A(iii).
61. 1B.
1C.
1D(i)
1D(ii)
1E
2i. The probability of the AAO amplitude being at or below -1
is
2ii. The probability of the AAO amplitude being at or below +1
is . Therefore, the probability of the AAO amplitude
being greater than -1 and less than or equal to +1 is .
2iii. The probability of the AAO amplitude being above +1 is
.
__MACOSX/Extra_Credit_folder/._AnswerSheet_ExtraCredit.d
ocx
Extra_Credit_folder/extra_credit_canvas.pdf
1
62. Extra Credit Assignment
DUE DATE: Friday, 6 December, in class – NO EXCEPTIONS
Download the following files onto your computer which you
will find on canvas on the “Extra
Credit Assignment” page:
extra_credit_P1.R
extra_credit_P2.R
extra_credit_P3.R
aao_amp_1979-2013.dat
Next, start up “R” and at the prompt (>>) enter your name in the
following way:
name<-“Jane Doe”
Important: Be sure to do this before you run each new program.
This step is very important since it will identify you on the
results of your work. If your
name does not appear appropriately on the graphical output that
you hand-in with your
completed assignments, you will receive no credit for this
assignment. In addition, if you
omit this step, the R-programs for this exercise will not work
correctly and you will get an
error message.
PLEASE HAND IN ALL OF THE FIGURES GENERATED BY
63. THE PROGRAMS
THAT YOU RUN FOR THIS ASSIGNMENT.
The Antarctic Oscillation (AAO)
As we discussed in class, principal component analysis of the
750mb geopotential height over
the entire southern hemisphere reveals the existence of an
annular mode of variability called the
Antarctic Oscillation (the AAO; also sometimes referred to as
the Southern Annular Mode
(SAM)) . Figure 1 shows the pattern of 750mb geopotential
height anomalies associated with the
AAO which recall is the first principal component.
2
Question 1:
Figure 1: The 750mb geopotential height associated with the
positive phase of the AAO.
(a) Run the program “extra_credit_P1.R” in R. This will load
the data for the principal
64. component time series of the monthly mean 750mb geopotential
height anomalies
associated with the Antarctic Oscillation (AAO) for the period
1979-2013, and will
generate three figures: extra_credit_plot1.jpg - a plot of the
time series of the AAO
principal component time series (i.e. the amplitude of the
pattern shown in Fig. 1);
extra_credit_plot2.jpg – a histogram of the AAO amplitude;
extra_credit_plot3.jpg –the
probability density function (PDF) of the AAO amplitude. The
time series of AAO
amplitude is called “aao_data.” (i) First compute the mean
AAO amplitude for the entire
35 year period, and record the value that you obtain on plot3.
(ii) Next, estimate the mode
of the probability density function using either plot2 or plot3,
and record this number on
plot3. (iii) Briefly explain how the mean is computed, and the
definition of the mode, and
compare the two numbers computed here.
(b) Compute the standard deviation of the AAO amplitude, and
record this number on plot3.
Explain what is meant by the standard deviation.
3
(c) Now run the program extra_credit_P2.R. This will generate
a new figure called
extra_credit_plot4.jpg which is the same as plot3 except a
normal distribution with the
same mean and standard deviation as the AAO amplitude time
65. series is superimposed on
the PDF. Briefly describe how well the PDF of the AAO
amplitude is described by a
normal distribution.
(d) Now run extra_credit_P3.R which yields an additional figure
called
extra_credit_plot5.jpg which shows the cumulative probability
distribution for the AAO
amplitude. (i) In your own words, explain what a cumulative
probability density function
shows. (ii) Using plot5, estimate the median of the distribution
and explain clearly how
you did this. Record this number on plot3 and compare to the
mean and the mode from
part (a).
(e) If the PDF of the AAO amplitude was described by a normal
distribution, what can you
say about the mean, the mode and the median of the amplitude?
Question 2:
Consider the following scenario. A group of researchers at the
NOAA Aeronomy
Laboratory in Boulder, Colorado, is trying to establish whether
a relationship exists
between the amplitude of the AAO and the rate of stratospheric
ozone depletion that
occurs each year over the Antarctic continent. They have asked
you to provide them with
the following probabilities:
(i) The probability that the AAO amplitude will be less than or
equal to -1;
(ii) The probability that the AAO amplitude will be greater than
66. -1 and less than or equal
to +1;
(iii) The probability that the AAO amplitude will be greater
than +1.
Estimate these three probabilities using information from
question 1, and record them on
plot5.
__MACOSX/Extra_Credit_folder/._extra_credit_canvas.pdf
Extra_Credit_folder/extra_credit_P3.R
#
# Enter name here.
#
#name<-"John Doe"
#
# Read the AAO principal component amplitude time series.
#
aao<-read.table("aao_amp_1979-2013.dat")
attach(aao)
aao_data<-V1
time<-seq(1979,2013,len=length(aao_data))
#
# Plot the Cumulative Probability Distribution.
#
jpeg("extra_credit_plot5.jpg")
plot(ecdf(aao_data),xlab="AAO
Amplitude",ylab="c(T)",main="Cumulative Probability
Function: AAO
Amplitude",sub=name,do.points=FALSE,verticals=TRUE)
dev.off()
detach()