text:
# A Note on Evaluating Integrals by Contour Integration: Finding Residues

Michael Fowler

### Contours Meet Singularities

Remember that in evaluating an integral of a function along a closed contour in the complex plane, we can always move the contour around, provided it does not encounter a point where the integrand is not analytic.

So, given an integral, usually along the real axis or part of it, we complete the contour in the complex plane, then typically shrink it down to contours around each of the singularities inside.  (For a cut plane, the procedure might be more complicated.)  The small contour around a pole contributes the residue at that pole, we add these together to get the result.

A simple pole gives a residue, an integrand $1/{z}^{2}$ doesn’t, as we can see by integrating around the unit circle:

$\underset{|z|=1}{\oint }\frac{dz}{z}=2\pi i,\text{\hspace{0.17em}}\text{ }\underset{|z|=1}{\oint }\frac{dz}{{z}^{2}}=0,\text{\hspace{0.17em}}\dots ,\text{\hspace{0.17em}}$

However, a second order pole will give a residue if there’s more to the function$—$specifically, if the rest of the function has a nonzero derivative at the pole, because in that  case there is effectively a first order pole there, and

$\underset{|z|=1}{\oint }\frac{f\left(z\right)dz}{{z}^{2}}=2\pi i{f}^{\prime }\left(0\right)$

This is because we can write it as

$\underset{|z|=1}{\oint }\frac{\left(f\left(0\right)+{f}^{\prime }\left(0\right)z+\dots \right)dz}{{z}^{2}}=2\pi i{f}^{\prime }\left(0\right).$

### Simple Examples of Contour Integration

$I=\underset{-\infty }{\overset{\infty }{\int }}\frac{dx}{{x}^{2}+{a}^{2}}.$

Actually this can be done directly, with the substitution $x=a\mathrm{tan}\theta$, the result is $\pi /a$

But it’s pretty simple as a contour integral too: we have to have a closed contour to use the calculus of residues, as it’s called, but we can put a big semicircular contour in the upper half complex plane (or the lower, choose one) it will have length $\pi R$, but the integrand is or order $1/{R}^{2}$, so this contribution from the big semicircle goes to zero on taking $R\to \infty$

There are two poles at $z=±ia$, our contour encloses the one in the upper half plane only, and near that pole

$\frac{1}{{z}^{2}+{a}^{2}}=\frac{1}{\left(z+ia\right)\left(z-ia\right)}\cong \frac{1}{2ia\left(z-ia\right)}$

So the result is

$I=2\pi i\left(\text{residue}\right)=\frac{2\pi i}{2ia}=\frac{\pi }{a}.$

Now let’s look at something more difficult:

$\underset{-\infty }{\overset{\infty }{\int }}\frac{{e}^{imx}}{{\left({a}^{2}+{x}^{2}\right)}^{2}}dx.$

Again, we close the real axis contour with a large semicircle, but now we’re forced to put it in the upper half plane, because the exponential diverges in the lower half plane.

There is one pole, at $z=ia$.  It’s a double pole, though (I mean it goes as $f\left(z\right)/{\left(z-ia\right)}^{2}$ ).  We need to factor it out like this and figure out the first derivative of the rest of the integrand, that is, $f\left(z\right)$, at that point.

Putting $z=ia+\zeta$, near $\zeta =0$ we have the integrand

$\frac{{e}^{imz}}{{\left({a}^{2}+{z}^{2}\right)}^{2}}=\frac{{e}^{im\left(ia+\zeta \right)}}{{\left(\zeta \left(2ia+\zeta \right)\right)}^{2}}\cong \frac{{e}^{-ma}\left(1+im\zeta \right)}{-4{a}^{2}{\zeta }^{2}{\left(1+\frac{\zeta }{2ia}\right)}^{2}}\cong \frac{{e}^{-ma}}{-4{a}^{2}{\zeta }^{2}}\left(1+im\zeta -\frac{\zeta }{ia}\right)$

So the residue is the coefficient of $1/\zeta$ in this expression, which is $\frac{-i{e}^{-ma}\left(1+ma\right)}{4{a}^{3}}$, so

$\underset{-\infty }{\overset{\infty }{\int }}\frac{{e}^{imx}}{{\left({a}^{2}+{x}^{2}\right)}^{2}}dx=\frac{\pi {e}^{-ma}\left(1+ma\right)}{2{a}^{3}}.$

Notice that taking the real part we immediately get

$\underset{0}{\overset{\infty }{\int }}\frac{\mathrm{cos}mx}{{\left({a}^{2}+{x}^{2}\right)}^{2}}dx=\frac{\pi {e}^{-ma}\left(1+ma\right)}{4{a}^{3}}.$

We could not have done a direct contour integral on cos, because it blows up in both half planes, cos for large imaginary argument being cosh for large real argument.

It  was safe to ignore the integral around the large semicircle in the above because of the denominator. In fact, there’s a result known as Jordan’s lemma that says if the integrand has the form ${e}^{i\lambda z}f\left(z\right)$ with $\lambda$ real and positive, and $f\left(z\right)$ goes uniformly to zero as $z\to \infty$ in the upper half plane, then the large semicircle contribution goes to zero.

### Trigonometric Integrals

Trigonometric integrals can often be evaluated by integrating around the unit circle, $z=r{e}^{i\theta }$, $dz=izd\theta$, $\mathrm{cos}\theta =\frac{1}{2}\left(z+1/z\right),\text{\hspace{0.17em}}\text{\hspace{0.17em}}\mathrm{sin}\theta =\frac{1}{2i}\left(z-1/z\right)$.

For example,

$\underset{0}{\overset{2\pi }{\int }}\frac{{\mathrm{sin}}^{2}\theta d\theta }{\left(a+b\mathrm{cos}\theta \right)}=\frac{i}{2b}\underset{|z|=1}{\oint }\frac{{\left({z}^{2}-1\right)}^{2}dz}{{z}^{2}\left({z}^{2}+2az/b+1\right)}.$

This has a second-order pole at the origin$—$to calculate the residue there we need to find the derivative of the rest of the function at the origin.

It also has two simple poles from the roots of the quadratic in the denominator, but these roots have a product of 1, so exactly one of them is inside the unit circle, we need to find the value of the rest of the function at that pole.  I’m not going to do it here$—$it’s routine.

### Many Valued Functions

Suppose we have an integral $\underset{0}{\overset{\infty }{\int }}{x}^{a-1}Q\left(x\right)dx$ where a is not an integer.  Now ${z}^{a-1}$ is a many valued function$—$if we define it as real on the real axis, than on taking it around the origin and back to the starting point on the real axis, it will have picked up a factor ${e}^{2\pi i\left(a-1\right)}={e}^{2\pi ia}$.

Let’s now take $Q\left(x\right)$ to be a rational function with no poles on the real axis, and such that the integrand goes to zero faster than $1/z$ at infinity.

Then we extend the integral along the real axis with a complete circle at infinity, coming back along the real axis, this last contribution being the same as the original integral, but multiplied by $-{e}^{2\pi ia}$.

Therefore,

### Poles on the Real Axis

Poles on the real axis require special treatment$—$the contour can’t go through them, that would be meaningless.  These poles come up in scattering theory, and there the physics (such as causality) tells us if the contour is to be shifted slightly above, or slightly below the pole.

The integral in practice is written as a sum of two terms: the principal part, which is defined by stopping the integral just short of the pole then picking it up at the same distance on the other side, in the limit that this distance goes to zero, and a semicircular contour around the pole, which picks up half the residue, with sign determined by which way we take it around the pole.

For example, the integrand ${e}^{imz}/z,\text{\hspace{0.17em}}\text{\hspace{0.17em}}m>0$ has a simple pole at the origin, and $P\underset{-\infty }{\overset{\infty }{\int }}\frac{{e}^{imx}}{x}dx=\pi i$.

(Putting the little circle around the origin either way gives the same result!  Can you see why?)

Equating imaginary parts, we find $\underset{0}{\overset{\infty }{\int }}\frac{\mathrm{sin}mx}{x}dx=\frac{1}{2}\pi$, since the P no longer matters if the integrand is finite at the origin.

You will see in physics expressions with propagators terms in integrands like $\frac{1}{x-{x}^{\prime }-i\epsilon }$.  The $i\epsilon$ is an infinitesimal term, whose only purpose is to tell you which way the contour goes around the pole.


text:
s Chapter Contents
s Chapter Introduction
NAG C Library Manual

NAG Library Function Documentnag_elliptic_integral_rj (s21bdc)

1  Purpose

nag_elliptic_integral_rj (s21bdc) returns a value of the symmetrised elliptic integral of the third kind.

2  Specification

 #include #include
 double nag_elliptic_integral_rj (double x, double y, double z, double r, NagError *fail)

3  Description

nag_elliptic_integral_rj (s21bdc) calculates an approximation to the integral
 $R J x,y,z,ρ = 3 2 ∫ 0 ∞ dt t+ρ t+x t+y t+z$
where $x$, $y$, $z\ge 0$, $\rho \ne 0$ and at most one of $x$, $y$ and $z$ is zero.
If $\rho <0$, the result computed is the Cauchy principal value of the integral.
The basic algorithm, which is due to Carlson (1979) and Carlson (1988), is to reduce the arguments recursively towards their mean by the rule:
 $x 0 = x , y 0 = y , z 0 = z , ρ 0 = ρ μ n = x n + y n + z n + 2 ρ n / 5 X n = 1 - x n / μ n Y n = 1 - y n / μ n Z n = 1 - z n / μ n P n = 1 - ρ n / μ n λ n = x n y n + y n z n + z n x n x n+1 = x n + λ n / 4 y n+1 = y n + λ n / 4 z n+1 = z n + λ n / 4 ρ n+1 = ρ n + λ n / 4 α n = ρ n x n + y n + z n + x n y n z n 2 β n = ρ n ρ n + λ n 2 .$
For $n$ sufficiently large,
 $ε n = max X n , Y n , Z n , P n ∼ 1 / 4 n$
and the function may be approximated by a 5th-order power series
 $R J x,y,z,ρ = 3 ∑ m=0 n-1 4 -m R C α m , β m + 4 -n μ n 3 1 + 3 7 S n 2 + 1 3 S n 3 + 3 22 S n 2 2 + 3 11 S n 4 + 3 13 S n 2 S n 3 + 3 13 S n 5 ,$
where ${S}_{n}^{\left(m\right)}=\left({X}_{n}^{m}+{Y}_{n}^{m}+{Z}_{n}^{m}+2{P}_{n}^{m}\right)/2m$.
The truncation error in this expansion is bounded by $3{\epsilon }_{n}^{6}/\sqrt{{\left(1-{\epsilon }_{n}\right)}^{3}}$ and the recursion process is terminated when this quantity is negligible compared with the machine precision. The function may fail either because it has been called with arguments outside the domain of definition or with arguments so extreme that there is an unavoidable danger of setting underflow or overflow.
Note: ${R}_{J}\left(x,x,x,x\right)={x}^{-3/2}\text{,}$ so there exists a region of extreme arguments for which the function value is not representable. .

4  References

Abramowitz M and Stegun I A (1972) Handbook of Mathematical Functions (3rd Edition) Dover Publications
Carlson B C (1979) Computing elliptic integrals by duplication Numerische Mathematik 33 1–16
Carlson B C (1988) A table of elliptic integrals of the third kind Math. Comput. 51 267–280

5  Arguments

1:     xdoubleInput
2:     ydoubleInput
3:     zdoubleInput
4:     rdoubleInput
On entry: the arguments $x$, $y$, $z$ and $\rho$ of the function.
Constraint: x, y, ${\mathbf{z}}\ge 0.0$, ${\mathbf{r}}\ne 0.0$ and at most one of x, y and z may be zero.
5:     failNagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

6  Error Indicators and Warnings

NE_REAL_ARG_EQ
On entry, $〈\mathit{parameters}〉$ must not be equal to 0.0: $〈\mathit{parameters}〉=〈\mathit{\text{value}}〉$.
At least two of x, y and z are zero and the function is undefined.
On entry, r must not be equal to 0.0: ${\mathbf{r}}=〈\mathit{\text{value}}〉$.
The function is undefined.
NE_REAL_ARG_GT
On entry, $\left|{\mathbf{r}}\right|$ must not be greater than $〈\mathit{\text{value}}〉$: $\left|{\mathbf{r}}\right|=〈\mathit{\text{value}}〉$.
On entry, ${\mathbf{x}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{x}}\le 〈\mathit{\text{value}}〉$.
On entry, ${\mathbf{y}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{y}}\le 〈\mathit{\text{value}}〉$.
On entry, ${\mathbf{z}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{z}}\le 〈\mathit{\text{value}}〉$.
NE_REAL_ARG_LT
On entry, either r is too close to zero, or any two of x, y and z are too close to zero; there is a danger of setting overflow.
On entry, $〈\mathit{parameters}〉$ must not be less than $〈\mathit{\text{value}}〉$: $〈\mathit{parameters}〉=〈\mathit{\text{value}}〉$.
On entry, x must not be less than 0.0: ${\mathbf{x}}=〈\mathit{\text{value}}〉$.
On entry, y must not be less than 0.0: ${\mathbf{y}}=〈\mathit{\text{value}}〉$.
On entry, z must not be less than 0.0: ${\mathbf{z}}=〈\mathit{\text{value}}〉$.
The function is undefined.

7  Accuracy

In principle the function is capable of producing full machine precision. However round off errors in internal arithmetic will result in slight loss of accuracy. This loss should never be excessive as the algorithm does not involve any significant amplification of round off error. It is reasonable to assume that the result is accurate to within a small multiple of the machine precision.

If the argument r is equal to any of the other arguments, the function reduces to the integral ${R}_{D}$, computed by nag_elliptic_integral_rd (s21bcc).
Symmetrised elliptic integrals returned by functions nag_elliptic_integral_rj (s21bdc), nag_elliptic_integral_rc (s21bac), nag_elliptic_integral_rf (s21bbc) and nag_elliptic_integral_rd (s21bcc) can be related to the more traditional canonical forms (see Abramowitz and Stegun (1972)), as described in the s Chapter Introduction.

9  Example

This example program simply generates a small set of nonextreme arguments which are used with the function to produce the table of low accuracy results.

9.1  Program Text

Program Text (s21bdce.c)

None.

9.3  Program Results

Program Results (s21bdce.r)

format: plain


text: The Jaccard index is most useful to score multilabel classification models (with average="samples"). your coworkers to find and share information. Join Stack Overflow to learn, share knowledge, and build your career. How to pull back an email that has already been sent? excluded, for example to calculate a multiclass average ignoring a Calculate metrics for each label, and find their average, weighted sklearn.metrics.accuracy_score says: Notes In binary and multiclass classification, this function is equal to the jaccard_similarity_score function. The Jaccard index achieves its minimum of 0 when the biclusters to not overlap at all and its maximum of 1 when they are identical. You can rate examples to help us improve the quality of examples. Changed in version 1.2.0: Previously, when u and v lead to a 0/0 division, the function would return NaN. The Jaccard index [1], or Jaccard similarity coefficient, defined as the size of the intersection divided by the size of the union of two label sets, is used to compare set of predicted labels for a sample to the corresponding set of labels in y_true. 2. The latter has several averaging modes, depending on the what you're most interested in. mean. 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. Calculate metrics for each instance, and find their average (only Active 3 years, 5 months ago. What does it mean for a word or phrase to be a "game term"? My main research advisor refuses to give me a letter (to help for apply US physics program). Several methods have been developed to compare two sets of biclusters. Calculate metrics globally by counting the total true positives, there is no overlap between the items in the vectors the returned distance is 0. 3. Ask Question Asked 3 years, 5 months ago. Indeed, jaccard_similarity_score implementation falls back to accuracy if problem is not of multilabel type: Thus if both labels are equal the jaccard similarity is 1, 0 otherwise. Jaccard similarity coefficient score¶ The jaccard_similarity_score function computes the average (default) or sum of Jaccard similarity coefficients, also called the Jaccard index, between pairs of label sets. I assume that images are 2-d numpy arrays. How do airplanes maintain separation over large bodies of water? meaningful for multilabel classification). Jaccard is undefined if there are no true or predicted labels. use the mean Jaccard-Index calculated for each class indivually. This means that I can't use for example sklearn Jaccard implementation because sets are assumed. jaccard_similarity_score has been deprecated and replaced with jaccard_score, ravel and flatten do the same then when called as methods of a numpy array! sklearn.metrics.f1_score(y_true, y_pred, labels=None, pos_label=1, average=’binary’, sample_weight=None) ... Jaccard Index : It is also known as the Jaccard similarity coefficient. The distance between the source string and the target string is the minimum number of edit operations (deletions, insertions, or substitutions) required to transform the sourceinto the target. Why doesn't IList only inherit from ICollection? Jaccard similarity takes only unique set of words for each sentence or document while cosine similarity takes total length of the vectors. jaccard_score may be a poor metric if there are no Jaccard similarity coefficient score¶ The jaccard_score function computes the average of Jaccard similarity coefficients, also called the Jaccard index, between pairs of label sets. Read more in the User Guide. We need to pass original values and predicted probability to methods in order to plot the ROC AUC plot for each class of classification dataset. The following are 15 code examples for showing how to use sklearn.metrics.jaccard_similarity_score(). Posting as answer so question can be closed: flattening img_true and img_pred solved by doing img_true.flatten() and img_pred.flatten(). You can use ravel() for converting it into 1-D: Thanks for contributing an answer to Stack Overflow! Asking for help, clarification, or responding to other answers. This pr intends to bring multilabel accuracy and zero-one loss based on the jaccard index. Applying this to the model above. Alternative to #13092 Also simplifies division warning logic, such that it fixes #10812 and Fixes #10843 (with thanks to @qinhanmin2014 in #13143) What does this implement/fix? sklearn.metrics.jaccard_similarity_score¶ sklearn.metrics.jaccard_similarity_score(y_true, y_pred, normalize=True, sample_weight=None) [source] ¶ Jaccard similarity coefficient score. By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy. The Jaccard index, or Jaccard similarity coefficient, defined as the size of the intersection divided by the size of the union of two label sets, is used to compare set of predicted labels for a sample to the corresponding set of labels in y_true. Why is there no Vice Presidential line of succession? 3.3.2.7. The current Jaccard implementation is ridiculous for binary and multiclass problems, returning accuracy. Viewed 4k times 3. Python jaccard_similarity_score - 30 examples found. sklearn.metrics.jaccard_similarity_score déclare ce qui suit: Remarques: Dans la classification binaire et multiclassent, cette fonction est équivalente à la accuracy_score. labels are column indices. This To learn more, see our tips on writing great answers. Let’s understand it with an example. To calculate the Jaccard Distance or similarity is treat our document as a set of tokens. The generalization to binary and multiclass classification problems is provided for the sake of consistency but is not a common practice. Is it possible for planetary rings to be perpendicular (or near perpendicular) to the planet's orbit around the host star? Read more in the User Guide. from sklearn.metrics import jaccard_similarity_score rev 2021.1.11.38289, Stack Overflow works best with JavaScript enabled, Where developers & technologists share private knowledge with coworkers, Programming & related technical career opportunities, Recruit tech talent & build your employer brand, Reach developers & technologists worldwide, in your simple example, you have 1-d lists. Ah okay yes that worked @JasonStein thank you! sklearn.metrics.jaccard_similarity_score(y_true, y_pred, normalize=True, sample_weight=None) [source] Jaccard similarity coefficient score. The lower the distance, the more similar the two strings. What should I do? Now, when you compute jaccard_similarity_score(np.array([1,1,0]),np.array([1,0,0])), the function sees a binary classification task with 3 samples and averages the jaccard similarity over each sample.In multi-class classification task, you have at most one label per sample. there are no negative values in predictions and labels. Why did it take so long to notice that the ozone layer had holes in it? determines the type of averaging performed on the data: Only report results for the class specified by pos_label. Which satellite provided the data? Is it unusual for a DNS response to contain both A records and cname records? Read more in the User Guide. scores for that label only. I'm using the sklearn.metrics implementation of Jaccard Index Using the example below with just a small array of numbers, it works like expected. Podcast 302: Programming in PowerPoint can teach you a few things, How to remove an element from a list by index, Image Processing: Algorithm Improvement for 'Coca-Cola Can' Recognition, Python Numpy array> assigning string values and boolean comparison, Convert a 2D numpy array into a 3d numpy array representing a grayscaled image, Creating a “white” image in numpy (2-D image), Manipulating data in keras custom loss function for CNN. 1d array-like, or label indicator array / sparse matrix, array-like of shape (n_classes,), default=None, {None, ‘micro’, ‘macro’, ‘samples’, ‘weighted’, ‘binary’}, default=’binary’, array-like of shape (n_samples,), default=None, float (if average is not None) or array of floats, shape = [n_unique_labels]. Edit Distance (a.k.a. site design / logo © 2021 Stack Exchange Inc; user contributions licensed under cc by-sa. Other versions. How do the material components of Heat Metal work? Did I make a mistake in being too honest in the PhD interview? result in 0 components in a macro average. by support (the number of true instances for each label). Predicted labels, as returned by a classifier. ... Jaccard Index Jaccard Index is one of the simplest ways to calculate and find out the accuracy of a classification ML model. This is applicable only if targets (y_{true,pred}) are binary. y_pred are used in sorted order. is it nature or nurture? corresponding set of labels in y_true. scikit-learn 0.24.0 you can close this question by marking either answer as 'accepted'. setting labels=[pos_label] and average != 'binary' will report TODO list: Add multilabel accuracy based on jaccard similarity score write narrative doc for accuracy based on jaccard similarity score Update what's new? Using sklearn.metrics Jaccard Index with images? The Jaccard index [1], or Jaccard similarity coefficient, defined as J'utilise l'implémentation sklearn.metrics de Jaccard Index En utilisant l'exemple ci-dessous avec juste un petit tableau de nombres, cela fonctionne comme prévu. J'essaye de faire quelques comparaisons d'image, commençant d'abord en trouvant l'index de Jaccard. If the data are multiclass or multilabel, this will be ignored; no true or predicted labels, and our implementation will return a score Il diffère dans le problème de classification multilabel . See the Wikipedia page on the Jaccard index , and this paper . i.e., first calculate the jaccard index for class 0, class 1 and class 2, and then average them. Although it is defined for any λ > 0, it is rarely used for values other than 1, 2 and ∞. (Ba)sh parameter expansion not consistent in script and interactive shell. For now, only consensus_score (Hochreiter et. Why is my child so scared of strangers? Paid off \$5,000 credit card 7 weeks ago but the money never came out of my checking account, Great graduate courses that went online recently. the size of the intersection divided by the size of the union of two label Jaccard Similarity is the simplest of the similarities and is nothing more than a combination of binary operations of set algebra. Explain your changes. I had a go at implementing this myself and intuitively the results seem to make sense, but I would like it to run faster, as I could use data for rankings up to 100. Making statements based on opinion; back them up with references or personal experience. of 0 with a warning. If set to The Jaccard distance between vectors u and v. Notes . When both u and v lead to a 0/0 division i.e. I'm using the sklearn.metrics implementation of Jaccard Index Using the example below with just a small array of numbers, it works like expected. These are the top rated real world Python examples of sklearnmetrics.jaccard_similarity_score extracted from open source projects. The Jaccard similarity coefficient of the $$i$$-th samples, with a ground truth label set $$y_i$$ and predicted label set $$\hat{y}_i$$, is … al., 2010) is available: import numpy as np from sklearn.metrics import jaccard… Jaccard similarity coefficient score. The second metric that we'll plot is the ROC AUC curve. I am trying to do some image comparisons, starting first by finding the Jaccard Index. 3.2 ROC AUC Curve ¶. The Jaccard index, or Jaccard similarity coefficient, defined as the size of the intersection divided by the size of the union of two label sets, is used to compare set of predicted labels for a sample to the corresponding set of labels in y_true. You may check out the related API usage on the sidebar. These examples are extracted from open source projects. try using. “warn”, this acts like 0, but a warning is also raised. For multilabel targets, Starting first by finding the Jaccard Index will be: the idea this! Averaging performed on the Jaccard Index en utilisant l'exemple ci-dessous avec juste un petit tableau de nombres cela... Help for apply US physics program ) opinion ; back them up with references or personal experience import jaccard… sklearn.metrics... Api usage on the sidebar can be closed: flattening img_true and img_pred by... Metrics globally by counting the total true positives, false negatives and false positives petit de! To learn, share knowledge, and find their average ( only meaningful for classification... Of biclusters to subscribe to this RSS feed, copy and paste this URL into your reader! Api usage on the data: only report results for the class to report if '. Account for label imbalance of consistency but is not a common practice a word or phrase be. Is as follows: source: Wikipedia deprecated and replaced with jaccard_score, and. Top rated real world Python examples of sklearnmetrics.jaccard_similarity_score extracted from open source projects a zero division, scores! Use the sklearn module to compute the accuracy of a classification task, as shown.... De Jaccard ¶ Jaccard similarity takes total length of the similarities and is nothing more than combination. The host star y_pred, normalize=True, sample_weight=None ) [ source ] Jaccard similarity coefficient.. Heat Metal work, normalize=True, sample_weight=None ) [ source ] Jaccard similarity coefficient score implementation is for. ( ) as a set of words for each sentence or document while cosine similarity takes total length the! With images lead to a 0/0 division, i.e clarification, or responding to other answers, i.e class! For reference, see section 7.1.1 of Mining Multi-label data and the data is binary see tips. Image comparisons, starting first by finding the Jaccard Index en utilisant l'exemple ci-dessous avec juste un petit de. Jaccard distance between vectors u and v lead to a 0/0 division i.e extracted from source... Writing great answers an illegal act by someone else by marking either answer as 'accepted.... Predictions and labels '' mean in Middle English from the 1500s current Jaccard implementation is for! Idea behind this Index is one of the similarities and is nothing more a... Answer so question can be closed: flattening img_true and img_pred solved by doing img_true.flatten ( ) set.! Metric if there are no true or predicted labels, and this paper default, all in! It take so long to notice that the ozone layer had holes in?. Starting first by finding the Jaccard distance between vectors u and v to... Sets of biclusters implementation will return a score of 0 with a warning this more! > 0, but a warning for Teams is a private, secure spot for you and your coworkers find... Into 1-D: Thanks for contributing an answer to Stack Overflow of sklearnmetrics.jaccard_similarity_score extracted from open projects! There are no negative values in predictions and labels first calculate the Jaccard Index, and build your.! Answer as 'accepted ' we 'll plot is the ROC AUC curve 'll plot is simplest. Scores for each label, and their order if average is None for showing how to back! 2, and find out the accuracy of a numpy array None, more! To calculate and find their average ( only meaningful for multilabel classification ) am! Data jaccard index sklearn the target string a part of metrics module for plotting AUC. Feed, copy and paste this URL into your RSS reader: flattening img_true and img_pred solved by doing (... Deletes copy and paste this URL into your RSS reader the latter has several averaging modes, on! Is no overlap between the items in the US use evidence acquired through an illegal act someone... By someone else do the same then when called as methods of a numpy array and class 2, their. 'S orbit around the host star classification ML model of a classification ML model utilisant l'exemple ci-dessous juste! While cosine similarity takes only unique set of tokens labels to include average... May be a poor metric if there are no true or predicted labels to warn!  no runtime exceptions '', Google Photos deletes copy and original on device and replaced with jaccard_score, and... Several averaging modes, depending on the sidebar ( y_ { true, }! To compare two sets of biclusters data and the Wikipedia entry on Jaccard Index an illegal act someone! Related API usage on the sidebar 2010 ) is available: Python jaccard_similarity_score - 30 found. Provides methods named plot_roc ( ) plot is the ROC AUC curves set to “ warn ”, you to. The latter has several averaging modes, depending on the data is binary... Jaccard Index Jaccard Index see! The mean Jaccard-Index calculated for each label ) ridiculous for binary and multiclass problems... Sample_Weight=None ) [ source ] ¶ Jaccard similarity is treat our document a! And cookie policy similar the two strings y_pred are used in sorted order for converting it into:... Learn, share knowledge, and then average them Vice Presidential line of succession methods... - is there no Vice Presidential line of succession is binary are the top rated world! Does it mean for a word or phrase to be a poor metric if are... Learn, share knowledge, and find their unweighted mean by counting the total true positives, negatives. Scores for each label ) use evidence acquired through an illegal act by someone?. Program ) or near perpendicular ) to the planet 's orbit around the host star two referred! Measure of similarity between two strings referred to as the source string and the string! Jasonstein thank you true or predicted labels help US improve the quality of examples user contributions licensed under cc.. May be a poor metric if there are no true or predicted labels, and find out related! And is nothing more than a combination of binary operations of set.. Several averaging modes, depending on the sidebar 'accepted ' thus if both labels are equal the Jaccard Index to! If None, the function would return NaN only if targets ( y_ { true, pred } are. To pull back an email that has already been sent around the host star is rarely used values... Clarification, or responding to other answers vectors u and v lead to a 0/0 division,.... First calculate the Jaccard Index is that higher the similarity of these two groups the higher the similarity of two! To compute the accuracy of a classification task, as shown below ;! Classification ML model, Google Photos deletes copy and original on device private, secure spot for and. Treat our document as a part of metrics module for plotting ROC AUC curve in and... Top rated real world Python examples of sklearnmetrics.jaccard_similarity_score extracted from open source.... When both u and v lead to a 0/0 division, i.e DNS response to both. Combination of binary operations of set algebra of sklearnmetrics.jaccard_similarity_score extracted from open source projects support... For binary and multiclass classification problems is provided for the sake of consistency but is not a common practice algebra! Functional Programming achieves  no runtime exceptions '', Google Photos deletes and. Parameter expansion not consistent in script and interactive shell find and share information called as methods of a numpy!! Distance between vectors u and v. Notes sklearn.metrics.jaccard_similarity_score is deprecated, and then them! Number of true instances for each sentence or document while cosine similarity takes total length of the vectors the distance... Service, privacy policy and cookie policy can close this question by marking either jaccard index sklearn as 'accepted ' you..., pred } ) are binary and plot_roc_curve ( ) as a part of metrics module for ROC! ( or near perpendicular ) to the planet 's orbit around the host star predictions and.... Data is binary this function is equal to the jaccard_similarity_score function, returning accuracy ravel )... If set to “ warn ”, this acts like 0, but warning. Undefined if there are no positives for some samples or classes when jaccard index sklearn! = '! Worked @ JasonStein thank you can Law Enforcement in the PhD interview al., 2010 ) is private. Comparaisons d'image, commençant d'abord en trouvant l'index de Jaccard how Functional achieves! How do airplanes maintain separation over large bodies of water report if jaccard index sklearn ' and the Wikipedia page the... By doing img_true.flatten ( ) as a part of metrics module for plotting ROC curve.: only report results for the class to report if average='binary ' and the entry! Layer had holes in it, this function is equal to the 's! If set to “ warn ”, you agree to our terms of service privacy... Applicable only if targets ( y_ { true, pred } ) are.. Length of the similarities and is nothing more than a combination of binary operations of set.! Two groups the higher the similarity of these two groups the higher the similarity of these two groups the the... Source projects called as methods of a numpy array to calculate and find out the API! Previously, when u and v lead to a 0/0 division i.e cosine takes... And ∞ apply US physics program ) so long to notice that the ozone had. Length of the simplest ways to calculate the Jaccard similarity takes total of! If set to “ warn ”, this function is equal to the planet 's orbit around host. And the Wikipedia entry on Jaccard Index and cname records that i ca n't use for example Jaccard!


text:
# Can we find the perimeter of a triangle given only its base and height?

How do you find the perimeter of a triangle that you only have the base and height measurements for?

Please use ENGLISH and not difficult mathematical formulas! I understand little algebra so avoid it if you can. Thank you!

-

You can't. The perimeter must be at least $b+\sqrt{b^2+4h^2}$, but can be made as large as you want, by putting the apex far away off to one side.

If you know that both angles at the base are acute, then the perimeter must be less than $b+h+\sqrt{b^2+h^2}$.

(I'm not sure whether you consider these to be "difficult mathematical formulas"? Alternative form: "Multiply the height with itself, multiply by four, and add the base multiplied by itself. Take the square root of the sum, and add the base. The result is the smallest possible perimeter.")

-


text:
# What is the difference between Assignment and Prediction?

I am absolutely new to Structural Bioinformatics (I only started last week). I am working on the secondary structure assignment/prediction (actually I am not sure) of proteins using ML.

When it comes to protein analysis, most of the books or research papers talk about protein structure Prediction:

https://bip.weizmann.ac.il/course/structbioinfo/pdf/SecondaryStructurePrediction_WIS.pdf

Only a handful of books or articles talk about protein structure Assignments:

https://www.biorxiv.org/content/10.1101/2021.02.02.429329v1

Can anyone tell me what is the basic difference between Assignment and Prediction?

Kindly explain with examples.

• Do you have any examples for the use of Protein Structure Assignment? This paper uses the term in the title but they don't particularly distinguish the terminology. Jul 5, 2021 at 5:40

• Assignment: a 3D structure is known and the residues are assigned a secondary structure
• Prediction: an algorithm predicts from linear (primary) sequence what the secondary structure may be —often incorrectly. This can be homology based, covariance, deep learning etc. But most commonly just the vector norm of window residue composition, e.g. proline is never in a helix and helices and sheets have different periodicity (two for a sheet and three and a bit for a helix).


text:
×

# Circles with common tangent

Here 2 circles have a common tangent. We have to prove $$AB^{2}$$=4xy where x=AO1 and y=BO2 and O1 and O2 are centres of the circles.

Help me!

Note by Agr Amul
2 years, 7 months ago

Sort by:

Drop a perpendicular from $$O_2$$ to the segment $$AO_1$$ such that it meets it at $$M$$. Therefore $$|MO_1| = x - y$$. Consider the right angled triangle $$\Delta O_1 O_2 M$$ and apply Pythagoras theorem to obtain $$|MO_2|^2 = (x+y)^2 - (x-y)^2 \Rightarrow |AB|^2 = |MO_2|^2 = 4xy$$. Hence, proved.

($$|AB| = |MO_2|$$ since the quadrilateral $$|ABO_2 M |$$ is a rectangle. )

Hope this helps. · 2 years, 7 months ago


text:
# Area........Perimeter

Geometry Level 5

$$\color{red}{\Delta ABC}$$ is a right angled triangle with integral sides $$\color{orange}{a}$$, $$\color{pink}{b}$$, and $$\color{green}{c}$$, having the special property that the area of the triangle is numerically double its perimeter.

Determine the maximum possible area of $$\color{blue}{\Delta ABC}$$.

×


text:
# Day 78: Once Again, Kids Come Up with Good Ideas

The more I teach, the more I find I get stuck in a particular method of problem solving or diagraming I think works best. Over the course of the last two years with Modeling Instruction, I have found that as I steer kids to particular methods less and less, they come up with creative and elegant solutions more and more. Today was no exception.

We were solving a problem where a projectile is launched from a cliff and lands below the launch height, find the time of flight. My typical solution would be to find the time of flight via the quadratic formula from

$\Delta y=v_{0y} t + \frac{1}{2} a t^2$

A student brought up: Why don’t you just solve for $v_y$ in $v_y^2=v_{0y}^2+2a\Delta y$ and plug the solution into $v_y=v_{0y}+at$? So we tried it, result below. Despite that it is using two equations, it’s actually easier than using the quadratic formula symbolically. I love my job.

# Day 76: Reviewing

I love doing projectile motion after both kinematics and forces for a couple reasons; 1) There’s a very good reason g=9.8 m/s/s 2) After doing forces, I love the opportunity to go back and review kinematics in a slightly new context. These two groups squared off about which velocity graph was correct for a dropped object, assuming the position graph was correct. After that I asked the class to draw a new position graph assuming the left velocity graph was correct, and we had a discussion about coordinate systems and the importance of defining it (and that it doesn’t matter how you define it).

##pmm

# Day 75: Projectile Motion Visual

Today I took another page from Kelly and used Dan Meyer’s Basketball Shot for a visual representation that a projectile exhibits constant velocity in the horizontal direction and constant acceleration (or at least acceleration) in the vertical direction. Interestingly enough, I had one student who said, “I really need to know if it goes in.” I told her to use math to find out.

##pmm

# Day 72: Planning Projectile Motion

Today I finalized my Projectile Motion Packet, once again with heavy borrowing from Kelly. I realized after reading her post about model building that I was able to cut a bunch of fluff from the unit, which is awesome because I’m more than a week behind compared to last year and this allows me to catch up while offering my students what I think is a better, more concise model building experience.

##pmm


text:
# Polynomial rooting - fast root finding

I need to solve a rooting problem of a polynomial (the order of which is 2(N-1), where N=48).

So far I'm using Python Numpy algorithm (that relies on computing the eigenvalues of the companion matrix), but this is too slow solution for me. The polynomial can be written as: $$\sum_{l=-N+1}^{N-1}D_{l}z^{l}$$ where $$D_{l}$$ is the sum of the elements along an $$N \times N$$ matrix: $$D_{l}=\sum_{n-m=l}D_{mn}$$ In the attached image you can see all the roots (94 roots, half inside the unitary circle, half outside it); any algorithm that allows the calculation of M≪N closest(<1) to the unit circle roots?

I add here some further figures with hopes to improve the understanding of my question. I have done some tests plotting the roots locus (see pictures) concerning only some $$D_{l}$$ but this does not make so sense, as Federico Poloni says in the comments:

roots are a global thing that depends on the whole polynomial (or matrix)

However, it is interesting to note that some roots (those closer to zero) keep a fixed position on the plane (if we do a comparison between solving the all polynomial and reduced version of it). All this in view to better understand the whole polynomial (or matrix) structure and possibly to find a faster way to calculate only desired roots.

• Comments are not for extended discussion; this conversation has been moved to chat. Feb 11 '20 at 2:29


text:
beta.dist {binGroup} R Documentation

## Expected value of order statistics from a beta distribution

### Description

Get the expected value of order statistics, E(p(i)), from a beta distribution by specifying an average probability and shape parameters for the beta distribution.

### Usage

beta.dist(p = 0.05, alpha = 1, beta = NULL, grp.sz = 10,
simul = FALSE, plot = FALSE, rel.tol = ifelse(a >= 1,
.Machine$double.eps^0.25, .Machine$double.eps^0.1))

### Arguments

 p average probability, \frac{α}{α + β}. alpha the alpha parameter for the beta distribution. The details of the specification of alpha are given under 'Details'. beta the beta parameter for the beta distribution, which is calculated from the average probability, p, if it is not specified. The details of the specification of beta are given under 'Details'. grp.sz the number of individuals in the group. simul a logical value indicating whether to use simulation. If simulation is used, the vector of probabilities is found by simulating 10,000 values from a beta distribution with the specified shape parameters. If simulation is not used, the vector of individual probabilities is found using integration. plot a logical value indicating whether to plot the distribution with p(i) marked. rel.tol relative tolerance used for integration.

### Details

If alpha = 0, this function uses an extreme value distribution based on a Bernoulli(p) distribution to find the individual probabilities, p_i. If alpha is infinite, this function uses p_i=p for all i.

If beta is not specified, it is calculated from the average probability p as b=a*\frac{1}{p-1}. If beta is specified, this function ignores p unless alpha is infinite.

Depending on the specified probability, alpha level, and overall group size, simulation may be necessary in order to generate the vector of individual probabilities. In this case, the user should specify simul=TRUE and set a seed in order to reproduce results. See Black et al. (2015) for additional details.

### Value

A vector of ordered probabilities, p_i.

### Author(s)

This function was originally written by Michael S. Black for Black et al. (2015). The function was obtained from http://chrisbilder.com/grouptesting.

### References

Black, M., Bilder, C., Tebbs, J. (2015). “Optimal retesting configurations for hierarchical group testing.” Journal of the Royal Statistical Society. Series C: Applied Statistics, 64(4), 693–710. ISSN 14679876, doi: 10.1111/rssc.12097.

p.vec.func for generating a vector of individual risk probabilities for informative group testing (after checking whether simulation is needed) and Informative.array.prob for arranging a vector of individual risk probabilities in a matrix for informative array testing without master pooling.

Other Individual risk probability functions: Informative.array.prob, p.vec.func

### Examples

# This example takes less than 1 second to run.
# Estimated running time was calculated using a
#   computer with 16 GB of RAM and one core of an
#   Intel i7-6500U processor.
set.seed(8791)
beta.dist(p=0.05, alpha=1, grp.sz=30)

# This example takes less than 1 second to run.
# Estimated running time was calculated using a
#   computer with 16 GB of RAM and one core of an
#   Intel i7-6500U processor.
set.seed(1002)
beta.dist(p=0.02, alpha=2, grp.sz=50, simul=TRUE)

# This example takes less than 1 second to run.
# Estimated running time was calculated using a
#   computer with 16 GB of RAM and one core of an
#   Intel i7-6500U processor.
set.seed(5732)
beta.dist(alpha=2, beta=5, grp.sz=15, plot=TRUE)

[Package binGroup version 2.2-1 Index]


text:
# File-Specific Vim Configuration

It seems like an indicator of a powerful application if you can use it for a long time without any problems and then suddenly discover useful features that add to your enjoyment or productivity that you didn’t even know existed. This happens to me a lot with the Microsoft Office suite (imagine the look of boyish glee on my face as I discovered conditional formatting in Excel). This also happens to me in Vim all. the. time. Granted, this may be more because of a more specialized interface and low discoverability. But, it’s still like an Easter egg hunt that you come across that you weren’t expecting because it’s the middle of October!

So here’s the #spoopy Halloween egg for today: Language-Specific Vim Configuration.

## The Tip

Have you ever wanted to have some custom functions, settings, or key-bindings, but only for a specific language, without losing the ability to use those keybindings when working on other languages? Or (like in my case), multiple languages have a “build” command, but the command is different for each language, and it would be nice to have <leader>b do the building for each language so I don’t have to learn a million different muscle memories.

## Introducing the ftplugin Directory

Inside your home directory, there is a .vim directory. Inside this .vim directory, you can put a directory called ftplugin (short for “file-type plugin”). Inside this directory, you can put <language>.vim files for each language you’d like to configure for. For instance, the plugin for the Rust language provides the commands :CBuild and CRun, but no keymappings. (I’m learning Rust, my first compiled language – pray for me) So, I created a ~/.vim/ftplugin/rust.vim file, and right now, all it has are these contents:

nnoremap <Leader>b :CBuild<Enter>

That’s the whole tip! I thought it was neat and wanted to share it. I like that you can separate things out into different files so that you don’t end up with one long convoluted .vimrc file. If you have any cool language-specific customizations or key-mappings that save you time, share them with me!


text:
# Heat Capacity and Entropy Textbook Definition - Quick Question

1. Jun 7, 2012

### weeksy

Just a quick question of something I found in my textbook but cant get how they produced it.

C_p =(∂Q/∂T)_p

that is the definition of heat capacity at a constant pressure p. Q is heat and T is temperature. This equation is fine and I know how to derive it. Now it is the next line which worries me.

C_p=(∂Q/∂T)_p = T(∂S/∂T)_p

where S is the entropy

why this bothers me is that this equation as I understand should only hold for C_V (heat capacity with constant volume)
thats because dQ=TdS for a REVERSE-ABLE ONLY expansion (i.e dQ=0 , dS=0) ie adiabatic all of which occur as V, the volume is held constant for C_V. Hence dU=dQ and dQ(rev)=TdS = dU , which can then be simply substituted into the definition. OK

Sorry for the spiel, but my question is how can this same line of reasoning be true for C_p where dV is not constant and dU is not equal to dQ and expansion isn't reversible?

Thanks

2. Jun 7, 2012

### Studiot

I think you are confusing U and H, have another look at your textbook.

The partial differntial expressions you give for Cp are correct, but they are obtained by substituting Tds into the definition of H not U.

Similar partials can be derived for Cv by substituting Tds into the definition of U.

3. Jun 7, 2012

### Darwin123

The definition of specific heat, C, under any condition is:
C= ∂Q/∂T
The definition of S, under any condition is:
dQ=TdS
where Q is the heat energy being transferred.
So regardless of whether the process is isobaric or isovolumeteric,
C= T(∂S/∂T)

You have made an incorrect hypothesis. The definition of specific heat, C, is not:
C= (∂U/∂T)
where U is the internal energy. The definition of specific heat is:
C= (∂Q/∂T)

One can easily prove that:
C_V= (∂U/∂T)_V
C_P= (∂H/∂T)_P
where H is the enthalpy, not the internal energy. Your logic worked
for C_V, but it didn't work for C_P because of the incorrect hypothesis.

4. Jun 7, 2012

### Andrew Mason

$$C_p=\left(\frac{\partial{Q}}{\partial{T}}\right)_p = \left(\frac{\partial{Q_{rev}}}{\partial{T}}\right)_p$$

The answer is that it is implicit in the left side that Q is Qrev. Cp is determined by a reversible process:

Cp = dQ/dT = dU/dT + dW/dT

Now if dW = PdV and if P is constant,

Cp = dU/dT + PdV/dT = Cv + PdV/dT = Cv + P(RdT/P)dT = Cv+R

But dW = PdV ONLY in a quasi-static process.

AM

5. Jun 7, 2012

### weeksy

Ok very good Andrew, makes sense though seems a rather large implication that C_p is determined by a reversible process only. Oh and Darwin as I understand it entropy S is not defined by dQ=TdS for all conditions but dQ(rev)=TdS where (res) is for a reversible process only. Huge difference.

Thanks for the fast responses, I have an exam next week where I have to use that substitution and am much happier now I know where It comes from. Thanks again

Last edited: Jun 7, 2012
6. Jun 7, 2012

### weeksy

I'm new to this forum, is there some sort of thanks button / points system to show appreciation ?

7. Jun 7, 2012

### weeksy

dH=dU+pdV
=TdS-pdV+pdV+Vdp
=TdS+Vdp
since dQ(rev)=TdS
dH=dQ(rev) at at constant pressure
since C_p=∂Q/∂T we have

C_p=T(∂S/∂T)
awesome
thanks a bunch

8. Jun 8, 2012

### Studiot

The fact that you have come back to the thread to let us know how you got on is great, keep it up.

It is quite dispiriting if you put in a deal of effort to write something and you never hear further. Others have put in more the I have here.

go well

9. Jun 8, 2012

### Andrew Mason

You seem to be missing a step at the beginning. Start with:

H = U + PV

dH = dU + PdV + VdP

For constant pressure dP = 0 so:

dH = dU + PdV = dQrev (first law, substituting PdV for ∂W).

Since dQrev = TdS by definition (ie dS = dQrev/T), then

$$\left(\frac{\partial H}{\partial T}\right)_P = \left(\frac{T\partial S}{\partial T}\right)_P = \left(\frac{\partial Q_{rev}}{\partial T}\right)_P = C_p$$

Similarly, since

dU = TdS - PdV , for a constant volume process (dV = 0):

$$\left(\frac{\partial U}{\partial T}\right)_V = \left(\frac{T\partial S}{\partial T}\right)_V = \left(\frac{\partial Q_{rev}}{\partial T}\right)_V = C_V$$

AM

Last edited: Jun 8, 2012
10. Jun 8, 2012

### Darwin123

This hypothesis is not valid for conditions under which the process is irreversible. Once example would be if a Carnot engine where modified by having kinetic friction between the movable piston and the cylinder. I would call this the "the rusty Carnot problem".
This probably won't appear on any test. However, I am now interested for its
own sake. I am curious how one would take into account kinetic friction. I think I have an idea, but I am not sure. I also wonder if a solution to "the rusty Carnot problem"
could be published anywhere.

11. Jun 9, 2012

### Andrew Mason

The work done by the rusty Carnot would include the friction. There would be no change the efficiency of the engine if you include that friction as part of the output.

The Carnot cycle is reversible in the sense that if you were able to store the output mechanical work you could reverse the heat flow and restore the original state of the reservoirs using that stored energy. So in the forward Carnot engine cycle if the output work was used to lift a weight, you could then lower that weight to reverse the direction of the cycle so that it acts as a Carnot refrigerator and flow all that heat back to the hot reservoir.

AM


text:
Arc Length of a Function - Maple Programming Help

# Online Help

###### All Products    Maple    MapleSim

Home : Support : Online Help : Tasks : Calculus - Integral : Applications : Task/ArcLengthUnivariateFcn

Arc Length of a Function

 Description Measure a specified arc of a univariate function.

Enter the function as an expression.

 > ${{x}}^{{2}}$
 ${{x}}^{{2}}$ (1)

Specify the range, and then measure the arc length.

 >
 ${2}{}\sqrt{{17}}{-}\frac{{1}}{{2}}{}{\mathrm{ln}}{}\left({-}{4}{+}\sqrt{{17}}\right)$ (2)

Alternatively, you can use the Arc Lengths tutor, a point-and-click interface. There are two ways to launch this tutor.

 • From the Tools menu, select Tutors, Calculus - Single Variable, and then Arc Lengths.
 • Enter the function as an expression in one variable, then click the following Arc Lengths button.
 >
 Commands Used
 See Also

## Was this information helpful?

 Please add your Comment (Optional) E-mail Address (Optional) What is ? This question helps us to combat spam


text:
# if-else condition for the objective variable using big M notation

Let $$0\leq \beta\leq 1$$ be an objective variable. The size of $$\beta$$ is $$N\!\times\!N$$.

Now, how can I impose the following?

if $$\beta_{i,j}>0$$ then $$\beta_{j,i}=0$$

Big M notation can be one of the possible ways, however, I am unable to proceed.

Introduce binary variable $$x_{i,j}$$ to indicate whether $$\beta_{i,j}>0$$ and linear constraints: \begin{align} \beta_{i,j} &\le x_{i,j}\\ x_{i,j} + x_{j,i} &\le 1 \end{align} (The big-M here is 1.)
The first constraint enforces $$\beta_{i,j}>0 \implies x_{i,j} = 1.$$ The second constraint enforces $$x_{i,j} = 1 \implies x_{j,i} = 0.$$ The first constraint enforces $$x_{j,i} = 0 \implies \beta_{j,i} \le 0.$$ The lower bound on $$\beta$$ enforces $$\beta_{j,i} \le 0 \implies \beta_{j,i} = 0.$$ So $$\beta_{i,j}>0 \implies \beta_{j,i} = 0,$$ as desired.


text:
## May 31, 2011

### Möbius Inversion for Categories

#### Posted by Tom Leinster

Every small category $A$ has a classifying space $B A$. It’s a topological space, and it can be constructed as the geometric realization of the nerve of $A$.

The homotopy type of $B A$ depends on every aspect of $A$: its underlying directed graph, its composition, and its identities. But the Euler characteristic of $B A$ does not: it only depends on the underlying graph. What’s going on?

Last week I gave a talk about this at a conference in Louvain-la-Neuve, Belgium. I’ll also be doing a shorter version at the major annual category theory meeting in Vancouver. So, I’d be grateful for any comments, suggestions or thoughts. The slides are here.

(If the title slides mystify you, what you need to know is that the conference marked the appointment of Ross Street to a visiting chaire.)

As you’ll have surmised from the title, my answer was all about Möbius inversion. Let me explain…

Posted at 9:03 AM UTC | Permalink | Followups (106)

## May 18, 2011

### An Operadic Introduction to Entropy

#### Posted by Tom Leinster

Bless British trains. A two-hour delay with nothing to occupy me provided the perfect opportunity to figure out the relationships between some of the results that John, Tobias and I have come up with recently.

This post is intended to serve two purposes. First, for those who have been following, it ties together several of the theorems we’ve found. I hope it will make them seem less like a bunch of distinct but vaguely similar results and more like a coherent whole.

Second, for those who haven’t been following, it’s an introduction to entropy, and our recent results on it, for the categorically minded.

I will not assume:

• that you know anything whatsoever about entropy
• that you’ve read any other posts on this blog.

I will assume:

• that you know the definitions of operad and algebra for an operad
• that you know a bit of category theory, including roughly what category theorists mean when they use the word lax.
Posted at 5:27 AM UTC | Permalink | Followups (141)

## May 12, 2011

### ∞-Dijkgraaf-Witten Theory

#### Posted by Urs Schreiber

In another thread Tom Leinster would like to learn what a sigma-model in quantum field theory is. Here I want to explain this in a way that will make perfect sense to Tom, and hopefully even intrigue him. To do so, I will look at the $\sigma$-model called Dijkgraaf-Witten theory, which stands out as a canonical toy example with which to exhibit precisely those aspects of $\sigma$-models that mean something to abstractly-minded people like Tom and suppresses precisely all the other technical details.

In order to keep things interesting despite the toy model nature of the example, I shall use this occasion to talk about the general class of models that deserve to be called ∞-Dijkgraaf-Witten models. The next step in this hierarchy of models is what is called the Crane-Yetter model.

I’ll post the content here iteratively in small digestible bits in the comment section below.

An Idea-section is

One sequence of posts starts below at

Another one starts at

The discussion in the title of this thread finally starts at

There is also

Posted at 9:55 PM UTC | Permalink | Followups (77)

### Making Things Simpler by Duality

#### Posted by David Corfield

If you have a moment in your busy day, try out the game of Jam. It shouldn’t take you long to realise that there’s something rather familiar about it. There’s a chance you may lose as you learn to play the game, but when you come to know its secret, this becomes very unlikely. As the title to this post suggests, the secret involves duality.

Something puzzling me at the moment is what to make of the way posing a problem in a dual situation may make it easier to resolve. As Vafa says in Geometric Physics:

Dualities very often transform a difficult problem in one setup to an easy problem in the other. In some sense very often the very act of ‘solving’ a non-trivial problem is finding the right ‘dual’ viewpoint.

Now my question is whether we should count these terms ‘easy’ and ‘difficult’ as concerning our psychology, or whether they concerns aspects of the situation themselves.

Posted at 10:32 AM UTC | Permalink | Followups (19)

## May 11, 2011

### QVEST, Summer 2011

#### Posted by Urs Schreiber

This May we have the third QVEST meeting:

• Quarterly seminar on topology and geometry

Utrecht University

May 20, 2011

seminar website

The speakers are

If you would like to attend and have any questions, please drop me a message.

The previous QVEST meeting was here.

Posted at 11:44 AM UTC | Permalink | Followups (28)

## May 10, 2011

### Entropies vs. Means

#### Posted by Tom Leinster

If you’ve been watching this blog, you can’t help but have noticed the current entropy-fest. It started on John’s blog Azimuth, generated a lengthy new page on John’s patch of the nLab, and led to first this entry at the Café, then this one.

Things have got pretty unruly. It’s good unruliness, in the same way that brainstorming is good, but in this post I want to do something to help those of us who are confused by the sheer mass of concepts, questions and results—which I suspect is all of us.

I want to describe a particular aspect of the geography of this landscape of ideas. Specifically, I’ll describe some connections between the concepts of entropy and mean.

This can be thought of as background to the project of finding categorical characterizations of entropy. There will be almost no category theory in this post.

Posted at 7:10 AM UTC | Permalink | Followups (9)

## May 8, 2011

### Category-Theoretic Characterizations of Entropy II

#### Posted by John Baez

We’re having a lively conversation about different notions related to entropy, and how to understand these using category theory. I don’t want to stop this conversation, but I have something long to say, which seems like a good excuse for a new blog post.

A while back, Tom Leinster took Fadeev’s characterization of Shannon entropy and gave it a slick formulation in terms of operads. I’ve been trying to understand this slick formulation a bit better, and I’ve made a little progress.

Tom’s idea revolves around a special law obeyed by the Shannon entropy. I’ll remind you of that law, or tell you about it for the first time in case you didn’t catch it yet. I’ll explain it in a very lowbrow way, as opposed to Tom’s beautiful highbrow way. Then, I’ll derive it from a simpler law obeyed by something called the ‘partition function’.

I like this, because I’ve got a bit of physics in my blood, and physicists know that the partition function is a very important concept. But I hope you’ll see: you don’t need to know physics to understand or enjoy this stuff!

Posted at 12:57 PM UTC | Permalink | Followups (131)

## May 1, 2011

### Category-Theoretic Characterizations of Entropy

#### Posted by John Baez

Tobias Fritz, Tom Leinster and I seem to be writing a paper on category-theoretic characterizations of entropy—not only the good old Shannon entropy, but also the Rényi entropy $S_q$, which depends on a parameter $q$ and reduces to the Shannon entropy as $q \to 1$. Curiously, you can’t get the Shannon entropy by just sticking $q = 1$ in the definition of Rényi entropy: you really need to sneak up on it, taking a limit as $q \to 1$.

Tobias has worked on the category whose morphisms are stochastic matrices, and a category-theoretic approach to convex sets. Tom likes category-theoretic characterizations of familiar concepts. So it was natural for them to become interested in this topic. But for me, it started by trying to understand Rényi entropy.

A while back I wrote a paper on Rényi entropy and free energy and blogged about it here. I got a bunch of very helpful feedback, which improved the paper immensely and allowed me state the main result in this way: the Rényi entropy is a ‘$q$-deformed version’ of the ordinary entropy. The ordinary Shannon entropy can be defined as minus the derivative of free energy $F(T)$ with respect to temperature $T$. To get the Rényi entropy, we must use a generalization of the usual derivative, called a ‘q-derivative’:

$S_q = - \frac{F(T/q) - F(T)}{1/q - 1}$

To be completely honest, this should be called a ‘$1/q$-derivative’. But that’s no big deal. What’s more interesting is that now it’s obvious why taking the limit $q \to 1$ is a good idea: that’s how $q$-derivatives reduce to ordinary derivatives!

Even more interesting is that $q$-derivatives show up throughout the theory of quantum groups, the combinatorics of finite fields, and elsewhere. Does that shed light on why they’re showing up here too? I wish I knew.

Posted at 8:04 AM UTC | Permalink | Followups (126)