text:
×

# Geometry Problem 1

Prove that in a triangle, the Nagel point and incenter concur if and only if the triangle is equilateral.

$$\textbf{Note:}$$ Call the tangent point of the A-excircle to side $$BC$$ be $$D$$. Connect $$AD$$. Do so similarly for the other two sides. The intersection of these three segments is the Nagel point.

Note by Alan Yan
1 year, 1 month ago

Sort by:

The question is easy. Firstly it is obvious that if triangle is equilateral then then the Nagel point and the incentre coincide. So we only need to prove the other side that if the Nagel point and the incentre coincide then the triangle is equilateral.

So my proof is as follows. Firstly denote the point where AB and AC touch the excircle as P and Q respectively. Observe that AP=AQ. Also observe that BD=BP,CD=CQ. Hence we obtain that AB+BD=AC+CD. Also by angle bisector theorem we have AB/BD=AC/CD. Solving we obtain that BD=DC. Substituting we get AB=AC. Same applies for some other excircle and so AB=AC=BC. Hence proved :) · 10 months, 4 weeks ago

Here is another solution:

In barycentric coordinates, the Nagel point is $$(s-a : s-b: s-c)$$ and the incenter is $$(a:b:c)$$. Thus, they concur if and only if $\frac{s-a}{a} =\frac{s-b}{b} = \frac{s-c}{c} \implies a = b = c$ · 10 months, 4 weeks ago

Hmm ..but i don't know actually what barycentric coordinates are . But i would like if u would post some more geometry problems. · 10 months, 4 weeks ago

https://brilliant.org/discussions/thread/geometry-problem-2-2/ · 10 months, 4 weeks ago

Can you define what the Nagel point is? Staff · 1 year, 1 month ago


text:
# Ranking News Items With Upvotes

July 14, 2015

As a follow-up to Deriving the Reddit Formula, let’s consider a social news website that lets users upvote items, but that doesn’t permit them to downvote items. How can we infer the probability that a random user will upvote a story, given only the age of the story $$t$$ and the total number of upvotes $$U$$?

To calculate that probability, we also need to know the total number of users visiting the site, call it $$N$$. Of course, not all $$N$$ users have seen a given story, so we first need an expression for the fraction of users who have seen a given story.

Following the model we used for Reddit users, if you think of a user’s reload behavior as a Poisson process with reload rate $$\lambda$$, then the fraction of users who have seen a given story of age $$t$$ is given by the formula:

$q = 1 - e^{-\lambda t}$

(This is one minus the $$q$$ from the previous model, which asked which fraction of users had not seen a given story.)

So the total number of users who have seen a given story is given by:

$n(t) = Nq = N(1-e^{-\lambda t})$

Therefore the fraction of users who upvoted a story — and therefore the expected probability of liking a story[1] — is given by:

$p = \frac{U}{n(t)} = \frac{U}{N(1-e^{-\lambda t})}$

Assuming a user gets utility of +1 from a story that she would upvote, the expected utility from a story of age is just:

$u(t, U) = \frac{U}{N(1-e^{-\lambda t})}$

To form an expectation, we need to multiply this quantity by the probability that the story hasn’t been seen before:

$E[u(t, U)] = e^{-\lambda t}\frac{U}{N(1-e^{-\lambda t})}$

Now for a neat trick. Suppose we want to use the expected utility to rank news items. Because utility is relative, we can multiply or divide it by positive numbers without affecting the rankings. So let’s divide the above expression by the number of site users $$N$$, which is a constant:

$E[u] = e^{-\lambda t}\frac{U}{1-e^{-\lambda t}}$

That is, we can form a ranking using only $$U$$ and $$t$$ — it turns out there’s no need to know $$N$$, the total number of users on the site!

We can also take a logarithm to make the formula comparable to the Reddit version:

$\ln E[u] = \ln(U) -\lambda t - \ln{(1-e^{-\lambda t})}$

(To make the first logarithm work, you’ll need to give each story an automatic upvote to start life with — but then you’ll also want to set a minimum $$t$$ before ranking so that the second logarithm doesn’t blow up. The C functions expm1 and log1p might come in handy here.)

The difference between this formula (which uses only upvotes) and the formula derived for Reddit (which includes both upvotes and downvotes) boils down to how we want to model the probability of upvoting something. Previously, we used the total number of votes, but here, we use the total number of visitors, using only what we know about the reload rate. As a consequence, the formulas are identical except that $$\ln{(U+D+2)}$$ (the total number of votes, including two “automatic” votes) is replaced with $$\ln{(1-e^{-\lambda t})}$$ (the fraction of users who have seen an item).

### Example

To get a feel for the algorithm, let’s calculate the substitution rate between points and time required to maintain a constant ranking:

$\frac{dE[u]/dt}{dE[u]/U} = \frac{-\lambda U}{e^{\lambda t}-1} = \frac{-\Delta U}{\Delta t}$

Which can be rewritten in terms of a fractional change in $$U$$:

$\frac{\Delta U}{U} = \frac{\lambda \Delta t}{(e^{\lambda t} - 1)}$

Let’s plug in some numbers to see how it works. Consider a reload rate of once per 4 hours $$\lambda = 1/4$$ and a story that is 2 hours old. This formula reveals that a fractional change in $$U$$ is equal to:

$\frac{\Delta U}{U} = \frac{\frac{1}{4} \Delta t}{(e^{1/2} - 1)} = 0.385 \Delta t$

That is, to maintain its rank value in the next hour ($$\Delta t = 1$$), the story will need to accumulate 38.5% more upvotes. (Why is that figure less than 50%? In this model, later votes are more difficult to acquire than earlier votes. As time progresses, more and more users have already had the chance to vote on a given item, which means that later votes are in a sense more “valuable”.)

### Conclusion

If you run a social news site, consider ranking your stories using a formal model rather than a hand-me-down formula whose origins were lost in the mists of time. The present model isn’t all that sophisticated, but it should provide a good starting point as you hone and tweak your site to provide just the right mix of things that are new and things that are good.

You’re reading evanmiller.org, a random collection of math, tech, and musings. If you liked this you might also enjoy:

format: plain


text:
# The Restricted Saion Partitions

The "gpu", "powernv" and "kannel" partitions are restricted partitions meant for general GPU or high-core computation. The GPU partitions are often used for deep learning, and the kannel partition for highly parallel physics simulations. Apply for access here.

The Saion system is set up slightly differently from the main cluster. Please read the Saion introduction here for the best way to organise your computations.

## "gpu"

This partition has a total of 16 GPU nodes. Each GPU node has 36 CPU cores and 512GB main memory. 8 nodes have four Tesla P100 GPUs and 16GB memory each. A further 8 nodes each have four NVIDIA V100 GPUs with 16GB memory.

The "gpu" partition will gives you the next free node, irrespective of the GPU type. If you want you can specify the GPU type (see below), but in practice most jobs won't see any significant difference.

The GPU-GPU interconnect on the nodes is very high bandwith, as is the interconnect between GPU nodes for multi-node GPU jobs. But the CPU-GPU connection is relatively slower, so you should try to do as many calculations on the GPU as possible for each piece of data that you transfer to the GPU.

Your allocation on these partitions is 36 CPU cores and 4 GPUs in total. Your longest job run time is 7 days.

You should build your application on a GPU compute node. The login nodes use a different CPU model and have no GPU-related libraries, so you can't build your application there.

We have CUDA 11.1, 11.3 and CuDNN 8; CUDA 10.1, 10.0 and 8; and CuDNN 6 and nccl2 are available as modules. Please use these. We may install more modules if there are user requests for them, but we think many users will want to build their own applications.

To build an application you need to log in to a GPU node. The login nodes do not have the CUDA and other libraries that you typically need. To start an interactive job, try this:

$srun -t 0-4 -c 8 -p gpu --mem=32G --gres=gpu:1 --pty bash -l This gives you 32G memory, 8 cores and one GPU for 4 hours. If you only intend to compile the code and not test it, you can of course refrain from asking for a GPU at all. That way you can still use a GPU node for building your code even if all GPUs are in use by somebody else. To specify a specific GPU, add the type to the gres request: $ ... --gres=gpu:V100:1 ...

But as noted above, most jobs won't see any notable difference. In fact, if you specify a single type of GPU you're limiting yourself to only those nodes with that GPU, and if those happen to be busy you will end up waiting far longer than you would have by just taking the first available GPU.

## powernv

The powernv partition is a 8-node IBM Power system. All nodes come with 512GB memory and 4 NVIDIA GPUs. All interconnects, both between GPU-GPU and CPU-GPU, are very fast, making this system especially useful for data-intensive GPU tasks.

Nodes CPU Cores GPU
2 2 × Power 9 160 4 × V100
2 2 × Power 8 128 4 × P100
4 2 × Power 8 160 4 × P100

You can use all cores and GPUs for up to 7 days. We do ask you to not allocate more resources than you actually need.

Also, you need to allocate cores in multiples of 8. The Power cores are grouped by 8 in the CPU, and need to be allocated as a unit.

### Building and Running your code

The Power CPUs are not Intel compatible. You need to rebuild your code on a Power node in order to run it on the Powernv system. As the nodes differ somewhat by hardware and software, we recommend that you use the saion-power03 node to build your code. That node is a lowest-common denominator, and code built there is likely to run well on all the nodes.

To build your code, run an interactive job on the power03 node:

$srun -p powernv --nodelist=saion-power03 --gres=gpu:1 -t 0-4 --mem=32G -c 16 --pty bash -l This gives you 32G memory, 16 cores and one GPU for 4 hours on the power03 node. This partition does not share code or modules with the other partitions on the Saion system. To make use of the system you always need to add the "-l" option to bash. '-l' stands for "login" and makes bash re-read and update all configuration when the jobs starts. With interactive jobs always start a "bash -l" shell on the node rather than starting your application directly. For batch jobs, make sure your first line reads: #!/bin/bash -l #SBATCH ..... .... ### IBM-supplied deep-learning software We have a full IBM-supplied suite of deep learning software installed on the powernv system. It is installed by way of an Anaconda Python installation. The "python/3.7.6" module contains a number of deep-learning related software that have been rebuilt and optimised for the Power system. Load it with: $ module load python/3.7.6

Software and libraries include Pytorch, Tensorflow, Caffe and Caffe2, and OpenCV, Keras, Pandas, Numba and many other support libraries.

The "pytorch/1.5" module is a partial installation of the PowerAI distribution, with a separately installed and updated version of Pytorch and related software.

### Other Software

The "openmpi.gcc/4.0.3" module contains an OpenMPI installation built for the Power nodes. However, as the system version and hardware differs between nodes, this MPI version is by default set to only use the ethernet interface. This may have an impact on the speed; however, these nodes are primarly meant for GPU computing so it's not a major issue.

If you want to use it, make sure to load this module last, after any other modules. The IBM PowerAI modules (python and pytorch) contain libraries that will interfere with MPI if they are loaded after this one.

For other software, you will need to build and install it yourself on these nodes. This can sometimes be very non-trivial; if you are looking to get started quickly we suggest you use the "gpu" partition instead. We are happy to give you advice and help if you get stuck, so don't hesitate to contact us if you want.

## "kannel"

The kannel partition has 16 KNL nodes. The kannel nodes are each equipped with an Intel Xeon Phi 7230 with 64 cores, four threads per core and 128G memory.The operating system on the kannel nodes is CentOS 7.3, the same we use on Sango but different from the login nodes. The KNL is fully x86-64 compatible, so you should be able to build and run most code unchanged on these systems.

Each KNL core is slower than a normal Intel CPU core, but there are more of them; they can run vectorized code efficiently; and they have a fast on-board interconnect to other KNL nodes. An application that scales well should be at least as fast on one KNL node (with a single KNL CPU) as it is on one Sango node (with two Xeons). An application optimized for KNL can be significantly faster.

The nodes also have a very fast network connected directly between the KNL CPUs themselves, so multi-node applications will be faster than across Sango nodes.

We have some software packages installed through the module system, and we welcome requests for more software that you may want to use on kannel.

The KNL nodes are X86-64 compatible, which means that most general Linux code built for Intel CPUs will run on them unchanged. But that will not take full advantage of the features of the KNL system. For that you do need to rebuild your code specifically for the KNL, and you ideally use the Intel compiler on a kannel node for best results.

To build an application you would do these steps:

$srun -p knl -t 0-8 --pty bash$ module load intel/2017_update1
• Then build your application using icc. We suggest you use these options when building for KNL:
C:       -O3 -xMIC-AVX512 -fma -align -finline-functions
C++:     -std=c11 -O3 -xMIC-AVX512 -fma -align -finline-functions
Fortran: -O3 -xMIC-AVX512 -fma -align array64byte -finline-functions

If you use GCC, try these options for a start:

gcc:      -march=knl -O3 -mavx512f -mavx512pf -mavx512er -mavx512cd -mfma -malign-data=cacheline -finline-functions
g++:      -std=c11 -march=knl -O3 -mavx512f -mavx512pf -mavx512er -mavx512cd -mfma -malign-data=cacheline -finline-functions
gfortran: -O3 -march=knl -mavx512f -mavx512pf -mavx512er -mavx512cd -mfma -malign-data=cacheline -finline-functions

Keep in mind that the GCC installed on kannel is quite old and will not generate the best code for the KNL nodes.

The AVX 512-related options generate code to take advantage of the 512 bit vector processing instructions on KNL when applicable. Good use of vectorization is essential for performance on KNL, so if you are developing your own code it may be well worth your time to make sure your code is really being vectorized.

## "amd" and "prio-gpu"

This is 4 nodes with dual X86 AMD CPUs, each with 64 full cores and 512GB memory; and one GPU node with 512GB memory and 4 NVIDIA P100 GPUs with 16GB each.

These systems are reserved for high-throughput data processing applications such as Relion (used for post-processing of cryo-microscopy data). If you think you may have a need for this, contact us and we can discuss it further.

Previous Section: The open Saion partitions.


text:
How to Add and Subtract Polynomials

Step By Step

Whether you want to add polynomials or subtract them, you follow a similar set of steps.

General Steps

Step 1

Arrange the Polynomial in standard form.

Standard form of a polynomial just means that the term with highest degree is first and each of the following terms.

Step 2

Arrange the like terms in columns and add the like terms.

Example 1

Let's find the sum of the following two polynomials.

$$(3y^5 - 2y + y^4 + 2y^3 + 5)$$ and $$(2y^5 + 3y^3 + 2 + 7)$$

Subtracting Polynomials

Example 2

Let's find the difference of the same two polynomials.

$$(3y^5 - 2y + y^4 + 2y^3 + 5)$$ and $$(2y^5 + 3y^3 + 2 + 7)$$

Practice Problems

Problem 1

This problem is like example 1.

First, remember to rewrite each polynomial in standard form, line up the columns and add the like terms.

Problem 2

This problem is like example 1.

First, remember to rewrite each polynomial in standard form, line up the columns and add the like terms.

Problem 3

This problem is like example 2 since we are subtracting.

First, remember to rewrite each polynomial in standard form, line up the columns and add the like terms.

(Be careful with $$-11x^3$$ term; it is already negative, so subtracting a negative leads to a positive $$11x^3$$)
Problem 4

Although this problem involves addition, there are no like terms. If you line up the polynomials in columns, you will see that no terms are in the same columns.


text:
# Big M method for continuous variables and cvx precision

Let p_{i,j} \in \mathbb{R}_{\geq 0}, for i=1,\dots, n, j=1, \dots, m. As one of the constraints of my problem, I am looking for h such that

g_i(h) := \sum_{j=1}^h p_{i,j} < 1.

To find h, I defined a_{i,j} \in \{0,1\} such that

a_{i,h} = \begin{cases} 1 \qquad \text{if } g_i(h) < 1 \quad h=1, \dots, m, \\ 0 \qquad \text{otherwise}. \end{cases}

To implement the if condition above, I used the big-M method as

\begin{align} g_i(h)& \geq 1 - M a_{i,h} \\ 1&> g_i(h) - M(1-a_{i,h} ) . \end{align}

The problem is that the big-M method works well for ILPs while the variable, here the $p$s, are non-integer. When g_i(h) is very close to 1, I do not get the correct value for h.
I tried it out with different precision levels of CVX but it did not help either.

I was wondering if there is a trick for this in CVX.

I’m not sure whether you are trying to model a strict linear inequality constraint, or a conditional (logical) constraint. Either way, you will have to address the matter of solver feasibility tolerance.

CVX treats and sends to the solver all < constraints as <=. In order to get strict inequality, you will need to introduce a small positive number, small_number. Then use the constraint
sum(p(i,:),2) + small_number <= 1 .

In order to allow small_number to be as small as possible, while still dealing with solver tolerance, you will need to adjust the solver feasibility tolerance (applicable to linear (inequality) constraints) from its default value. Do this using cvx_solver_settings( '{name}', {value} ) . See http://cvxr.com/cvx/doc/solver.html#advanced-solver-settings . You will need to examine the solver documentation to determine the parameter name to adjust.

I believe that cvx_precision controls solver termination criteria, but not solver feasibility tolerance, which I believe is is what you need to adjust.

1 Like

Great! It worked out. I am using Gurobi, so I set a small value for ‘FeasibilityTol’.
Many thanks Mark.


text:
# Set color of title-background

I'm trying to give the title (and the title only (with some margin), not the entire page) in the first page of my presentation background color "greyone". This background-box should be page-wide while text is centered. I haven't been able to figure out how to..

I've defined a new beamer template in my preamble by

\documentclass['serif]{beamer}
\usecolortheme{eelke}
% INFORMATION
\title{Presentation Title}
\author{A. Uthor}
% FRONTPAGE
\defbeamertemplate*{title page}{eelke}[1]
{
\centering
\usebeamerfont{title}\inserttitle\par % this should have a background box in color grayone. Text should be white for readability.
\vskip20pt
\usebeamercolor[bg]{titlelike}
\setbeamerfont{author}{size=\fontsize{11}{15}}
\usebeamerfont{author}\insertauthor\par %
\vskip20pt
\setbeamerfont{date}{size=\fontsize{11}{15}}
\usebeamerfont{date}\insertdate\par} \begin{document}\begin{frame}\maketitle\end{frame}\end{document}

Further I have defined a new color in beamercolorthemeeelke.sty file

\definecolor{greyone}{RGB}{77,77,77}
\setbeamercolor{palette quaternary}{fg=white,bg=greyone, wd=\paperwidth}
\setbeamercolor{titlelike}{parent=palette quaternary}

which is called for in the preamble: \usecolortheme{eelke}

Can anyone help me out?

• Please make your code compilable, starting with \documentclass{...} and ending with \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to help you. Help them help you: remove that one hurdle between you and a solution to your problem. – jubobs Nov 19 '13 at 10:39
• I've changed it to a compilable code. – Halbertsma Nov 19 '13 at 11:36

You can use a beamercolorbox but with beamerleftmargin and beamerrightmargin previously added to textwidth.

\documentclass['serif]{beamer}
%\usecolortheme{eelke}

\definecolor{greyone}{RGB}{77,77,77}
\setbeamercolor{palette quaternary}{fg=white,bg=greyone}
\setbeamercolor{titlelike}{parent=palette quaternary}

% INFORMATION
\title{Presentation Title}
\author{A. Uthor}
% FRONTPAGE
\makeatletter
\defbeamertemplate*{title page}{eelke}[1]
{
\@tempdima=\textwidth%
\begin{beamercolorbox}[sep=1em,wd=\the\@tempdima]{titlelike}
\centering
\usebeamerfont{title}\inserttitle\par % this should have a background box in color grayone. Text should be white for readability.
\end{beamercolorbox}
\vskip20pt
\usebeamercolor[bg]{titlelike}
\setbeamerfont{author}{size=\fontsize{11}{15}}
\usebeamerfont{author}\insertauthor\par %
\vskip20pt
\setbeamerfont{date}{size=\fontsize{11}{15}}
\usebeamerfont{date}\insertdate\par}
\makeatother

\begin{document}
\begin{frame}
\maketitle
\end{frame}
\end{document}
`


text:
# Xelatex Calibri without serif math

I have to write a document in Calibri. Please find my minimal example thereafter. The issue is when I include some math, the design looks "ugly".

Is there a way to change the serif math font and number to some SANS-SERIF which looks close to Calibri?

  \documentclass[11pt]{article}
\usepackage{fontspec}
\usepackage{xltxtra}
\usepackage{lipsum}
\setmainfont[Mapping=tex-text]{Calibri}
\begin{document}

\begin{table}
\begin{center}
\begin{tabular}{l c }
\hline
& Model 1 \\
\hline
(Intercept) & $10.9983^{***}$ \\
& $(0.0420)$      \\
a  & $0.0040^{**}$   \\
& $(0.0016)$      \\
b         & $0.0053^{***}$  \\
& $(0.0012)$      \\
c & $0.0052^{***}$  \\
& $(0.0001)$      \\
\hline
R$^2$       & 0.9317          \\
Adj. R$^2$  & 0.9309          \\
Num. obs.   & 243             \\
\hline
\multicolumn{2}{l}{\scriptsize{\textsuperscript{***}$p<0.01$,
\textsuperscript{**}$p<0.05$,
\textsuperscript{*}$p<0.1$}}
\end{tabular}
\caption{Statistical models}
\label{table:coefficients}
\end{center}
\end{table}

lum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris. Nam
arcu libero, nonummy eget, consectetuer id, vulputate a, magna. Donec vehicula
augueeuneque.

$\bar{x} = \frac{x_1+x_2+\cdots +x_n}{n}$

\end{document}

-
There is no Unicode math sans serif font, at the moment. –  egreg Dec 21 '13 at 14:42
this won't help with the "real" math, but it shouldn't be necessary to use math coding for the numbers in the table. for entries like (0.0016) try just removing the  signs. since that column appears to be centered, those entries should align. and for an entry like 0.0053^{***}, try first removing the  signs, and then code the *** as \rlap{***}. i don't use calibri, but most text fonts have the * located in a "super" position, and the \rlap{...} will hide their width, again making the entry the same length as the others. –  barbara beeton Dec 21 '13 at 15:00
@barbarabeeton Hello yeah I was considering doing that. Is working well but as I use texreg package on R I get automatically the $...$ style. So I will see if someone has a better solution. If not I will manually make the changes and consider your solution which is finally working but takes just a bit more time... Thanks –  Swiss12000 Dec 21 '13 at 15:38

use unicode-math:

\documentclass[11pt]{article}
\usepackage{unicode-math}
\usepackage{lipsum}
\setmainfont[Mapping=tex-text]{Calibri}
\setmathfont{XITS Math}% for the symbols
\setmathfont[range=\mathup]{Calibri}
\setmathfont[range=\mathit]{Calibri-Italic}
\begin{document}

\begin{table}
\centering
\begin{tabular}{l c }
\hline
& Model 1 \\
\hline
(Intercept) & $10.9983^{***}$ \\
& $(0.0420)$      \\
a  & $0.0040^{**}$   \\
& $(0.0016)$      \\
b         & $0.0053^{***}$  \\
& $(0.0012)$      \\
c & $0.0052^{***}$  \\
& $(0.0001)$      \\
\hline
R$^2$       & 0.9317          \\
Adj. R$^2$  & 0.9309          \\
Num. obs.   & 243             \\
\hline
\multicolumn{2}{l}{\scriptsize{\textsuperscript{***}$p<0.01$,
\textsuperscript{**}$p<0.05$,
\textsuperscript{*}$p<0.1$}}
\end{tabular}
\caption{Statistical models}\label{table:coefficients}
\end{table}

lum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris. Nam
arcu libero, nonummy eget, consectetuer id, vulputate a, magna. Donec vehicula
augueeuneque.

$\bar{x} = \frac{x_1+x_2+\cdots +x_n}{n}$

\end{document}

-
Hello, I get an error it says "font-not-found" The font XITS Math cannot be found. I use miktex on win 7 –  Swiss12000 Dec 21 '13 at 16:28
Then use \setmathfont{latinmodern-math.otf}. However, you should be able to load XITS Math with MikTeX's package manager. You can also comment this line out, then the default math symbols are used. –  Herbert Dec 21 '13 at 16:59
Oh you right is working fine through the package admin. Thanks. Is working on my side –  Swiss12000 Dec 21 '13 at 17:14

There is no Unicode sans serif math font available. If your document uses math only marginally, then mathspec can help.

I use TeX Gyre Heros, because I don't have Calibri.

\documentclass[11pt]{article}

\usepackage{mathspec}

\usepackage{lipsum}

\setmainfont[Ligatures=TeX]{TeX Gyre Heros}
\setmathsfont(Digits,Latin,Greek){TeX Gyre Heros}

\begin{document}

\begin{table}
\centering

\begin{tabular}{l c }
\hline
& Model 1 \\
\hline
(Intercept) & $10.9983^{***}$ \\
& $(0.0420)$      \\
a  & $0.0040^{**}$   \\
& $(0.0016)$      \\
b         & $0.0053^{***}$  \\
& $(0.0012)$      \\
c & $0.0052^{***}$  \\
& $(0.0001)$      \\
\hline
R$^2$       & $0.9317$          \\
Adj. R$^2$  & $0.9309$          \\
Num. obs.   & $243$             \\
\hline
\multicolumn{2}{l}{\scriptsize{\textsuperscript{***}$p<0.01$,
\textsuperscript{**}$p<0.05$,
\textsuperscript{*}$p<0.1$}}
\end{tabular}
\caption{Statistical models}
\label{table:coefficients}

\end{table}

\lipsum*[2]
$\bar{x} = \frac{x_1+x_2+\cdots +x_n}{n}$

\end{document}

Note some changes to your document: don't load xltxtra; don't use center inside table; Never leave a blank line before a displayed equation.

Possibly a better way to typeset your table is by using siunitx and booktabs:

\documentclass[11pt]{article}

\usepackage{mathspec}
\usepackage{siunitx}
\usepackage{booktabs}

\usepackage{lipsum}

\setmainfont[Ligatures=TeX]{TeX Gyre Heros}
\setmathsfont(Digits,Latin,Greek){TeX Gyre Heros}

\begin{document}

\begin{table}
\newcommand\tnote[1]{${}^{#1}$}
\centering

\begin{tabular}{
l
S[table-format=2.4,
table-space-text-post=\tnote{***},
]
}
\toprule
& {Model 1} \\
\midrule
(Intercept) & 10.9983\tnote{***}      \\
& {\footnotesize(0.0420)} \\
a           & 0.0040\tnote{**}        \\
& {\footnotesize(0.0016)} \\
b           & 0.0053\tnote{***}       \\
& {\footnotesize(0.0012)} \\
c           & 0.0052\tnote{***}       \\
& {\footnotesize(0.0001)} \\
\midrule
R$^2$       & 0.9317             \\
Adj. R$^2$  & 0.9309             \\
Num. obs.   & {243}              \\
\bottomrule
\multicolumn{2}{l}{\scriptsize{\textsuperscript{***}$p<0.01$,
\textsuperscript{**}$p<0.05$,
\textsuperscript{*}$p<0.1$}}
\end{tabular}
\caption{Statistical models}
\label{table:coefficients}

\end{table}

\lipsum*[2]
$\bar{x} = \frac{x_1+x_2+\cdots +x_n}{n}$

\end{document}

-
nice, but why even bother with coding the numbers in the column as math? they'd look much nicer with the decimal points aligned, and that doesn't need math coding. –  barbara beeton Dec 21 '13 at 15:02
@barbarabeeton Probably you're right. Maybe the table was just by way of example. –  egreg Dec 21 '13 at 15:04


text:
When does an injective group homomorphism have an inverse?

Given two groups $$A$$ and $$B$$ and an injective homomorphism $$f : A \to B$$. When does a homomorphism $$g : B \to A$$ exist with $$g\circ f = \mathrm{id}_A$$ (but not necessarily $$f\circ g = \mathrm{id}_B$$)?

• You may assume that $f$ is the inclusion of a subgroup $A \subseteq B$. I don't think that there is a general simple criterion. If $B$ is abelian, you have the splitting lemma which says that $A \subseteq B$ has a retract if and only if $B \to B/A$ has a section if and only if $A$ is a direct summand of $B$. – Martin Brandenburg Jun 28 '10 at 10:49
• BB in his answer below mentions semidirect products, you talk about direct sums. Who of you is right (or both)? – Hans-Peter Stricker Jun 28 '10 at 10:57
• I only adressed the case that $B$ is abelian. – Martin Brandenburg Jun 28 '10 at 11:05
• @Martin: I see. – Hans-Peter Stricker Jun 28 '10 at 11:07

If and only if $B$ is a semidirect product of $A$ and another group (the latter is normal). One direction is obvious, and another direction is easy: $B$ is a semidirect product of the image of $f$ and the kernel of $g$.
If you look at this problem from the side of $$B$$, i. e. how do we find endomorphic retracts of a given group, then there's also somewhat definite answer.
Define equation over group $$G$$ with coefficients in $$H \le G$$ as a collection of elements $$w_i \in H * \mathrm{Free}(x_1, x_2, \dots)$$. Solution of an equation is a homomorphism $$\phi: H * \mathrm{Free}(x_1, x_2, \dots) \to G$$ identical on $$H$$ and such that $$\phi(w_i) = 1$$.
Let's call $$H \le G$$ algebraically closed (should be not confused with algebraic closure of a group, nor by Levine nor Farjoun) if every system of equations $$w_i(X_1, \dots, X_l) = 1$$ with coefficients in $$H$$ have solution in $$G$$ if and anly if it has solution in $$H$$ already.


text:
# How I can change the name of multiple files at once in R or terminal?

I have 200 .vcf files in a folder with long names like

LP6005409-DNA_E03_vs_LP6005408-DNA_E03.snp.pass.vcf

How can I change the name of each file to, for example A1.vcf ....A200.vcf?

Renaming these files manually takes ages, help please.

> file.rename(list.files(pattern = "vcf"), paste0("A",1:length(list.files(pattern = ".vcf")),".vcf"))
Error in file.rename(list.files(pattern = "vcf"), paste0("A", 1:length(list.files(pattern = ".vcf")),  :
'from' and 'to' are of different lengths

[fi1d18@cyan01 new]$$for i in *.vcf; do echo mv$$i A$${k}.vcf ; k=echo "1+$${k}" | bc; done
mv LP2000325-DNA_A01_vs_LP2000317-DNA_A01.snp.pass.vcf A.vcf
(standard_in) 2: syntax error
mv LP6008031-DNA_A04_vs_LP6008032-DNA_D03.snp.pass.vcf A.vcf
(standard_in) 2: syntax error
[fi1d18@cyan01 new]$for i in *.vcf; do mv$i A${k}.vcf ; k=echo "1+${k}" | bc; done
(standard_in) 2: syntax error
mv: try to overwrite A.vcf', overriding mode 0500 (r-x------)?

just to complete your question, you can do it in R in one line.

After setting the directory as your working directory, just type the following:

file.rename(list.files(pattern = "vcf"), paste0("A",1:length(list.files(pattern = ".vcf")),".vcf"))

Maybe you can try file.rename(list.files(pattern = ".vcf"), paste0("A",1:length(list.files(pattern = ".vcf")),".vcf")). Also, if there is still an error, can you post the output of list.files(pattern = ".vcf") just to see the structure of your files in folder (maybe one file has a weird name not detected by the pattern).

Use perl-rename. This is usually called rename on Debian-based systems like Ubuntu or Mint, and perl-rename or prename on others. Assuming you have it as rename, you can simply do:

rename -n 's/.*\.vcf/"A" . ++$c . ".vcf"/e' *snp.pass.vcf  The -n causes rename to only print what it would do, without doing anything. So once you make sure it does what you want, run the command again without the -n. • On a Mac, you may need to install it first. Use brew install rename or use zmv in zsh (not bash) shell: superuser.com/q/152627 Nov 11 '19 at 18:37 • @TimurShtatland note that there are many renames in the Linux world, just to keep things interesting ;) Nov 11 '19 at 18:42 EDIT: (Based on the comments by @terdon, with minor changes) Try this Perl one-liner. It is recommended for general use, even if your file names contain "unexpected" characters such as newlines. perl -e 'for ( 0..$$#ARGV ) { rename ARGV[_] => "A@{[$$_ + 1 ]}.vcf"; } ' *pass.vcf  Here, -e tells perl to look for code on the command line instead of a file with the script. @ARGV is the array of the command line arguments, here, files with old names. for ( 0..$#ARGV ) { ... } loop goes through the indexes of elements of this array, assigning each implicitly to $_. The first argument to rename is the old file name: $ARGV[$_]. Instead of the comma separator of the method arguments I use => synonym for clarity in this method call. The new file name is the second argument. @{[ ... ]} inside the double quotes is the Perl idiom to evaluate the expression inside, which is $_ + 1, to make the file numbering start with 1. If you don't care about this, it is easier to make it start with 0: just use "A$_.vcf", or, better, "A${_}.vcf". The last form needs to be used for cases like this: "A${_}pass.vcf" to prevent Perl from treating $_pass as a variable, where $_ is intended. DEPRECATED: Use the one-liner below when you are sure that the old file names do not have "unexpected" characters such as newlines. It is not for general use, see: Why you shouldn't parse the output of ls. It will work with the example shown by the OP. It also works with blanks and tabs in the file names, but it breaks when file names have newlines. The (deprecated) Perl one-liner: ls *.pass.vcf | perl -lne 'rename $$_, "A$$..vcf";'  Here, ls | lists all files with old names, one per line and passes the stdout into stdin of the next command, which is the Perl one line script. -l removes the new lines from the input. -n reads the input one line at a time. These are all commonly used command line Perl options. In the one liner script, $_ is the line read from stdin, and $. is the line number. • That is a slick perl one liner – M__ Nov 11 '19 at 2:11 If your filenames do not contain blank spaces, you can do it with a for-loop in bash: Make a test run with echo so that the command is only printed but not yet executed: for i in *.vcf; do echo mv $$i A$${k}.vcf ; let k++ ; done  And if the result looks good remove the echo statement to execute the mv commands: for i in *.vcf; do mv $$i A$${k}.vcf ; let k++ ; done  • Sorry I tried your code and I got error mentioned in the main post Nov 12 '19 at 10:32 • @Angel note that there is no reason to use bc even if you do choose to do it this way. ((k++)) or k=$((k+1)) or let k++ all work to increment the value of a shell variable: k=0; while [[ $k -lt 10 ]]; do echo$k; ((k++)); done. Alternatively: for((k=0; k<=10;k++)); do echo \$k; done`. Nov 14 '19 at 13:27
• Thanks for the comment! Nov 15 '19 at 20:44


text:
# module 'statsmodels formula api has no attribute 'ols

import statsmodels Simple Example with StatsModels. We can either use statsmodel.formula.api or statsmodel.api to build a linear regression model. subset (array-like) – An array-like object of booleans, integers, or index values that indicate the subset of df to use in the model.Assumes df is a pandas.DataFrame; drop_cols (array-like) – Columns to drop from the design matrix. Is there any solution beside TLS for data-in-transit protection? $\begingroup$ It is the exact opposite actually - statsmodels does not include the intercept by default. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. I'm trying to run an ARMA model using statsmodels.tsa.ARIMA.ARMA, but I get AttributeError: module 'pandas' has no attribute 'WidePanel'. By using our site, you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our Terms of Service. Nominal Response Marginal Regression Model using GEE. 4.4.1.1.10. statsmodels.formula.api.OLS¶ class statsmodels.formula.api.OLS (endog, exog=None, missing='none', hasconst=None, **kwargs) [source] ¶. missing str Find the farthest point in hypercube to an exterior point. See the SO threads Coefficients for Logistic Regression scikit-learn vs statsmodels and scikit-learn & statsmodels - which R-squared is correct?, as well as the answer … 7. Catatan penting : Jika Anda benar-benar awam tentang apa itu Python, silakan klik artikel saya ini. my time of original posting. Detrend an array with a trend of given order along axis 0 or 1. lagmat(x, maxlag[, trim, original, use_pandas]), lagmat2ds(x, maxlag0[, maxlagex, dropex, …]). Do all Noether theorems have a common mathematical structure? Statsmodels also provides a formulaic interface that will be familiar to users of R. Note that this requires the use of a different api to statsmodels, and the class is now called ols rather than OLS. rsquared. Estimation and inference for a survival function. Apa perbedaannya? MI performs multiple imputation using a provided imputer object. Python 3 version of the code can be obtained by running 2to3.py over the entire statsmodels source. glsar(formula, data[, subset, drop_cols]), mnlogit(formula, data[, subset, drop_cols]), logit(formula, data[, subset, drop_cols]), probit(formula, data[, subset, drop_cols]), poisson(formula, data[, subset, drop_cols]), negativebinomial(formula, data[, subset, …]), quantreg(formula, data[, subset, drop_cols]). This module contains a large number of probability distributions as well as a growing library of statistical functions. Dynamic factor model with EM algorithm; option for monthly/quarterly data. ordinal_gee(formula, groups, data[, subset, …]), nominal_gee(formula, groups, data[, subset, …]), gee(formula, groups, data[, subset, time, …]), glmgam(formula, data[, subset, drop_cols]). # import formula api as alias smf import statsmodels.formula.api as smf # formula: response ~ predictor + predictor est = smf. statsmodels.formula.api.ols. The idea is… Statsmodels is an extraordinarily helpful package in python for statistical modeling. Q-Q plot of the quantiles of x versus the quantiles/ppf of a distribution. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. It might be possible to add a non-formula API to specify which columns belong together. An alternative would be to downgrade scipy to version 1.2. But there is no harm in removing it by ourselves. Ecclesiastical Latin pronunciation of "excelsis": /e/ or /ɛ/? Canonically imported Fit VAR and then estimate structural components of A and B, defined: VECM(endog[, exog, exog_coint, dates, freq, …]). But, we don't have any case like that yet. The main statsmodels API is split into models: statsmodels.api: Cross-sectional models and methods. $\endgroup$ – desertnaut May 26 … #regression with formula import statsmodels.formula.api as smf #instantiation reg = smf.ols('conso ~ cylindree + puissance + poids', data = cars) #members of reg object print(dir(reg)) reg is an instance of the class ols. Seasonal decomposition using moving averages. e predict() function of the statsmodels.formula.api OLS implementation. See the documentation for the parent model for details. NominalGEE(endog, exog, groups[, time, …]). This is essentially an incompatibility in statsmodels with the version of scipy that it uses: statsmodels 0.9 is not compatible with scipy 1.3.0. ImportError: No module named statsmodels.api I looked and it is in the folder is in the directory. To subscribe to this RSS feed, copy and paste this URL into your RSS reader. Traceback (most recent call last): File "", line 1, in File "statsmodels/api.py", line 7, in from .regression.recursive_ls import RecursiveLS I think you need to use a dataframe or a dictionary with the correct name of the explanatory variable(s). sklearn.linear_model.LinearRegression¶ class sklearn.linear_model.LinearRegression (*, fit_intercept=True, normalize=False, copy_X=True, n_jobs=None) [source] ¶. You are importing the formula API but applying the linear model function. AttributeError: module 'statsmodels.formula.api' has no attribute 'OLS' 以上のようなエラーが出ました。 ドキュメント通りに進めたつもりでしたが、どこか不備があるのでしょうか。 Does the Construct Spirit from the Summon Construct spell cast at 4th level have 40 HP, or 55 HP? add_trend(x[, trend, prepend, has_constant]). Stumped. import statsmodels.api as sm File "C:\Python27\lib\site-packages\statsmodels\tools\tools.py", line 14, in from pandas import DataFrame ImportError: No module named pandas...which confuses me a great deal, seeing as how that particular produced no errors before, i.e. AttributeError: module 'statsmodels.tsa.api' has no attribute 'statespace' Appreciate the help. If not, why not? hessian (params) The Hessian matrix of the model: information (params) Sebelumnya kita sudah bersama-sama belajar tentang simple linear regression (SLR), kali ini kita belajar yang sedikit lebih advanced yaitu multiple linear regression (MLR). ... from_formula (formula, data[, subset]) Create a Model from a formula and dataframe. I’ll use a simple example about the stock market to demonstrate this concept. # AVOIDING THE DUMMY VARIABLE TRAP X = X[:, 1:] NOTE : if you have n dummy variables remove one dummy variable to avoid the dummy variable trap. It has been reported already. An intercept is not included by default and should be added by the user. using import statsmodels.api as sm. Is an arpeggio considered counterpoint or harmony? Residuals, normalized to have unit variance. Each univariate distribution is an instance of a subclass of rv_continuous (rv_discrete for discrete distributions): ... Test whether a dataset has normal kurtosis. Kwiatkowski-Phillips-Schmidt-Shin test for stationarity. statsmodels.regression.linear_model.OLS class statsmodels.regression.linear_model.OLS(endog, exog=None, missing='none', hasconst=None, **kwargs) ... scalar – Has an attribute weights = array(1.0) due to inheritance from WLS. MarkovAutoregression(endog, k_regimes, order), MarkovRegression(endog, k_regimes[, trend, …]), First-order k-regime Markov switching regression model, STLForecast(endog, model, *[, model_kwargs, …]), Model-based forecasting using STL to remove seasonality, ThetaModel(endog, *, period, deseasonalize, …), The Theta forecasting model of Assimakopoulos and Nikolopoulos (2000). Does your organization need a developer evangelist? That helped us to determine that the model we tried was no good. categorical (data[, col, dictnames, drop]): Returns a dummy matrix given an array of categorical variables. In statsmodels it supports the basic regression models like linear regression and logistic regression.. using formula strings and DataFrames. How to professionally oppose a potential hire that management asked for an opinion on based on prior work experience? # Plot a linear regression line through the points in the scatter plot, above. Future posts will cover related topics such as exploratory analysis, regression diagnostics, and advanced regression modeling, but I wanted to jump right in so readers could get their hands dirty with data. Class representing a Vector Error Correction Model (VECM). What does the phrase, a person with “a pair of khaki pants inside a Manila envelope” mean? array_like. using import statsmodels.tsa.api as tsa. The sm.OLS method takes two array-like objects a and b as input. properties and methods. See also. ols = statsmodels.formula.api.ols(model, data) anova = statsmodels.api.stats.anova_lm(ols, typ=2) I noticed that depending on the order in which factors are listed in model, variance (and consequently the F-score) is distributed differently along the factors. Podcast 291: Why developers are demanding more ethics in tech, “Question closed” notifications experiment results and graduation, MAINTENANCE WARNING: Possible downtime early morning Dec 2, 4, and 9 UTC…, Wrong output multiple linear regression statsmodels. OLS method. OLS method. The numerical core of statsmodels worked almost without changes, however there can be problems with data input and plotting. class method of models that support the formula API. AutoReg(endog, lags[, trend, seasonal, …]), ARIMA(endog[, exog, order, seasonal_order, …]), Autoregressive Integrated Moving Average (ARIMA) model, and extensions, Seasonal AutoRegressive Integrated Moving Average with eXogenous regressors model, arma_order_select_ic(y[, max_ar, max_ma, …]). 前提・実現したいこと重回帰分析を行いたいです。ここに質問の内容を詳しく書いてください。 発生している問題・エラーメッセージ下記のエラーが解消できず、困っています。AttributeError: module 'statsmodels.formula.api' has no attribute 'O my time of original posting. For a user having some familiarity with OLS regression and once the data is in a pandas DataFrame, powerful regression models can be constructed in just a few lines of code. Formulas are also available for specifying linear hypothesis tests using the t_test and f_test methods after model fitting. It only takes a minute to sign up. You need to understand which one you want. UnobservedComponents(endog[, level, trend, …]), Univariate unobserved components time series model, seasonal_decompose(x[, model, filt, period, …]). Calling fit() throws AttributeError: 'module' object has no attribute 'ols'. Why can't I run this ARMA? However, linear regression is very simple and interpretative using the OLS module. The DynamicVAR class relies on Pandas' rolling OLS, which was removed in version 0.20. Did China's Chang'e 5 land before November 30th 2020? Statsmodels is a Python module that allows users to explore data, estimate statistical models, and perform statistical tests. Parameters endog array_like. How to import statsmodels module to use OLS class? Bayesian statistics in Python: This chapter does not cover tools for Bayesian statistics.Of particular interest for Bayesian modelling is PyMC, which implements a probabilistic programming language in Python. # To include a regression constant, one must use sm.add_constant() to add a column of '1s' # to the X matrix. exog array_like. # /usr/bin/python-tt import numpy as np import matplotlib.pyplot as plt import pandas as pd from statsmodels.formula.api import ols df = pd.read ... AttributeError: module 'pandas.stats' has no attribute 'ols'. Fit VAR(p) process and do lag order selection, Vector Autoregressive Moving Average with eXogenous regressors model, SVAR(endog, svar_type[, dates, freq, A, B, …]). import statsmodels.formula.api as smf. Calculate the crosscovariance between two series. We can list their members with the dir() command i.e. Filter a time series using the Baxter-King bandpass filter. Jika Anda awam tentang R, silakan klik artikel ini. pacf_ols(x[, nlags, efficient, adjusted]). I have the following ouput from a Pandas pooled OLS regression. Import Paths and Structure explains the design of the two API modules and how The following are 30 code examples for showing how to use statsmodels.api.OLS().These examples are extracted from open source projects. We do this by taking differences of the variable over time. MICEData(data[, perturbation_method, k_pmm, …]). See statsmodels.tools.add_constant. If you upgrade to the latest development version of statsmodels, the problem will disappear: For me, this fixed the problem. Statsmodels version: 0.8.0 Pandas version: 0.20.2. MathJax reference. Может ли эта ошибка быть из версии, которую я использую? Current function value: 802.354181 Iterations: 3 Function evaluations: 5 Gradient evaluations: 5 >>> res=c.fit([0.4],method="bfgs") Optimization terminated successfully. rsquared_adj. In a regression there is always an intercept that is usually listed before the exogenous variables, i.e.


text:
# nLab K-theory spectrum

### Context

#### Stable Homotopy theory

stable homotopy theory

# Contents

#### Higher algebra

higher algebra

universal algebra

# Contents

## Idea

The K-theory spectrum $KU$ (for complex K-theory) or $KO$ (for orthogonal K-theory) in the strict sense is the spectrum that represents the generalized (Eilenberg-Steenrod) cohomology theory topological K-theory. For complex topological K-theory this is periodic with period 2 (reflect Bott periodicity) of the form

$\mathbb{Z} \times B U ,\; U ,\; \cdots \,.$

More generally, to every stable (infinity,1)-category $C$ is associated a K-theory space which in good cases, such as when the category is presented by a Waldhausen category is the degree 0 piece of a corresponding algebraic K-theory spectrum. The detailed construction is known as the Waldhausen S-construction.

## Properties

### Periodicity

$KU$ is a 2-periodic ring spectrum. This is the original Bott periodicity.

### As a localization of an $\infty$-group $\infty$-ring

Snaith's theorem asserts that the K-theory spectrum for periodic complex K-theory is the ∞-group ∞-ring of the circle 2-group localized away from the Bott element $\beta$:

$KU \simeq \mathbb{S}[B U(1)][\beta^{-1}] \,.$

### Relation between $KU$, $KO$ and $KR$-

#### $KO$ as homotopy-fixed points of $KU$

Complex conjugation on complex vector bundles induces on the complex K-theory spectrum $KU$ an involutive automorphism. KR-theory is the corresponding $\mathbb{Z}_2$-equivariant cohomology theory.

In particular, the homotopy fixed point of KU under this automorphism is KO

$KO \simeq (KU)^{\mathbb{Z}/2}$

and this way where in complex K-theory one has KU-modules (∞-modules), so in KR-theory one has $KO$-modules.

#### Wood’s theorem

$KO \wedge \Sigma^{-2}\mathbb{CP}^2 \simeq KU$

a proof in terms of moduli stacks is given in Mathew 13, section 3

cohomology theories of string theory fields on orientifolds

string theoryB-field$B$-field moduliRR-field
bosonic stringline 2-bundleordinary cohomology $H\mathbb{Z}^3$
type II superstringsuper line 2-bundle$Pic(KU)//\mathbb{Z}_2$KR-theory $KR^\bullet$
type IIA superstringsuper line 2-bundle$B GL_1(KU)$KU-theory $KU^1$
type IIB superstringsuper line 2-bundle$B GL_1(KU)$KU-theory $KU^0$
type I superstringsuper line 2-bundle$Pic(KU)//\mathbb{Z}_2$KO-theory $KO$
type $\tilde I$ superstringsuper line 2-bundle$Pic(KU)//\mathbb{Z}_2$KSC-theory $KSC$

## References

Discussion of $KO$ in analogy to the construction of tmf is in

with a summary in

• Akhil Mathew, The homotopy groups of $TMF$ (pdf)

Revised on November 1, 2014 22:45:43 by Urs Schreiber (141.0.9.61)


text:
# Free Fall

#### notes

Free Fall:

Whenever objects fall towards the earth under this force alone, we say that the objects are in free fall. Is there any Whenever objects fall towards the earth under this force alone, we say that the objects are in free fall. Is there any But due to the earth’s attraction, there will be a change in the magnitude of the velocity. Any change in velocity involves acceleration. Whenever an object falls towards the earth, an acceleration is involved. This acceleration is due to the earth’s gravitational force. Therefore, this acceleration is called the acceleration due to the gravitational force of the earth (or acceleration due to gravity). It is denoted by g. The unit of g is the same as that of acceleration, that is, ms–2.

As

F = ma             (becausea = g)  ...(1)

F = mg                                         ...(2)

and  "F" = "G"("Mm")/"d"^2    (therefore Universal law of gravitation)            ...(3)

From (ii) and (iii)

therefore  "mg" = "G"("Mm")/"d"^2

therefore  "g" = "GM"/"d"^2

M = Mass of the earth.

d = Distance between the object and the earth.

G = Gravitational constant

If the object is placed on the earth then d = R (radius of the earth)

therefore  "g" = "GM"/"R"^2

Earth is not a sphere it is flattened at poles.

Hence R- Radius at pole and Re - Radius at equator   Re > Rp

"g" ∝ 1/"R"

therefore The value of 'g' is more at poles = (9.9 m/s2) and less at the equator = (9.8 m/s2)

If you would like to contribute notes or other learning material, please submit them using the button below.

### Shaalaa.com

Acceleration due to gravity [00:10:02]
S
0%


text:
# Prove n^3 less than or equal to 3^n for n=1,2,

1. Oct 14, 2009

### naele

1. The problem statement, all variables and given/known data
Prove that $$n^3 \leq 3^n$$ for $n=1,2,...$

2. Relevant equations
Binomial theorem

3. The attempt at a solution
Check for P(1)= $$1^3 \leq 3^1$$. So the base case holds, now assume P(k) is true and show that it implies P(k+1).

By assumption $$3\cdot k^3 \leq 3\cdot 3^n$$. And this is where I get stuck because obviously $$(k+1)^3 \nleq 3k^3$$

2. Oct 14, 2009

### Office_Shredder

Staff Emeritus
If that last part is obvious, you should be able to prove it. It'll be tough...

Consider instead expanding (k+1) and finding an upper bound for that based on k3

3. Oct 14, 2009

### naele

Well it's not "obvious" but plotting $$3k^3 - (k+1)^3$$ shows negative values for positive k. On the other hand, I'm not sure what you mean by finding an upper bound.

Expanding gives $$k^3+3k^2 +3k+1$$. Comparing that with $$k^3 + k^3 +k^3$$. I could try a term by term comparison of $$3\cdot 3^k=3^k + 3^k +3 ^k$$. The first terms of each side are ok because that's by assumption. But $$3k^2 > 3^k$$ so hmmm.

4. Oct 14, 2009

### Office_Shredder

Staff Emeritus
If you can find a natural number k that breaks the inequality, you're done. You've proven the hypothesis to be false.

By inductive hypothesis
$$3k^2<k^3<3^k$$ as long as $k \geq 3$

So your base case is in fact going to be a couple of values of k, but that's not a real problem

5. Oct 14, 2009

### HallsofIvy

Staff Emeritus
Do you realize that you are saying that the very statement you are trying to prove is "obviously" false? $3k^3= k^{k+1}$ so if $(k+1)^3\nleq 3k^3= 3^{k+1}$ then $n^2< n^3$ is not true for all n.


text:
New interface

# Rupture properties of the 2020 Mw 6.8 Calama (northern Chile) intraslab earthquake. Comparison with similar intraslab events in the region

Abstract : We study the 2020 ${{\rm{M}}_{\rm{W}}}$ 6.8 Calama earthquake sequence that occurred within the subducting oceanic Nazca plate. The mainshock is modeled via waveform inversion using a dynamic rupture model, while detection and location techniques are used to better characterize its aftershock sequence. We analyze the local seismotectonic and thermal context of the subducting Nazca plate to understand the trigger mechanism of this earthquake and how it compares with other significant earthquakes in the vicinity. The stress drop and the related dynamic rupture parameters of the Calama mainshock are similar to those of the nearby 2007 ${{\rm{M}}_{\rm{W}}}$ 6.8 Michilla and 2015 ${{\rm{M}}_{\rm{W}}}$ 6.7 Jujuy intraslab earthquakes, which occurred to the west (trenchwards) and to the east (under the back-arc) of the Calama earthquake, respectively. The sequences of these three events were located using a 3-D tomographic velocity model. While the Michilla earthquake sequence occurred within the oceanic crust at temperatures of ~250°C, the Calama sequence occurred within the upper lithospheric mantle at ~350°C and exhibited a smaller aftershock productivity than Michilla. Additionally, the 3-D tomographic model shows intermediate ${{\rm{V}}_{\rm{P}}}/{{\rm{V}}_{\rm{S}}}$ ratios (1.72-1.76) in the region of the Calama earthquake. This indicates a less hydrated environment that could be responsible for the smaller aftershock productivity of the Calama earthquake.
Keywords :
Document type :
Journal articles

https://hal-insu.archives-ouvertes.fr/insu-03861042
Contributor : Nathalie POTHIER Connect in order to contact the contributor
Submitted on : Saturday, November 19, 2022 - 9:14:54 AM
Last modification on : Monday, November 21, 2022 - 3:49:07 AM

### Citation

Carlos Herrera, Francisco Pastén-Araya, Leoncio Cabrera, Bertrand Potin, Efraín Rivera, et al.. Rupture properties of the 2020 Mw 6.8 Calama (northern Chile) intraslab earthquake. Comparison with similar intraslab events in the region. Geophysical Journal International, 2022, ⟨10.1093/gji/ggac434⟩. ⟨insu-03861042⟩

Record views


text:
# Underbrace and Subscripts

How do I place a underbrace in a subscript?

I_{2,(\underbrace{3,3,3,3,3}_5)}

does not typeset correctly (the 3's are not subscript sized)

-
Thanks - the answer below worked great! –  Bart Snapp Nov 16 '10 at 2:20

How about a quick and simple I_{2,(\underbrace{\scriptstyle3,3,3,3,3}_5)}?

-

Jan already gave a good answer. However, I'd say it's a real weakness of \underbrace that you have to do this manually. (One might even call it a bug.) Here's a surprisingly complicated redefinition of \underbrace that automatically inserts \scriptstyle if needed.

\documentclass{article}
\makeatletter
\let\saved@underbrace\underbrace
\renewcommand*\underbrace[1]{\@ifnextchar_{\ub@with{#1}}{\ub@without{#1}}}
\def\ub@with#1_#2{\mathpalette\underbrace@i{{#1}{_{#2}}}}
\newcommand*\ub@without[1]{\mathpalette\underbrace@i{{#1}{}}}
\newcommand*\underbrace@i[2]{\underbrace@ii#1#2}
\newcommand*\underbrace@ii[3]{\saved@underbrace{#1#2}#3}
\makeatother
\begin{document}
$I_{2,(\underbrace{3,3,3,3,3}_5)}$
\end{document}

One of the problems I had to overcome is very similar to this question of mine: The underscore must go inside the mathpalette (if present).

-
I'll add something like this to unicode-math when I tackle the other under/over brace issues. Thanks! –  Will Robertson Nov 16 '10 at 14:04
@will: luatex seems not to have a problem here, the digits are in script style already with no other modifications (it seems an issue confined to the plain tex definition of underbrace) –  Khaled Hosny Nov 16 '10 at 15:13
@Khaled yeah, I was more referring to the terrible brokenness of these in xetex. –  Will Robertson Nov 16 '10 at 15:18


text:
Article Contents
Article Contents

# Dual generalizations of the concept of cyclicity of codes

• In this paper we focus on two generalizations of the notion of cyclicity of codes: polycyclic codes and sequential codes. We establish a duality between these two generalizations and also show connections between them and other well-known generalizations of cyclicity such as the notions of negacyclicity and constacyclicity. In particular, it is shown that a code $C$ is sequential and polycyclic if and only if $C$ and its dual C are both sequential if and only if $C$ and its dual C are both polycyclic. Furthermore, any one of these equivalent statements characterizes the family of constacyclic codes.
Mathematics Subject Classification: Primary 94B15; Secondary 94B60, 94B05.

 Citation:


text:
# Contents

## 内容

• Stack                                 堆栈
• SortedList                          有序列表
• ArrayList                            动态数组
• Array                                 数组
• RandomAccessLists             随机存取列表
• Conclusion                              结论

## 介绍

When you hear the word persistence in programming, most often, you think of an application saving its data to some type of storage, such as a database, so that the data can be retrieved later when the application is run again. There is, however, another meaning for the word persistence when it is used to describe data structures, particularly those used in functional programming languages. In that context, a persistent data structure is a data structure capable of preserving the current version of itself when modified. In essence, a persistent data structure is immutable.

An example of a class that uses this type of persistence in the .NET Framework is the string class. Once a string object is created, it cannot be changed. Any operation that appears to change a string generates a new string instead. Thus, each version of a string object can be preserved. An advantage for a persistent class like the string class is that it basically gives you undo functionality built-in. As newer versions of a persistent object are created, older versions can be pushed onto a stack and popped off when you want to undo an operation. Another advantage is that because persistent data structures cannot change state, they are easier to reason about and are thread safe.

.NET Framework中的String类正好是使用了持久化能力的一个例子。一旦创建了一个String类型实例，它便不能被改变了，对于欲改变其值的任何操作都将被产生一个新的String对象，通过这样，每一个版本的String实例都将被驻留下来。这样的具有持久化特点的类型像String类型都内置了撤销（Undo）功能，当该对象的新一个版本产生的时候，旧版本将被压入栈中，如果需要执行撤销动作的时候，只需将旧版本从堆栈中取出。另外一个优点是由于可持久化数据类型不能更改其内部状态，很容易得知它是线程安全的。

There is an overhead that comes with persistent data structures, however. Each operation that changes a persistent data structure creates a new version of that data structure. This can involve a good deal of copying to create the new version. This cost can be mitigated to a large degree by reusing as much of the internal structure of the old version in creating a new one. I will explore this idea in making two common data structures persistent: the singly linked list and the binary tree, and describe a third data structure that combines the two. I will also describe several classes I have created that are persistent versions of some of the classes in the System.Collections namespace.

## 持久化的单向链表

The singly linked list is one of the most widely used data structures in programming. It consists of a series of nodes linked together one right after the other. Each node has a reference to the node that comes after it, and the last node in the list terminates with a null reference. To traverse a singly linked list, you begin at the head of the list and move from one node to the next until you have reached the node you are looking for or have reached the last node:

Let's insert a new item into the list. This list is not persistent, meaning that it can be changed in-place without generating a new version. After taking a look at the insertion operation on a non-persistent list, we'll look at the same operation on a persistent list.

Inserting a new item into a singly linked list involves creating a new node:

We will insert the new node at the fourth position in the list. First, we traverse the list until we've reached that position. Then the node that will precede the new node is unlinked from the next node...

...and relinked to the new node. The new node is, in turn, linked to the remaining nodes in the list:

Inserting a new item into a persistent singly linked list will not alter the existing list but create a new version with the item inserted into it. Instead of copying the entire list and then inserting the item into the copy, a better strategy is to reuse as much of the old list as possible. Since the nodes themselves are persistent, we don't have to worry about aliasing problems.

To insert a new node at the fourth position, we traverse the list as before only copying each node along the way. Each copied node is linked to the next copied node:

The last copied node is linked to the new node, and the new node is linked to the remaining nodes in the old list:

On an average, about N/2 nodes will be copied in the persistent version for insertions and deletions, where N equals the number of nodes in the list. This isn't terribly efficient but does give us some savings. One persistent data structure where this approach to singly linked list buys us a lot is the stack. Imagine the above data structure with insertions and deletions restricted to the head of the list. In this case, N nodes can be reused for pushing items onto a stack and N - 1 nodes can be reused for popping a stack.

## 持久化二叉树

A binary tree is a collection of nodes in which each node contains two links, one to its left child and another to its right child. Each child is itself a node, and either or both of the child nodes can be null, meaning that a node may have zero to two children. In the binary search tree version, each node usually stores a key/value pair. The tree is searched and ordered according to its keys. The key stored at a node is always greater than the keys stored in its left descendents and always less than the keys stored in its right descendents. This makes searching for any particular key very fast.

Here is an example of a binary search tree. The keys are listed as numbers; the values have been omitted but are assumed to exist. Notice how each key as you descend to the left is less than the key of its predecessor, and vice versa as you descend to the right:

Changing the value of a particular node in a non-persistent tree involves starting at the root of the tree and searching for a particular key associated with that value, and then changing the value once the node has been found. Changing a persistent tree, on the other hand, generates a new version of the tree. We will use the same strategy in implementing a persistent binary tree as we did for the persistent singly linked list, which is to reuse as much of the data structure as possible when making a new version.

Let's change the value stored in the node with the key 7. As the search for the key leads us down the tree, we copy each node along the way. If we descend to the left, we point the previously copied node's left child to the currently copied node. The previous node's right child continues to point to nodes in the older version. If we descend to the right, we do just the opposite.

This illustrates the "spine" of the search down the tree. The red nodes are the only nodes that need to be copied in making a new version of the tree:

You can see that the majority of the nodes do not need to be copied. Assuming the binary tree is balanced, the number of nodes that need to be copied any time a write operation is performed is at most O(Log N), where Log is base 2. This is much more efficient than the persistent singly linked list.

Insertions and deletions work the same way, only steps should be taken to keep the tree in balance, such as using an AVL tree. If a binary tree becomes degenerate, we run into the same efficiency problems as we did with the singly linked list.

## Random Access Lists

An interesting persistent data structure that combines the singly linked list with the binary tree is Chris Okasaki's random-access list. This data structure allows for random access of its items as well as adding and removing items from the beginning of the list. It is structured as a singly linked list of completely balanced binary trees. The advantage of this data structure is that it allows access, insertion, and removal of the head of the list in O(1) time as well as provides logarithmic performance in randomly accessing its items.

Here is a random-access list with 13 items:

When a node is added to the list, the first two root nodes (if they exist) are checked to see if they both have the same height. If so, the new node is made the parent of the first two nodes; the current head of the list is made the left child of the new node, and the second root node is made the right child. If the first two root nodes do not have the same height, the new node is simply placed at the beginning of the list and linked to the next tree in the list.

To remove the head of the list, the root node at the beginning of the list is removed, with its left child becoming the new head and its right child becoming the root of the second tree in the list. The new head of the list is right linked with the next root node in the list:

The algorithm for finding a node at a specific index is in two parts: in the first part, we find the tree in the list that contains the node we're looking for. In the second part, we descend into the tree to find the node itself. The following algorithm is used to find a node in the list at a specific index:

1. Let I be the index of the node we're looking for. Set T to the head of the list where T will be our reference to the root node of the current tree in the list we're examining.

1. If I is equal to 0, we've found the node we're looking for; terminate algorithm. Else if I is greater than or equal to the number of nodes in T, subtract the number of nodes in T from I and set T to the root of the next tree in the list and repeat step 2. Else if I is less than the number of nodes in T, go to step 3.

1. Set S to the number of nodes in T divided by 2 (the fractional part of the division is ignored. For example, if the number of nodes in the current subtree is 3, S will be 1).

1. If I is less than S, subtract 1 from I and set T to T's left child. Else subtract (S + 1) from I and set T to T's right child.

1. If I is equal to 0, we've found the node we're looking for; terminate algorithm. Else go to step 3.

This illustrates using the algorithm to find the 10th item in the list:

Keep in mind that all operations that change a random-access list do not change the existing list but rather generate a new version representing the change. As much of the old list is reused in creating a new version.

## 不可改变集合类型

Included with this article are a number of persistent collection classes I have created. These classes are in a namespace called ImmutableCollections. I have created persistent versions of some of the collection classes in the System.Collections namespace. I will describe each one and some of the challenges in making them persistent. There are several collection classes that are currently missing; I need to add a queue, for example. Hopefully, I will get to those in time. Also, even though I've taken steps to make these classes efficient, they cannot compete with the System.Collections classes in terms of speed, but they really aren't meant to. They are meant to provide the advantages of immutability while providing reasonable performance.

### 堆栈

This one was easy. Simply create a persistent singly linked list and limit insertions and deletions to the head of the list. Since this class is persistent, popping a stack returns a new version of the stack with the next item in the old stack as the new top. In the System.Collections.Stack version, popping the stack returns the top of the stack. The question for the persistent version was how to make the top of the stack available since it cannot be returned when the stack is popped. I chose to create a Top property that represents the top of the stack.

### 有序列表

The SortedList uses AVL tree algorithms to keep the tree in balance. I found it useful to create an IAvlNode interface. Two classes implement this interface, the AvlNode class and the NullAvlNode class. The NullAvlNode class implements the null object design pattern. This simplified many of the algorithms.

### 动态数组

This is the class that proved most challenging. Like the SortedList, it uses a persistent AVL tree as its data structure. However, unlike the SortedList, items are accessed by index (or by position) rather than by key. I have to admit that the algorithms for accessing and inserting items in a binary tree by index weren't intuitive to me, so I turned to Knuth. Specifically, I used Algorithms B and C in section 6.2.3 in volume 3 of The Art of Computer Programming.

I made an assumption about the ArrayList in order to improve performance. I assumed that the Add method is by far the most used method. However, adding items to the ArrayList one right after the other causes a lot of tree rotations to keep the tree in balance. To solve this, I created a template tree that is already completely balanced. Since this template tree is immutable, it can exist at the class level and be shared amongst all of the instances of the class.

When an instance of the ArrayList class is created, it takes a small subtree of the template tree. As items are added, the nodes in the template tree are replaced with new nodes. Since the tree is completely balanced, no rebalancing is necessary. If the subtree gets filled up, another subtree of equal height is taken from the template tree and joined to the existing tree. Insertions and deletions are handled normally with rebalancing performed if necessary. Again, the assumption is that adding items to the ArrayList occurs much more frequently than inserting or deleting items.

### 数组

The Array class uses the random access list structure to provide a persistent array with logarithmic performance. Unlike a random access list, it has a fixed size.

### 随机存取列表

This class does not have a parallel in the System.Collections namespace, but it was one of the first persistent classes I wrote, and I decided to include it here. It's a straightforward implementation of Chris Okasaki's random-access list described above. This data structure was designed to be used in functional languages where lists have three basic operations: Cons, Head, and Tail. Cons adds an item to the head of the list, Head is the first item in the list, and Tail represents all of the items in the list except for the Head.

## 结论

Persistent data structures help simplify programming by eliminating a whole class of bugs associated with side-effects and synchronization issues. They are not a cure-all but are a useful tool for helping a programmer deal with complexity. I have explored ways of making data structures persistent and have provided a small .NET library of persistent data structures. I hope you have enjoyed the article, and as always, I welcome feedback.

2008.11.13 更新：

posted @ 2008-11-12 16:11  ted  阅读(...)  评论(...编辑  收藏


text:
# nLab trefoil knot

The trefoil knot is a famous knot. One of the reasons is that in the list of knots, ordered by crossing number, it is the first ‘real’ knot one meets, being the simplest non-trivial knot. (The first knot listed is usually the ‘unknot’, i.e. the unknotted circle.) The trefoil has crossing number 3.

• $\langle x,y \mid x y x=y x y\rangle$, which is the braid group, Br 3;
• $\langle a,b | a^2= b^3\rangle$, in which the pair of numbers, $(2,3)$ is apparent. These reflect the fact that the trefoil is a $(2,3)$-torus knot. (Of course, it is also a (3,2)-torus knot.)


text:
## Monday, October 24, 2016

### Making Mountains Out of Molehills, I Mean Out of Noise

The base terrain in my map generator is created with low-frequency noise.  This gives a rolling landscape which looks natural (if a bit uninteresting):

To make the map more dramatic and (hopefully) more interesting, I'd like to add some more distinctive terrain features, such as mountains.

A common way to model mountains is to use higher-frequency (more "peaky") noise.  Overlaying several multiples of higher frequency noise (i.e., octaves)  produces something that looks like this:
I don't know how this compares to real mountains, but it looks pretty realistic to my eye.   The psuedo-code for this looks something like this:

// Combine 6 octaves of noise with a 50% fall off
height[x,y] = Noise.octave(x*4,y*4,6,0.5);

Note that I'm multiplying the (x,y) coordinates by 4 when passing them into the noise function.  This is a handy trick for starting your octaves at a higher frequency.  Each doubling of the coordinates effectively shifts the noise up one octave.  So in this case, I'm skipping the lowest two frequencies of noise.  The frequency is related to the scale of your coordinate system, so you'll have to experiment with the starting frequency, number of octaves, and fall off to find a combination that looks good to you.

Some people prefer mountains with sharper peaks.  This can be generated by replacing the vanilla noise function with "ridged multi-fractal" noise:
You can see this produces mountains with sharper peaks.

There isn't a lot of good description of ridged multifractal noise on the Internet, but it turns out to be a fairly simple concept.  Recall that Perlin noise produces numbers that from -1 to 1.  Noise is specifically designed to be smooth -- if you plot out the noise you'll find that there are no abrupt changes of values in any direction.  Since sharp peaks are an abrupt change of value (the mountain goes steeply upward on one side of the peak, and then steeply downward on the other side), it's difficult to get sharp peaks out of noise.  Musgrave [citation required] suggested applying the absolute() function to Perlin noise to get a noise that changes directions sharply at zero.  Since we want our peaks to be at 1 rather than zero, we have to also flip the noise over.  In pseudo-code that looks like this:

// Ridged noise
height[x,y] = 1 - Math.abs(Noise.noise(x*4,y*4));

(Note that I'm again applying the trick to get higher-frequency noise.)  Ridged multifractal noise is just doing this same thing with noise octaves.  I'm not sure whether Musgrave applied the absolute value transformation to the individual noise being summed into the octave, or to the entire octave.  I chose the latter, and I think it looks fine.  The pseudo-code looks like this:

// Combine 6 octaves of ridged noise with a 50% fall off
height[x,y] = 1 - Math.abs(Noise.octave(x*4,y*4,6,0.5));

Another way to create "peakier" mountains is to use the square root of the noise:
To my eye, these are very peaky; maybe too much so.  Martin O'Leary's original map generator made use of this approach.

Once you've decided on an approach that generates mountains you like, how do you add them to the map?  Making it the base terrain over the whole map is not a great idea:
As I suggested earlier, I really want an "interesting" map that isn't dominated by any one characteristic but presents a mix of terrains.  Ideally,
1. Mountains should cover a reasonable percentage of the map.
2. Mountains should merge realistically into the neighboring terrains.
3. The distribution of the mountains should be a reasonable pattern.
The first criteria is fairly simple to achieve:  Select what percentage of the map should be mountains and generate that many mountains.  The second criteria is also not difficult:  The edges of mountain areas should get progressively lower until they match the surrounding terrain.  We can do this by multiplying the mountain height by a steadily diminishing value (a gradient mask).  The third criteria is a little more difficult.

For example, we can't simply throw mountains randomly on the map until we've met our percentage of mountain terrain.  The mountains will be scattered around the map and make no sense.

We can use noise to get a more natural clumping of the mountains.  The basic idea is to use the noise as a mask.  Generate noise from 0 to 1 at every location on the map.  Find a threshold number T such that the locations with noise > T comprise the mountain percentage of the map (to meet criteria #1).  This will give us natural-looking clumps of mountains.  To meet criteria #2, we can extend the mountains to a second threshold T', but between T and T' we'll fade out the mountains.  In psuedo-code:

// Create the mountain mask.  Changing the frequency of the
// noise here can create different kinds of clumps
for each location "loc" on the map:
noise[loc] = Noise.noise(x,y);
// Find the two thresholds
T = findThreshold(noise, mountainPercentage);
T2 = findThreshold(noise, hillPercentage);
// Put down the mountains/hills
for each location "loc" on the map:
if noise[loc] > T2 then
// Use whichever mountain algorithm you like here
rawHeight = Noise.noise(x*4,y*4);
// Mask this value
actualHeight = rawHeight * Math.min(1, (noise[loc]-T2)/(T-T2));
// And add it to the terrain
height[loc] += actualHeight;

The examples used in this posting have all used this algorithm.  You can look back at them and examine the clumping and the way they fade into the terrain.  This is generally a pretty good approach, but since it locates the mountains without any regard to the existing terrain, it can create odd placements, such as mountains in the lowest parts of the terrain:

If you don't like the semi-random placement from using a noise mask, and already have a base terrain, an approach that yields reasonable (if somewhat boring) placement is to locate the mountains on the highest parts of the existing terrain.  And again, you can use thresholding to fade the mountains into the surrounding terrain:
On the other hand, if you're producing top-down maps as I am, all this may be overkill.  Maybe you just need to decide where mountains go and mark that on the map.  For example, here's a mountain placement that looks pretty realistic:

But when you turn that into a top-down, 2D map it is difficult to even see where the mountains are:
Partly this is "just" a display problem -- the map needs a better visualization of the mountains.  But it's also true that for this sort of map, you don't need a detailed, hyper-realistic heightmap of the mountain areas.


text:
Correlations Between Reconstructed EUR Exchange Rates vs. CHF, DKK, GBP, JPY and USD

• M. Ausloos
• K. Ivanova

Abstract

On Jan. 1, 1999 the European Union introduced a common currency Euro ($EUR$), to become the legal currency in all eleven countries which form the $EUR$. In order to test the $EUR$ behavior and understand various features, the $EUR$ exchange rate is artificially extrapolated back to 1993 by a linear superposition of the exchange rates of the 11 currencies composing $EUR$ with respect to several currencies not belonging to the $EUR$, i.e. Swiss Franc ($CHF$), Danish Kroner ($DKK$), British Pound ($GBP$), Japanese Yen ($JPY$) and U.S. Dollar ($USD$) of interest for reasons given in the text. The distribution of fluctuations of the exchange rates is shown to be Gaussian for the central part of the distribution, and having fat tails for the large size fluctuations. Within the {\it Detrended Fluctuation Analysis} ($DFA$) statistical method we have obtained the power law behavior describing the root-mean-square deviation of the exchange rate fluctuations as a function of time. For the period between Jan. 1995 and Jan. 1999 we have compared the time-dependent exponent of these exchange rate fluctuations for $EUR$ and that of the 11 currencies which form the $EUR$. The German Mark ($DEM$) and the French Franc ($FRF$) have been the currencies primarily leading the fluctuations of the exchange rates, while Italian Lira ($ITL$) and ($PTE$) Portuguese Escudo are the less relevant currencies from this point of view. Technical considerations for the $EUR$ implementation are given as conclusions. The cases of exchange rates with $DKK$ appear quite different from the other four major currencies.

If you experience problems downloading a file, check if you have the proper application to view it first. In case of further problems read the IDEAS help page. Note that these files are not on the IDEAS site. Please be patient as the files may be large.
File URL: http://arxiv.org/pdf/cond-mat/0104260

Bibliographic Info

Paper provided by arXiv.org in its series Papers with number cond-mat/0104260.

as in new window
Length:
Date of revision:
Handle: RePEc:arx:papers:cond-mat/0104260

Contact details of provider:
Web page: http://arxiv.org/

Keywords:

References

References listed on IDEAS
Please report citation or reference errors to , or , if you are the registered author of the cited work, log in to your RePEc Author Service profile, click on "citations" and make appropriate adjustments.:
as in new window
1. J. MUYSKENS & C. de Neubourg, 1986. "Introduction," Discussion Papers (REL - Recherches Economiques de Louvain) 1986031, Université catholique de Louvain, Institut de Recherches Economiques et Sociales (IRES).
Full references (including those not matched with items on IDEAS)

Citations

Citations are extracted by the CitEc Project, subscribe to its RSS feed for this item.
as in new window

Cited by:
1. T. Di Matteo & T. Aste & M. M. Dacorogna, 2003. "Using the Scaling Analysis to Characterize Financial Markets," Papers cond-mat/0302434, arXiv.org.
2. Wang, Dong-Hua & Yu, Xiao-Wen & Suo, Yuan-Yuan, 2012. "Statistical properties of the yuan exchange rate index," Physica A: Statistical Mechanics and its Applications, Elsevier, vol. 391(12), pages 3503-3512.
3. Wang, Gang-Jin & Xie, Chi, 2013. "Cross-correlations between Renminbi and four major currencies in the Renminbi currency basket," Physica A: Statistical Mechanics and its Applications, Elsevier, vol. 392(6), pages 1418-1428.

Lists

This item is not listed on Wikipedia, on a reading list or among the top items on IDEAS.

Corrections

When requesting a correction, please mention this item's handle: RePEc:arx:papers:cond-mat/0104260. See general information about how to correct material in RePEc.

For technical questions regarding this item, or to correct its authors, title, abstract, bibliographic or download information, contact: (arXiv administrators).

If you have authored this item and are not yet registered with RePEc, we encourage you to do it here. This allows to link your profile to this item. It also allows you to accept potential citations to this item that we are uncertain about.

If references are entirely missing, you can add them using this form.

If the full references list an item that is present in RePEc, but the system did not link to it, you can help with this form.

If you know of missing items citing this one, you can help us creating those links by adding the relevant references in the same way as above, for each refering item. If you are a registered author of this item, you may also want to check the "citations" tab in your profile, as there may be some citations waiting for confirmation.

Please note that corrections may take a couple of weeks to filter through the various RePEc services.


text:
# Linear Regression?

How was the formula for Ordinary Least Squares Linear Regression arrived at?

Note I am not only looking for the proof, but also the derivation. Where did the formula come from?

-
Which formula? $w = (X^{T}X)^{-1}X^{T}y$? –  user2468 Apr 14 '12 at 4:45
No, the one used to find the linear equation. It can be found here- easycalculation.com/statistics/learn-regression.php –  user26649 Apr 14 '12 at 4:49
Sorry- I'm unfamiliar with posting mathematical symbols online, so have no idea how I could post the formula itself. –  user26649 Apr 14 '12 at 4:50
You've tried looking at this, haven't you? –  Ｊ. Ｍ. Apr 14 '12 at 4:56

I once wrote it up in detail for my blog, but I never published it because I thought people would not find it interesting. But since you ask, here it is. There are a lot of formulas, but there is nothing difficult in it.

Scientific calculators all have a "linear regression" feature, where you can put in a bunch of data and the calculator will tell you the parameters of the straight line that forms the best fit to the data. For example, suppose you have a bunch of data that looks like this:

Linear regression will calculate that the data are approximated by the line $3.06148942993613\cdot x + 6.56481566146906$ better than by any other line.

When the calculator does it, you just put in the data values and out pop the parameters of the line, its slope and its $y$-intercept. This can seem rather mysterious. When you see the formulas for the parameters of the line, they look even more mysterious. But it turns out that it is rather easy to figure out.

We want to find the line $y = mx + b$ that fits the data as well as possible. The first thing we need to decide is how to measure the goodness of the fit. If a data point is $(x, y)$ and the line actually goes through $(x, y')$ instead, how do we decide the extent to which that is a problem?

We need to pick some error-measuring function $\varepsilon(y, y')$ that tells us the error we attribute to the line going through $y'$ instead of $y$. Then we can do the calculation to figure out the line that has the minimum total error.

The $\varepsilon$ function we choose must satisfy some criteria. For example, $\varepsilon(y, y)$ should be 0 for all $y$: if the line actually goes exactly through the data point, we should attribute a 0 error to that. And $\varepsilon(y, y')$ should never be negative: a error of 0 is perfect, and you shouldn't be able to do better than perfect.

The $\varepsilon$ function that the pocket calculators all use is $$\varepsilon(y, y') = (y-y')^{2}.$$ This is for a few reasons. One is that it satisfies the important criteria above, and some others. For example, it is symmetric: if the line passes a certain distance above where the point actually is, that has the same error as if it passes the same distance below where the point actually is.

Also, this error function says that missing a data point by three feet isn't three times as bad as missing it by one foot; it's nine times as bad. It's okay to miss the point by a little bit, but missing by a lot is unacceptable. This is usually something like what we want.

But the real reason the calculators all use this error function is that it's really easy to calculate the best-fitting line for this particular definition of "best-fitting".

Let's do the calculation. Suppose that the data are the $N$ points $(x_{1}, y_{1}), (x_{2}, y_{2}), (x_{3}, y_{3})$…. And we're going to try to approximate them with the line $y = mx + b$. We want to find the values of $m$ and $b$ that minimize the total error.

The total error is:

$$E(m, b) = \sum{\varepsilon(y_i, mx_i+b)}$$

That is, for each point $(x_{i}, y_{i})$, we take where it really is (that's $y_{i}$) and where the line $y = mx + b$ predicts it should be (that's $mx_{i} + b$) and calculate the error of the prediction. We add up the error for each point that the line was supposed to predict, and that's the total error for the line.

Since $\varepsilon(y, y') = (y-y')^{2}$, the total error is:

$$E(m, b) = \sum{(y_i - mx_i - b)^2}$$

Or, grinding out the algebra:

$$E(m, b) = \sum{(y_i^2 + m^2x_i^2 + b^2 - 2mx_iy_i - 2by_i + 2bmx_i)}$$

We can add up each of the six kinds of components separately and then total them all at the end:

$$E(m, b) = \sum{y_i^2} + \sum{m^2x_i^2} + \sum{b^2} - \sum{2mx_iy_i} - \sum{2by_i} + \sum{2bmx_i}$$

We're going to need to spend a lot of time talking about things like $\sum x_iy_i$, so let's make some abbreviations:

$$\begin{array}{lcl} \mathcal X &= & \sum x_i \cr \mathcal Y &= & \sum y_i \cr \mathcal A &= & \sum x_i^2 \cr \mathcal B &= & \sum x_iy_i \cr \mathcal C &= & \sum y_i^2 \cr \end{array}$$

Also please recall that $N$ is the total number of points.

With these abbreviations, we can write the total error as:

$$E(m, b) = {\cal C} + m^2{\cal A} + b^2N - 2m{\cal B} - 2b{\cal Y} + 2bm{\cal X}$$

Now, remember that we would like to find the values of $m$ and $b$ that result in the minumum error. That is, we would like to minimize $E$ with respect to $m$ and $b$. But that is just a straightforward calculus problem. We want to find the value of $m$ that minimizes $E$, so we take the derivative of $E$ with respect to $m$:

$\def\d#1{{\partial E\over \partial #1}}$ $$\d m = 2m{\cal A} - 2{\cal B} + 2b{\cal X}$$

And we know that if there is a minimum value for $E$, it will occur when $\d m = 0$:

$$2m{\cal A} - 2{\cal B} + 2b{\cal X} = 0\qquad{(*)}$$

And similarly, $\d b$ will also have to be 0:

$$\d b = 2bN - 2{\cal Y} + 2m{\cal X} = 0\qquad{(**)}$$

So we have two equations (* and **) in two unknowns ($m$ and $b$) and we can solve them. First we'll solve the second equation for $b$:

$$b = {{\cal Y} - m{\cal X}\over N}$$

Now we'll solve the first equation for $m$:

\eqalign{ m{\cal A} - {\cal B} + b{\cal X} & = & 0 \cr m{\cal A} - {\cal B} + {{\cal Y} - m{\cal X}\over N}{\cal X} & = & 0 \cr m{\cal A} - {\cal B} + {{\cal XY} - m{\cal X}^2\over N} & = & 0 \cr mN{\cal A} - N{\cal B} + {\cal XY} - m{\cal X}^2 & = & 0 \cr m(N{\cal A} - {\cal X}^2 ) & = & N{\cal B} - {\cal XY} \cr %m & N{\cal B} - {\cal XY} \over N{\cal A} - {\cal X}^2 \cr } Thus:

$$m = { N{\cal B} - {\cal XY} \over N{\cal A} - {\cal X}^2 }$$

And that's it. We can get $m$ from $N$, $\cal A$, $\cal B$, $\cal X$, and $\cal Y$, and we can get $b$ from $m$, $N$, $\cal X$, and $\cal Y$.

$\def\dd#1{{\partial^2 E\over \partial {#1}^2}}$ (Actually, we also need to check the second derivatives to make sure we haven't found the values of $m$ and $b$ that give the maximum error. But it should be clear from the geometry of the thing that it is impossible that there could be a very-worst line: No matter how badly the data are approximated by any given line, you could always find another line that was worse, just by taking the bad line and moving it another few miles away from the data. But we should take the second derivatives anyway, if for no other reason than to rule out the possibility of a saddle point in the $E$ function. The second derivatives are $\dd m = 2\cal A$ and $\dd b = 2N$, which are both positive, so we really have found a minimum for the error function.)

Now let's do some checking, and make sure it works and makes sense. First, it should fail if $N=1$, because there are plenty of lines that all go through any single point. And indeed, when there's only one point, say $(x, y)$, then $X^{2} = x^{2}$, ${\cal A} = x^{2}$, the denominator of the expression for $m$ vanishes and the whole thing blows up.

It should also fail if all the $x$ values are equal, because then the line through the data is vertical, and has an infinite slope. And sure enough, if all the $x$ values are equal, then ${\cal X} = Nx$, ${\cal X}^{2} = N^{2}x^{2}$, ${\cal A} = Nx^{2}$, and the denominator of the expression for $m$ vanishes.

Now what if all the points happen to lie on a (non-vertical) straight line? Then there are some numbers $p$ and $q$ so that $y_{i} = px_{i} + q$ for all $i$. We hope that the equations for $m$ and $b$ will give $m = p$ and $b = q$. If they don't, we're in trouble, since the equations are supposed to find the best line through the points, and the points actually lie on the line $y = px + q$; this line will therefore have a total error of 0, and that's the best we can do. Well, let's see how it works out.

In such a case, we have ${\cal Y} = \sum {y_i} = \sum {px_i+q} = p{\cal X} + qN$. Similarly, we also have:

\eqalign{ {\cal B} & = & \sum{x_iy_i} \cr & = & \sum{x_i(px_i+q)} \cr & = & \sum{px_i^2} + \sum{qx_i} \cr & = & p{\cal A} + q{\cal X} \cr }

Plugging these into the formula for $m$ above we get:

\eqalign{ m & = & { N{\cal B} - {\cal XY} \over N{\cal A} - {\cal X}^2 } \cr & = & { N(p{\cal A} + q{\cal X}) - {\cal X}(p{\cal X} + qN) \over N{\cal A} - {\cal X}^2 } \cr & = & { pN{\cal A} + qN{\cal X} - p{\cal X}^2 - qN{\cal X} \over N{\cal A} - {\cal X}^2 } \cr & = & { pN{\cal A} - p{\cal X}^2 \over N{\cal A} - {\cal X}^2 } \cr % & = & { p(N{\cal A} - {\cal X}^2) \over N{\cal A} - {\cal X}^2 } \cr & = & p \cr }

as hoped, and then plugging into the formula for $b$, we get $b$ = $q$, also as hoped.

It's handy to be able to fit a line to any data set. A while back I wrote a trivial little program to read data points from the standard input, do the least-squares analysis, and print out $m$ and $b$. Little utilities like this often come in handy.

-
Thank You. The post was perfect! –  user26649 Apr 14 '12 at 18:27
You posted this a million years ago but I just thought I'd let you know that "Also, this error function says that missing a data point by three feet isn't three times as bad as missing it by one foot; it's nine times as bad. It's okay to miss the point by a little bit, but missing by a lot is unacceptable. This is usually something like what we want." was an angle I'd never really thought of. Thanks for the fantastic answer. –  crf Nov 12 '12 at 4:17
@MJD I like the answer, and I can follow what you have here. Though, the formula I learned for calculating m was $m = \frac {\sum(x_i-\bar x)(y_i-\bar y)}{\sum (x_i- \bar x)^2}$. It's not fully clear to me how I can arrive at this one from your formula of m. Also, it's absent in the question, but I assume this is the formula he was asking about? –  user17753 Nov 12 '12 at 16:12
@user17753 That formula is equivalent. To see this, note that $\bar x = \frac1N\mathcal X$, and $\bar y = \frac1N\mathcal Y$. Then your expression expands to ${\mathcal B} - 2{\mathcal XY}/N + N{\mathcal XY}/N^2 \over {\mathcal A} - 2{\mathcal X^2}/N + N{\mathcal X^2}/N^2$ and then to $N{\mathcal B}-{\mathcal XY}\over N{\mathcal A} - {\mathcal X^2}$, which is what I gave. –  MJD Nov 12 '12 at 20:22

Suppose you are given a set of data points $\{(x_i,y_i)\}$. The goal of linear regression is to find a line that minimizes the sum of square of errors at each $x_i$. Let the equation of the desired line be $y=a+bx$.

To minimize: $E=\sum_i (y_i-a-b x_i)^2$

Differentiate $E$ w.r.t $a$ and $b$, set both of them to be equal to zero and solve for a and b.

-

Since the question contains a historical focus, that treatize of Jeffrey M. Stanton on Francis Galton (and Pearson for the extensions) (at the ams) might be what is really wanted . I am surprised, that the wikipedia misses the historical reference completely.

(Cite from the article at AMS: )

In 1875, Galton had distributed packets of sweet pea seeds to seven friends; each friend received seeds of uniform weight (also see Galton 1894), but there was substantial variation across different packets. Galton's friends harvested seeds from the new generations of plants and returned them to him (see Appendix A). Galton plotted the weights of the daughter seeds against the weights of the mother seeds. Galton realized that the median weights of daughter seeds from a particular size of mother seed approximately described a straight line with positive slope less than 1.0:

"Thus he naturally reached a straight regression line, and the
constant variability for all arrays of one character for a given
character of a second. It was, perhaps, best for the progress of the
correlational calculus that this simple special case should be
promulgated first; it is so easily grasped by the beginner." (Pearson
1930, p. 5)

-