Chapter 2 Summary Statistics
Our first topic will be summary statistics and the basic question we want to ask is: given a list of numbers how can we describe its basic shape?
We will typically denote our list of numbers \(x\) and refer to it as a sample or dataset. We can generate a particular example in R by doing the following.
## [1] 43 3 1 1 25 12 37 29 15 45
This will sample \(10\) numbers “randomly” from the the integers between \(0\) and \(50\). Random can be a loaded term and we will talk more about what it can mean later, but here it means that each number is equally likely to be selected at each draw. The replace=TRUE
bit means that we “put” a number back into the pot after we draw it so that we have the possibility of drawing it again. We will talk more about the various ways samples can be taken later on in the course.
2.1 Frequency Histograms
We can visualize the list of numbers using a histogram as shown here.
This is essentially a bar graph where the x-axis shows ranges and the y-axis gives the count of numbers in each range that appear in the sample. Or, said another way, the height of each bar is equal to the count of numbers in each range. This is called a frequency histogram because it displays the number of times each number appears on the list.
2.2 How Large Are the Numbers on the List?
So, what do we really mean by the size of the numbers on the list? The right definition can often depend on what you are interested in. Maybe you only need to know the range of the numbers.
## [1] 45
## [1] 1
These measure the extremes of the dataset, but how are the numbers distributed between them? Are they piled up on one side of the other? Do they mostly fall in the middle or are they evenly spread out? We can see the distrubution on a histogram, but how do we quantify these properties? We will do this with two numbers. One will measure where the “center” of the sample falls and the other measures how spread out the sample is. These are sometimes called measures of central tendency. Let’s first discuss how we can describe the center of the dataset.
2.2.1 The Median
The median of a list of numbers is the value at the midpoint if we were to arrange the numbers in order. This can also be thought of as a value separating the higher half from the lower half.
## [1] 1 1 3 12 15 25 29 37 43 45
## [1] 20
We can visualize the median on a frequency histogram.
A nice property of the median is that it is not very sensitive to outliers, that is, numbers that are far from the center of the dataset.
## [1] 20
Now watch what happens we add some very large numbers to the list.
## [1] 25
## [1] 25
## [1] 25
Notice that the median isn’t very sensitive to the value of an added outlier. So, when data is known to have some kind of skew it is common to use medians to describe the center. A typical example of this is income due to its concentration in the hands of relatively few.
The median also has the property that if we were to randomly select a number from our list it would be just as likely be greater than the median as less. There is an interesting relationship between statistics and probability that we will discuss more in chapter 4.
2.2.2 The Average
Another way to define the center of a dataset is the average and in order to define it we will introduce a bit more notation. Recall that we are calling our list of numbers \(x\). We could reference the individual numbers in the list by \(x_i\) where \(i\) can range between \(1\) and \(n\) where \(n\) is the size of the list. The average or mean of the list \(x\) can then be defined by the following expression. Note that we are following a fairly standard convention of denoting the average by the Greek letter “mu”. Sometimes the mean is also denoted \(\bar{x}\).
\[\mu(x) = \bar{x} = \frac{1}{n} \sum_{i=1}^n x_i\] Here we are using summation notation which is convenient way of writing down a sum of an arbitrary number of terms. Let’s look at an example to make sure we see how this notation works.
Example: Let \(x = \{1, 6, 4, 7, 8\}\), then the average of \(x\) is given by
\[\mu(x) = \frac{1}{5} \sum_{i=1}^5 x_i = \frac{1}{5} (1 + 6 + 4 + 7 + 8) = \frac{1}{5} (26) = 5.2\]
Of course, we could also let R do this for us.
## [1] 5.2
Now let’s talk about some interpretations of the average. One is that it is the number that “balances” the histogram in the sense depicted in this image.
As we slide the rightmost part of the histogram out the average must move with it in order to prevent the histogram from tipping. Maybe this is why the average is sometimes called the first moment (see the definition of a moment from physics).
We can perform a similar experiment as we did with medians to look at how outliers affect the mean.
## [1] 5.2
## [1] 156544.2
## [1] 57546.67
## [1] 12757932
Unlike the median, the mean is very sensitive to outliers, but this isn’t always a bad thing as we will see in a moment.
Another interpretation of the mean is that is the value for a “typical” number of the list. Or, more precisely, if we randomly select a number from the list the mean would be the best guess for what the value would be in the sense that it would, in the long run, be closer to the actually selected numbers than any other guess. We will talk more about this as well in chapter 4. Notice that here we care about the outlier because we would, even if it was only occassionally, draw it from the list if we were to take enough draws.
To finish off this section we note that the relationship between the mean and median can give information about the shape of the histogram. Here is a nice graphic from the wikipedia page on skewness. The third measure shown here is the mode. This is the value that occurs most often in the list, so it corresponds to the maximum value of the histogram.
2.2.3 Root Mean Square
There is another measure of size that is important, but sometimes not given the attention it deserves. The expression below defines the root mean square of a list.
\[RMS(x) = \sqrt{\frac{1}{n}\sum_{i=1}^n x_i^2}\]
Why do we need another way of measure the size of the list? Consider the following example.
Notice that this histogram is fairly symmetric about \(0\). This means that we should expect the mean to be close to \(0\) (for example, by thinking about the balancing analogy above).
## [1] -0.01712676
Notice what happens when we add balanced outliers.
## [1] -0.01712676
The mean is unchanged! This isn’t good if we are interested in measuring the size of the magnitude of the numbers. This is where the root mean square comes in. It is sensitive to adding balanced outliers.
## [1] 1.034873
## [1] 1.126244
It is reasonable to ask why we use this measure instead of something “simpler” like, for instance, taking the average of absolute values. In truth, that would also be a reasonable way to measure the size of the magnitudes of the numbers (average absolute deviation is a fairly common way to measure error). However, the root mean square is related to the notion of the norm of a vector in the Euclidean space \(\mathbb{R}^n\) which, as we will see in chapter 3, can be exploited. If this is unfamiliar, then the takeaway is that this formula fits into a larger framework and this is convenient.
2.3 How Spread Out Are the Numbers?
Now that we know a few ways to describe the center of a list of numbers we can talk about measuring how the numbers are arranged around the center. Generally speaking we will use the mean as our definition of center.
2.3.1 Standard Deviation
The deviation of a number on our list is defined as the difference between the number and the mean of the sample. The standard deviation is defined to be the root mean square of the deviations.
We can write the standard deviation formally as the following expression.
\[\sigma(x) = \sqrt{\frac{1}{n}\sum_{i-1}^n (x_i - \bar{x})^2}\] Let’s revisit the list we used in the mean example above, but this time compute the standard deviation. Recall that our list is \(x = \{1, 6, 4, 7, 8\}\) and the average of the list was \(5.2\).
\[\sigma(x) = \sqrt{\frac{1}{5} \sum_{i=1}^5 (x_i - 5.2)^2} = \] \[ = \sqrt{ \frac{1}{5} ((1 - 5.2)^2 + (6 - 5.2)^2 + (4 - 5.2)^2 + (7 - 5.2)^2 + (8 - 5.2)^2)} \approx 2.48 \]
We can also do this using R.
## [1] -4.2 0.8 -1.2 1.8 2.8
Now that we have the deviations we can take the root mean square to obtain the standard deviation.
## [1] 2.481935
R does have a built in sd
function. Let’s give that a shot.
## [1] 2.774887
This value is different because this function in R is actually what is typically called the sample standard deviation. What we defined above is technically called the population standard deviation. The sample standard deviation is given by the following.
\[S(x) = \sqrt{\frac{1}{n-1}\sum_{i-1}^n (x_i - \bar{x})^2}\]
The difference between the population and sample standard deviations is outside of our scope for now, but the fact that there are two notions of standard deviations is something to be aware of. We will go into more detail when we discuss probability in chapter 4.
2.3.2 Variance
The variance of a list of numbers is defined to be the square of the standard deviation and, as such, is typically denoted \(\sigma^2\).
\[\sigma^2(x) = \frac{1}{n}\sum_{i-1}^n (x_i - \bar{x})^2\]
There are instances when working with a quantity that contains a square root is inconvenient and often using the variance can lead to simpler arithmetic, but it carries essentially the same information as the standard deviation.
2.4 Density Histograms
As we previously mentioned, frequency histograms are essentialy just bar charts. This means that the scale of the y-axis depends on the numbers appear in our list. This can make it difficult to reason about the data or compare datasets to each other. For example, given the following histogram how could we quickly estimate the percentage of numbers that fall between \(1\) and \(2\)?
We would need to sum up the heights of each bar between \(1\) and \(2\) and then divide by the size of the list. This isn’t particularly difficult, but we can make this more easily read off the histogram. A density histogram is one where the the area of each bar corresponds to the percentage of numbers that fall within each range. If we restrict ourselves to histograms with bins of all the same width, then we can obtain the density histogram by dividing the frequency of each number by the sample size.
To estimate the percentage of the numbers that fall between \(1\) and \(2\) we can estimate the total area of the bars between \(1\) and \(2\). Each bar has width \(0.5\), so the area of the bar between \(1\) and \(1.5\) is about \(0.5 * 0.2 = 0.1\) and the bar between \(1.5\) and \(2\) is has area about \(0.5 * 0.1 = 0.05\). So, the percentage of the numbers that fall between \(1\) and \(2\) is about \(15\%\).
Density histograms will play an important role in chapter 4 when we talk about the relationship between probability and statistics.
2.5 Standardization
We can think of converting from a frequency histogram to a density histogram as a way of “standardizing” the data. In other words, we rescale so that the y-axes of all of our histograms have the same scale. It is often also convenient to rescale the data itself. We will give an example of why we might want to do this shortly, but first we will describe a typical way in which this is done.
Consider the following density histogram.
To standardize this histogram we will make two modifications. The first will be to compute the mean of the data and then subtract that from each number in the sample. Let’s do this using R and then look at the resulting histogram.
Notice that the histogram is now centered at \(0\) instead of whatever the mean of the original dataset was. It can be nice to center histograms at \(0\) if we are comparing the shape of data across datasets that may have different means (we will look at an example of this in the next section). It is interesting to note that the mean of the dataset after subtracting the original mean is \(0\).
## [1] 1.577203e-15
Note that this number is in scientific notation and is very close to zero. It is not exactly zero due to rounding error in the numerical computation.
The second modification we will make is to divide each number in the sample by the standard deviation of the sample. Let’s do this and then look at the effect on the histogram.
Notice that this standardized histogram has the same shape as the previous one, but it has been rescaled so that the majority of the values fall between \(-2\) and \(2\).
We can interpret the rescaled data to be telling us how many standard deviations from the mean each datapoint in the original dataset falls. Sometimes these are called standard units and this is also related to the z-statistic that is used in hypothesis tests. But, this is a topic for chapter 5.
In the next section we will look at an example of how standardizing data can be a powerful tool for data analysis.
2.6 Example
Consider the following situation motivated by a real situation within Mailchimp data. We have many users and each of their email campaigns have an associated open rate. Below we see density histograms for three different users showing the distributions of their open rates across all campaigns they have sent.
We can see from these histograms that the mean open rates for these users are about \(20\), \(30\), and \(60\) respectively. We can also see that the variances around the means are different for each user. This makes sense since each user’s audience will engage at different rates across campaigns.
Now suppose we want to analyze the impact of some Mailchimp feature on open rate. We could split each histogram by whether or not the campaigns used the feature.
Now we have two histograms for each of these users. One showing open rate using the feature and the other showing open rate not using the feature. It appears that there is a difference between open rates, but the actual amount of change seems to vary between the users. So, how can we quantify how much the feature impacts open rate?
An issue here is that it is difficult to separate the impact of the feature from the natural difference between audience engagement across these users. Let’s try standardizing the histograms and see what happens.
We don’t want to standardize using sd(x_1_a)
and mean(x_1_a)
because we would
After standardizing we can see that the histograms corresponding to using the feature have collapsed to almost the same histogram and similarly for the histograms corresponding to not using the feature. The peaks of the histograms corresponding to using the feature are at about \(1\) standard unit and the peaks of the histograms corresponding to not using the feature are at about \(-1\) standard unit. We can interpret this as telling us that that if a user uses the feature they should expect for the campaign to perform at about \(1\) standard deviation above their mean open rate. Similarly, if a user does not use the feature then they should expect the campaign to perform at about \(1\) standard deviation below their mean open rate.
Note that the data used in this example was fake and generated so that these standardized histograms lined up well and the separation between using and not using the feature was large. Real data is generally much noisier than this and the effect of feature usage is much harder to tease out.
There is one more important thing to note about this example. In order to get an idea of the feature’s impact we need to standardize in a slightly different way than was described above. We have split each users data into two groups, but we will standardize each group with respect to the overall mean and standard deviation of the user’s campaign open rate data as show below. Note that x_1_a
is the data from campaigns sent by this user that did not use the feature in question.
If we had instead standardized using the mean and standard deviation of x_1_a
then we would have ended up with data that was mean \(0\) and variance \(1\) as we noted previously. So, all of the histograms would have piled on top of each other and we would have hidden the actual impact of the feature from ourselves as shown below.
2.7 Lab Questions
2.7.1 Introduction to R
R is a high level statistical computing language. We will be using RStudio as an development environment for this course. I am borrowing a lot from this great book on R for Data Science , this overview, as well as some stuff from this great bayes analysis book.
Before we get started, let’s make some appearance changes that will make the screen shots easier to see.
Whew, that’s better. Now, let’s get to know the development environment. First create a file, and then we step through the sections
We will walk through these one by one in the lab
2.7.2 Getting help
## starting httpd help server ... done
## If the browser launched by '/usr/bin/open' is already running, it
## is *not* restarted, and you must switch to its window.
## Otherwise, be patient ...
shows many of the help documentation that is available. You can also get help with most any function with by prepending ?
to the funcion call. For instance, to get help with the sample() function in base R,
And the documentation will show in the Help tab.
2.7.3 Running code
You can run code three ways:
- Type code directly into the RELP (Read–eval–print loop)
## [1] "hello world"
Type code into the text editor, and hit Run (top left) (you can also run your current line by hitting cmd + enter, see here for more keyboard shortcuts).
Saving your code and calling the saved code from the command line.
2.7.4 Tutorial : Quick overview
On the command line run the following command:
learnr::run_tutorial("R_Basics", "sur")
and follow the prompts.
2.7.5 Functions
Functions allow you make code repeatable and callable. We will be learning more about functions in later
## [1] "hello, world"
The inputs to the function can be given a default.
## [1] "intial string"
if you pass an argument, it will override the default
## [1] "something clever"
Typically functions are used to perform an actions, or series of actions.
## [1] 3
2.7.6 Variable assignment and types
Variables can assigned with = operator and -> and <- operators (always remember that the arrow points to the variable, also the -> is not often used).
## [1] 10
## [1] 10
This list is not exhaustive, but in general you will be working with five type of variables: 1. strings 2. numeric 3. dates 4. data.frame: rectangular data, think a spreadsheet 5. factors: categorical variables, distinct buckets like “big”, “small” 6. lists: list are hierarchical holders of different data types
2.7.7 Packages
In R you can compile a series of functions and data into a package. Creating packages is outside the scope of this course, but if you want to get good at R, going through the process of creating packages is one the best routes. There are thousands of packages available that people have put together. For instance, ggplot
is a common graphing package. To install a pacakge run install.packages("ggplot")
. To load a package, run library(ggplot)
. For instance,
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
## Loading required package: ggplot2
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
these commands would load some commonly used packages for statisical computing, some bigquery and SQL commands, and another plotting package. Notice that these packages will only load if you have installed them, but you will only need to install them once.
2.7.8 Loading data
Let’s create a csv to work on. First create an empty code file
Copy and paste, or type the following in the file:
a,b,c
1,2,3
4,5,6
7,8,9
Save the file as data.csv
, a prompt will ask you if really want to do that (change file type), say yes. Next, let’s load that file into memory. Close the csv, and create another empty R file as above. In the new file type the following
dat = read_csv("./data.csv")
Hit Run
(or cmd + enter) and you will get some parsing information print to the screen, and a new element in memory called dat (because that is what you named it). To inspect it, click on the data element in the Environment tab
2.7.9 Tutorial 1: Data Basics
On the command line run the following command:
learnr::run_tutorial("ex-data-basics", "learnr")
and follow the prompts.
<IP_ADDRESS> Tidyverse Packages
(The following is borrowed from the R From Students mentioned above)
When a user installs the Tidyverse, 19 packages are installed . When the user loads the tidyverse using library(tidyverse)
a core subset of 8 packages are loaded into R. To use any of the packages not loaded with the core Tidyverse, a user must explicitly load those packages (e.g. library(readxl)
) or call the packages using the package name prefix (e.g. readxl::read_xlsx()
to run the read_xlsx()
function from the readxl
package).
The packages listed below are in the “Core Tidyverse” and loaded with library(tidyverse)
.
Core Tidyverse
ggplot2
: data visualization
dplyr
: data manipulation
tidyr
: data reshaping
readr
: data import
purrr
: functional programming
tibble
: tidy dataframes
stringr
: string manipulation
forcats
: factor use
Additional Tidyverse
There are 11 additional Tidyverse packages that install, but do not automatically load.
Import
readxl
: reading Excel files
haven
: reading SPSS, Stata, and SAS data
jsonlite
: manipulating JSON
xml2
: reading xml
httr
: accessing web APIs
rvest
: web scraping
feather
: data sharing with Python and beyond
Wrangle
lubridate
: date manipulation
hms
: time-of-day manipulation
Modeling
modelr
: modeling pipelines
broom
: takes model results and makes them tidy
More info on each can be found at https://tidyverse.tidyverse.org.
2.7.10 dplyr Verbs
Almost any time a student works with data, they will need to manipulate that data in some way. Below, we will introduce the main 6 dplyr
verbs to help wrangle data to gain additional insight. These verbs, select
, filter
, mutate
, group_by
, summarize
, arrange
are explained in detail below.
In order to motivate use of the aforementioned verbs, we will look to answer the following question:
What is the average GDP per country since 1980?
<IP_ADDRESS> Verb 1: select
To begin, we only need to work with certain columns. The relevant columns to this question are country
, year
, pop
, and gdpPercap
. We can make this selection using the select
function. The first argument in the select
function is the data we wish to select from. The subsequent arguments are the names of the columns from the data we will select. In the code below, we save our selected columns into a new tibble
called gapminder_selected
. We use a different name for the output data frame so as to not overwrite the original data frame object.
## # A tibble: 1,704 x 4
## country year pop gdpPercap
## <fct> <int> <int> <dbl>
## 1 Afghanistan 1952 8425333 779.
## 2 Afghanistan 1957 9240934 821.
## 3 Afghanistan 1962 10267083 853.
## 4 Afghanistan 1967 11537966 836.
## 5 Afghanistan 1972 13079460 740.
## 6 Afghanistan 1977 14880372 786.
## 7 Afghanistan 1982 12881816 978.
## 8 Afghanistan 1987 13867957 852.
## 9 Afghanistan 1992 16317921 649.
## 10 Afghanistan 1997 22227415 635.
## # … with 1,694 more rows
Once we view the data, we see that we still have 1704 rows but only 4 columns.
<IP_ADDRESS> Verb 2: filter
To further answer our question, we need to filter our data down to the years of interest. We can achieve this goal using the filter
function. Like the select
function, the first argument in the filter
function is the data and subsequent argument is the logical statement of which you wish to filter. In the code below, we filter our selected data and save our filtered data into a new tibble called gapminder_filtered
.
## # A tibble: 852 x 4
## country year pop gdpPercap
## <fct> <int> <int> <dbl>
## 1 Afghanistan 1982 12881816 978.
## 2 Afghanistan 1987 13867957 852.
## 3 Afghanistan 1992 16317921 649.
## 4 Afghanistan 1997 22227415 635.
## 5 Afghanistan 2002 25268405 727.
## 6 Afghanistan 2007 31889923 975.
## 7 Albania 1982 2780097 3631.
## 8 Albania 1987 3075321 3739.
## 9 Albania 1992 3326498 2497.
## 10 Albania 1997 3428038 3193.
## # … with 842 more rows
Once we view the data, we see that our data now consist of 852 rows. This represents the rows of data since 1980.
2.7.11 Tutorial 2: filter
On the command line run the following command:
learnr::run_tutorial("ex-data-filter", "learnr")
and follow the prompts.
<IP_ADDRESS> Verb 3: mutate
The next step in answering our question is creating a column that contains the GDP. The mutate
function creates new columns according to a specific function that we provide. To answer our question, we need to determine the GDP in each year. To find the GDP, we need to multiply the gdpPercap
by the pop
. Similar to the previous two verbs, the first argument in the mutate
function is the data. Subsequent arguments are columns you wish to create with corresponding formulas. In the code below, we mutate our filtered data and save our mutated data into a new tibble called gapminder_mutated
.
## # A tibble: 852 x 5
## country year pop gdpPercap GDP
## <fct> <int> <int> <dbl> <dbl>
## 1 Afghanistan 1982 12881816<PHONE_NUMBER>3401.
## 2 Afghanistan 1987 13867957<PHONE_NUMBER>0309.
## 3 Afghanistan 1992 16317921<PHONE_NUMBER>1589.
## 4 Afghanistan 1997 22227415<PHONE_NUMBER>5875.
## 5 Afghanistan 2002 25268405<PHONE_NUMBER>0424.
## 6 Afghanistan 2007 31889923<PHONE_NUMBER>1949.
## 7 Albania 1982 2780097 3631.<PHONE_NUMBER>3.
## 8 Albania 1987 3075321 3739.<PHONE_NUMBER>8.
## 9 Albania 1992 3326498 2497.<PHONE_NUMBER>.
## 10 Albania 1997 3428038 3193.<PHONE_NUMBER>9.
## # … with 842 more rows
Once we view the data, we see the new column, GDP
, has been added to the end of our tibble.
2.7.12 Tutorial 3: mutate
On the command line run the following command:
learnr::run_tutorial("ex-data-mutate", "learnr")
and follow the prompts.
<IP_ADDRESS> Verb 4: group_by
The next step will be to group our data by the field of interest. In this instance, since we want to know GDP by country, we need to group the data by country. A way to conceptualize this step is to think of placing each group of data into a specific room. In subsequent steps we will apply a function to each group (or room) of data. Just like the previous verbs, the first argument in the group_by
function is the data. The following arguments are the columns you wish to group by. In the code below, we group our mutated data and save our grouped data into a new tibble called gapminder_grouped
.
## # A tibble: 852 x 5
## # Groups: country [142]
## country year pop gdpPercap GDP
## <fct> <int> <int> <dbl> <dbl>
## 1 Afghanistan 1982 12881816<PHONE_NUMBER>3401.
## 2 Afghanistan 1987 13867957<PHONE_NUMBER>0309.
## 3 Afghanistan 1992 16317921<PHONE_NUMBER>1589.
## 4 Afghanistan 1997 22227415<PHONE_NUMBER>5875.
## 5 Afghanistan 2002 25268405<PHONE_NUMBER>0424.
## 6 Afghanistan 2007 31889923<PHONE_NUMBER>1949.
## 7 Albania 1982 2780097 3631.<PHONE_NUMBER>3.
## 8 Albania 1987 3075321 3739.<PHONE_NUMBER>8.
## 9 Albania 1992 3326498 2497.<PHONE_NUMBER>.
## 10 Albania 1997 3428038 3193.<PHONE_NUMBER>9.
## # … with 842 more rows
Students will notice that there appears to be no change to the data. This is mostly true as we have simply told R that we would like to apply future functions to each group of data instead of to the entire tibble. The only difference in output is a note explaining what the data has been grouped into and the number of groups. In this case, it explains the data is grouped by country
and that there are 142 groups.
<IP_ADDRESS> Verb 5: summarise
Next, in order to determine the average GDP by country, we need to apply a function to each group we have identified. Specifically, we will need to take the average GDP over each country. Since we have already grouped by country, we next need to apply the summarise function. Like the previous verbs, the first argument in the summarise
function is the data. The following arguments are the function to apply to each group. In the code below, we summarise the grouped data and save the summarised data into a new tibble called gapminder_summarised
.
## # A tibble: 142 x 2
## country AVG_GDP
## <fct> <dbl>
## 1 Afghanistan<PHONE_NUMBER>1.
## 2 Albania<PHONE_NUMBER>2.
## 3 Algeria<PHONE_NUMBER>52.
## 4 Angola<PHONE_NUMBER>5.
## 5 Argentina<PHONE_NUMBER>31.
## 6 Australia<PHONE_NUMBER>04.
## 7 Austria<PHONE_NUMBER>40.
## 8 Bahrain<PHONE_NUMBER>8.
## 9 Bangladesh<PHONE_NUMBER>64.
## 10 Belgium<PHONE_NUMBER>91.
## # … with 132 more rows
We now have an answer to our question. The tibble above shows the average GDP per country since 1980.
2.7.13 Tutorial 4: summarize
On the command line run the following command:
learnr::run_tutorial("ex-data-summarise", "learnr")
and follow the prompts.
<IP_ADDRESS> Verb 6: arrange
However, we can refine our result to provide more understanding. Currently, our data is sorted alphabetically by country. This does not provide much insight. We can use the arrange
function to sort the data by average GDP; either ascending or descending. Like all other verbs, the first argument in the arrange
function is the data. The following arguments are the one or more columns which you wish to sort by. In the code below, we arrange our summarised data and save our arranged data into a new tibble called gapminder_arranged
.
## # A tibble: 142 x 2
## country AVG_GDP
## <fct> <dbl>
## 1 Sao Tome and Principe 213138942.
## 2 Comoros 585013190.
## 3 Guinea-Bissau 788263198.
## 4 Gambia 806874307.
## 5 Djibouti 894915489.
## 6 Liberia<PHONE_NUMBER>.
## 7 Lesotho<PHONE_NUMBER>.
## 8 Equatorial Guinea<PHONE_NUMBER>.
## 9 Eritrea<PHONE_NUMBER>.
## 10 Central African Republic<PHONE_NUMBER>.
## # … with 132 more rows
We see, from the output above, the countries with the smallest average GDP since 1980.
It may be more interesting, however, to sort the average GDP in descending order so we can learn which countries have the highest average GDP. To do this we simply place a - sign in front of AVG_GDP
in the code above.
gapminder_arragned_descending = arrange(gapminder_summarised, -AVG_GDP)
gapminder_arragned_descending
## # A tibble: 142 x 2
## country AVG_GDP
## <fct> <dbl>
## 1 United States 9.20e12
## 2 Japan 3.28e12
## 3 China 2.96e12
## 4 Germany 2.20e12
## 5 United Kingdom 1.48e12
## 6 France 1.48e12
## 7 India 1.39e12
## 8 Italy 1.33e12
## 9 Brazil 1.27e12
## 10 Mexico 9.26e11
## # … with 132 more rows
<IP_ADDRESS> Simplifying Code with the Pipe Operator: %>%
After helping learners see how each function works we can introduce the pipe operator (%>%
). This helpful code chains together commands and passes the results of one function directly into the next function. This results in very logical data manipulation steps that are fairly easy to learn and makes the code easy to understand:
gapminder_arragned_descending_chained =
gapminder %>%
select(country, year, pop, gdpPercap) %>%
filter(year >= 1980) %>%
mutate(GDP = gdpPercap * pop) %>%
group_by(country) %>%
summarise(AVG_GDP = mean(GDP)) %>%
arrange(-AVG_GDP)
gapminder_arragned_descending_chained
## # A tibble: 142 x 2
## country AVG_GDP
## <fct> <dbl>
## 1 United States 9.20e12
## 2 Japan 3.28e12
## 3 China 2.96e12
## 4 Germany 2.20e12
## 5 United Kingdom 1.48e12
## 6 France 1.48e12
## 7 India 1.39e12
## 8 Italy 1.33e12
## 9 Brazil 1.27e12
## 10 Mexico 9.26e11
## # … with 132 more rows
2.7.14 Lecture questions:
- Run the following R code many times and notice that the answer is always an integer.
## [1] -3
Now run this snippet a few times and notice that sometimes the answer is an integer, but sometimes it’s a half integer. Why is this?
## [1] -2.5
```
Run an experiment to verify that fact that if we were to randomly select a number from our list it would be just as likely that the number be greater than the median as less than the median.
Show that a standardized dataset has mean \(0\) and standard deviation \(1\). You can either do this formally or by looking at some examples in R.


Asynchronous Progamming Using the C (libcouchbase) SDK with Couchbase Server
You can integrate the C SDK with many non-blocking (asynchronous, reactive) I/O frameworks, or event loops. When the C SDK is integrated with an event loop, it becomes a true non-blocking library that works in harmony with the rest of your non-blocking application. You can integrate with popular event loop libraries (if supported) through built-in plugins or write your own plugin for custom I/O libraries.
When the library is used in non-blocking (or asynchronous mode), calls to lcb_wait
are replaced with yielding to the event loop: Rather than calling lcb_wait
to block until an operation is complete, the operation’s event loop itself will wait for pending Couchbase operations to complete alongside other non-Couchbase I/O, if necessary.
When the operation has been completed, the corresponding callback (usually set via lcb_install_callback3
) is invoked with the result.
Using a Built-In I/O Plugin
The library contains I/O plugins for common libraries such as libevent, libev, and libuv.
If your application makes use of any of these libraries for its purposes, integrating with the library is as simple as providing an instance of such an implementation to the lcb_create_st
structure.
Here is an example using libevent
:
static void
bootstrap_callback(lcb_t instance, lcb_error_t err)
{
lcb_CMDSTORE cmd = { 0 };
LCB_CMD_SET_KEY(&cmd, "foo", 3);
LCB_CMD_SET_VALUE(&cmd, "bar", 3);
cmd.operation = LCB_SET;
err = lcb_store3(instance, NULL, &cmd);
}
static void get_callback(lcb_t instance, int cbtype, const lcb_RESPBASE *rb)
{
const lcb_RESPGET *rg = (const lcb_RESPGET *)rb;
fprintf(stdout, "I stored and retrieved the key 'foo'. Value: %.*s.\n", (int)rg->nvalue, rg->value);
event_base_loopbreak((void *)lcb_get_cookie(instance));
}
static void store_callback(lcb_t instance, int cbtype, const lcb_RESPBASE *rb)
{
lcb_error_t rc;
lcb_CMDGET gcmd = { 0 };
LCB_CMD_SET_KEY(&gcmd, rb->key, rb->nkey);
rc = lcb_get3(instance, NULL, &gcmd);
}
static lcb_io_opt_t
create_libevent_io_ops(struct event_base *evbase)
{
struct lcb_create_io_ops_st ciops;
lcb_io_opt_t ioops;
lcb_error_t error;
memset(&ciops, 0, sizeof(ciops));
ciops.v.v0.type = LCB_IO_OPS_LIBEVENT;
ciops.v.v0.cookie = evbase;
error = lcb_create_io_ops(&ioops, &ciops);
if (error != LCB_SUCCESS) {
fprintf(stderr, "Failed to create an IOOPS structure for libevent: %s\n", lcb_strerror(NULL, error));
exit(EXIT_FAILURE);
}
return ioops;
}
static lcb_t
create_libcouchbase_handle(lcb_io_opt_t ioops)
{
lcb_t instance;
lcb_error_t error;
struct lcb_create_st copts;
memset(&copts, 0, sizeof(copts));
/* If NULL, will default to localhost */
copts.version = 3;
copts.v.v3.connstr = "couchbase://localhost/default";
copts.v.v0.io = ioops;
error = lcb_create(&instance, &copts);
/* Set up the callbacks */
lcb_set_bootstrap_callback(instance, bootstrap_callback);
lcb_install_callback3(instance, LCB_CALLBACK_GET, get_callback);
lcb_install_callback3(instance, LCB_CALLBACK_STORE, store_callback);
lcb_connect(instance);
return instance;
}
/* This example shows how we can hook ourself into an external event loop.
* You may find more information in the blogpost: http://goo.gl/fCTrX */
int main(void)
{
struct event_base *evbase = event_base_new();
lcb_io_opt_t ioops = create_libevent_io_ops(evbase);
lcb_t instance = create_libcouchbase_handle(ioops);
/*Store the event base as the user cookie in our instance so that
* we may terminate the program when we're done */
lcb_set_cookie(instance, evbase);
/* Run the event loop */
event_base_loop(evbase, 0);
/* Cleanup */
event_base_free(evbase);
lcb_destroy(instance);
exit(EXIT_SUCCESS);
}
| The previous example has some error checking left out for brevity. A more complete example can be found inside the example/libeventdirect directory within the source tree. |
In the above example, the lcb_create_io_opts()
function is used to instantiate the built-in libevent implementation of the IOPS API.
Note that the lcb_create_io_ops_st
structure contains a cookie
field which should contain a pointer to an implementation-defined object; in the case of the libevent implementation this should be a pointer to an existing struct event_base
(which is an instance of the libevent loop itself).
Each of the built-in implementations contains its own header file that provides more detail about what the cookie field is supposed to contain.
The header files are named in the form of ${TYPE}_io_opts.h
, where ${TYPE}
is the name of the implementation.
They are located inside the libcouchbase include directory upon installation, and are located in the plugins directory within the source tree.
After the IOPS instance has been created, it is set in the io
field of the lcb_create_st
structure and the lcb_t
object is created.
Creating a Custom I/O Implementation
| The I/O interface is a work in progress and subject to change |
A custom I/O implementation can be created by implementing the interface, featured in <libcouchbase/iops.h>. The I/O abstraction layer known as IOPS (I/O OperationS) communicates with the underlying platform and I/O frameworks, instructing the implementation to:
-
Create and connect sockets
-
Reads and write from and to the socket (I/O)
-
Scheduling callbacks to be invoked when a socket is available for writing or reading (events)
-
Scheduling callbacks to be invoked after a certain period has elapsed (timers)
Usage Differences in Non-Blocking Mode
For the most part, programming with libcouchbase is the same regardless of whether you’re using it in a blocking or non-blocking application. There are some key differences to note, however:
-
lcb_wait()
should not be called in non-blocking mode. By definition, thelcb_wait()
routine will block the application until all pending I/O completes. In non-blocking mode the pending I/O is completed when control is returned back to the event loop. -
You must not schedule operations until the bootstrap callback,
lcb_set_bootstrap_callback()
, has been invoked. This is because operations must be forwarded to a destination node in the cluster depending on the key specified within the operation. Until the client has been bootstrapped it does not know how to forward keys to any nodes.Unlike blocking mode where you may simply do:
lcb_connect(instance); lcb_wait(instance); if (lcb_get_bootstrap_status(instance) == LCB_SUCCESS)) { // Start operations }
You need to use the callback variant that notifies your application when the library is ready.
-
You are responsible for ensuring that the
iops
structure passed to the library remains valid untillcb_destroy
is invoked. Likewise, you are responsible for freeing theiops
structure vialcb_destroy_io_opts()
when it is no longer required. -
Currently the library does blocking DNS look-ups via the standard
getaddrinfo()
call. Typically this should not take a long time but may potentially block your application if an invalid host name is detected or the DNS server in use is slow to respond.


| Number of Classes | Line Coverage | Mutation Coverage |
|---|---|---|
| 16 | 61% | 33% |
| Name | Line Coverage | Mutation Coverage |
|---|---|---|
| AbstractAnnotation.java | 71% |
28% |
| AbstractXYAnnotation.java | 41% |
33% |
| CategoryLineAnnotation.java | 67% |
50% |
| CategoryPointerAnnotation.java | 62% |
24% |
| CategoryTextAnnotation.java | 62% |
50% |
| TextAnnotation.java | 91% |
57% |
| XYBoxAnnotation.java | 84% |
37% |
| XYDataImageAnnotation.java | 0% |
0% |
| XYDrawableAnnotation.java | 63% |
30% |
| XYImageAnnotation.java | 34% |
38% |
| XYLineAnnotation.java | 55% |
44% |
| XYPointerAnnotation.java | 58% |
21% |
| XYPolygonAnnotation.java | 47% |
33% |
| XYShapeAnnotation.java | 48% |
33% |
| XYTextAnnotation.java | 84% |
42% |
| XYTitleAnnotation.java | 66% |
31% |


lithium-technologies
Businessmodel of Lithium Technologies
Customer Segments
Lithium Technologies offers a range of software solutions to commercial and institutional clients across a range of business sectors. The Company principally serves clients active within the following industries:
- Communications, including telecommunications companies, internet service providers, mobile network operators, mail carriers, and cable network operators;
- Technology, including technology companies, electronic device manufacturers, software and application developers, and other high-tech companies;
- Financial Services, including banking institutions, lending companies, credit card companies, and other financial services providers; and
- Retail, including digital and physical retail businesses, major retail chains, and large consumer brands. Lithium Technologies names a number of its clients on its website. This includes high-profile names such as AT&T, Sony, Sephora, British Gas, Skype, Verizon, Virgin Mobile, Barclaycard, Moneygram, and Time Warner Cable.
Lithium’s key market is the US, which accounts for a significant portion of the Company’s business. The Company also serves clients across Europe and Asia Pacific.
Value Propositions
Lithium Technologies provides value to its clients in the following ways:
- Its industry standing and reputation, with the Company established as a leading provider of social and community-focused software solutions, particularly in the US, as evidenced by the Company’s ability to secure regular business from high-profile companies such as AT&T, British Gas, and Sony;
- Its efficiency and functionality, with the Company’s solutions offering extensive functionality, including assisting clients in planning, publishing, and analysing social media campaigns, as well as ensuring that they receive ongoing feedback;
- Its international reach, with the Company serving an extensive range of clients I its domestic market of the US, as well as numerous customers across markets in Asia Pacific and Europe, in particular the UK and Germany;
- Its network of partners, with the Company working closely with a broad network of partner companies that support and extend the in-house capabilities of its various operating units; and
- Its industry expertise, with the Company employing specialist technical personnel to ensure that the Company’s solutions are developed and maintained effectively, as well as a team of experienced industry executives. ### Channels
Lithium Technologies operates a website at www.lithium.com, through which it provides information on its products, services, solutions, partners, and target industries.
The Company does not operate a dedicated online sales portal, nor does it have an online customer portal, but it does allow customers to request free software trials directly through its website. Lithium Technologies additionally offers functionality through mobile apps that are available on iOS and Android devices.
Lithium Technologies makes the bulk of its sales through its in-house direct sales force, which is organised across the Company’s operating regions. The Company’s sales personnel operate out of the Company’s international network of sales and administrative offices that spans North America, Asia Pacific, and Europe, including locations in the UK, Germany, Singapore, India, Australia, and the US.
Lithium Technologies additionally reaches customers through a network of channel and distribution partners. This includes authorised resellers, independent software vendors, and distributors. The Company also collaborates with original equipment manufacturers to develop integrated solutions.
Customer Relationships
Lithium Technologies does not make sales of its products and solutions on a self-service basis. It does, however, allow customers to request free software trials through its website, and provides mobile apps that can be downloaded independently from the relevant application marketplace.
Once purchased the Company’s solutions allow customers to access tools and functionality without interacting with members of the Company’s sales and service personnel.
Lithium Technologies makes sales primarily through its direct sales force, the members of which consult closely with clients in order to fully establish their individual circumstances and requirements. The Company seeks to establish lasting customer relationships, and continues to provide support to clients after sales have been made.
Lithium Technologies offers a range of ongoing support services, with customers able to contact dedicated support personnel over the phone or via email in order to access personalised technical assistance. The Company additionally offers a broad selection of online resources, including developer documents, FAQs, and white papers, that can be accessed independently.
Lithium Technologies additionally operates a user community portal, where customers can share ideas, collaborate on problems, and engage in discussions. The Company also operates profiles with several social networks – including Twitter, LinkedIn, Facebook, Google+, YouTube, and Instagram – through which it can interact directly with customers and publish company updates.
Key Activities
Lithium Technologies is a social and community software developer. It is engaged in the development and deployment of software solutions that assist customers in connecting with, engaging with, and understanding their communities.
The Company’s offerings include online community, social media management, social media analytics, earned media, and technology products, as well social marketing, social customer support, and crowdsourcing tools.
Lithium Technologies additionally offers ancillary support, training, and certification services to its clients. The Company is based in the US but serves an international client base across Asia Pacific and Europe, targeting commercial and institutional customers in the retail, financial services, technology, and communications sectors.
Key Partners
Lithium Technologies works closely with a variety of partners spanning multiple sectors, that support and supplement the Company’s in-house operations. These partners can be organised broadly into the following categories:
- Supplier and Service Partners, including suppliers of services, equipment, tools, and technologies that are utilised across the Company’s operating units in support of its core development, delivery, and support operations;
- Channel and Distribution Partners, comprising the Company’s network of authorised resellers, distributors, and independent software vendors that assist in supporting and extending the capabilities of the Company’s in-house sales and marketing teams;
- Original Equipment Manufacturer Partners, including a range of software developers, application developers, and technology companies that work with the Company in developing and deploying integrated solutions; and
- Technology Partners, including technology companies, IT service providers, and software companies that assist in developing and maintaining the Company’s solutions and IT infrastructure. Lithium Technologies names a number of its partners on its website. This includes channel partners such as Netconomy, Avanade, and Optingo; original equipment manufacturer partners such as Aspect and Ipsos; and technology partners such as Microsoft Dynamics, Actiance, and Ooyala.
Key Resources
Lithium Technologies’s key resources are its proprietary technologies and intellectual properties, its products and platforms, its IT and communications infrastructure, its sales and distribution channels, its partnerships, and its personnel.
Lithium Technologies utilises a range of proprietary technologies in the development and deployment of its software solutions, which it protects in a number of ways.
Searches of records published by the US Patent and Trademark Office identified a range of patent applications filed in the name of lithium Technologies, including applications entitled ‘System and method for providing a social customer care system’, ‘Systems and methods for application plugin deployment for websites’ and ‘Gamification for online social communities’.
Lithium Technologies additionally owns and or leases a number of physical properties that comprise its network of sales and administrative offices across North America, Asia Pacific, and Europe.
Cost Structure
Lithium Technologies incurs costs in relation to the development of its technologies and solutions, the development and maintenance of its IT and communications infrastructure, the operation of its sales and distribution channels, the management of its partnerships, the procurement of services, the implementation of marketing and advertising campaigns, and the retention of its personnel.
Revenue Streams
Lithium Technologies generates revenue through the development and sale of software solutions to commercial and institutional clients across the financial services, retail, technology, and communications sectors, as well as through the provision of ancillary support and training services. The Company derives revenue under sales and service contracts that are agreed on a case-by-case basis.


procedure Roll(Dx, Dy: Integer; FillBack: Boolean; FillColor: TColor32);
Use Roll to scroll the whole bitmap Dx pixels right and Dy pixels down.
Dx an Dy may be negative.
The content of the new area may optionally be cleared with FillColor, if FillBack is true.


This section contains examples of problems developers might encounter when using reflection to locate, invoke, or get information about methods.
The
example illustrates what happens when type erasure is not taken into
consideration by code which searches for a particular method in a class.
MethodTrouble
import java.lang.reflect.Method; public class MethodTrouble<T> { public void lookup(T t) {} public void find(Integer i) {} public static void main(String... args) { try { String mName = args[0]; Class cArg = Class.forName(args[1]); Class<?> c = (new MethodTrouble<Integer>()).getClass(); Method m = c.getMethod(mName, cArg); System.out.format("Found:%n %s%n", m.toGenericString()); // production code should handle these exceptions more gracefully } catch (NoSuchMethodException x) { x.printStackTrace(); } catch (ClassNotFoundException x) { x.printStackTrace(); } } }
$ java MethodTrouble lookup java.lang.Integer java.lang.NoSuchMethodException: MethodTrouble.lookup(java.lang.Integer) at java.lang.Class.getMethod(Class.java:1605) at MethodTrouble.main(MethodTrouble.java:12) $ java MethodTrouble lookup java.lang.Object Found: public void MethodTrouble.lookup(T)
When a method is declared with a generic parameter type, the compiler will
replace the generic type with its upper bound, in this case, the upper bound of
T
is
Object
. Thus, when the code searches for lookup(Integer)
, no
method is found, despite the fact that the instance of
MethodTrouble
was created as follows:
Class> c = (new MethodTrouble()).getClass();
Searching for lookup(Object)
succeeds as expected.
$ java MethodTrouble find java.lang.Integer Found: public void MethodTrouble.find(java.lang.Integer) $ java MethodTrouble find java.lang.Object java.lang.NoSuchMethodException: MethodTrouble.find(java.lang.Object) at java.lang.Class.getMethod(Class.java:1605) at MethodTrouble.main(MethodTrouble.java:12)
In this case, find()
has no generic parameters, so
the parameter types searched for by
getMethod()
must match exactly.
An
IllegalAccessException
is thrown if an attempt is made to invoke a private
or
otherwise inaccessible method.
The
example shows a typical stack trace which results from trying to invoke a
private method in an another class.
MethodTroubleAgain
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; class AnotherClass { private void m() {} } public class MethodTroubleAgain { public static void main(String... args) { AnotherClass ac = new AnotherClass(); try { Class<?> c = ac.getClass(); Method m = c.getDeclaredMethod("m"); // m.setAccessible(true); // solution Object o = m.invoke(ac); // IllegalAccessException // production code should handle these exceptions more gracefully } catch (NoSuchMethodException x) { x.printStackTrace(); } catch (InvocationTargetException x) { x.printStackTrace(); } catch (IllegalAccessException x) { x.printStackTrace(); } } }
The stack trace for the exception thrown follows.
$ java MethodTroubleAgain java.lang.IllegalAccessException: Class MethodTroubleAgain can not access a member of class AnotherClass with modifiers "private" at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:65) at java.lang.reflect.Method.invoke(Method.java:588) at MethodTroubleAgain.main(MethodTroubleAgain.java:15)
private
methods in a separate
class and public methods in a separate private class.) However,
Method
is declared to extend
AccessibleObject
which provides the ability to suppress this check via
AccessibleObject.setAccessible()
. If it succeeds, then subsequent invocations of this method object will not
fail due to this problem.
Method.invoke()
has been retrofitted to be a variable-arity method. This is an enormous
convenience, however it can lead to unexpected behavior. The
example shows various ways in which
MethodTroubleToo
Method.invoke()
can produce confusing results.
import java.lang.reflect.Method; public class MethodTroubleToo { public void ping() { System.out.format("PONG!%n"); } public static void main(String... args) { try { MethodTroubleToo mtt = new MethodTroubleToo(); Method m = MethodTroubleToo.class.getMethod("ping"); switch(Integer.parseInt(args[0])) { case 0: m.invoke(mtt); // works break; case 1: m.invoke(mtt, null); // works (expect compiler warning) break; case 2: Object arg2 = null; m.invoke(mtt, arg2); // IllegalArgumentException break; case 3: m.invoke(mtt, new Object[0]); // works break; case 4: Object arg4 = new Object[0]; m.invoke(mtt, arg4); // IllegalArgumentException break; default: System.out.format("Test not found%n"); } // production code should handle these exceptions more gracefully } catch (Exception x) { x.printStackTrace(); } } }
$ java MethodTroubleToo 0 PONG!
Since all of the parameters of
Method.invoke()
are optional except for the first, they can be omitted when the method to be
invoked has no parameters.
$ java MethodTroubleToo 1 PONG!
The code in this case generates this compiler warning because
null
is ambiguous.
$ javac MethodTroubleToo.java MethodTroubleToo.java:16: warning: non-varargs call of varargs method with inexact argument type for last parameter; cast to java.lang.Object for a varargs call cast to java.lang.Object[] for a non-varargs call and to suppress this warning m.invoke(mtt, null); // works (expect compiler warning) ^ 1 warning
It is not possible to determine whether null
represents an
empty array of arguments or a first argument of null
.
$ java MethodTroubleToo 2 java.lang.IllegalArgumentException: wrong number of arguments at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at MethodTroubleToo.main(MethodTroubleToo.java:21)
This fails despite the fact that the argument is null
, because
the type is a
Object
and ping()
expects no arguments at all.
$ java MethodTroubleToo 3 PONG!
This works because new Object[0]
creates an empty array, and
to a varargs method, this is equivalent to not passing any of the optional
arguments.
$ java MethodTroubleToo 4 java.lang.IllegalArgumentException: wrong number of arguments at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at MethodTroubleToo.main(MethodTroubleToo.java:28)
Unlike the previous example, if the empty array is stored in an
Object
, then it is treated as an
Object
. This fails for the same reason that case 2 fails, ping()
does not expect an argument.
foo(Object... o)
is declared the compiler will put
all of the arguments passed to foo()
in an array of type
Object
. The implementation of foo()
is the same as if it were declared
foo(Object[] o)
. Understanding this may help avoid the types of
problems illustrated above.
An
InvocationTargetException
wraps all exceptions (checked and unchecked) produced when a method object
is invoked. The
example shows how to retrieve the original exception thrown by the invoked
method.
MethodTroubleReturns
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; public class MethodTroubleReturns { private void drinkMe(int liters) { if (liters < 0) throw new IllegalArgumentException("I can't drink a negative amount of liquid"); } public static void main(String... args) { try { MethodTroubleReturns mtr = new MethodTroubleReturns(); Class<?> c = mtr.getClass(); Method m = c.getDeclaredMethod("drinkMe", int.class); m.invoke(mtr, -1); // production code should handle these exceptions more gracefully } catch (InvocationTargetException x) { Throwable cause = x.getCause(); System.err.format("drinkMe() failed: %s%n", cause.getMessage()); } catch (Exception x) { x.printStackTrace(); } } }
$ java MethodTroubleReturns drinkMe() failed: I can't drink a negative amount of liquid
InvocationTargetException
is thrown, the method was invoked. Diagnosis of the problem would be the same
as if the method was called directly and threw the exception that is retrieved
by
getCause()
. This exception does not indicate a problem with the reflection package or
its usage.


interface BaseCallback
Callbacks that are applicable to all Async WiseFy operations. All Async interfaces should extend this class.
Author
Patches
Since
3.0
abstract fun wisefyFailure(wisefyFailureCode: Int): Unit
Called when com.isupatches.wisefy.WiseFyPrechecks determines that there is an issue and an operation cannot be completed. |
interface AddNetworkCallbacks : BaseCallback
Callbacks for adding a network as a saved configuration on a device. |
|
interface ConnectToNetworkCallbacks : BaseCallback
Callbacks for attempting to connect to a network. |
|
interface DisableWifiCallbacks : BaseCallback
Callbacks for disabling a device's wifi. |
|
interface DisconnectFromCurrentNetworkCallbacks : BaseCallback
Callbacks for disconnecting a device from it's current network. |
|
interface EnableWifiCallbacks : BaseCallback
Callbacks for enabling a device's wifi. |
|
interface GetCurrentNetworkCallbacks : BaseCallback
Callbacks for retrieving a device's current network. |
|
interface GetCurrentNetworkInfoCallbacks : BaseCallback
Callbacks for retrieving a device's current network. |
|
interface GetFrequencyCallbacks : BaseCallback
Callbacks for retrieving the frequency of a network. |
|
interface GetIPCallbacks : BaseCallback
Callbacks for retrieving a device's IP. |
|
interface GetNearbyAccessPointsCallbacks : BaseCallback
Callbacks for retrieving a list of nearby access points. |
|
interface GetRSSICallbacks : BaseCallback
Callbacks for retrieving RSSI level of a nearby access point. |
|
interface GetSavedNetworksCallbacks : BaseCallback
Callbacks for retrieving a list of saved networks on a device. |
|
interface RemoveNetworkCallbacks : BaseCallback
Callbacks for removing a saved network on a device. |
|
interface SearchForAccessPointCallbacks : BaseCallback
Callbacks for finding a nearby access point on a device. |
|
interface SearchForAccessPointsCallbacks : BaseCallback
Callbacks for finding a list of nearby access points on a device. |
|
interface SearchForSavedNetworkCallbacks : BaseCallback
Callbacks for retrieving a saved network on a device. |
|
interface SearchForSavedNetworksCallbacks : BaseCallback
Callbacks for retrieving a list of saved networks on a device. |
|
interface SearchForSSIDCallbacks : BaseCallback
Callbacks for finding a nearby SSID on a device. |
|
interface SearchForSSIDsCallbacks : BaseCallback
Callbacks for finding a list of nearby SSIDs on a device. |


Create a standalone time-picker
time
:
[[time]]
Create a time-picker with custom style
time
:
[[time]]


gmmbvl_em_gauss - compute likelihoods for all points and all components L = gmmbvl_em_gauss(X,M,R) X - (n x d) matrix of input data M - (k x d) matrix of components means R - (k x d^2) matrix of Cholesky submatrices of components covariances in vector reshaped format. To get the covariance of component k: Rk = reshape(R(k,:),d,d); S = Rk'*Rk; returns L - (n x k) likelihoods of points x_n belonging to component k
0001 function L = gmmbvl_em_gauss(X,M,R) 0002 %gmmbvl_em_gauss - compute likelihoods for all points and all components 0003 % 0004 %L = gmmbvl_em_gauss(X,M,R) 0005 % X - (n x d) matrix of input data 0006 % M - (k x d) matrix of components means 0007 % R - (k x d^2) matrix of Cholesky submatrices of components covariances 0008 % in vector reshaped format. To get the covariance of component k: 0009 % Rk = reshape(R(k,:),d,d); S = Rk'*Rk; 0010 %returns 0011 % L - (n x k) likelihoods of points x_n belonging to component k 0012 0013 % Nikos Vlassis, 2000 0014 0015 % 0016 % $Name: $ 0017 0018 [n,d] = size(X); 0019 k = size(M,1); 0020 0021 L = zeros(n,k); 0022 for j = 1:k 0023 0024 % Cholesky triangular matrix of component's covariance matrix 0025 Rj = reshape(R(j,:),d,d); 0026 0027 % We need to compute the Mahalanobis distances between all inputs 0028 % and the mean of component j; using the Cholesky form of covariances 0029 % this becomes the Euclidean norm of some new vectors 0030 New = (X - repmat(M(j,:),n,1)) * inv(Rj); 0031 Mah = sum(New.^2,2); 0032 0033 L(:,j) = (2*pi)^(-d/2) / det(Rj) * exp(-0.5*Mah); 0034 end


Raw data interface to a PvBuffer. More...
Public Member Functions | |
| uint64_t | GetPayloadLength () const |
| Get the payload length specified in the leader information of this block. More... | |
| PvResult | Alloc (uint64_t aPayloadLength) |
| Allocates memory for this PvRawData. More... | |
| void | Free () |
| Frees (de-allocates) the buffer's internal memory. More... | |
| PvResult | Attach (void *aRawBuffer, uint64_t aPayloadLength) |
| Attach this PvRawData to an external memory buffer. More... | |
| uint8_t * | Detach () |
| Releases an attached memory buffer. More... | |
Protected Member Functions | |
| PvRawData (PvBufferLib::RawData *aRawData) | |
| Constructor. More... | |
| virtual | ~PvRawData () |
| Destructor. More... | |
Raw data interface to a PvBuffer.
A PvBuffer represents a generic buffer with no specific payload type. If the payload type is raw data (according to the GigE Vision specification), the user can obtain a pointer to a PvRawData buffer interface through PvBuffer::GetRawData.
This PvRawData pointer is owned by the PvBuffer and does not need to be released after use. It is valid as long as the PvBuffer exists.
|
protected |
Constructor.
Declared as protected as PvRawData cannot be instantiated by the user.
A pointer to the PvRawData interface can be obtained from a PvBuffer using PvBuffer::GetImage.
| [in] | aRawData | Pointer to internal PureGEV class. |
|
protectedvirtual |
Destructor.
Declared as protected as the user does no need (or can) delete a PvRawData directly.
| PvResult PvRawData::Alloc | ( | uint64_t | aPayloadLength | ) |
Allocates memory for this PvRawData.
Allocs a PvRawData of specific payload length
| [in] | aPayloadLength | The payload length of the raw data, in pixels. See GetPayloadLength. |
| PvResult PvRawData::Attach | ( | void * | aRawBuffer, |
| uint64_t | aPayloadLength | ||
| ) |
Attach this PvRawData to an external memory buffer.
This method is identical to Alloc(uint64_t), with the following exceptions:
| [in] | aRawBuffer | A pointer to the buffer. |
| [in] | aPayloadLength | The payload length of the raw data, in pixels. See GetPayloadLength. |
| uint8_t * PvRawData::Detach | ( | ) |
Releases an attached memory buffer.
Does nothing other then resetting the memory buffer pointer to NULL.
| void PvRawData::Free | ( | ) |
Frees (de-allocates) the buffer's internal memory.
| uint64_t PvRawData::GetPayloadLength | ( | ) | const |
Get the payload length specified in the leader information of this block.
If you wish to construct a buffer with payload type "Raw Data", simply call PvRawData::Alloc or PvRawData::Attach and the payload length field will be set automatically at the time the block is transmitted.
Copyright (c) 2002-2015 Pleora Technologies Inc.
www.pleora.com


title = "Password Reset" url = "/password-reset/:code?" layout = "default" description = "Users can reset their account passwords here." is_hidden = 0 [resetPassword] paramCode = "code" ==


Across: 1. Greek strongman developed app with a function used primarily in swimming pools (12) 9. Junta ruined outing (5) 11,10. 25 can act! Let 'Beth be so played! (4 9) 12. Each can shot off top of fence having 27 to do with it (10) 13. The start of 27: light returning to country (5) 15. Musical 25 of questionable calibre, ultimately fake (8) 18. First lady cut short, a person yielding spirtual leader (3 5) 20. Fighting fellow in Bonanza cast, recalled on April 25 (5) 24. Sad end: weak are brought back to life (10) 25. Shining light in performing arts? (4) 27. This way drug only less than half ingested, which is significant (9) 28. Vessel in sea or tank? (5) 29. Country embraced clear emphatic leadership, building a real first: as part of 1972 duumvirate, this chap held 14 portfolios at once! (5 7) Down: 1. Ask unwelcome questions about 26 opening being inside out, yielding ducks perhaps (7) 2,22. Folk singer Judith Durham maybe good replacement for King, having had stroke at some point earlier (4 6) 3. Modernising communist bucked system (6) 4. Soldier perhaps kept in dull food (8) 5. Corn nun cultivated around church, not being worried (9) 6. Some of the world love CIA controlling each nation's leader (7) 7. Regularly let Joe's cat throw up (5) 8. More inclined to teapot? (7) 14. Hard stuff smuggled back in illicit sale nightly (9) 16. What 1 across mob did about the media? (7) 17. Film robe being 21 for leading member (8) 19. Weakness of article with a lame ending and backward goal (7) 21. Late revolutionary socialist rehabilitated? (7) 22. see 2 23,26. Brain damaged friend of Dr Z who was a 25 for the West Indies (5 4) .


New York Times columnist and author, Andrew Ross Sorkin has been described "the most famous financial journalist of his generation." His book, Too Big to Fail, was the first behind-the-scenes account of the financial crisis that led to our current recession.
The Economist, The Financial Times, and Business Week all named Too Big to Fail one of the best books of the year. The book was published by Viking, October 20, 2009. The book was adapted as a movie by HBO Films and premiered on HBO on May 23, 2011.
Lot's of heat but not very much light. It came across as a kind of daytime soap opera version showing the personalities of the players rather than dealing with the nuts and bolts of what really happened. Even that would not have been so bad but the movie tries to portray lots of these folks as sympathetic figures just trying to do the right thing.
I am watching this for the 3rd time, trying to understand how this large group of capitalistic pigs could royally screw their families, descendents, neighbors, countrymen and the rest of the whole world with absolutely no compassion.
Prepared by: Kimberly Padilla
Date: June 19, 2019


| 0 |
https://mledits.github.io/icse_sp5/21/7452/details.html |
| 1 |
https://mledits.github.io/icse_sp5/5/24440/details.html |
| 2 |
https://mledits.github.io/icse_sp5/11/18205/details.html |
| 3 |
https://mledits.github.io/icse_sp5/4/54074/details.html |
| 4 |
https://mledits.github.io/icse_sp5/4/72314/details.html |
| 5 |
https://mledits.github.io/icse_sp5/18/58607/details.html |
| 6 |
https://mledits.github.io/icse_sp5/7/63474/details.html |
| 7 |
https://mledits.github.io/icse_sp5/7/72121/details.html |
| 8 |
https://mledits.github.io/icse_sp5/5/41916/details.html |
| 9 |
https://mledits.github.io/icse_sp5/6/27616/details.html |
| 10 |
https://mledits.github.io/icse_sp5/5/50147/details.html |
| 11 |
https://mledits.github.io/icse_sp5/9/694/details.html |
| 12 |
https://mledits.github.io/icse_sp5/11/10202/details.html |
| 13 |
https://mledits.github.io/icse_sp5/3/59609/details.html |
| 14 |
https://mledits.github.io/icse_sp5/7/62583/details.html |
| 15 |
https://mledits.github.io/icse_sp5/7/52219/details.html |
| 16 |
https://mledits.github.io/icse_sp5/7/53194/details.html |
| 17 |
https://mledits.github.io/icse_sp5/4/37660/details.html |
| 18 |
https://mledits.github.io/icse_sp5/8/4907/details.html |
| 19 |
https://mledits.github.io/icse_sp5/7/45518/details.html |
| 20 |
https://mledits.github.io/icse_sp5/11/31880/details.html |
| 21 |
https://mledits.github.io/icse_sp5/10/13215/details.html |
| 22 |
https://mledits.github.io/icse_sp5/5/58085/details.html |
| 23 |
https://mledits.github.io/icse_sp5/5/49647/details.html |
| 24 |
https://mledits.github.io/icse_sp5/7/52948/details.html |
| 25 |
https://mledits.github.io/icse_sp5/8/65028/details.html |
| 26 |
https://mledits.github.io/icse_sp5/4/17463/details.html |
| 27 |
https://mledits.github.io/icse_sp5/9/10489/details.html |
| 28 |
https://mledits.github.io/icse_sp5/6/41740/details.html |
| 29 |
https://mledits.github.io/icse_sp5/5/31938/details.html |
| 30 |
https://mledits.github.io/icse_sp5/5/12491/details.html |
| 31 |
https://mledits.github.io/icse_sp5/3/8249/details.html |
| 32 |
https://mledits.github.io/icse_sp5/3/41175/details.html |
| 33 |
https://mledits.github.io/icse_sp5/8/52511/details.html |
| 34 |
https://mledits.github.io/icse_sp5/7/11648/details.html |
| 35 |
https://mledits.github.io/icse_sp5/7/53373/details.html |


| Name: MR. MANISH DWIVEDI | Reg No: 15-1SMHC19 |
|---|---|
| Age / Sex:28/M | Contact No:8826238994 |
| Marital Status:SINGLE | Date:23/1/19 |
| Occupation: JTO . STUDIED MTECH | Dr. PJFP |
| Address:NATIVE UP. IN BLORE SINCE 4 MONTHS | DIAGNOSIS- |
BELOW KNEE PAIN. SINCE 3 MONTHS. BEFORE IT WAS LESS ON AND OFF.
TONUGE ON THE SIDES IS SERRATED.
H/O OF IBS 3-4 YEARS. PASSES STOOL FREQUENTLY. ANY TENSION IMM GETS THIS PROBLEM.
RX:
ARNICA200+RUTA200+SYMPYTHUM 200 – 4-4-4-4 3 DRAM PILLS.
CALC PHOS +SIL 6X – DISC 4-4-4-4 15 GRAMS.


The Minima Blockchain Explorer
Testnet Powered by Minima
Transaction details not found in your local database instance.


Did my first full circuit of the Church Stretton hills yesterday. Started at car park to the north of The Lawley and walked over it. Strongest winds I have seen here has me walking leaning 20 degrees into to to stop me blowing over. Down the other side over fields to the base of Caer Caradoc. Climbed Little Cardoc and then the main hill. Stopped near top in wind shade and had some lovely chicken sandwiches… yum yum.. Post early lunch I went up Willston Hill then along bridleway to right of Hope Bowder Hill. Through Hope Bowder and then over Ragleth Hill brought me to the A49.
Crossing over into Little Stretton, I followed my favorite path up the Mynd - Ashes Hollow. It was good fun as the steam was in full spate, and the normal 2 inch crossings turned into 1 foot crossings and all small scrambles were over wet rock. At the top, I joined the Shropshire Way then along the open access boundary past Jonathan’s Rock to Plush Hill. Followingi the path past Inwood House then Oakfield, I finally joined paths over farmers fields to the car park.
Overall 18.25 miles with about 1150 metres of ascent. Unfortunately my legs have never ached so much so next week I really need to calm down a bit. Mind, it will be my first Peak District yomp of the year.


{% extends "layout.html" %} {% block content %}
General Settings
| Plot type: Correlation Z-score DESeq2 Anota2seq | ⓘ |
| Gene type: All Coding Non-coding | ⓘ |
| Minimum no. of reads: | ⓘ |
| Min z-score (+/-)/ Max padj (%): | ⓘ |
| Region: All CDS 5' 3' | ⓘ |
| Normalise by mapped reads: | ⓘ |
| Allow ambiguously mapped reads: | ⓘ |
| Store results | |
| Highlight gene List: | ⓘ |
| Transcript List: | ⓘ |
| Minimum coverage: |
Ribo-Seq files Condition 1
Ribo-Seq files Condition 2
RNA-Seq files Condition 1
RNA-Seq files Condition 2
Seq types
Studies
Files