text:
# Single-cell quality control with scater

### Overview

question Questions
• How to ensure the quality of single-cell RNA-seq data?

• What are the confounding factors that may affect the interpretation of downstream analyses?

objectives Objectives
• Examine scRNA-seq data for low-quality cells

• Visualise data with various types of plots

• Filtering low-quality cells with the appropriate approach

requirements Requirements

time Time estimation: 1 hour

Supporting Materials

last_modification Last modification: Dec 1, 2020

# Introduction

Single-cell RNA-seq (scRNA-seq) is emerging as a promising technology for analysing variability in cell populations. However, the combination of technical noise and intrinsic biological variability makes detecting technical artefacts particularly challenging. Removal of low-quality cells and detection of technical artefacts is critical for accurate downstream analysis.

A number of factors should be examined before downstream analyses, many of which we’ll address here:

• Low library size: When cells are very degraded or absent from the library preparation, the number of reads sequenced from that library will be very low. It’s important to remove these cells from downstream analyses.

• Low number of expressed genes: A low number of expressed genes may be a result of poor-quality cells (e.g. dying, degraded, damaged, etc.), followed by high PCR amplification of the remaining RNA. Again, these cells should be removed from downstream analyses.

• High mitochondrial gene content: High concentrations of mitochondrial genes is often a result of damaged cells where the endogenous RNA escapes or degrades. As mitochondria has its own cell membranes, it is often the last DNA/RNA in damaged cells to degrade and hence occurs in high quantities during sequencing.

• Batch effect: Large scRNA-seq projects usually need to generate data across multiple batches due to logistical constraints. However, the processing of different batches is often subject to variation, e.g., changes in operator, differences in reagent quality and concentration, the sequencing machine used, etc. This results in systematic differences in the observed expression in cells from different batches, which we refer to as “batch effects”. Batch effects are problematic as they can be major drivers of variation in the data, masking the relevant biological differences and complicating interpretation of the results.

We will use scater (McCarthy et al. 2017) to visualise scRNA-seq data, obtaining information about the factors mentioned above, filter out low-quality cells and confirm that filtering has worked. We’ll then look at confounding factors such as batch effect to see if the data is biased to any technical artifacts.

### Agenda

In this tutorial, we will cover:

# Overview

We will use a pre-calculated expression matrix, along with some additional metadata such as lists of mitochondrial genes and annotation of technical information for each sequencing library. We will plot the data and carry out quality control filtering based on the visualise-filter-visualise paradigm of this approach (see workflow below).

1. Create a new history for this tutorial
2. Import the files from Zenodo or from the shared data library

https://zenodo.org/record/3386291/files/annotation.txt
https://zenodo.org/record/3386291/files/counts.txt
https://zenodo.org/record/3386291/files/mt_controls.txt

• Open the Galaxy Upload Manager (galaxy-upload on the top-right of the tool panel)

• Select Paste/Fetch Data
• Paste the link into the text field

• Press Start

• Close the window

By default, Galaxy uses the URL as the name, so rename the files with a more useful name.

### tip Tip: Importing data from a data library

As an alternative to uploading the data from a URL or your computer, the files may also have been made available from a shared data library:

• Go into Shared data (top panel) then Data libraries

• Select the desired files
• Click on the To History button near the top and select as Datasets from the dropdown menu
• In the pop-up window, select the history you want to import the files to (or create a new one)
• Click on Import

# Visualise the data

Take a look at the uploaded data by clicking on the galaxy-eye symbol for each dataset.

• The counts.txt file is a 40-sample expression matrix. Each sample (Cell_001 - Cell_040) is listed as the column headers and the start of each row is a gene name. The rest of the data refers to the number of reads mapped to each gene/sample.
• annotation.txt is a file listing experimental information about each cell. Parameters here include Mutation_Status, Cell_Cycle, and Treatment. These will be useful for looking at batch effects later.
• The mt_controls.txt file is a list of mitochondrial genes. This list will be used later to calculate the % of mitochondrial reads in each sequencing library.

### hands_on Hands-on: Calculate QC metrics

1. Scater: Calculate QC metrics tool with the following parameters:
• param-file Expression matrix in tabular format”: counts.txt (Input dataset)
• param-file “Format dataset describing the features in tabular format”: annotation.txt (Input dataset)
• param-file “Dataset containing the list of the mitochondrial control genes”: mt_controls.txt (Input dataset)

### comment Comment

The output of this tool is a SingleCellExperiment object in Loom format, which contains all the information from the input files, along with a host of other quality control metrics, calculated from the input data.

Next, lets take a look at the data by plotting various properties to see what our data looks like.

### hands_on Hands-on: Plot library QC

1. Scater: plot library QC tool with the following parameters:
• param-file “Input SingleCellLoomExperiment dataset”: output_loom (output of Scater: Calculate QC metrics tool)
• param-check “Plot on log scale”: No
2. If we have a large number of cells (500+), set the ‘Plot on log scale’ option to ‘Yes’. This will make it easier to pick cut-offs when dealing with large numbers. When the tool has finished running, click on the galaxy-eye to view the plots. If it doesn’t appear in the browser, you may have to download it and view it externally. You should be presented with plots similar to those below.

### comment Comment

There are four plots, two distribution bar plots and two scatter plots. The first distribution plot is the number of reads in each library (from a single cell). The second plot is the distribution of feature counts per cell. Feature counts in this case refers to the number of genes expressed in each cell. The third plot Scatterplot of reads vs genes is a combination of the two barplots, in that it plots both the read count and the expressed gene count for each cell. The final scatterplot is the % MT genes, which plots the number of genes expressed verses the percentage of those genes that are mitochondrial genes.

Let’s look at each plot in turn and see what it tells us.

• Read counts. You can see that there are a few cells that have less than ~200,000 reads, with other cells having up to one million reads. Although 200,000 reads is still quite a lot and we wouldn’t want to get rid of so much data, we might want to think about removing cells that only contain a smaller number of reads (say, 100,000).
• Feature counts. Similar to the read counts plot, we see a few cells that have a very low number of expressed genes (<600), then followed by a more even distribution.
• Scatterplot of reads vs genes. This takes the information provided in the two distribution plots above and creates a scatterplot from them. The really poor-quality cells are represented by the points near the intersection of the x and y axis, being data with low read count and low gene count. These are the cells we want to remove during filtering.
• % MT genes. You can see from the plot that there are a few cells outside the main “cloud” of datapoints. Some of these could be removed by filtering out cells with low feature counts, but others might need to be removed by mitochondrial content, such as the cell around 37.5%

# Filtering

## Manual filtering

In the Scater: filter SCE Galaxy tool there are two filtering methods available. First, there’s an “automatic” filtering method that uses PCA to identify outliers cells and remove them from the data. This is particularly useful for very large datasets (hundreds of samples). Second, there’s a manual filtering method where users can put a range of filtering parameters, informed by the previous plotting tool. Here, we’ll use the manual filtering method.

### hands_on Hands-on: Filtering with scater

1. Scater: filter SCE tool with the following parameters:
• param-file “Input SingleCellLoomExperiment dataset”: output_loom (output of Scater: Calculate QC metrics tool)
• “Type of filter”: manual
• “Number of reads mapped to a gene for it to be counted as expressed”: 4.0
• “Minimum library size (mapped reads) to filter cells on”: 100000
• “Minimum number of expressed genes to filter cells on”: 500
• “Maximum % of mitochondrial genes expressed per cell”: 35.0

### comment Comment

Let’s have a look at the parameters and their values:

1. “Number of reads mapped to a gene for it to be counted as expressed”: by default, only one read needs to be mapped to a gene for it to be counted as “expressed”. We can be a little bit more stringent here and increase the number of reads that need to be mapped to a gene for it to be categorised as “expressed”.
2. “Minimum library size (mapped reads) to filter cells on”: This value asks how many mapped reads from each cell do you require to be mapped to your genome to be included in downstream analysis. We can see from our plots that we have a few cells that have less than 200,000 reads. 200,000 can still be quite a lot of reads (depending on the experiment), but we can use a smaller number to see what the initial effect of filtering is. Initially, use 100,000 as the value here.
3. “Minimum number of expressed genes”: You can see that some cells only express a few hundred genes, so we’ll remove these cells also.
4. “Maximum % of mitochondrial genes expressed per cell”. You can see that as well as having one obvious outlier (~37%).

### hands_on Hands-on: Plot library QC after filtering

1. Scater: plot library QC tool with the following parameters:
• param-file “Input SingleCellLoomExperiment dataset”: output_loom (output of Scater: filter SCE tool)

### comment Comment

How did the filtering go? Do you think it’s done a good job? Have you removed too many cells? Too few cells? About right?

Often, it’s a matter of trial and error, where you would start off by being quite lenient (low parameters) and then increasing the stringency until you’re happy with the results. Using the initial Calculate QC metrics file, play around with the filtering parameters and visualise the output to see the effect different paramters have.

## Automatic (PCA) filtering

Another filtering approach is to identify outliers in the data and remove them. PCA can be run once a SingleCellExperiment object has been normalised, and outliers cells identified based on the pre-computed quality control metrics within the SingleCellExperiment object.

As we are using a rather small test dataset, it’s unlikely that PCA filtering will make any difference; for a larger, noisier dataset this is what we would perform instead:

1. Scater: filter SCE tool with the following parameters:
• param-file “Input SingleCellLoomExperiment dataset”: output_loom (output of Scater: Calculate QC metrics tool)
• “Type of filter”: automatic

### comment Comment

The data will be normalised and then PCA ran on it using the following information from the data:

• pct_counts_top_100_features
• total_features_by_counts
• pct_counts_feature_control
• total_features_feature_control
• log10_total_counts_endogenous
• log10_total_counts_feature_control

When using these filtering approaches, it is sometimes good to try running them in reverse - try PCA filtering first and then if that doesn’t remove enough low-quality cells then use the manual filtering. We could actually pipeline them together - use PCA filtering first and then use the output of that to do further manual filtering.

As discussed previously, technical artefacts can bias scRNA-seq analyses. Strong batch effects can mask real biological differences in the data, so must be identified and removed from the data. Logging meta-data details such as date of library construction, sequencing batch, sample name, technical replicate, plate number, etc., is essential to identify batch effects in the data. We can use this information to visualise the data to examine it for clustering according to batch, rather than any real biological feature.

### hands_on Hands-on: PCA plot

1. Scater: PCA plot tool with the following parameters:
• param-file “Input SingleCellLoomExperiment dataset”: output_loom (output of Scater: filter SCE tool)
• “Feature (from annotation file) to colour PCA plot points by”: Mutation_Status
• “Feature (from annotation file) to shape PCA plot points by”: Cell_Cycle

### question Questions

1. Do you see any obvious batch effect?
2. Do any of the categories suggesting some sort of technical artefact?

### solution Solution

1. We can see that the S and G2M categories in Cell_Cycle cluster away from the rest of the data. Spend some time thinking about whether this might be a batch effect or biologically significant.

# Conclusion

We have gone through the process of filtering low-quality data from an scRNA-seq expression matrix, using the visualise-filter-visualise paradigm, which proves to be a very effective way of quality-controlling scRNA-seq data. Cells that have low read-coverage, low expression values, or high mitochondrial gene expression have been filtered out. We have then examined ways of looking at confounding factors to examine batch effects in our data. The workflow available from the “Supporting Materials” of this tutorial can be directly imported and used or adapted to a specific analysis.

### keypoints Key points

• Single-cell RNA-seq data is often noisy

• scater can be used to apply the visualise-filter-visualise paradigm of quality control

# Useful literature

Further information, including links to documentation and original publications, regarding the tools, analysis techniques and the interpretation of results described in this tutorial can be found here.

# References

1. McCarthy, D. J., K. R. Campbell, A. T. L. Lun, and Q. F. Wills, 2017 Scater: pre-processing, quality control, normalization and visualization of single-cell RNA-seq data in R. Bioinformatics 33: 1179–1186. 10.1093/bioinformatics/btw777

# Feedback

Did you use this material as an instructor? Feel free to give us feedback on how it went.

# Citing this Tutorial

1. Graham Etherington, Nicola Soranzo, 2020 Single-cell quality control with scater (Galaxy Training Materials). /archive/2020-12-01/topics/transcriptomics/tutorials/scrna-scater-qc/tutorial.html Online; accessed TODAY
2. Batut et al., 2018 Community-Driven Data Analysis Training for Biology Cell Systems 10.1016/j.cels.2018.05.012

### details BibTeX

@misc{transcriptomics-scrna-scater-qc,
author = "Graham Etherington and Nicola Soranzo",
title = "Single-cell quality control with scater (Galaxy Training Materials)",
year = "2020",
month = "12",
day = "01"
url = "\url{/archive/2020-12-01/topics/transcriptomics/tutorials/scrna-scater-qc/tutorial.html}",
note = "[Online; accessed TODAY]"
}
@article{Batut_2018,
doi = {10.1016/j.cels.2018.05.012},
url = {https://doi.org/10.1016%2Fj.cels.2018.05.012},
year = 2018,
month = {jun},
publisher = {Elsevier {BV}},
volume = {6},
number = {6},
pages = {752--758.e1},
author = {B{\'{e}}r{\'{e}}nice Batut and Saskia Hiltemann and Andrea Bagnacani and Dannon Baker and Vivek Bhardwaj and Clemens Blank and Anthony Bretaudeau and Loraine Brillet-Gu{\'{e}}guen and Martin {\v{C}}ech and John Chilton and Dave Clements and Olivia Doppelt-Azeroual and Anika Erxleben and Mallory Ann Freeberg and Simon Gladman and Youri Hoogstrate and Hans-Rudolf Hotz and Torsten Houwaart and Pratik Jagtap and Delphine Larivi{\{e}}re and Gildas Le Corguill{\'{e}} and Thomas Manke and Fabien Mareuil and Fidel Ram{\'{\i}}rez and Devon Ryan and Florian Christoph Sigloch and Nicola Soranzo and Joachim Wolff and Pavankumar Videm and Markus Wolfien and Aisanjiang Wubuli and Dilmurat Yusuf and James Taylor and Rolf Backofen and Anton Nekrutenko and Björn Grüning},
title = {Community-Driven Data Analysis Training for Biology},
journal = {Cell Systems}
}
`


text:
# How to make page numbering continuous after a second \mainmatter?

I am writing a document with multiple \mainmatters and \backmatters. The structure is basically:

...
\mainmatter
\backmatter
...
\mainmatter
\backmatter
...

Is there a simple way of preventing LaTeX to reset the page counter? Also \backmatter should not reset the counter.

-
Welcome to TeX.SX! What's the purpose of alternating \mainmatter and \backmatter? –  egreg Jun 27 '12 at 14:34
Thank you :) The purpose is, that i have multiple documents, each with its own reference list, which i must summarize in tex using the book class. Since references should be listed in the backmatter multiple backmatters/mainmatter are necessary. –  Julian Jun 28 '12 at 5:27

This depends highly on the document class you're using. Taking the standard book as base, \fontmatter and \mainmatter both reset the page counter. \backmatter on the other hand doesn't:

\newcommand\frontmatter{%
\cleardoublepage
\@mainmatterfalse
\pagenumbering{roman}}
\newcommand\mainmatter{%
\cleardoublepage
\@mainmattertrue
\pagenumbering{arabic}}
\newcommand\backmatter{%
\if@openright
\cleardoublepage
\else
\clearpage
\fi
\@mainmatterfalse}

The important thing that causes the page numbering to be reset when issuing the above commands is \pagenumbering (taken from latex.ltx):

\def\pagenumbering#1{%
\global\c@page \@ne \gdef\thepage{\csname @#1\endcsname
\c@page}}

As mentioned, this sets the page counter to one (\global\c@page \@ne) and redefines the representation \thepage (\gdef\thepage{\csname @#1\endcsname\c@page}). So, with an issue of \pagenumbering{roman} (as is performed by \frontmatter), LaTeX issues something equivalent to

\setcounter{page}{1}
\renewcommand{\thepage}{\arabic{page}}

memoir does something similar. If your question is only "How to prevent LaTeX from resetting the page counter?", then you should not use \frontmatter and friends, or at least void what \pagenumbering is doing. You might just be better off redefining the page counter printing mechanism \thepage as is done above. Or, for convenience of use in order to stick to your current layout, perhaps the following suffices in your preamble (which removes the page counter resetting):

\makeatletter
\def\pagenumbering#1{%
\gdef\thepage{\csname @#1\endcsname \c@page}}
\makeatother

Finally, neither book nor memoir resets the page counter for \backmatter.

-
Wouldn't \def\pagenumbering#1{} be more economic? :) However, redefining \mainmatter seems to be better than changing drastically the meaning of an important command. –  egreg Jun 27 '12 at 19:41
@egreg: If the OP doesn't want to change to a different numbering representation (like roman or arabic), then yes. –  Werner Jun 27 '12 at 19:46

An easy solution to your problem is getting rid of the \pagenumbering command issued by \mainmatter, which is responsible of resetting the page number. So I propose

\makeatletter
\def\mainmatter{%
\cleardoublepage
\@mainmattertrue
\pagenumbering{arabic}
\def\mainmatter{\cleardoublepage\@mainmattertrue}
}
\makeatother

The first call of \mainmatter would do as usual, so the page numbering will be arabic, starting from 1. Then it redefines itself to issue only \cleardoublepage and \@mainmattertrue. The latter restores chapter numbering.

-

format: plain


text:
# Wiegand 26-Bit Calculator - Transforming a decimal number into an 26-Bit binary number

I made a 26-bit binary Wiegand calculator for an ESP32 following this format:

This is "Arduino C" :

unsigned int * getWiegand(unsigned int dec) {
unsigned int* wiegandNum = new unsigned int[26];

Serial.println();
// transform dec number into binary number and store it in binaryNum[]
int n = 1;
for(int i = 23; i>=0; i--) {
int k = dec >> i;
if (k & 1)
wiegandNum[n++] = 1;
else
wiegandNum[n++] = 0;
}
// check for parity of the first 12 bits
bool even = true;
for(int i=1;i<13;i++) {
if(wiegandNum[i] == 1) {
even = !even;
}
}
// add 0 or 1 as first bit (leading parity bit - even) based on the number of ones in the first 12 bits
if(even) {
wiegandNum[0] = 0;
} else {
wiegandNum[0] = 1;
}

// check for parity of the last 12 bits
bool odd = false;
for(int i=13; i<25;i++) {
if(wiegandNum[i] == 1) {
odd = !odd;
}
}
// add 0 or 1 as last bit (trailing parity bit - odd) based on the number of ones in the last 12 bits
if(odd) {
wiegandNum[25] = 0;
} else {
wiegandNum[25] = 1;
}

return wiegandNum;
}

void setup() {
Serial.begin(115200);

unsigned int* wiegandArray = getWiegand(12679548);
for(int i=0;i<26;i++) {
Serial.print(wiegandArray[i]);
}
}

12679548 will return 01100000101111001011111000 which, based on this online tool is correct.

Execution time for this function is 255 microseconds. I don't know if the time is good or not, but I believe that the code can be improved.

What do you think ?

References:

• The structure or class Serial is used within the code but is not defined within the question. This code can't be reviewed because it is incomplete. We need to see the declaration and instantiation of the object Serial. – pacmaninbw Dec 9 '19 at 13:11
• @pacmaninbw Serial.println() is just like cout<<endl;. It's from the ESP32 Core libraries. I have never defined it inside a program. arduino.cc/reference/en/language/functions/communication/serial/… – GeorgicaFaraFrica Dec 9 '19 at 13:59
• Please do not update the code in your question to incorporate feedback from answers, doing so goes against the Question + Answer style of Code Review. This is not a forum where you should keep the most updated version in your question. Please see what you may and may not do after receiving answers. – Simon Forsberg Dec 9 '19 at 15:19

## Separate calculation from I/O

The Serial.println(); call from within getWeigand really shouldn't be there. It's better if the function does just one thing, and that is to calculate and return the number.

## Don't leak memory

The code calls new but there isn't any matching delete which means that the program leaks memory. It's better to make sure all memory is freed, but better still, see the next suggestion.

## Avoid using new and delete

Modern C++ doesn't use new and delete as much as it used to. In this case, much better than passing around a raw array pointer and hoping the other end knows what the size is, is to use std::array instead. That is an improvement over a plain array because it works with all of the standard container algorithms and has its own .size() operator. See I.13 for more details on why passing around a single array pointer is not a good idea.

## Prefer single bit shifting to multi-bit shifting

Many processors have hardware optimizations for multi-bit shifts, but not all do. That means on some machines, multi-bit shifts take longer. For that reason, and because I think it's more readable, I'd suggest changing the first for loop to this:

for (int i = 24; i > 0; --i) {
wiegandNum[i] = dec & 1;
dec >>= 1;
}

Instead of doing things like this:

if(even) {
wiegandNum[0] = 0;
} else {
wiegandNum[0] = 1;
}

just use the value directly:

wiegandNum[0] = !even;

Lines like this one:

for(int i=1;i<13;i++) {

are much easier to read with a little more whitespace:

for (int i = 1; i < 13; i++) {

## Create a test routine

With code like this, it's usually good to do extensive testing to make sure it does what you intend. I am not using an Arduino, but created a version that runs on Linux (or really any computer that supports C++):

#include <string>
#include <iostream>
#include <iomanip>
std::string weiString(unsigned int dec)
{
std::string str{};
for (const auto digit: answer) {
str.push_back(digit ? '1' : '0');
}
return str;
}

int main()
{
struct {
unsigned n;
std::string expected;
bool operator()() const {
std::string calculated = weiString(n);
bool ok{calculated == expected};
std::cout << std::hex << n
<< std::dec
<< '\t' << expected
<< '\t' << calculated
<< '\t' << (ok ? "OK" : "incorrect!")
<< '\n';
return ok;
}
} tests[]{
{12679548,  "01100000101111001011111000" },
{0xffff,    "00000000011111111111111111" },
{0x1ffff,   "10000000111111111111111111" },
{0xffffff,  "01111111111111111111111111" },
{0xfffffff, "01111111111111111111111111" },  // ignore high bits
};

for (const auto& test: tests) {
test();
}
}

## Results

Here's the alternate version that uses these suggestions. It also uses the exclusive-or operator ^ to simplify parity calculations:

#include <array>

std::array<unsigned, 26> getWiegand(unsigned int dec)
{
std::array<unsigned, 26> wiegandNum;
for (int i = 24; i > 0; --i) {
wiegandNum[i] = dec & 1;
dec >>= 1;
}
// check for parity of the first 12 bits
bool even = false;
for (int i = 1; i < 13; i++) {
even ^= wiegandNum[i];
}
wiegandNum[0] = even;

// check for parity of the last 12 bits
bool odd = true;
for (int i = 13; i < 25; i++) {
odd ^= wiegandNum[i];
}
wiegandNum[25] = odd;

return wiegandNum;
}

Even shorter is to process one of the parity bits over the entire array as it's generated and then recalculate just the other one and adjust. It might be less obvious why this works, but it does. See if you can see why.

std::array<unsigned, 26> getWiegand(unsigned int dec)
{
bool odd = true;
std::array<unsigned, 26> wiegandNum;
for (int i = 24; i > 0; --i) {
wiegandNum[i] = dec & 1;
odd ^= wiegandNum[i];
dec >>= 1;
}
// check for parity of the first 12 bits
bool even = false;
for (int i = 1; i < 13; i++) {
even ^= wiegandNum[i];
}
wiegandNum[0] = even;
wiegandNum[25] = odd ^ even;
return wiegandNum;
}

• Wow. What a great answer. Great tricks with wiegandNum[0] = even; and the XOR operator. Can you please explain to me single bit shifting ? The for changed from this: for(int i = 23; i>=0; i--) to this for (int i = 24; i > 0; --i). They don't look alike, yet they function exactly the same. What is this magic ? – GeorgicaFaraFrica Dec 9 '19 at 15:20
• No magic at all. :) Your original code started from the most significant bit while this version starts from the least. The advantage is that we can shift the whole number (dec >>= 1;) to the right by one bit each time and just test the low bit with dec & 1. It's a pretty common trick. – Edward Dec 9 '19 at 15:23
• I will need to do some reading on that. Some drawings will most certainly help :)). – GeorgicaFaraFrica Dec 9 '19 at 15:24
• Just for fun, I added an even shorter version to my answer at the end, but you'll probably want to think about it for a while to understand why it works. – Edward Dec 9 '19 at 15:30

Be careful when allocating memory with new[] and passing to the caller:

unsigned int * getWiegand(unsigned int dec)
{
unsigned int* wiegandNum = new unsigned int[26];
// ...
return wiegandNum;
}

void setup()
{
unsigned int* wiegandArray = getWiegand(12679548);
// BUG: never deleted!
}

This is a memory leak. Prefer to use a smart pointer or container instead.

BTW, is it really necessary to use 26 unsigned int values each storing one bit, or could/should you use a more compact representation?

• I have no idea what's good or not. That program is all my knowledge about C++. I don't know anything about smart pointers or containers. Storing one bit in one unsigned int is the only representation I could think off. I need access to every bit for an if(wiegandArray[0] == 1) {// do something} else if(wiegandArray[0] == 0) {// do something else}. – GeorgicaFaraFrica Dec 9 '19 at 14:11
• I also need the container of the binary number to be re-usable. The program will get an unspecified number of binary numbers that will have to be placed into an array to be manipulated later. Something like this: unsigned int* wiegandArray; and then this: wiegandArray = getWiegand(12679548); gets called each time a new number is being served. I couldn't put all the code of the project here. – GeorgicaFaraFrica Dec 9 '19 at 14:22


text:
# Does every continuous function have a left and right derivative?

I understand that differentiability implies continuity, whereas the converse isn't true. But must a continuous function have both a left and right derivative, not necessarily equal to one another?

• $f(x) = x \sin(1/x),$ with $f(0)$ defined to be $0,$ is continuous and has neither a left nor a right derivative at $x=0.$ – Dave L. Renfro Feb 21 '14 at 22:12
• There is a nice graph of the function I gave in the StackExchange question Calculating Dini derivatives (which I found by doing a google image search for "right derivative" AND "sin(1/x)". – Dave L. Renfro Feb 21 '14 at 22:28

For $f(x)=x \sin{\frac{1}{x}}$, $f(0)=0$ (Just like Dave commented) you have: $$\frac{f(0 + \Delta x) - f(0)}{ \Delta x} = \frac{(0 + \Delta x) \sin (\frac{1}{0 +\Delta x}) - 0}{\Delta x} = \sin (\frac{1}{\Delta x})$$ As $\Delta x$ approaches $0$ from the left/right you will just get $- \sin(x)$ / $\sin(x)$ as $x$ tends to $\infty$, i.e, no limit.

But, let $\epsilon > 0$ and $\delta = \epsilon$: $$|x|=|x-0| < \delta \implies |x \sin (\frac{1}{x}) - 0| = |x \sin (\frac{1}{x})| \leq |x| < \delta = \epsilon$$ Hence $f$ is continous at $0$.

• This does not address the OP's question at all. – Mark Viola Mar 29 at 22:17

The famous Weierstrass function, which is continuous but nowhere differentiable, fails everywhere to have left- and right-derivatives, as well. This takes a bit of work to check.

• I wouldn't have believed it was possible at the time – user10389 Feb 22 '14 at 13:42

If $f$ has a left and right derivative at every point, then it certainly has finite Dini derivatives at every point, and then it follows immediately from the Denjoy-Young-Saks Theorem that $f$ is differentiable away from a set of measure $0$. But as pointed out in Ted Shifrin's answer, there are certainly continuous functions which are nowhere differentiable, e.g. Weierstrass's function.

[Or in other words: it is relatively common to describe Weierstrass-like nowhere differentiable functions as "having corners at every point". The above paragraph shows that this is very loose language: taken literally, there are no such functions!]

Thus the Weierstrass function is continuous everywhere and certainly has left and right hand derivatives only at a set of measure zero. This checks a weak form of Ted's answer, but enough to use the Weierstrass function to answer the OP's question...lazily.

Really though this answer is almost a joke: I believe I am applying too big a theorem to deduce too small a result. When I first read the question I was tempted to say that a function which has (finite!) left and right hand derivatives at every point must be differentiable on the complement of a countable set, just like a function which has left and right hand limits at every point must be continuous except at countably many points. Is that actually true? (Added: Hmm, I think I've changed my guess; I now doubt that's true. But I'd still like to know.)


text:
If you are happy with Frechet bundles here is an alternative approach. Let $\pi \colon {\mathcal G} \times M \to M$ be the projection and consider $\pi^{-1}(TM) \to {\mathcal G} \times M$ a real vector bundle of rank $n$. Following the notation in the paper let $P_{GL^+} \to M$ be the $GL^+(n, {\mathbb R})$ bundle of oriented frames of $TM$. The bundle of oriented frames of $\pi^{-1}(TM)$ is $\pi^{-1}(P_{GL^+})$. As in the paper pick a lift $P_{\widetilde{GL}^+} \to M$ of $P_{GL^+}$ to $\widetilde{GL}^+(n, {\mathbb R}) \to M$ of bundles over $M$. This exists because we assume $M$ is spin. Then $\pi^{-1}(P_{\widetilde{GL}^+})$ is a lift of $\pi^{-1}(P_{GL^+})$ to $\widetilde{GL}^+(n, {\mathbb R})$.

If $g \in {\mathcal G}$ and $m \in M$ then $\pi^{-1}(TM)_{(g, m)} = T_m M$ so has on it an inner product defined by $g(m)$. Denote this "universal" inner product on $\pi^{-1}(TM)$ by $g$. It will be smooth for the usual reason with Frechet manifolds which is because if $M$ and $N$ are finite-dimensional bundles then the evaluation map $$M \times C^\infty(M, N) \to N$$ is a smooth map of Frechet manifolds [1]. Again following the approach in the paper we let $P_{SO} \subset \pi^{-1}(P_{GL^+})$ be the subbundle of oriented orthonormal frames for the metric $g$. Taking the pre-image of this in $\pi^{-1}(P_{\widetilde{GL}^+})$ gives us a $Spin(r, s)$ bundle over $\mathcal{G} \times M$. The associated vector bundle to this using the spin representation gives us $E$ as a smooth, finite rank, Frechet vector bundle.

Finally you want a theorem that says that when you "push-down" $E$ with $\pi$ the result is a smooth Frechet vector bundle on ${\mathcal G}$. This seems reasonably but I'm not sure where to find it. I can't see it in [1].

Sorry this is a bit sketchy but that reflects the sketchiness of my knowledge of Frechet manifolds.

[1] Richard Hamilton -- The Inverse Function Theorem of Nash Moser. http://dx.doi.org/10.1090%2FS0273-0979-1982-15004-2

2 Forgot the reference.

If you are happy with Frechet bundles here is an alternative approach. Let $\pi \colon {\mathcal G} \times M \to M$ be the projection and consider $\pi^{-1}(TM) \to {\mathcal G} \times M$ a real vector bundle of rank $n$. Following the notation in the paper let $P_{GL^+} \to M$ be the $GL^+(n, {\mathbb R})$ bundle of oriented frames of $TM$. The bundle of oriented frames of $\pi^{-1}(TM)$ is $\pi^{-1}(P_{GL^+})$. As in the paper pick a lift $P_{\widetilde{GL}^+} \to M$ of $P_{GL^+}$ to $\widetilde{GL}^+(n, {\mathbb R}) \to M$ of bundles over $M$. This exists because we assume $M$ is spin. Then $\pi^{-1}(P_{\widetilde{GL}^+})$ is a lift of $\pi^{-1}(P_{GL^+})$ to $\widetilde{GL}^+(n, {\mathbb R})$.

If $g \in {\mathcal G}$ and $m \in M$ then $\pi^{-1}(TM)_{(g, m)} = T_m M$ so has on it an inner product defined by $g(m)$. Denote this "universal" inner product on $\pi^{-1}(TM)$ by $g$. It will be smooth for the usual reason with Frechet manifolds which is because if $M$ and $N$ are finite-dimensional bundles then the evaluation map $$M \times C^\infty(M, N) \to N$$ is a smooth map of Frechet manifolds [1]. Again following the approach in the paper we let $P_{SO} \subset \pi^{-1}(P_{GL^+})$ be the subbundle of oriented orthonormal frames for the metric $g$. Taking the pre-image of this in $\pi^{-1}(P_{\widetilde{GL}^+})$ gives us a $Spin(r, s)$ bundle over $\mathcal{G} \times M$. The associated vector bundle to this using the spin representation gives us $E$ as a smooth, finite rank, Frechet vector bundle.

Finally you want a theorem that says that when you "push-down" $E$ with $\pi$ the result is a smooth Frechet vector bundle on ${\mathcal G}$. This seems reasonably but I'm not sure where to find it. I can't see it in [1].

Sorry this is a bit sketchy but that reflects the sketchiness of my knowledge of Frechet manifolds.

[1] Richard Hamilton -- The Inverse Function Theorem of Nash Moser

1

If you are happy with Frechet bundles here is an alternative approach. Let $\pi \colon {\mathcal G} \times M \to M$ be the projection and consider $\pi^{-1}(TM) \to {\mathcal G} \times M$ a real vector bundle of rank $n$. Following the notation in the paper let $P_{GL^+} \to M$ be the $GL^+(n, {\mathbb R})$ bundle of oriented frames of $TM$. The bundle of oriented frames of $\pi^{-1}(TM)$ is $\pi^{-1}(P_{GL^+})$. As in the paper pick a lift $P_{\widetilde{GL}^+} \to M$ of $P_{GL^+}$ to $\widetilde{GL}^+(n, {\mathbb R}) \to M$ of bundles over $M$. This exists because we assume $M$ is spin. Then $\pi^{-1}(P_{\widetilde{GL}^+})$ is a lift of $\pi^{-1}(P_{GL^+})$ to $\widetilde{GL}^+(n, {\mathbb R})$.

If $g \in {\mathcal G}$ and $m \in M$ then $\pi^{-1}(TM)_{(g, m)} = T_m M$ so has on it an inner product defined by $g(m)$. Denote this "universal" inner product on $\pi^{-1}(TM)$ by $g$. It will be smooth for the usual reason with Frechet manifolds which is because if $M$ and $N$ are finite-dimensional bundles then the evaluation map $$M \times C^\infty(M, N) \to N$$ is a smooth map of Frechet manifolds [1]. Again following the approach in the paper we let $P_{SO} \subset \pi^{-1}(P_{GL^+})$ be the subbundle of oriented orthonormal frames for the metric $g$. Taking the pre-image of this in $\pi^{-1}(P_{\widetilde{GL}^+})$ gives us a $Spin(r, s)$ bundle over $\mathcal{G} \times M$. The associated vector bundle to this using the spin representation gives us $E$ as a smooth, finite rank, Frechet vector bundle.

Finally you want a theorem that says that when you "push-down" $E$ with $\pi$ the result is a smooth Frechet vector bundle on ${\mathcal G}$. This seems reasonably but I'm not sure where to find it. I can't see it in [1].

Sorry this is a bit sketchy but that reflects the sketchiness of my knowledge of Frechet manifolds.


text:
Definitions

# Dirichlet character

In number theory, Dirichlet characters are certain arithmetic functions which arise from completely multiplicative characters on the units of $mathbb Z / k mathbb Z$. Dirichlet characters are used to define Dirichlet L-functions, which are meromorphic functions with a variety of interesting analytic properties. If $chi$ is a Dirichlet character, one defines its Dirichlet L-series by

$L\left(chi,s\right) = sum_\left\{n=1\right\}^infty frac\left\{chi\left(n\right)\right\}\left\{n^s\right\}$

where s is a complex number with real part > 1. By analytic continuation, this function can be extended to a meromorphic function on the whole complex plane. Dirichlet L-functions are generalizations of the Riemann zeta-function and appear prominently in the generalized Riemann hypothesis.

Dirichlet characters are named in honour of Johann Peter Gustav Lejeune Dirichlet.

## Axiomatic definition

A Dirichlet character is any function χ from the integers to the complex numbers which has the following properties:

`1) There exists a positive integer k such that χ(n) = χ(n + k) for all n.`
`2) If gcd(n,k) > 1 then χ(n) = 0; if  gcd(n,k) =  1 then χ(n) ≠ 0.`
`3) χ(mn) = χ(m)χ(n) for all integers m and n.`

These consequences are important:

By property 3), χ(1)=χ(1×1)=χ(1)χ(1); since gcd(1, k) = 1, property 2) says χ(1) ≠ 0, so

`4) χ(1) = 1.`
1) says that a character is periodic with period k; we say that χ is a character to the modulus k. This is equivalent to saying that

`5) if a ≡ b (mod k) then χ(a) = χ(b).`

If gcd(a,k) = 1, Euler's theorem says that aφ(k) ≡ 1 (mod k) (where φ(k) is the totient function). Therefore by 5) and 4), χ(aφ(k)) = χ(1) = 1, and by 3), χ(aφ(k)) =χ(a)φ(k) . So for all a relatively prime to k,

`6) χ(a) is a φ(k)-th complex root of unity.`

Condition 3) says that a character is completely multiplicative.

The unique character of period 1 is called the trivial character. Note that any character vanishes at 0 except the trivial one, which is 1 on all integers.

A character is called principal if it assumes the value 1 for arguments coprime to its modulus and otherwise is 0. A character is called real if it assumes real values only. A character which is not real is called complex.

## Construction via residue classes

The last two properties show that every Dirichlet character χ is completely multiplicative. One can show that χ(n) is a φ(k)th root of unity whenever n and k are coprime, and where φ(k) is the totient function: By simple group arithmetic, $chi\left(n\right)^\left\{phi\left(k\right)\right\} = chi\left(n^\left\{phi\left(k\right)\right\}\right) = chi\left(1\right) = 1$. Dirichlet characters may be viewed in terms of the character group of the unit group of the ring Z/kZ, as given below.

### Residue classes

Given an integer k, one defines the residue class of an integer n as the set of all integers congruent to n modulo k: $hat\left\{n\right\}=\left\{m | m equiv n mod k \right\}.$ That is, the residue class $hat\left\{n\right\}$ is the coset of n in the quotient ring Z/kZ.

The set of units modulo k forms an abelian group of order $phi\left(k\right)$, where group multiplication is given by $hat\left\{mn\right\}=hat\left\{m\right\}hat\left\{n\right\}$ and $phi$ again denotes Euler's phi function. The identity in this group is the residue class $hat\left\{1\right\}$ and the inverse of $hat\left\{m\right\}$ is the residue class $hat\left\{n\right\}$ where $hat\left\{m\right\} hat\left\{n\right\} = hat\left\{1\right\}$, i.e., $m n equiv 1 mod k$. For example, for k=6, the set of units is $\left\{hat\left\{1\right\}, hat\left\{5\right\}\right\}$ because 0, 2, 3, and 4 are not coprime to 6.

### Dirichlet characters

A Dirichlet character modulo k is a group homomorphism $chi$ from the unit group modulo k to the non-zero complex numbers (necessarily with values that are roots of unity since the units modulo k form a finite group). We can lift $chi$ to a completely multiplicative function on integers relatively prime to k and then to all integers by extending the function to be 0 on integers having a non-trivial factor in common with k. The principal character $chi_1$ modulo k has the properties

$chi_1\left(n\right)=1$ if gcd(n, k) = 1 and
$chi_1\left(n\right)=0$ if gcd(n, k) > 1.

When k is 1, the principal character modulo k is equal to 1 at all integers. For k greater than 1, the principal character modulo k vanishes at integers having a non-trivial common factor with k and is 1 at other integers.

## A few character tables

The tables below help illustrate the nature of a Dirichlet character. They present all of the characters from modulus 1 to modulus 10. The characters χ1 are the principal characters.

### Modulus 1

There is $phi\left(1\right)=1$ character modulo 1:

χ  n     0
$chi_1\left(n\right)$ 1

This is the trivial character.

### Modulus 2

There is $phi\left(2\right)=1$ character modulo 2:

χ  n     0     1
$chi_1\left(n\right)$ 0 1

Note that χ is wholly determined by χ(1) since 1 generates the group of units modulo 2.

### Modulus 3

There are $phi\left(3\right)=2$ characters modulo 3:

χ  n     0     1     2
$chi_1\left(n\right)$ 0 1 1
$chi_2\left(n\right)$ 0 1 −1

Note that χ is wholly determined by χ(2) since 2 generates the group of units modulo 3.

### Modulus 4

There are $phi\left(4\right)=2$ characters modulo 4:

χ  n     0     1     2     3
$chi_1\left(n\right)$ 0 1 0 1
$chi_2\left(n\right)$ 0 1 0 −1

Note that χ is wholly determined by χ(3) since 3 generates the group of units modulo 4.

The Dirichlet L-series for $chi_1\left(n\right)$ is

$L\left(chi_1, s\right)= \left(1-2^\left\{-s\right\}\right)zeta\left(s\right),$

where $zeta\left(s\right)$ is the Riemann zeta-function. The L-series for $chi_2\left(n\right)$ is the Dirichlet beta-function

$L\left(chi_2, s\right)=beta\left(s\right).,$

### Modulus 5

There are $phi\left(5\right)=4$ characters modulo 5. In the tables, i is a square root of $-1$.

χ  n     0     1     2     3     4
$chi_1\left(n\right)$ 0 1 1 1 1
$chi_2\left(n\right)$ 0 1 i −i −1
$chi_3\left(n\right)$ 0 1 −1 −1 1
$chi_4\left(n\right)$ 0 1 i i −1

Note that χ is wholly determined by χ(2) since 2 generates the group of units modulo 5.

### Modulus 6

There are $phi\left(6\right)=2$ characters modulo 6:

χ  n     0     1     2     3     4     5
$chi_1\left(n\right)$ 0 1 0 0 0 1
$chi_2\left(n\right)$ 0 1 0 0 0 −1

Note that χ is wholly determined by χ(5) since 5 generates the group of units modulo 6.

### Modulus 7

There are $phi\left(7\right)=6$ characters modulo 7. In the table below, $omega = exp\left(pi i /3\right).$

χ  n     0     1     2     3     4     5     6
$chi_1\left(n\right)$ 0 1 1 1 1 1 1
$chi_2\left(n\right)$ 0 1 ω2 ω −ω −ω2 −1
$chi_3\left(n\right)$ 0 1 −ω ω2 ω2 −ω 1
$chi_4\left(n\right)$ 0 1 1 −1 1 −1 −1
$chi_5\left(n\right)$ 0 1 ω2 −ω −ω ω2 1
$chi_6\left(n\right)$ 0 1 −ω −ω2 ω2 ω −1

Note that χ is wholly determined by χ(3) since 3 generates the group of units modulo 7.

### Modulus 8

There are $phi\left(8\right)=4$ characters modulo 8.

χ  n     0     1     2     3     4     5     6     7
$chi_1\left(n\right)$ 0 1 0 1 0 1 0 1
$chi_2\left(n\right)$ 0 1 0 1 0 −1 0 −1
$chi_3\left(n\right)$ 0 1 0 −1 0 1 0 −1
$chi_4\left(n\right)$ 0 1 0 −1 0 −1 0 1

Note that χ is wholly determined by χ(3) and χ(5) since 3 and 5 generate the group of units modulo 8.

### Modulus 9

There are $phi\left(9\right)=6$ characters modulo 9. In the table below, $omega = exp\left(pi i /3\right).$

χ  n     0     1     2     3     4     5     6     7     8
$chi_1\left(n\right)$ 0 1 1 0 1 1 0 1 1
$chi_2\left(n\right)$ 0 1 ω 0 ω2 −ω2 0 −ω −1
$chi_3\left(n\right)$ 0 1 ω2 0 −ω −ω 0 ω2 1
$chi_4\left(n\right)$ 0 1 −1 0 1 −1 0 1 −1
$chi_5\left(n\right)$ 0 1 −ω 0 ω2 ω2 0 −ω 1
$chi_6\left(n\right)$ 0 1 −ω2 0 −ω ω 0 ω2 −1

Note that χ is wholly determined by χ(2) since 2 generates the group of units modulo 9.

### Modulus 10

There are $phi\left(10\right)=4$ characters modulo 10.

χ  n     0     1     2     3     4     5     6     7     8     9
$chi_1\left(n\right)$ 0 1 0 1 0 0 0 1 0 1
$chi_2\left(n\right)$ 0 1 0 i 0 0 0 i 0 −1
$chi_3\left(n\right)$ 0 1 0 −1 0 0 0 −1 0 1
$chi_4\left(n\right)$ 0 1 0 i 0 0 0 i 0 −1

Note that χ is wholly determined by χ(3) since 3 generates the group of units modulo 10.

## Examples

If p is a prime number, then the function

$chi\left(n\right) = left\left(frac\left\{n\right\}\left\{p\right\}right\right),$ where $left\left(frac\left\{n\right\}\left\{p\right\}right\right)$ is the Legendre symbol, is a Dirichlet character modulo p.

More generally, if m is an odd number the function

$chi\left(n\right) = left\left(frac\left\{n\right\}\left\{m\right\}right\right),$ where $left\left(frac\left\{n\right\}\left\{m\right\}right\right)$ is the Jacobi symbol, is a Dirichlet character modulo m. These are called the quadratic characters.

## Conductors

Residues mod N give rise to residues mod M, for any factor M of N, by discarding some information. The effect on Dirichlet characters goes in the opposite direction: if χ is a character mod M, it gives rise to a character χ* mod N for any multiple N of M. With some attention to the values at which characters take the value 0, one gets the concept of a primitive Dirichlet character, one that does not arise from a factor; and the associated idea of conductor, i.e. the natural (smallest) modulus for a character. Imprimitive characters can cause missing Euler factors in L-functions.

## History

Dirichlet characters and their L-series were introduced by Johann Peter Gustav Lejeune Dirichlet, in 1831, in order to prove Dirichlet's theorem on arithmetic progressions. He only studied them for real s and especially as s tends to 1. The extension of these functions to complex s in the whole complex plane was obtained by Bernhard Riemann in 1859.


text:
Why is this Galois group abelian?

Consider the field extension $\mathbb Q(\zeta_3,\sqrt[3]2,\zeta_8)/\mathbb Q(\zeta_3)$, with intermediate fields $\mathbb Q(\zeta_3,\sqrt[3]2)$ and $\mathbb Q(\zeta_3,\zeta_8)$.

Denote

$L:=\mathbb Q(\zeta_3,\sqrt[3]2,\zeta_8)$, $K=\mathbb Q(\zeta_3)$, $M_1=\mathbb Q(\zeta_3,\sqrt[3]2)$, $M_2=\mathbb Q(\zeta_3,\zeta_8)$

Now I know that the extension $L/K$ is galois. I think that all other subextensions are galois too (?)

How do I see from this, that the Galois group of $L/K$ is abelian?

• I assume that $\zeta_8$ is an eighth-root of 1 but which one? – Piquito Jun 18 '15 at 15:09
• How do you know that those are the only intermediate fields? The ones you have listed are all Galois over $K$ since they are all splitting fields. I would calculate the order of the Galois group. Note that the finite nonabelian groups that have all subgroups normal must have order divisible by $8$. – Taylor Jun 18 '15 at 15:32
• I'm not sure what your'e looking for here, exactly. It's not true that $M_1$ and $M_2$ are the only intermediate fields -- there's also $\mathbb{Q}(\zeta_3,i)$, $\mathbb{Q}(\zeta_3,\sqrt{2})$, $\mathbb{Q}(\zeta_3,i\sqrt{2})$, $\mathbb{Q}(\zeta_3,i\sqrt[3]{2})$, $\mathbb{Q}(\zeta_3,\sqrt[6]{2})$, and $\mathbb{Q}(\zeta_3,i\sqrt[6]{2})$. Do you just want to know what the Galois group is? – Jim Belk Jun 18 '15 at 18:09
• I didn't mean to claim that they are the only ones. I just think that the intermediate fields help to split the Galois group into two parts – Dan Jun 19 '15 at 11:40

Basic facts about linearly disjoint extensions and how they mesh with extensions being Galois give you everything you want. If you have not seen the concept before you can use the notes I prepared for a local seminar as a first aid. Pete L. Clark has published more extensive and polished lecture notes on his web page.

Anyway:

1. $M_1/K$ is a Galois extension and cyclic of degree three because it is a root extension of the type, where the base field contains the appropriate roots of unity.
2. $M_2/K$ is a Galois extension, of degree four with the Galois group isomorphic to the Klein four group. This is because $M_2$ is the 24th cyclotomic field.
3. Because $[M_1:K]=3$ and $[M_2:K]=4$ are coprime we have $M_1\cap M_2=K$.
4. For two Galois extensions (of the same field $K$) the trivial intersection condition of item 3 is equivalent to the extensions being linearly disjoint, so (see Proposition 7 in my notes) the compositum $L=M_1M_2$ is Galois over $K$, and the Galois group $$Gal(L/K)\cong Gal(M_1/K)\times Gal(M_2/K)$$ is thus abelian as a direct product of two abelian groups.

The relevant results can surely also be found in many textbooks:

• Two Galois extensions are linearly disjoint, iff their intersection is trivial.
• The compositum of two linearly disjoint Galois extensions is itself Galois, and the corresponding Galois group is the direct product of the Galois groups of the two smaller extensions.
• One answer-lesson that I liked – Piquito Jun 18 '15 at 19:15

I don’t think this is so hard. Your ground field is $K=\Bbb Q(\zeta_3)$, the field of cube roots of unity. You have one extension gotten by adjoining to $K$ the cube root of $2$, and this is abelian, in fact cyclic of order $3$. The other extension of $K$ is gotten by adjoining the eighth roots of unity, and that’s abelian, since it’s already abelian over $\Bbb Q$. So you have a compositum of two abelian extensions of $K$, and this extension is consequently abelian.


text:
# A standard pair of six sided dice is rolled. What is the probability of rolling a sum less than or equal to 10?

Feb 8, 2017

the probability is $\frac{1}{12}$

#### Explanation:

You will get 36 possible cases with two sided dices :

(1,1), (1,2),(1,3),...,(64),(6,5),(6,6)

but only these ones will give you a sum less than equal to 10:

(6,4),(4,6),(5,5)

Then the probability is:

$p = \frac{3}{36} = \frac{1}{12}$

Feb 9, 2017

$P \left(\text{sum} \le 10\right) = \frac{11}{12}$

#### Explanation:

There are 36 possible combinations from the two dice which are listed in this table:

The combination where the sum is less than or equal to 10 are coloured, and so

$P \left(\text{sum} \le 10\right) = \frac{36 - 3}{36} = \frac{33}{36} = \frac{11}{12}$


text:
5k views

### Which to believe: Kolmogorov-Smirnov test or Q-Q plot?

I'm trying to determine if my dataset of continuous data follows a gamma distribution with parameters shape $=$ 1.7 and rate $=$ 0.000063. The problem is when I use R to create a Q-Q plot of my ...
3k views

### What is randomness?

In probability and statistics, the concept of "random" and "randomness" are frequently used. Often the concept of a random variable is used to model events that occur due to chance. My question ...
21k views

### Explain the xkcd jelly bean comic: What makes it funny?

I see that one time out of the twenty total tests they run, $p < 0.05$, so they wrongly assume that during one of the twenty tests, the result is significant ($0.05 = 1/20$). xkcd jelly bean ...
37k views

### Significance contradiction in linear regression: significant t-test for a coefficient vs non-significant overall F-statistic

I'm fitting a multiple linear regression model between 4 categorical variables (with 4 levels each) and a numerical output. My dataset has 43 observations. Regression gives me the following $p$-...
31k views

### Is a p-value of 0.04993 enough to reject null hypothesis?

In a Wilcoxon signed-ranks statistical significance test, we came across some data that produces a $p$-value of $0.04993$. With a threshold of $p < 0.05$, is this result enough to reject the null ...
5k views

### machine learning techniques for longitudinal data

I was wondering if there were any machine learning techniques (unsupervised) for modelling longitudinal data? I've always used mixed effects models (mostly non-linear) but I was wondering if there are ...
217 views

### Compute a Pvalue from the averaged Pearson and Spearman rho

On the one hand, Pearson correlation is sensitive to outliers, while Spearman is not. On the other hand, if you have quantitative data, Spearman will treat it like ordinal data. How about averaging ...
3k views

### Should I report the descriptive statistics in publication before or after outliers removal?

I have already removed three outliers from the ANOVA and ANCOVA analysis to improve the models. I want to report the descriptive statistics and p-values. First I removed these outliers, and then I ...
191 views

### What is not normal distribution?

I am running analyses for my dissertation and just got myself in a muddle. I am running descriptive stats to determine whether to use paired t-tests vs Wilcoxon signed rank tests. I've read that it ...
299 views

### Creating a composite rank of restaurants with some missing data

I have monthly sales data of 500 restaurants for one year. For the same restaurants, I also have customer defection or dissatisfaction rates. I want to create a composite score that can rank ...
3k views

### Average of root mean square error

Is taking the average of different rmse valid? for example average rmse = (rmse1+rmse2+rmse3)/3 Thank you for your help!
63 views

### source info for a cartoon [closed]

I want to use this image in a presentation for teachers and I cant find the source, when I drop it in google images your site comes up, any idea of the source?
1k views

### Problems with modeling a cumulative dependant variable

I am building a .NET program. One of its functions is to provide a predictive model for a vehicles life-to-date maintenance costs, basically what is the cumulative cost(Y) for a vehicle at specific ...


text:
# rubber-info - Man Page

extract information from LaTeX documents

## Synopsis

rubber-info [options] [action] source

## Description

Rubber-info is a utility for extracting various kinds of information from a LaTeX document. Information can be extracted from the source (for instance when calculating dependencies) or from the compilation log files (to extract errors and warnings). This program is a complement for the compilation system rubber(1).

The command-line options are those used by rubber(1) plus one of the actions described below.

## Actions

One of the following command-line options must be specified, to decide which information to extract. Of course, for actions that read a log file, a compilation must have been done before. If none of these actions is specified, --check is assumed.

--boxes

Extracts from the log file the places in the source where bad boxes appeared (these are the famous overfull and underfull \hbox and \vbox)

--check

Report errors if there are any, otherwise report undefined references if there are any, otherwise list warnings and bad boxes. This is the default action.

--deps

Analyse the source files and produce a space-separated list of all the files that the document depends on and that Rubber cannot rebuild.

--errors

Extract from the log file the list of errors that occurred during the last compilation.

-h,  --help

Display the list of all available options and exit nicely.

--refs

Report the list of undefined or multiply defined references (i.e. the \ref's that are not defined by one \label).

--rules

Analyse the source files and produce a list of dependency rules. One rule is produced for each intermediate target that would be made when running rubber. Rules are formatted in the style of Makefiles.

--version

Print the version number and exit nicely.

--warnings

Stupidly enumerate all LaTeX warnings, i.e. all the lines in the log file that contain the string "Warning".

## Bugs

There are surely a some...

This page documents Rubber version 1.5.1. The program and this man-page are maintained by Sebastian Kapfer <sebastian.kapfer@fau.de>. The homepage for Rubber can be found at https://launchpad.net/rubber/.


text:
rivet is hosted by Hepforge, IPPP Durham

## Rivet analyses reference

### BABAR_2004_I632399

$\phi$ momentum spectra in $\Upsilon(4S)$ decays
Experiment: BABAR (PEP-II)
Inspire ID: 632399
Status: VALIDATED
Authors:
• Peter Richardson
No references listed
Beams: * *
Beam energies: ANY
Run details:
• Any process producing Upsilon(4S) originally e+e-

Measurement of the momentum spectrum of $\phi$ mesons produced in $B$ decays at the $\Upsilon(4S)$ resonance.

Source code: BABAR_2004_I632399.cc
  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 // -*- C++ -*- #include "Rivet/Analysis.hh" #include "Rivet/Projections/UnstableParticles.hh" namespace Rivet { /// @brief phi spectrum at 4S class BABAR_2004_I632399 : public Analysis { public: /// Constructor DEFAULT_RIVET_ANALYSIS_CTOR(BABAR_2004_I632399); /// @name Analysis methods ///@{ /// Book histograms and initialise projections before the run void init() { // Initialise and register projections declare(UnstableParticles(), "UFS"); // Book histograms book(_b_phi, 1, 1, 1); book(_h_phi, 2, 1, 1); book(_c_4S, "/TMP/N4S"); } void findDecayProducts(const Particle & p, Particles & phi) { for(const Particle & child : p.children()) { if(child.pid()==333) phi.push_back(child); else if(!child.children().empty()) findDecayProducts(child,phi); } } /// Perform the per-event analysis void analyze(const Event& event) { // Find the Upsilons among the unstables const UnstableParticles& ufs = apply(event, "UFS"); Particles upsilons = ufs.particles(Cuts::pid==300553); for (const Particle& ups : upsilons) { LorentzTransform cms_boost; if (ups.p3().mod() > 1*MeV) cms_boost = LorentzTransform::mkFrameTransformFromBeta(ups.momentum().betaVec()); Particles phis; findDecayProducts(ups, phis); _c_4S->fill(); for(const Particle & phi : phis) { FourMomentum p2 = cms_boost.transform(phi.momentum()); _h_phi->fill(p2.p3().mod()); _b_phi->fill(0.5); } } } /// Normalise histograms etc., after the run void finalize() { if(_c_4S->effNumEntries()!=0) { scale(_h_phi , 0.5/ *_c_4S); scale(_b_phi , 50./ *_c_4S ); } } ///@} /// @name Histograms ///@{ Histo1DPtr _h_phi,_b_phi; CounterPtr _c_4S; ///@} }; DECLARE_RIVET_PLUGIN(BABAR_2004_I632399); }


text:
# L'Hopital's Rule? [closed]

Why don't the derivatives of the functions in question have to be continuous at the point your finding the limit at? Because, if the derivative "jumps", then the limit doesn't equal the value right?

-

## closed as unclear what you're asking by user7530, AWertheim, hardmath, Sami Ben Romdhane, Daniel RustDec 23 '13 at 9:38

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.

Not sure I understand your question. Is it about L'Hospital's rule? Are you asking whether the rule applies if the derivative is discontinuous at the point? Or what? –  Betty Mock Dec 12 '13 at 3:50
I think the question is clear. l'Hospital's rule says that under certain conditions, $\lim_{x\to a} \frac{f(x)}{g(x)} = \lim_{x\to a}\frac{f'(x)}{g'(x)}$. One of those conditions is that both $f'$ and $g'$ must be exist. OP wants to know why it works even when $f'$ and $g'$ are discontinuous. –  MJD Dec 12 '13 at 4:22
@dfg You said “if the derivative "jumps", then the limit doesn't equal the value right?”. Do you have an example in mind? Because I cannot think of one where this occurs. –  MJD Dec 12 '13 at 4:23
To dfg: Do you know a proof for L'Hospital's Rule? In case not, then why do you want continuity of $f'$ and $g'$. If they were continuous the final limit answer would be $f'(a)/g'(a)$. The fact is that the limit is not necessarily $f'(a)/g'(a)$. In fact it may happen that either or both of $f'(a)$ and $g'(a)$ don't exist. A proof of L'Hospital is given at paramanands.blogspot.com/2013/11/… –  Paramanand Singh Dec 12 '13 at 5:07
To add to my previous comment, if you are really concerned about jumps of the derivative then no need to worry. A derivative can't have jumps as shown at math.stackexchange.com/a/577978 –  Paramanand Singh Dec 12 '13 at 5:14

There seems to be some confusion about what L'Hopital actual states. Please see, for example, http://en.wikipedia.org/wiki/L%27H%C3%B4pital%27s_rule#General_form

In particular, the rule applies to the case where $f,g$ are differentiable on $(a,b)$ and you are evaluating the one-sided limits $\lim_{x \to a^+}$.

To give an example: let $f(x) = |x|$ and $g(x) = x$. Observe that $g$ is differentiable on the whole real line, but $f$ is only differentiable on $(-\infty,0)\cup(0,\infty)$. The rule of L'Hopital thus only applies separately to the two intervals $(-\infty,0)$ and $(0,\infty)$. We have that

$$-1 = \frac{-x}{x} = \lim_{x \to 0^-} \frac{f(x)}{g(x)} = \lim_{x\to 0^-} \frac{f'(x)}{g'(x)} = \lim_{x\to 0^{-}} \frac{-1}{1} = -1$$

and

$$1 = \frac{x}{x} = \lim_{x\to 0^+} \frac{f(x)}{g(x)} = \lim_{x \to 0^+} \frac{f'(x)}{g'(x)} = \lim_{x\to 0^+} \frac{1}{1} = 1$$

But evidently the limits

$$\lim_{x\to 0} \frac{f(x)}{g(x)} \text{ and } \lim_{x \to 0} \frac{f'(0)}{g'(0)}$$

do not exist!

L'Hopital's rule is a statement concerning the equality of the limits of two functions. In a first course of calculus it is, however, often applied in the case where $f$ and $g$ are continuously differentiable in a neighborhood of the point concerned, and so students often end up being used to a statement of the form:

$$\lim_{x \to c} \frac{f(x)}{g(x)} = \frac{f'(c)}{g'(c)}$$

when the ratio $f(c)/g(c)$ is indeterminate. Please observe, however, that in the case where $f$ and $g$ are differentiable at $c$ and $f(c) = g(c) = 0$, the proof of L'Hopital's rule becomes trivial: the definition of differentiability states that

$$f(x) = f'(c)(x-c) + o(|x-c|) \qquad g(x) = g'(c)(x-c) + o(|x-c|)$$ so clearly

$$\lim_{x\to c} \frac{f(x)}{g(x)} = \lim_{x\to c} \frac{f'(c) + o(1)}{g'(c) + o(1)} = \frac{f'(c)}{g'(c)}$$

In particular, once differentiability is assumed at the limit point $c$, whether $f$ and $g$ are differentiable on a full neighborhood of $c$ is inconsequential. The power of L'Hopital's rule is precisely in the case where $f$ and $g$ are not assumed to be differentiable at the point $c$.

Lastly, what if we are to ask about the case where $f$ and $g$ are differentiable at $c$, but we want to compute the limit using the "limit of the ratio of the derivatives" instead of directly evaluating the derivatives at $c$? Are the two approaches given above guaranteed to yield the same answer? The answer is indeed yes due to Darboux's theorem, which says that if $f$ is a differentiable function (not necessarily continuously differentiable) on an open interval that contains the closed interval $[a,b]$. Then for every $\lambda$ that is between $f'(a)$ and $f'(b)$, there exists $c\in [a,b]$ such that $f'(c) = \lambda$. This in particular implies that "jump discontinuities" are not allowed on an interval over which a function is differentiable.

(Incidentally, the typical differentiable but not continuously differentiable function looks more like $x^2 \cos(1/x)$. Its derivative is $$\begin{cases} 2x \cos(1/x) + \sin(1/x) & x\neq 0\\ 0 & x = 0\end{cases}$$ When a function is differentiable but not continuously differentiable, the problem is that it oscillates to much, so that at least one of the one-sided limits $\lim_{x\to c^\pm} f'(x)$ do not exist.)

The case where the discontinuity is "essential" (as described in the parenthetical paragraph above) is ruled out, in the statement of L'Hopital's rule, by the assumption that $\lim_{x\to c^\pm} \frac{f'(x)}{g'(x)}$ exists as an extended real number.

-
Wow, thanks. Really appreciate the detail. –  Vimzy Dec 12 '13 at 19:03