text:
## Introduction

At the start an ominous warning is given, one which I have experienced all to many times. Probability is often very counter intuitive. It’s easy to make mistakes, you can’t trust your intuition and you need to stay principled to be sure. These notes are my attempts at staying principled.

## Why study probability

As a data scientist I use probability and statistics every day. But most of it is relatively simple. Yet it would be nice to have a very firm grounding of all statistics because of it usefulness in so many situations whenever data is concerned. Therefore my reasoning is mainly a better foundation for statistics and a Computer science. The fact that it is used a lot in Finance and other sciences is an added bonus.

Strategies used in this book: - Simulation (Also see hacker-statistics) - Biohazards: get a feel for the common pitfalls - Sanity checks: using multiple methods for verification

## Pebble World

We have a sample space $$S$$ containing all the outcomes of an experiment. We call a subset of the set an event (can be one or more outcomes). If the actual outcome is in the subset, we say that that event has occured.

We can use set theory methods. like intersections, unions, complements to create new subsets of the experiment. This means combining events. See also de morgan laws (2 examples of combining outcomes are given in the book)

## Naive definition of probability

Naive definition (relies on many assumptions like each outcome being equally likely). Say we want to know the probability of A. Let a be the number of outcomes favorable to A. Let s be the total number of outcomes in sample space $$S$$.

p_naive <- function(a, s) a / s

Note that our set rules, like the complement, also holds. So to calculate the complement.

p_naive_complement <- function(a, s) 1 - p_naive(a, s)

Because of the restrictions (making it naive) it is often not applicable. Some cases where it is applicable.

• Symmetry: if the elements are symmetrical in it’s shape (think geometric shapes). (Note that it still depends on the next design point)
• By design: if the design of the experiment is made in such a way that we want to have equal probability for each case. Note here that this can be hard to make happen in real life.
• When we use it just as a comparison to reason about what probabilities would come out the experiment if the restrictions would hold.

## Counting

Check out books and sites on Combinatorics for a more thorough mathematical view on counting.

The multiplication rule: Combine multiple experiments by multiplying the counts of the different experiment outcomes.

Note that although it is easy to think about the experiments in a certain order, this is not needed for the multiplication rule to work.

This can even be used for problems in which you need to find the number of possibilities for a number 1, 2, 3.

Example: We have 10 train wagons. How many different ways to select numbers 1, 2, 3? $$10 * (10 - 1) * (10 - 2) = 720$$

The multiplication rule leads to the counting of subsets.

Example: We have a combined experiment of

1. ball or no ball
2. card or no card
3. coin or no coin

Each of these has 2 outcomes so the combined number of probabilities would be $$2 * 2 * 2 = 2^{3}$$. Now if we think of each of the individual as having anything or not (maybe it can be represented by a having a certain number of not). It can be used for any set of elements and the question of how many subsets are there.

If the experiments are actually sampling from a the same set again and a again we have the calculation for sampling with replacement. This only works if order matters. Having a result for experiment 2 and the same result for experiment 3 mean different things.

outcomes_with_replacement <- function(n, k) {
x <- n ** k
return(x)
}
# Number of ways to obtain a sample size of k (different order would be different way)

As seen before for counting outcomes with replacement we need to subtract the previously chosen elements from the set. $$n(n-1)(n-2)$$ in a previous train example and in general $$n(n-1) \dots (n-k+1)$$. Then we need to add a guard that selecting more elements than are in a set is impossible.

outcomes_without_replacement <- function(n, k) {
# Only works for k bigger than 0 (it needs to select something)
if (k > n) {
return(0)
}
res <- 1
for (i in 0:(k - 1)) {
res <- res * (n-i)
}
return(res)
}

outcomes_without_replacement(10, 10)
## [1] 3628800
factorial(10)
## [1] 3628800

And we can also see that if $$n$$ is the same size as $$k$$ it is a factorial calculation of $$n! = n (n-1) \dots 1$$.

Now to use our counting to calculate probabilities by using our naïve definition of probability. To calculate the birthday paradox: The number of ways to select $$k$$ birthdays (which can take any day of the year so with replacement) will be used as the sample space $$S$$. Now it is much easier to calculate no birthday overlap than one or more overlaps, so we will use the set rules and in the end do $$1 -$$ probability of no birthday overlap.

p_no_birthday <- function(k) outcomes_without_replacement(365, k) / outcomes_with_replacement(365, k)
p_birthday <- function(k) 1 - p_no_birthday(k)
p_birthday(23)
## [1] 0.5072972
pbirthday(23) # R buildin
## [1] 0.5072972

When using counting it is important to label the different objects (or sometimes it is easier to think of labeling the different experiments). If we look back at the train example, having a train at position 1 means something different as having that train at position 2. In this example it is clear, but a mistake can be made when we talk about an experiment with 2 dice (combination of 2 experiments) and we would not keep the dice results apart (See Leibniz’s mistake).

Sometimes we have to adjust for counting too many correct outcomes. One place where this happens is if order does not matter. For instance for selecting two pots of soup to pour into the soup from 8 different pots (where order of soup does not matter): $$8 * 7 = 56$$ different possibilities if order mattered. But because any outcome of pot a and pot b is the same as pot b and pot a (ab is ba) we can divide by 2. Note that we also can’t select the same object twice for any of these cases.

The book also shows an example of layering the overcount-correction. First for sampling a team of 2 players out of 4. Then again for sampling 2 teams out of the 4 players (divide by 2 again since knowing one team means knowing the other team).

binomial_coeff <- function(n, k) {
overcounted <- outcomes_without_replacement(n, k)
# we overcount by the total ways of picking k since we do not care about the order
total_ways_picking <- factorial(k)
out <- overcounted / total_ways_picking
return(out)
}

binomial_coeff(100, 2)
## [1] 4950
choose(100, 2)  # R buildin
## [1] 4950

The book has nice examples of how this applies to word permutations and calculating full house in Poker. The book also mentions Newton-Pepys problem which Norvig showed nicely in his Probability notebook.

## Story proofs

$${n \choose k} = {n \choose n - k }$$ : Think about a committee, choosing who is not going to be on.

$$n{n - 1 \choose k - 1} = k{n \choose k}$$ : Picking a team captain. Left is picking the team captain ($$n$$) then picking the rest of the team. Right is first picking the k team members ($${n \choose k}$$) and then selecting the captain afterwards from the team ($$k$$).

$${m + n \choose k} = \sum_{j=0}^{k}{m \choose j}{n \choose k - j}$$ : Vandermonde’s. Think of a selection from 2 groups. $$m + n$$ Is the size of the combined groups. On the right hand side we sum over each of the posibilities of selecting from one group and the other.

$$\frac{(2n)!}{2^{n} \cdot n!} = (2n-1)(2n-3) \cdots 3 \cdot 1$$ : $$n$$ Partnerships for $$2n$$ people. Left hand side: we look for a random order of the people and then form pairs of every 2 people. Since the order of the pairs does not matter we overcount by $$n!$$. And because the order within a pair also does not matter we overcount by $$2^{n}$$. Right hand side: How many people person 1 can select from, times how many people then person 2 can select from, etc.

## General definition of probability

Few simple axioms

1. $$P(\emptyset) = 0$$ (Empty set)
2. $$P(S) = 1$$ (Complete experiment’s event space)
3. If $$A_{1}$$ and $$A_{2}$$ are mutually exclusive events (meaning no intersection at all): $$P(\bigcup_{j=1}^{\infty}A_{j}) = \sum_{j=1}^{\infty}P(A_{j})$$

Some properties for any events $$A$$ and $$B$$

1. $$P(A^{c}) = 1 - P(A)$$ - (Classic set complement)
2. If $$A \subseteq B$$ then $$P(A) \leq P(B)$$
3. $$P(A \cup B) = P(A) + P(B) - P(A \cap B)$$

This last one is actually taking account of overcounting the part where A and B intersect. If there were 3 event-outcome spaces which overlap. then you would subtract all 3 pairs and add the intersection of all 3 again since you both added and subtracted it 3 times leaving it at 0. This is call inclusion - exclusion. Useful for when events are not disjoint. Full rule:

$$P(\bigcup_{i=1}^{n}A_{i}) = \sum_{i}P(A_{i}) - \sum_{i<j}P(A_{i} \cap A_{j}) + \sum_{i<j<k} P(A_{i} \cap A_{j} \cap A_{k}) - \cdots + (-1)^{n+1}P(A_{1} \cap \cdots \cap A_{n})$$

## Matching problem simulation

De Montmort’s Matching problem is a difficult problem described in Example 1.6.4 about calculating the change of winning in a game. In this game you win if the nth card you pull (sample without replacement) is number n (given that you have each card a unique number between 1 and $$n$$)

# 52 cards
n <- 100
perform_game <- function(n) {
ordered_sample <- sample(n)
correct_vector <- ordered_sample == (1:n)
return(sum(correct_vector) >= 1)
}
perform_game(n)
## [1] TRUE

Now we can repeat this experiment to get some probability estimates.

test_repeats <- 10^4
repeat_vector <- replicate(test_repeats, perform_game(n))
# total number of success divided by total number of tries
sum(repeat_vector) / test_repeats
## [1] 0.6277

## Birthday problem simulation

Just like previous problem we can also take a simulation based approach to finding the birthday results

n_people <- 23
perform_test <- function(p) {
birthday_dates <- sample(365, p, replace=TRUE)
# tabulates takes a vector and interprets them as indices which it will increment of a (bigger) vector
birthday_vector <- tabulate(birthday_dates)
double_or_more_birthdays <- sum(birthday_vector >= 2)
return(double_or_more_birthdays >= 1)
}
perform_test(n_people)
## [1] FALSE

Again we can repeat the experiment

test_repeats <- 10^4
repeat_vector <- replicate(test_repeats, perform_test(n_people))
sum(repeat_vector) / test_repeats
## [1] 0.5073

And we can compare it to what R’s buildin function says.

p_birthday(n_people)
## [1] 0.5072972

### Question 8

The number of ways to create teams.

Note that the teams do not have an ordering or labeling within the team and also the teams themselves aren’t ordered or labeled.

A: Split 12 people in 3 teams of 5, 5, 2

The solution is to split it into smaller problems and account for overcounting. On an individual problem, using binominal coefficient already accounts for theovercounting that happens when taking without replacement when order does not matter. Then every sub-problem can also be done in another order so we divide by the ways in which we can do those. Lastly, the 3rd (non-)team is not a sub-problem because that team is already set once the other 2 are decided.

total_people <- 12
team_a <- 5
team_b <- 5
(choose(total_people, team_a) * choose((total_people - team_a), team_b)) / factorial(2)
## [1] 8316

A second way of looking at it could be to say we pick each spot individually and then divide by the overcounting of each of the teams and then account for combination of the 2 teams of 5

team_c <- 2
indivual_positions_team <- factorial(total_people)
team_a_overcount <- factorial(team_a)
team_b_overcount <- factorial(team_b)
team_c_overcount <- factorial(team_c)
indivual_positions_team / (team_a_overcount * team_b_overcount * team_c_overcount * factorial(2))
## [1] 8316

We will do the same for B: Split 12 people up in 3 teams of 4

In this case because we can swap all 3 of the teams out for each other we can divide by factorial(3)

total_people <- 12
team_a <- 4
team_b <- 4
(choose(total_people, team_a) * choose((total_people - team_a), team_b)) / factorial(3)
## [1] 5775

Or with method 2: all the team overcounts are the same

team_overcount <- factorial(4)
indivual_positions_team / ((team_overcount ** 3) * factorial(3))
## [1] 5775

### Question 9

We have a plane with discrete locations called points. How many paths are there between point $$0,0$$ to point $$110, 111$$. The only permitted movement is one unit up or one unit right.

A: We need to go (in total) 110 times right and 111 up. In how many ways is this possible (going over a grid)

A way to look at this is to order 110 right arrow characters, in a long list of 110 right arrow + 111 up arrow characters.

choose((110 + 111), 110)
## [1] 1.802617e+65

B: Now we have to go through the point (110, 111) and end up in (210, 211).

Now the approach is to use the multiplication rule. The old amount of ways to get to (110, 111) times the amount of ways to go from (110, 111) to (210, 211)

leg2_up <- 211 - 111
leg2_right <- 210 - 110
leg1_ways = choose((110 + 111), 110)
leg2_ways = choose((leg2_up + leg2_right), leg2_right)
leg1_ways * leg2_ways
## [1] 1.632243e+124

### Question 15

A Story proof is needed for $$\sum_{k=0}^{n}{n \choose k} = 2^{n}$$

The left hand side can be interpreted as the number of subsets in n (See Example 1.4.4). The right hand side can be seen as a sum, where for each k it finds the amount of different subsets possible (how many ways to choose k from n, see Definition 1.4.12). Then because we sum over all different possible k values (k < 0 would lead to 0 and k > n would also lead to 0) the can be seen as equal.

### Question 16

First the algebraic solution:

$${n \choose k} + {n \choose k-1} =$$ $$\frac{n!}{(n-k)!k!} + \frac{n!}{(n-k+1)!(k-1)!} =$$ $$\frac{n!}{(n-k)!k!} + \frac{n!k!}{k!(n-k+1)!(k-1)!} =$$

Given that $$\frac{k!}{(k-1)!} = k$$

$$\frac{n!}{(n-k)!k!} + \frac{n!k}{k!(n-k+1)!} =$$

Given that $$\frac{n!}{(n-k)!} = \frac{n!(n-k+1)}{(n-k+1)!}$$

$$\frac{n!(n-k+1)}{k!(n-k+1)!} + \frac{n!k}{k!(n-k+1)!} =$$ $$\frac{n!(n+1)}{k!(n-k+1)!} = {n+1 \choose k}$$

Story solution. We introduce a president to the whole set of people. Now we either select this president for our selection, or not (2 distinct possibilities). If we do, there is a single way of picking the president and $${n \choose k-1}$$ ways of picking the rest. If we don’t then we are sure that it won’t be the president and we pick the group as if nobody was introduced: $${n \choose k}$$

### Question 20

A: A story proof. Our newly sized total group could be ordered by age. We could simply say we pick the oldest for the extra selection needed, and the rest would be picked using the old fashioned method (ie. $${n \choose k}$$). But we could have also picked the n - 1 oldest. Since we have already counted picking the oldest, we know this person is not going in the group, but the person before is going in the group. That means we still need $$k$$ but we have 1 less to select from. We can continuously count the ways we can pick the person younger than the previously oldest person who is selected, creating a sum of all possibilities (as long as the group-to-select-from size stays bigger than the selection size, in the other cases no selection is possible)

$${n+1 \choose k+1} = \sum_{j=k}^{n}{j \choose k}$$

B: We can write down taking $$k$$ from $$n$$ with replacement as $${n + k - 1 \choose k}$$ So picking 40 bears from 5 delicious flavours means $${5 + 30 - 1 \choose 30}$$.

Now for some $${5 + i - 1 \choose i} = {4 + i \choose i} = {4 + i \choose 4}$$ (Because of complement).

$$\sum^{50}_{i=30}{4 + i \choose 4} = \sum^{54}_{i=34}{i \choose 4} = \sum^{54}_{i=4}{i \choose 4} - \sum^{33}_{i=4}{i \choose 4}$$

Now we can fill in the formula from A to get:

choose(55, 5) - choose(34, 5)
## [1] 3200505

### Question 24

This question is about a family with 6 children, 3 boys and 3 girls. Since we already know in advance how many boys and girls there are we can reformulate the question into creating permutations of the letters “BBBGGG” where the location in the word means in what order the children are born.

Our total would be positive (only this ordering is valid, any change in ordering would make the answer invalid). Divided by the total number of ways to order the boys and girls.

1 / choose(6, 3)
## [1] 0.05

Another way of calculating is by giving each boy and girl a number and identifying each individually (one of the tips given in the book). Then suddenly having a different order of girls or boys in the good solution means a different result. In this case there are $$3!$$ ways to select the first 3 boys (eg. b3b2b1), $$3!$$ of selecting the last 3 girls (eg. g2g1g3). But in total there are $$6!$$ ways to order 6 individuals.

(factorial(3) * factorial(3)) / factorial(6)
## [1] 0.05

### Question 25

Here we have 6 districts and 6 robberies. This feels a lot like rolling a dice 6 times. What is the probability that one number is rolled more than 1 time. This more than 1 time feels very similar to the birthday problem so it is probably a good idea to use the complement here as well. So 1 minus the chance that all the numbers are different. Total ways to order the 6 sides of a die is $$6!$$ which are the positive events. Total number of ways to roll 6 dice is $$6^{6}$$

p_all_different <- factorial(6) / 6**6
p_1ormore_same <- 1 - p_all_different
p_1ormore_same
## [1] 0.9845679

### Question 28

College has 10 time slots, 3 statistics courses. What is the probability that 2 or more statistics courses overlap. Again we see a 2 or more. We could calculate it for each case but we might as well use the complement again. 1 minus the chance of no courses overlapping.

Like the birthday calculation

p_no_overlap <- outcomes_without_replacement(10, 3) / outcomes_with_replacement(10, 3)
p_atleast1_overlap <- 1 - p_no_overlap
p_atleast1_overlap
## [1] 0.28
# Or more direct
1 - ((10 * 9 * 8) / (10 ** 3))
## [1] 0.28

### Question 29

a.) We need to compare getting 22 versus getting 21 after rolling 4 dice. Ways of getting 21:

• 6663 $${4 \choose 1}$$
• 6654 $${4 \choose 2} \cdot {2 \choose 1}$$
• 6555 $${4 \choose 1}$$

Ways of getting 22:

• 6664 $${4 \choose 1}$$
• 6655 $${4 \choose 2}$$

Now the order can be different but the amount of ways to roll for dice A,B,C,D and get 6,6,6,X will be the same. And for getting 6,6,5,5 there are less ways than 6,6,5,4. Therefore there are more ways for 21. Since we need to do it with exactly 4 throws the denominator stays the same. So we know the probability of getting 21 is greater.

b.) We need to compare the change that a 2 letter word is a palindrome versus a 3-letter word. Notice that for an uneven-number-of-letters palindrome, the center letter never matters since it stays the same no matter in which direction you read it. Therefore comparing 2-letter and 3-letter words both come down to making sure the first and last letter are the same. And since they come down to the same probability experiment we already know that the probability will be equal (without doing any calculations).

The calculation would be $$\frac{24}{24 \cdot 24}$$ if we just limited ourselves to the alphabet but could be different if other signs and/or capitalization was included.

### Question 31

There are $$N$$ Elk, and a random sample is taken of $$n$$. A second sample of $$m$$ is taken. What is the probability that $$k$$ of the second sample $$m$$ were already tagged.

Since we are looking from the viewpoint of the second sample. The total sample space will be simply the number of ways we can get the second sample: $${N \choose m}$$. Then the number of positive cases is the number of ways of getting $$k$$ from $$n$$ and $$m - k$$ of $$N - n$$ so $${n \choose k} \cdot {N - n \choose m - k}$$

### Question 33

A jar contains $$r$$ red balls and $$g$$ green balls. A ball is taken randomly and a second ball is taken randomly.

a.) We do not know what color the first ball was. Therefore we did not gain any new information about the chance of getting a green ball. The chance of getting a green ball is the same in our eyes.

b.) We can split the sample space into green balls $$g_{1 \dots n}$$ and red balls $$r_{1 \dots m}$$. An experiment is taking two balls from either $$g$$ or $$r$$ but it can’t be the same ball. The total amount of draws is $$(n + m) \cdot (n + m - 1)$$. Then the amount of possible draws to have the first ball as green and the second anything is $$(n) \cdot (n + m - 1)$$ and for the second green it’s either the first is green and the second too or first is red and second green $$n(n - 1) + mn$$ which is the same as $$n(n + m - 1)$$.

Another way of looking at it is seeing there are $$n$$ ways of picking the right second ball, and given that the right second ball is chosen, there are $$(n + m - 1)$$ to select the right first ball. (Remember that the experiments do not have to occur chronologically)

c.) To calculate the amount of red and green balls to have an equal outcome with 16 balls, we need to create a function to calculate the probability.

If we take the case of both are the same color $$n(n-1) + m(m-1)$$ and the denominator stays the same as in previous parts of the question. We equate the whole thing to $$1/2$$ because it can only be equally likely if both cases have 50% change.

…. Some magic happens ….

$$n^{2}+m^{2}-2nm-n-m=0$$

$$(n-m)^{2} = n + m$$

$$(n-m)^{2} = 16$$

$$n-m$$ is -4 or 4. So one is 6 and the other is 10 or the other way around.

### Question 34

a.) First we need to find the chance of getting a flush (but not a royal flush!). Which means we need to subtract the change of a royal flush from the chance of a normal flush.

All flushes: $$\frac{{13 \choose 5}4}{{52 \choose 5}}$$

Now we subtract the single royal flush which can only be done in one way only per color.

$$\frac{1 \cdot 4}{{52 \choose 5}}$$

so we can write it out as $$\frac{({13 \choose 5} - 1)4}{{52 \choose 5}}$$

((choose(13, 5) - 1) * 4) / (choose(52, 5))
## [1] 0.001979253

(Note that usually you also wouldn’t count a straight flush as a normal flush)

b.) Getting a two pair.

Choose the two ranks $${13 \choose 2}$$, choose the suits $${4 \choose 2}{4 \choose 2}$$, and choose the other card $$(52 - 8)$$.

enumer <- choose(13, 2) * choose(4, 2) * choose(4, 2) * (52 - 8)
enumer / (choose(52, 5))
## [1] 0.04753902

Or we have 13 cards to choose first rank, then 12 ways to choose the second rank. Same calculations for the suit and the last card. Only in this case we overcount since having rank A and rank B is the same as rank B and rank A. So we devide by 2 and get the same result.

enumer <- (13 * choose(4, 2) * 12 * choose(4, 2) * (52 - 8))
(enumer / 2) / choose(52, 5)
## [1] 0.04753902

### Question 42

Show that the probability of a nonrepeatword which uses all 26 letters is very close to $$1/e$$.

There are $$26!$$ number of ways to order all the letters, therefore that many full nonrepeatwords. In general there are $${26 \choose k} k!$$ ways of getting all the $$k$$ words so the complete probability calculation would look like $$\frac{26!}{\sum^{26}_{k=1}{26 \choose k} k!}$$.

The denominator is equal to the first terms of the Taylor series therefore $$1/e$$ is a very close approximation.

### Question 50

For calculating the probability of having one suit miss from a 13-card hand, we need to calculate the probability for each suit missing, and then applying the inclusion-exclusion rule.

First for the high level vier. We have 4 suits, therefore 4 times the probabiliy of a single suit missing. Then $${4 \choose 2} = 6$$ ways of combining those 4 suits, so 6 times minus the probability of two suits missing at the same time. Then $${4 \choose 3} = 4$$ ways of combining 3 suits which will be added to the probability. And finally you could think of all 4 suits but there is no way to get the 13 cards then so this chance is 0.

cards_left <- function(suits) {
return (52 - (suits * 13))
}
denom <- choose(52, 13)
single_enum <- choose(cards_left(1), 13)
p_single <- single_enum / denom
double_enum <- choose(cards_left(2), 13)
p_double <- double_enum / denom
triple_enum <- choose(cards_left(3), 13)  # Really just 1 since we have to take the last suit
p_triple <- triple_enum / denom
# if we wanted we could add the p_quadruple but the enum would be 0

(4*p_single) - (6*p_double) + (4*p_triple)
## [1] 0.05106552

### Question 54

This question is about class selection. We have in total 30 different lecture slots in a week, every day 6, 5 days a week. If we randomly select 7 slots from the 30 in total, what are the chances we have one for every day.

First the direct counting method:

nr_ways_select_lessons <- choose(6 * 5, 7)

# Select a single day to have 3 courses
ways_select_triple_day <- choose(5, 1)
ways_select_triple <- choose(6, 3)
ways_select_single <- choose(6, 1)
triple_day_method <- ways_select_triple_day * ways_select_triple * (ways_select_single^4)

# Select 2 days to have 2 courses
ways_select_double_day <- choose(5, 2)
ways_to_select_double <- choose(6, 2)
double_day_method <- ways_select_double_day * (ways_to_select_double^2) *  (ways_select_single^3)

(triple_day_method + double_day_method) / nr_ways_select_lessons
## [1] 0.3023873

Now for the inclusion / exclusion method:

We can calculate 1 minus the mount of ways we can have 1 day without any lessons.

So, if $$P(D_{i})$$ is the probablity of having no class on day $$i$$. Then we need to calculate $$P(\bigcup^{5}_{k=1}D_{k})$$. To which the inclusion-exclusion rule can be applied.

prob_days_free <- function(days) {
nr_ways_select_lessons <- choose(6 * 5, 7)
nr_ways_with_days_free <- choose(6 * (5 - days), 7)
return (nr_ways_with_days_free / nr_ways_select_lessons)
}
ways_select_single_day <- choose(5, 1)
ie_first_term <- ways_select_single_day * prob_days_free(1) # for every day, inclusion term

ways_select_two_days <- choose(5, 2)
ie_second_term <- ways_select_two_days * prob_days_free(2)

ways_select_three_days <- choose(5, 3)
ie_third_term <- ways_select_three_days * prob_days_free(3)

# Applying inclusion exclusion
prob_some_gap_day <- ie_first_term - ie_second_term + ie_third_term
1 - prob_some_gap_day
## [1] 0.3023873

### Question 59

A story in which there are 100 passangers with a 100 seats. The first person might choose to sit on their seat, or pick a random one. All other people will sit on their seat, except when someone is already sitting there, then they will pick a random seat. Give the probability that the last passenger can sit in their seat.

What can happen

• The first person can sit in their own seat and everyone goes to their respective seats
• The first person can switch to seat 2 - 99 ($$x$$) causing something else to happen
• person $$x$$ goes to seat 1 and after person $$x$$ everything continues as if nothing happened
• person $$x$$ goes to a random other seat in $$x$$ - 99, causing this loop to continue
• person $$x$$ goes to 100, causing the last person having to select seat 1

As can be seen, the only two solutions are really 100 and 1, all others are selected already if they are available. For these 98 other people both seats are equally likely (100 and 1 both are not their seat) and for the first person who takes a seat at random they are also both equally likely. As seen in the informal step through description, it always ends with a person either picking the first or the last seat. Therefore by symmetry the chance of getting 100 or 1 for the last passenger is $$\frac{1}{2}$$.

This answer can be checked by making a simulation.

create_seating <- function() {
all_seats <- replicate(100, 0)
first_seat <- sample(1:100, 1)
all_seats[first_seat] <- 1
for (p in 2:99) {
if (all_seats[p] == 0) {
all_seats[p] <- p
} else {
random_seat <- sample(which(all_seats == 0), 1)
all_seats[random_seat] <- p
}
}
return(all_seats)
}
test_sample <- function() {
seating <- create_seating()
return(seating[100] == 0)
}

test_repeats <- 10^4
repeat_vector <- replicate(test_repeats, test_sample())
sum(repeat_vector) / test_repeats
## [1] 0.4878


text:
• ### The Extreme Energy Events HECR array: status and perspectives(1703.06358)

March 18, 2017 astro-ph.IM, astro-ph.HE
The Extreme Energy Events Project is a synchronous sparse array of 52 tracking detectors for studying High Energy Cosmic Rays (HECR) and Cosmic Rays-related phenomena. The observatory is also meant to address Long Distance Correlation (LDC) phenomena: the network is deployed over a broad area covering 10 degrees in latitude and 11 in longitude. An overview of a set of preliminary results is given, extending from the study of local muon flux dependance on solar activity to the investigation of the upward-going component of muon flux traversing the EEE stations; from the search for anisotropies at the sub-TeV scale to the hints for observations of km-scale Extensive Air Shower (EAS).
• ### Search for the neutron-rich hypernucleus 9{\Lambda}He(1210.4431)

Nov. 1, 2012 nucl-ex
Search for the neutron-rich hypernucleus 9LHe is reported by the FINUDA experiment at DAFNE, INFN-LNF, studying (pi+, pi-) pairs in coincidence from the K-stop + 9Be --> 9LHe + pi+ production reaction followed by 9LHe --> 9Li + pi- weak decay. An upper limit of the production rate of 9LHe undergoing this two-body pi- decay is determined to be (2.3 +/- 1.9) 10-6/K-stop at 90% confidence level.
• ### First observation of the hyper superheavy hydrogen 6{\Lambda}H(1203.1954)

May 15, 2012 nucl-ex, nucl-th
Three candidate events of the neutron-rich hypernucleus 6{\Lambda}H were uniquely identified in the FINUDA experiment at DA{\Phi}NE, Frascati, by observing {\pi}+ mesons from the (K-stop,{\pi}+) production reaction on 6Li targets, in coincidence with {\pi}-mesons from 6{\Lambda}H \rightarrow 6He+{\pi}- weak decay. Details of the experiment and the analysis of its data are reported, leading to an estimate of (2.9\pm2.0)\cdot10-6/K- stop for the 6{\Lambda}H production rate times the two-body {\pi}- weak decay branching ratio. The 6{\Lambda}H binding energy with respect to 5H + {\Lambda} was determined jointly from production and decay to be B{\Lambda} = (4.0 \pm 1.1) MeV, assuming that 5H is unbound with respect to 3H + 2n by 1.7 MeV. The binding energy determined from production is higher, in each one of the three events, than that determined from decay, with a difference of (0.98 \pm 0.74) MeV here assigned to the 0+g.s. \rightarrow 1+ excitation. The consequences of this assignment to {\Lambda} hypernuclear dynamics are briefly discussed.
• ### An improved determination of the two--nucleon induced non mesonic weak decay of $\Lambda$-hypernuclei(1101.4481)

Jan. 24, 2011 nucl-ex
The decay of $\Lambda$-hypernuclei without pion emission, known as Non Mesonic Weak Decay (NMWD), gives an effective tool to investigate $\Delta$S=1 four-baryon interactions. It was theoretically suggested that the two-nucleon induced mechanism could play a substantial role in reproducing the observed NMWD decay rates and nucleon spectra, but at present no direct evidence of such a mechanism has been obtained. The FINUDA experiment, exploiting the possibility to detect both charged and neutral particles coming from the hypernucleus decay, has allowed us to deduce the relative weight of the two nucleon induced decay rate to the total NMWD rate. The value of $\Gamma_{2N}$/$\Gamma_{NMWD}$=0.24$\pm$${0.03_{stat}}^{+0.03_{sys}}_{{-{0.02_{sys}}}}$ has been deduced, with an error reduced by a factor more than two compared with the previous assessment.
• ### A new approach in modeling the response of RPC detectors(1012.5508)

Dec. 26, 2010 hep-ex, physics.ins-det
The response of RPC detectors is highly sensitive to environmental variables. A novel approach is presented to model the response of RPC detectors in a variety of experimental conditions. The algorithm, based on Artificial Neural Networks, has been developed and tested on the CMS RPC gas gain monitoring system during commissioning.
• ### Study of gas purifiers for the CMS RPC detector(1012.5511)

Dec. 26, 2010 hep-ex, physics.ins-det
The CMS RPC muon detector utilizes a gas recirculation system called closed loop (CL) to cope with large gas mixture volumes and costs. A systematic study of CL gas purifiers has been carried out over 400 days between July 2008 and August 2009 at CERN in a low-radiation test area, with the use of RPC chambers with currents monitoring, and gas analysis sampling points. The study aimed to fully clarify the presence of pollutants, the chemistry of purifiers used in the CL, and the regeneration procedure. Preliminary results on contaminants release and purifier characterization are reported.
• ### Proton spectra from Non-Mesonic Weak Decay of p-shell Lambda-Hypernuclei and evidence for the two-nucleon induced process(0910.4939)

Feb. 12, 2010 nucl-ex
New spectra from the FINUDA experiment of the Non Mesonic Weak Decay (NMWD) proton kinetic energy for 9(Lambda)Be, 11(Lambda)B, 12(Lambda)C, 13(Lambda)C, 15 (Lambda)N and 16(Lambda)O are presented and discussed along with the published data on 5(Lambda)He and 7(Lambda)Li. Exploiting the large mass number range and the low energy threshold (15 MeV) for the proton detection of FINUDA, an evaluation of both Final State Interactions (FSI) and the two nucleon induced NMWD contributions to the decay process has been done. Based on this evaluation, a linear dependence of FSI on the hypernuclear mass number A is found and for the two nucleon stimulated decay rate the experimental value of Gamma2/Gammap=0.43+-0.25 is determined for the first time. A value for the two nucleon stimulated decay rate to the total decay rate Gamma2/GammaNMWD=0.24+-0.10 is also extracted.
• ### Micrometric Position Monitoring Using Fiber Bragg Grating Sensors in Silicon Detectors(physics/0512255)

Dec. 28, 2005 physics.ins-det
We show R&D results including long term stability, resolution, radiation hardness and characterization of Fiber Grating sensors used to monitor structure deformation, repositioning and surveying of silicon detector in High Energy Physics.
• ### Two- and Three-Dimensional Reconstruction and Analysis of the Straw Tubes Tomography in the Btev Experiment(physics/0512256)

Dec. 28, 2005 physics.ins-det
A check of the eccentricity of the aluminised kapton straw tubes used in the BTeV experiment is accomplished using X-ray tomography of the section of tubes modules. 2 and 3-dimensional images of the single tubes and of the modules are reconstructed and analysed. Preliminary results show that a precision better than 40 $\mu$m can be reached on the measurement of the straw radii.
• ### A Novel Approach for an Integrated Straw tube-Microstrip Detector(physics/0512257)

Dec. 28, 2005 physics.ins-det
We report on a novel concept of silicon microstrips and straw tubes detector, where integration is accomplished by a straw module with straws not subjected to mechanical tension in a Rohacell $^{\circledR}$ lattice and carbon fiber reinforced plastic shell. Results on mechanical and test beam performances are reported on as well.
• ### An Uncoventional Approach for a Straw Tube-Microstrip Detector(physics/0412100)

Dec. 16, 2004 physics.ins-det
We report on a novel concept of silicon microstrips and straw tubes detector, where integration is accomplished by a straw module with straws not subjected to mechanical tension in a Rohacell lattice and carbon fiber reinforced plastic shell. Results on mechanical and test beam performances are reported on as well.

format: plain


text:
# Tight bounds on the maximal area of small polygons: Improved Mossinghoff polygons

A small polygon is a polygon of unit diameter. The maximal area of a small polygon with \$n=2m\$ vertices is not known when \$m \ge 7\$. In this paper, we construct, for each \$n=2m\$ and \$m\ge 3\$, a small \$n\$-gon whose area is the maximal value of a one-variable function. We show that, for all even \$n\ge 6\$, the area obtained improves by \$O(1/n^5)\$ that of the best prior small \$n\$-gon constructed by Mossinghoff. In particular, for \$n=6\$, the small \$6\$-gon constructed has maximal area.

## Citation

Christian Bingane. Tight bounds on the maximal area of small polygons: Improved Mossinghoff polygons. Discrete & Computational Geometry, 2021.


text:
# B. Simon

Search this author in Google Scholar

Articles: 1

### Schrödinger operators with purely discrete spectrum

Barry Simon

Methods Funct. Anal. Topology 15 (2009), no. 1, 61-66

We prove $-\Delta +V$ has purely discrete spectrum if $V\geq 0$ and, for all $M$, $|{\{x\mid V(x) < M\}}|<\infty$ and various extensions.


text:
# Why is the A-value of methoxy group lower than that of the hydroxyl group?

I am studying conformational analysis of monosubstituted cyclohexane. "A-value" refers to the energy difference between conformers with substitutent in equatorial (more favored) and axial positions. A higher A-value means that the axial conformer will more readily convert to equatorial.

According to Wikipedia, methoxy has A-value of $$0.6 \text{ kcal/mol}$$ while that of hydroxyl is $$0.87 \text{ kcal/mol}$$. Why does methoxy, a bulkier group, have a lower A-value than hydroxyl?

I think that in both cases the group attached to the oxygen faces away from the axial hydrogens, so the size of those groups shouldn't matter very much. That is to say, the A-value of methoxy may be the same as or at the most only slightly larger than that of hydroxyl. This explanation does not suffice as its A-value is in fact smaller.

A possible reason could be that the $$\text{C-O}$$ bond is shorter in methoxy than in hydroxyl. However, I don't understand why this should be true. Hints would be appreciated.

## 1 Answer

I'm hazarding an educated guess here and going to say that the O-C bond is longer than the O-H bond and that there are more interaction between the axial substituents of the H from the hydroxyl group compared to the O-C-H of the longer distant from the other substituent methoxy group.


text:
# Friedmann Equation

1. Jan 23, 2007

### Logarythmic

1. The problem statement, all variables and given/known data
By substituting in

$$\left( \frac{\dot{a}}{a_0} \right)^2 = H^2_0 \left(\Omega_0 \frac{a_0}{a} + 1 - \Omega_0 \right)$$

show that the parametric open solution given by

$$a(\psi)=a_0 \frac{\Omega_0}{2(1-\Omega_0)}(\cosh{\psi} - 1)$$

and

$$t(\psi)=\frac{1}{2H_0} \frac{\Omega_0}{(1 - \Omega_0)^{3/2}}(\sinh{\psi} - \psi)$$

solve the Friedmann equation.

2. The attempt at a solution
I get

$$\dot{a} = a_0 \frac{\Omega_0}{2(1 - \Omega_0)}(\dot{\psi}\sinh{\psi})$$

and

$$\dot{\psi}=\frac{2H_0(1-\Omega_0)^{3/2}}{\Omega_0(\cosh{\psi}-1)}$$

but I can't get to the first equality. Is this the correct approach?

2. Jan 23, 2007

### Physics Monkey

You may find it easier to write $$\dot{a} = \frac{\frac{da}{d\psi}}{\frac{dt}{d\psi}}$$. Dividing by $$a_0$$ and squaring should leave you with some expression involving only $$\psi$$. A little algebra is then all you need to re-express things in terms of $$a$$.

3. Jan 23, 2007

### Logarythmic

I get the right hand side to equal

$$H^2_0 \frac{2(1-\Omega_0}{\cosh{\psi}-1}$$

and the LHS

$$H^2_0 \frac{(1-\Omega_0)\sinh^2{\psi}}{(\cosh{\psi}-1)^2}$$

but I can't get them equal...

4. Jan 23, 2007

### Physics Monkey

I agree with your second expression from computing da/dt, but I think you've made a mistake with your first expression.


text:
# Homework Help: The Entropy Change Argon in a non-isothermal process expansion.

1. May 29, 2010

### blackscorpion

1. The problem statement, all variables and given/known data
a) Calculate the entropy change when Argon, at 25oC and 0.101 MPa pressure, in
a container of volume 0.5 litre is allowed to expand to 1.0 litre and is simultaneously
heated to 100oC.
b) Calculate the entropy change when the same initial sample is compressed to 0.05
litre and cooled to –25oC.
(Hint: choose a suitable path or combination of successive paths to move between the
two states described )

2. Relevant equations
Delta S =nC$$_{}V$$ln(T$$_{}2$$-T$$_{}1$$) + nRln(V$$_{}2$$/V$$_{}1$$)

Where since Argon is monotonic C$$_{}V$$=3R/2

3. The attempt at a solution
But the question does not state the value of n and since this is not an ideal gas I cannot work it out.

2. May 29, 2010

### irycio

Oh, c'mon :P. If you are allowed to assume, that argon is an ideal gas, and pV=nRT applies, read your first sentence again. Y~ou've got temperature, pressure and volume. You might want to use it to calculate n...

3. May 29, 2010

### blackscorpion

Except you get different values of n at the two different values of temperature and corresponding volume.
So you cant assume ideality...

4. May 29, 2010

### Mapes

There is only one state where you are given pressure, temperature, and volume: the initial state.

5. May 29, 2010

### irycio

But it doesn't say that the pressure remains constant, or at least you didn't write it.
You've got: p1=0.101 MPa, T1=25C, V1=0.5l and T2=100C, V2=1l. You need to assume that the pressure has changed.

Edit: Dammit, Mapes was faster :P.

6. May 29, 2010

### blackscorpion

Ohhhh It's suddenly clicked!
I was assuming it was isobaric even though the question doesnt actually suggest it is...
Wow I feel stupid =p


text:
/ Experiment-HEP hep-ex/0212039

Measurement of single spin azimuthal asymmetries in semiinclusive electroproduction of pions and kaons on a longitudinally polarized deuterium target

Airapetian, A. ; Akopov, N. ; Akopov, Z. ; Amarian, M. ; Ammosov, V.V. ; Andrus, A. ; Aschenauer, E.C. ; Augustyniak, W. ; Avakian, R. ; Avetissian, A. ; Avetissian, E. ; Bailey, P. ; Baturin, V. ; Baumgarten, C. ; Beckmann, M. ; Belostotski, S. ; Bernreuther, S. ; Bianchi, N. ; Blok, H.P. ; Bottcher, H. ; Borissov, A. ; Bouwhuis, M. ; Brack, J. ; Brull, A. ; Bryzgalov, V.

Published in: Phys.Lett.
Year: 2003
Vol.: B562
Page No: 182-192
Pages: 10

Abstract: Single-spin asymmetries have been measured for semi-inclusive electroproduction of $\pi^+$, $\pi^-$, $\pi^0$ and $K^+$ mesons in deep-inelastic scattering off a longitudinally polarised deuterium target. The asymmetries appear in the distribution of the hadrons in the azimuthal angle $\phi$ around the virtual photon direction, relative to the lepton scattering plane. The corresponding analysing powers in the $\sin \phi$ moment of the cross section are $0.012 \pm 0.002 {(stat.)} \pm 0.002 {(syst.)}$ for $\pi^+$, $0.006 \pm 0.003 {(stat.)} \pm 0.002 {(syst.)}$ for $\pi^-$, $0.021 \pm 0.005 {(stat.)} \pm 0.003 {(syst.)}$ for $\pi^0$ and $0.013 \pm 0.006 {(stat.)} \pm 0.003 {(syst.)}$ for $K^+$. The $\sin 2\phi$ moments are compatible with zero for all particles.

Total numbers of views: 1277
Numbers of unique views: 586
e-proceeding


text:
# ODBC

ODBC is an API for interacting with databases from any vendor and in any location. ODBC is widely supported by operating systems (e.g., Windows), database systems (e.g., MariaDB), and commonly-used tools such as Stata. This compatability across environments may come at the expense of performance. Most users will not notice this drawback. However for high-performance needs, please contact RCS at research@hbs.edu to discuss alternatives.

ODBC set up is different on Windows versus on the Grid or Mac.  Please refer to the appropriate sections for detailed instructions:

Updated 4/12/2019


text:
# Diskdrillactivationkey

Diskdrillactivationkey

Activation Code Of “Disk Drill Pro Crack Full Version [2020]” Free Download disk drill activation key Â· Ahead.Nero.Burning.Rom.V7.5.9.0.Plus keygen download Â· Descargar gratis pack de fotos de chicas en minifalda Â· Previous. Next. This is a great post. I have been searching for that information for a long time and yours is the greatest I’ve found so far. Then again, what may I say, it in fact was my experience. I’m very pleased to read through this web page and look forward to some more first-time posts and also a Twitter feed. I think that you made some nice points in features also. disk drill activation key fent21 i hægtes This is my first time i visit here. I found so many entertaining stuff in your blog, especially its discussion. From the tons of comments on your articles, I guess I am not the only one having all the enjoyment here! keep up the good work About I am a blogger and a computer science teacher. My main goal in life is to learn more about myself and the world. I like programming, philosophy, maps, physics and a lot of other things. My email address is: m0o0ooo0o@gmail.comQ: Percentage of the power drawn by the LEDs from the battery I have a meter on which I need to estimate the percentage of the power drawn from the battery in the case of two LEDs powered directly from the battery. LED1 is powered directly from the battery. It has a forward voltage of about 4V and a resistance of 10Ω. LED2 is connected to LED1 through a resistor R1 of 50Ω. It has a forward voltage of about 2V, and a resistance of 50Ω. Both LEDs have a white color. I have estimated that the power dissipated in both LEDs as being 0.02 Watts per each. If I’m right, then I can use the following equation: $$V = I \times R$$ For both LEDs, I get the following results: $$V_1 = 0.02 \times (50+10) = 0.98V$$  V_2 = 0.02 \times 3e33713323


text:
Search

### Journal Articles

#### Contour Method and Collapsibility Criteria for $2{\times}3{\times}K$ Contingency Tables

Author
Hong C.S, Son B.U, Park J.Y
Journal
Publisher
한국데이터정보과학회 in 2004
Cited Count
0
Partners
KISTI
Category
Natural Sciences > Statistics
Keywords
Categorical data, Collapsibility, Contour plot, Log-linear models, Odds ratio
##### Abstract

The contour method which was originally designed for $2{\times}2{\times}2$ contingency table is studied for $2{\times}2{\times}K$ and $2{\times}3{\times}K$ tables. Whereas a contour plot for a $2{\times}2{\times}K$ table is represented on unit squared two dimensional plane, a contour plot of a $2{\times}3{\times}K$ table can be expressed with a regular hexahedron on three dimensional space. Based on contour plots for categorical data fitted to all possible three dimensional log-linear models, one might identify whether $2{\times}2{\times}k$ or $2{\times}3{\times}K$ tables are collapsible over the third variable.

##### References

No relevant information is available
If you register references through the customer center, the reference information will be registered as soon as possible.

view options


text:
## [Solved] - Indexed Palette Swaps / Color Cycling

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Semicolon
Prole
Posts: 3
Joined: Tue Apr 04, 2017 5:34 pm

### [Solved] - Indexed Palette Swaps / Color Cycling

Problem has been solved, please see this post: https://love2d.org/forums/viewtopic.php ... 38#p211438

---

I have an indexed png sprite. I would like to recolor that sprite in real time using a separate palette image.
Here's an example of what I'm trying to accomplish:
My sprite: My palette (scaled up):

This seemed like a good place to use a shader, so I set about searching for one, or at least some guidelines for writing one.
Eventually, that brought me to this link:

https://www.khronos.org/opengl/wiki/Com ... d_textures

A paletted texture sounded like exactly what I was going for, so I attempted to convert their shader into something I could use in LÖVE.
This is what I came up with:

Code: Select all

//Fragment shader
uniform sampler2D ColorTable; // 16 x 1 pixels
uniform sampler2D MyIndexTexture;
varying vec2 TexCoord0;

vec4 effect( vec4 color, Image MyIndexTexture, vec2 TexCoord0, vec2 screen_coords ){
//What color do we want to index?
vec4 myindex = texture2D(MyIndexTexture, TexCoord0);
vec4 texel = texture2D(ColorTable, myindex.xy);
return texel;   //Output the color
}
Unfortunately, when I attempted to draw my sprite using this shader, this was my result:

It's close, but some groups of colors are being set to a single color.
For example, the orange, yellow, pink and white hues on the original sprite are all being set to pink on the modified sprite.
Any help to fix this (or perhaps a different shader with a different methodology for accomplishing the same thing) would be greatly appreciated.

Things I have tried:
• Turning on gamma-correct rendering (just makes it worse)

Using a 256 x 1 palette (still converts multiple colors to the same color)

Using ImageData:mapPixel() and pre-rendering the sprites (useful, but too slow for real-time)

Finally, here is a simple .love illustrating the problem.
Attachments
Last edited by Semicolon on Wed Apr 05, 2017 6:18 pm, edited 1 time in total.

raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

### Re: Indexed Palette Swaps / Color Cycling

You'll notice that you sample your color by X and Y components, i.e. Red and Green channels values mapped to 0-1 range. Starting there, you need at least 2d color map texture. Realistically you will use all 3 colors so you really need 3d color map texture.

To elaborate on the way it works:
First, it samples the color from your texture as normal. Then it (implicitly) converts that color to texture coordinates, so that red becomes X, green becomes Y and blue becomes Z. Using specially cratfted colormap texture, that goes from black to red on X axis, from black to green on Y axis, and from black to blue on Z axis (that's an identity map, it doesn't alter the color), you can use these previously obtained coordinates to sample new color from that texture.

So you need to create a 3d texture such that in coordinates R, G, B of input color as X, Y, Z values, there's an output color. E.g. if you want to change teal to magenta, in coordinates 0, 1, 1 (teal's color values) there's magenta color. Since you're going for low color depth, you can somehow encode input color such that each R, G, B combination on the input corresponds to exactly one X coordinate on the output. Then you can create such texture that has output color in that X coordinate, and use a 1d texture for that.

In general, as long as you're not doing rainbowy real time effects, I suggest simply creating altered color sprites by mapping pixel colors offline.

Jasoco
Inner party member
Posts: 3651
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

### Re: Indexed Palette Swaps / Color Cycling

I did something like this, but much simpler a few months ago when I was working on a sort of GameBoy Link's Awakening style engine. I was trying to make it as genuine as possible so I wrote a shader that would take a palette of fixed colors and apply them to 4-color greyscale images. Basically the four shades of grey would be replaced with the four chosen colors. I could expand it if I need to to do more than 4 colors, but it worked well.

It probably wouldn't help at all since it's much simpler than what you want to do but I'll post the shader anyway...

Code: Select all

nesShader = love.graphics.newShader[[
extern vec4 color1;
extern vec4 color2;
extern vec4 color3;
extern vec4 color4;

vec4 effect( vec4 color, Image texture, vec2 texture_coords, vec2 screen_coords ){
vec4 pixel = Texel(texture, texture_coords );//This is the current pixel color
if (pixel.a == 0.0) { return vec4(0.0,0.0,0.0,0.0); }
if (pixel.r < 0.25) { return vec4(color4.r/255,color4.g/255,color4.b/255,color4.a/255); }
else if (pixel.r < 0.5) { return vec4(color3.r/255,color3.g/255,color3.b/255,color3.a/255); }
else if (pixel.r < 0.75) { return vec4(color2.r/255,color2.g/255,color2.b/255,color2.a/255); }
else { return vec4(color1.r/255,color1.g/255,color1.b/255,color1.a/255); }
return pixel;
}
]]
You'd have to send each color separately every frame. But it worked fine.

Semicolon
Prole
Posts: 3
Joined: Tue Apr 04, 2017 5:34 pm

### Re: Indexed Palette Swaps / Color Cycling

@raidho36: Aaah, spot on. Everything makes sense now. Thanks!

@Jasoco: Cool! That looks perfect for a game-boy palette-ifier. Out of curiosity, why would one need to send the color information every frame? Would it be possible to send the palette information only when the palette changes?

Thanks for the help guys, marking as solved. I've attached an updated version of the .love below with proper palette swapping.
(Use the left/right arrow keys to change palettes)
Attachments
properPaletteSwapper.love

Jasoco
Inner party member
Posts: 3651
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

### Re: Indexed Palette Swaps / Color Cycling

Semicolon wrote:
Wed Apr 05, 2017 6:17 pm
@Jasoco: Cool! That looks perfect for a game-boy palette-ifier. Out of curiosity, why would one need to send the color information every frame? Would it be possible to send the palette information only when the palette changes?
I wouldn't know how to do it. Since the shader is being called for every single image (In my case, every single 8x8 pixel sub-tile with 4 sub-tiles per 16x16 tile and a whole bunch of them per frame for the map and entities.) I wouldn't know of a way to store that information in the shader unless you were to load the shader separately for every single tile instead of reusing the same one. Can you even do that? Would it take a lot of memory to have the same shader duplicated for every single sprite?

Just for fun, here it was in action:

MasterLee
Party member
Posts: 141
Joined: Tue Mar 07, 2017 4:03 pm
Contact:

### Re: [Solved] - Indexed Palette Swaps / Color Cycling

I did only the palette effect the following way:

Code: Select all

[[
extern vec4 palette[4];
vec4 effect(vec4 color,Image texture,vec2 texture_coords,vec2 pixel_coords)
{
return palette[int(Texel(texture,texture_coords).r*4)];
}
]]
It is much shorter and uses less if. In my map the pixel data is premultilplied by 64(=256/number of colors)). That is the reason why r multiplied by 4.

D0NM
Party member
Posts: 235
Joined: Mon Feb 08, 2016 10:35 am
Contact:

### Re: [Solved] - Indexed Palette Swaps / Color Cycling

well... in our open source http://www.zabuyaki.com
I swap only certain colours:

Code: Select all

local sh_swap_colors = [[
extern number n = 1;
extern vec4 colors[16];
extern vec4 newColors[16];
vec4 effect( vec4 color, Image texture, vec2 texture_coords, vec2 screen_coords ){
vec4 pixel = Texel(texture, texture_coords );//This is the current pixel color
for (int i = 0; i < n; i++) {
if(pixel == colors[i])
return newColors[i] * color;
}
return pixel * color;
}   ]]

local function swapColors(colors_default, alternate_colors)
alternate_colors[#alternate_colors+1] = {} --TODO: Remove on fix of Love2D 0.10.2 shaders send bug
colors_default[#colors_default+1] = {} --Love2D 0.10.2 shaders send bug workaround


text:
# Point Lights Issue ( reconstructing position from logarithmic depth )

This topic is 1859 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

We are having a problem with our point lights not working. Our current setup is a deferred rendering for lighting. Now somebody can correct me if I am wrong but this is how we are doing it:

• We render stuff and our colors are recorded on a color RT
• Normals on another RT
• Depth on another RT ( our depth is logarithmic )

When we render the point lights they need to read the depth RT so they can use the depth to calculate the world position of the pixel and then we can do the lighting calculations.

Our problem is we have no way of reversing that logarithmic depth at this point... any clues on how we could go about doing this? Or maybe there is a better way to handle the scenario all together. Thanks for your help in advance.

##### Share on other sites
The point light in Catalin Zima's blog worked for me. http://www.catalinzima.com/tutorials/deferred-rendering-in-xna/

##### Share on other sites
hm... interesting okay ill give that a go. Thank you! any other advice people have is welcomed. We have a very nice fireball effect and I would like to add a point light to the process, that and we want lanterns!

EDIT:
showed this to the coders and this was the response i got:

yea yea
that's what we used to set it up in the first place
its literally the only xna deferred tutorial[/quote]

Also note we are not using XNA, we are using SlimDX, not sure if that matters at this point. I guess the big issue is that we are using Log depth, and this tutorial and others are not. We are attempting to use log depth to create better precision... but not sure if that is the main reason as to why ours does not work when others have no issues. Edited by riuthamus

##### Share on other sites

Our problem is we have no way of reversing that logarithmic depth at this point..
You probably should have named your thread "reconstructing position from logarithmic depth" then

WolframAlpha can be useful for tasks like this.
e.g. assuming you're using the formula: [font=courier new,courier,monospace]depth = [/font][font=courier new,courier,monospace]log(c*originalZ + 1) / log(c*far + 1)[/font]
You can copy that into wolfram, and ask it to solve for z: http://www.wolframal...) ; solve for z
And it spits out [font=courier new,courier,monospace]originalZ = [/font][font=courier new,courier,monospace](pow(c*far+1,depth)-1)/c[/font]

I make no guarantees about the validity of this formula -- just giving you another tool to try ;) Edited by Hodgman

##### Share on other sites
Hm... thank you very much and if i can rename it, i will. I know on my ipforums you can if you are a thread owner.. but not sure how this one works. I will give it a good ol' college try!

##### Share on other sites
If I use the formula that wolframalpha gives, it gives us a closer result then we were getting before but the position is still off by a bit. I debugged a pixel in PIX and the position came out to (101.089287, 618.003845, -55.915211, -105.442390). Our blocks are 10 units big. The pixel I was debugging should have had a value close to (0, 600, 0). The Y axis (our up axis) is pretty close, but the other 2 are off by a bit.

This is how the log depth is encoded in the gbuffer:

output.Position.z = log(0.001 * output.Position.z + 1) / log(0.001 * FarPlane + 1) * output.Position.w;

The vertex shader of the point light also adjusts the light's z position in the same way. And this is how the position is reconstructed in the light:

 input.ScreenPosition.xy /= input.ScreenPosition.w; float2 texCoord = 0.5f * (float2(input.ScreenPosition.x, -input.ScreenPosition.y) + 1); //read depth float depthVal = DepthMap.Sample(depthSampler, texCoord).r; depthVal = (pow(0.001 * FarPlane + 1, depthVal) - 1) / 0.001; //Compute screen-space position float4 position = float4(input.ScreenPosition.xy, depthVal, 1.0f); // transform to world space position = mul(position, InvertViewProjection); position /= position.w;

Every time I debug a pixel, the attenuation always equals 0 since the position it calculates is out of the lights range. This is what it ends up looking like:
[attachment=11022:RuinValor 2012-08-31 17-49-01-90.png]

##### Share on other sites

Hm... not sure if this is reviving a dead topic... but we never got an answer and have started development on this. If this is a dead topic please close it mod. I will make another.


text:
## Measures of Diversity

### Shannon-Wiener Index

This diversity measure is based on information theory; simply, the measure of order (or disorder) within a particular system. For our uses, this order could be characterized by the number of species and/or the number of individuals in each species, within our sample plot.

By applying these numbers to the Shannon-Wiener equations we can determine what is referred to as the degree of uncertainty. With this number we can then specify our degree of diversity.

In questioning how difficult it would be to predict correctly the species of the next individual collected, we define un-certainty, in turn defining diversity. For example, if our number of uncertainty is low, ie. we feel confident in naming the next individual's species, our types of species are few. And, of course, vice versa... if our number of un-certainty is high, the number of species are greater and our chances of knowing the next individual's species are low.

### Shannon-Wiener index

$$H' = - \displaystyle\sum\limits_{i=1}^{c} p_i log_2 p_i$$

where H = Information content of sample, Index of species diversity, or Degree of Uncertainty, c = Number of categories(species) pi = Proportion of total sample belonging to ith category(species)

### Alternative Form

An alternative form for Shannon-Wiener index:

$$N_1 = 2^{H'}$$

where N1 is the number of equally common categories (species) for the diversity H'. The equations varies depending on the type of logarithms used to calculate the H'.

### Measures of Evenness

The maximum Shannon-Wiener index for a given number of categories(species) can be calculated as:

$$H'_{max} = log_2 C$$

The minimum Shannon-Wiener index for a given data set can be calculated as:

$$H'_{min} = log_2 N \left( \frac{N - C + 1}{N} \right) \left(log_2 \left( N - C + 1 \right) \right)$$

Where:

C is the number of categories or species
N is the total number of observations.

The evenness of the sample can be calculated by the following two equations:

$$J' = \frac{H'}{H'_{max}}$$
$$Eveness = \frac{N_1}{C}$$

### Base conversion with Logarithms

To convert from known log bases to any other log base use:

$$log_b x = \frac{log_e x}{log_e b}$$

where b is the base value, loge is the natural logarithm, and x is the value to be transformed. For example to take a log base 2 you would use:

$$log_2 x = \frac{log_e x}{log_e 2}$$

### Other Hints

• The theoretical maximum for H' is log(C). The minimum value(when N>>C) is log[N / (N-C)].
• This method is best when doing random samples of a large plot in which you know the total number of species.

Also See:

Chapter 10 - Species Diversity Measures pages 361-367 in:

Krebs, C. J. 1989. Ecological Methodology. Harper and Row, Publishers. New York. 654 pp.
or
Chapter 4 - Measures of dispersion and variability pages 32-36 in:
Zar, J. H. 1984. Biostatistical Analysis. Prentice-Hall, Inc. Englewood Cliffs, New Jersey. 718 pp.

 Natural Resources Biometrics by David R. Larsen is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License . Author: J. Mark Travis and Dr. David R. Larsen Created: October 11, 1995 Last Updated: July 29, 2014


text:
# Stratonovich Integral and Ito's lemma

Let $(\Omega, \mathcal{F},\mathbb{P},\{\mathcal{F}\}_t)$ be a filtered- probability space and $W_t$ be standard Wiener process. I want to show stratonovich integral of $W_t$, i.e $\int_{0}^{t} W_s ○ dW_s$ , is not a martingale by Ito lemma.

Thanks.

• There is a conversion formula from stratonovich integral to ito integral: en.wikipedia.org/wiki/Stratonovich_integral. – Gordon Jul 26 '16 at 13:39
• After you have it converted, you can then use ito's lemma. – Gordon Jul 26 '16 at 13:45
• How, I can't prove this formula. I cant see prove of these in this page – Crisis2008 Jul 26 '16 at 13:48
• You can not use Ito's lemma directly – user16651 Jul 26 '16 at 13:52
• Why? We can use Ito lema – Crisis2008 Jul 26 '16 at 13:55

It is well-known, $W_t$ is a continues, adapted and locally bounded process.Let $I=\{t_i\}_{i=0}^{n}$ is a sequence of partitions of $[0,t]$, Indeed $0=t_0<t_1<\cdots<t_n=t$ .By definition of stratonovich integral, we have $$\int_{0}^{t} W_s\circ dW_s=\frac{1}{2}\underset{n\to \infty }{\mathop{\lim }}\sum_{i=0}^{n-1}(W(t_{i+1})+W(t_i))(W(t_{i+1})-W(t_i))$$ $$\int_{0}^{t} W_s\circ dW_s=\frac{1}{2}\underset{n\to \infty }{\mathop{\lim }}\sum_{i=0}^{n-1}(W^2(t_{i+1})-W^2(t_i))\quad(\operatorname{Telescoping series })$$ $$\int_{0}^{t} W_s\circ dW_s=\frac{1}{2}\underset{n\to \infty }{\mathop{\lim }}(W^2(t_n)-W^2(t_0))$$ Therefore $$\int_{0}^{t} W_s\circ dW_s=\frac{1}{2}(\,W^2(t)-W^2(0)\,)=\frac{1}{2}W_t^2\quad (\underset{n\to \infty }{\mathop{\lim }}W(t_n)=W(t))$$ Hence
$$\int_{0}^{t} W_s\circ dW_s=\frac{1}{2}W_t^2$$
• Note $\int_{0}^{t} W_s\,dW_s=\frac{1}{2}\left(W_t^2-t\right)$ whereas $\int_{0}^{t} W_s\circ dW_s=\frac{1}{2}W_t^2$ .This is the difference between Ito's and Stratonovich's integrals – user16651 Jul 26 '16 at 21:39


text:
# Is there a way of rendering LaTeX equations in Crystal Reports?

I'm developing a report in Crystal Reports and need to render some math formulas and equations in it. The formulas and equations are stored in a SQL Server database in plain text (using LaTeX markup).

Getting them to render in HTML is not a problem, because I'm using MathJax to do the work at browser level (in either HTML/CSS or MathML).

The real problem is: how can I get these equations rendered in the report? I've searched throught the web and found nothing about it. Doing some more search at the Crystal interface, the only thing I've found is inserting the (obsolete) "Microsoft Equation Editor" as a OLE object in the report, but neither this worked.

So, how render these LaTeX math equations in this Crystal report? Is there some (obscure) component/plugin that does the job? If not, is there a better manner of doing this? Someone already got and resolved a similar use-case?

OBS 1: I must have this report generated in PDF because of already validated standards in use at my job.

OBS 2: The app which will generate this report is a ASP.NET MVC 3 web app, with a SQL Server 2008 database (using NHibernate).

-
I don't know crystal well enough, but you may need to hit a web service that has latex installed and get either a rendered PDF | PostScript | PNG (whatever) to include in said report. –  Xepoch Mar 1 '12 at 15:27
Similarly, i'm not very familiar with LaTeX but you set text fields in Crystal to be interpreted as HTML (all be it with limited functionality)- this may help –  Lee Tickett Mar 1 '12 at 15:45
These equations, are they static or dynamic? That is, are you expecting them to change by virtue of the data? –  Orbling Mar 1 '12 at 21:53
@Orbling These equations are dynamic. They are filled by the user and saved in the database and may change in the future. –  Renan Marks Mar 2 '12 at 11:59
@LeeTickett The problem is not only showing in HTML, because I need to "compile" the LaTeX markup to some image or typesetting that renders the equation like it was handwritten. Mainly because it could be equations or even chemistry formulas. –  Renan Marks Mar 2 '12 at 12:08
show 1 more comment

You'll need to create a user-function library (UFL) to do this. Pass the LaTeX representation of the formula to the UFL, generate an image representation of the formula, return the image's URL.

To use the path, insert a 'picture', then reference the UFL's function in the 'graphic location' property:

//Insert | Picture...; graphic location conditional formula
latex({table.latex_field})

-
This solution seems to be the best one (by using an API, etc) but seems like a bit "excessive" in the point that the project is being developed entirely in C#. Falling back to pure C is a little "out of scope" for a solution like this. However is nice to know that Crystal Reports have extension points! –  Renan Marks Mar 6 '12 at 17:45
If it helps, you can also build UFLs in Delphi, COM, and Java. –  craig Mar 8 '12 at 13:30

I've found a workaround that is at the same time elegant and not relies on extending the Crystal Reports using C.

I've found this small and simple "latex equation renderer": mimeTeX. Using it, I'm able to render latex equations into GIF images (as a CGI application). With that, I created a phantom byte array field in the datatable where the report is getting data.

Here is what I've done:

1. Recover the latex equation markup from my real database;
2. Query mimeTeX using this markup and mimeTeX returns a gif image;
3. Take this image and convert it to png format (Crystal surprisingly do not support GIF files);
4. Finally put this PNG image (its bytes) in the phantom field created in the datatable used by the report;
5. Now you can use this field in the report! The images for each record (equation) are generated and displayed without problems!

The only drawback I've found until now using this approach is that all the images are streched to the same size of the field placeholder. If the images have sizes that varies much, some will be displayed pixelated and others will become "squashed". But I'm looking forward how to resolve this issue!

--- Edit ---

Solved the "squashed images" problem. I resize the images in code maintaining their aspect ratio and "pasting" them in a fixed size image. Now all the images get the same size and doesn't get squashed!

Here is the code for the resizing:

MemoryStream ResizeImage(Stream OriginalFile, int NewWidth, int MaxHeight, bool OnlyResizeIfWider)
{
int finalWidth = NewWidth;
int finalHeight = MaxHeight;

System.Drawing.Image FullsizeImage = System.Drawing.Image.FromStream(OriginalFile);

// Prevent using images internal thumbnail
FullsizeImage.RotateFlip(System.Drawing.RotateFlipType.Rotate180FlipNone);
FullsizeImage.RotateFlip(System.Drawing.RotateFlipType.Rotate180FlipNone);

if (OnlyResizeIfWider)
{
if (FullsizeImage.Width <= NewWidth)
{
NewWidth = FullsizeImage.Width;
}
}

int NewHeight = FullsizeImage.Height * NewWidth / FullsizeImage.Width;
if (NewHeight > MaxHeight)
{
NewWidth = FullsizeImage.Width * MaxHeight / FullsizeImage.Height;
NewHeight = MaxHeight;
}

System.Drawing.Image NewImage = FullsizeImage.GetThumbnailImage(NewWidth, NewHeight, null, IntPtr.Zero);

// Clear handle to original file so that we can overwrite it if necessary
FullsizeImage.Dispose();

MemoryStream bmpStream = new MemoryStream();

// Put in a new image of A x B pixels to evict distortion
using (var bitmap = new Bitmap(finalWidth, finalHeight))
{
using (var canvas = Graphics.FromImage(bitmap))
{
canvas.InterpolationMode = InterpolationMode.HighQualityBicubic;
canvas.Clear(Color.White);
canvas.DrawImage(NewImage, 0, 0);
canvas.Save();
}

bitmap.Save(bmpStream, ImageFormat.Bmp);
}

return bmpStream;
}

-


text:
# If α and β are the zeros of the quadratic polynomial g(s) = 6s2 - 12s + 8, find the value of $$\frac{α}{β} + \frac{β}{α} + 4(\frac{1}{α} +\frac{1}{β})+6αβ$$

1. 8
2. 16
3. 15
4. 24

Option 3 : 15

## Detailed Solution

Concept:

If α and β are the two zeros of the quadratic polynomial ax2 + bx + c, then:
ax2 + bx + c = (x - α)(x - β) = x2 - (α + β)x + αβ = 0

Sum of roots = α + β = −b/a

Product of roots = αβ = c/a.

Calculation:

g(s) = 6s2 - 12s + 8

a = 6, b = - 12, c = 8

α + β = - (-12/6) = 2

αβ = 8/6 = 4/3

Now,

$$\frac{α}{β} + \frac{β}{α} + 4(\frac{1}{α} +\frac{1}{β})+6αβ$$

⇒ $$\frac{α^2+β^2}{αβ}+ 4(\frac{α+β}{αβ} )+6αβ$$

⇒ $$\frac{(α+β)^2-2αβ}{αβ}+ 4(\frac{α+β}{αβ} )+6αβ$$

Substituting α + β = 2 and αβ = 4/3

⇒ $$\frac{(2)^2-2\;\times\;\frac{4}{3}}{\frac{4}{3}}+ 4(\frac{2}{\frac{4}{3}} )+6\times\frac{4}{3}$$

⇒ $$\frac{\frac{4}{3}}{\frac{4}{3}}+ 4(\frac{2\;\times\;3}{4} )+2\times4$$

⇒ 1 + 6 + 8 = 15

$$\frac{α}{β} + \frac{β}{α} + 4(\frac{1}{α} +\frac{1}{β})+6αβ = 15$$


text:
# Combining two results from partial integration

I have a set of two PDEs: $$\partial_{\tau}\theta+\partial_{\eta}\psi=0$$ $$\partial_{\tau}\psi=-\partial_{\eta}\theta+\alpha\partial_{\eta}^{2}\psi$$

These can be combined into a wave equation of the form: $$\partial_{\tau}^{2}\theta=\partial_{\eta}^{2}\left[\theta+\alpha\partial_{\tau}\theta\right]$$

which with the ansatz: $$\theta=\sin\left(\eta\right)\exp\left(-\omega\tau\right)$$

gives the dispersion relation: $$\omega^2-\alpha\omega+1=0$$

The solution to the dispersion relation is $\omega=\omega_r+i\omega_i$ with $\omega_r=\frac{1}{2}\alpha$ and $\omega_i=\pm\sqrt{1-\frac{1}{4}\alpha^2}$.

Now i would like to determine $\psi\left(\eta,\tau\right)$, I attempted to do this by using the original equations in a rewritten form:

1. $$\partial_{\eta}\psi = -\partial_{\tau}\theta \rightarrow \psi\left(\eta,\tau\right) = -\omega\cos\left(\eta\right)\exp\left(-\omega\tau\right)+K_1$$

2. $$\partial_{\tau}\psi = -\partial_{\eta}\theta-\alpha\partial_{\eta}\partial_{\tau}\theta \rightarrow \psi\left(\eta,\tau\right) = \left(\frac{1}{\omega}-\alpha\right)\cos\left(\eta\right)\exp\left(-\omega\tau\right) + K_2$$

but as far as i can see these two partial solutions cannot be combined to satisfy both original equations simulateously. How do i go about getting a solution for $\psi$?

• How is the solution you derived a solution? since you end up with $\omega^2$ on the l.h.s and something linear on the r.h.s? unless its a dispersion relation that you obtain? or I am being silly. – Chinny84 Feb 8 '16 at 11:06
• @Chinny84 - I indeed obtain a dispersion relation: $\omega^2 - \alpha\omega + 1=0$, from there $\omega=\omega_r+i\omega_i$ with $\omega_r=\frac{1}{2}\alpha$ and $\omega_i=\pm\sqrt{1-\frac{1}{4}\alpha^2}$. I didn't include it in the question because i wanted to keep it short... – nluigi Feb 8 '16 at 11:15
• @Chinny84 - do you mean the wave equation or the continuity/navier-stokes equations? I think i have gone over the derivations about a hundred times now and i think i atleast got the pde's correct. Please correct me if i am wrong... – nluigi Feb 8 '16 at 11:22
• no i was wrong! Sorry about that haste remark. I will work on this. I used both in way, since both form foundations to Magneto-Hydrodynamics. – Chinny84 Feb 8 '16 at 11:24
• @Chinny84 - I actually think i found a solution and am writing an answer as we speak... perhaps you can comment on it in a few minutes? – nluigi Feb 8 '16 at 11:26

As it turns out the two results for $\psi$ are actually equivalent as by the dispersion relation:

$$\frac{1}{\omega}-\alpha=\frac{1}{\omega}\left(1-\alpha\omega\right)=-\omega$$

Alternative method: First, redefine $\theta$ and $\psi$ using a scalar $\phi$: $$\theta=\partial_{\eta}\phi\quad\psi=-\partial_{\tau}\phi$$

This ensures that: $$\partial_{\tau}\theta+\partial_{\eta}\psi=0$$ is exactly satisfied and yields a wave equation for $\phi$ from the other equation: $$\partial_{\tau}^{2}\phi=\partial_{\eta}^{2}\left[\phi+\alpha\partial_{\tau}\phi\right]$$

The solution for $\phi$ has a similar form as previously found for $\theta$: $$\phi\left(\eta,\tau\right)=\left[A\sin\left(\eta\right)+B\cos\left(\eta\right)\right]\exp\left(-\omega\tau\right)$$ where the constants $A$ and $B$ are yet to be determined.

From the definitions for $\theta$ and $\psi$ I find: $$\theta=\partial_{\eta}\phi=\left[A\cos\left(\eta\right)-B\sin\left(\eta\right)\right]\exp\left(-\omega\tau\right)$$

$$\psi=-\partial_{\tau}\phi=\omega\left[A\sin\left(\eta\right)+B\cos\left(\eta\right)\right]\exp\left(-\omega\tau\right)$$

Now if I am looking for a solution of $\psi$ which corresponds to a $\theta$ distribution: $$\theta=\sin\left(\eta\right)\exp\left(-\omega\tau\right)$$ I require $A=0$ and $B=-1$ such that: $$\psi=-\omega\cos\left(\eta\right)\exp\left(-\omega\tau\right)$$


text:
# Racah-Wigner coefficients

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

The mathematical entities known as coefficients enter mathematics and physics in describing the reduction of the -fold Kronecker product of the unitary irreducible representations of the unitary unimodular group , the group of unitary unimodular matrices, into unitary irreducible representations of . This reduction has the form:

 (a1)

where the symbols and quantities entering this relation have the following definitions:

1) denotes the -dimensional unitary irreducible representation of given explicitly below, where , and this label is called an irreducible representation label or an angular momentum quantum number.

2) denotes the matrix direct product (Kronecker product), and such products enter the left-hand side with arbitrary irreducible representation labels .

3) denotes the matrix direct sum, and the direct sum on the right-hand side contains each irreducible representation a number of times equal to

 (a2)

in which is any irreducible representation label given by

 (a3)

(see below). For an arbitrary triple of irreducible representation labels, the quantity is or , and it is if and only if the so-called triangle conditions are satisfied:

 (a4)

for .

4) denotes a real orthogonal matrix of dimension , with elements called Wigner–Clebsch–Gordan coefficients (WCG coefficients) for and generalized Wigner–Clebsch–Gordan coefficients (generalized WCG coefficients) for .

5) The summation is over all given by:

 (a5)

where is given by:

 (a6)

and the minimum value of is determined recursively from

 (a7)

The content of (a1) is completed by giving the explicit form of the unitary irreducible representations entering the direct product. These may be described as follows: Let denote an arbitrary non-negative integer and let the pairs and consist of non-negative integers such that (such pairs are called weights, or contents, of ). Introduce the homogeneous polynomials of degree in the elements of an arbitrary -matrix of indeterminates defined by:

 (a8)

where the summation is to be carried out over all -matrices of non-negative integers with row and column sums given by the weights and of :

 (a9)

Significant properties of the functions (a8) are:

transposition:

 (a10)

where denotes matrix transposition;

multiplication:

 (a11)

generation:

 (a12)

orthogonality:

 (a13)

inner product:

 (a14)

where the bar denotes complex conjugation, and are arbitrary polynomials in the , and

In the first two of these properties, denotes the -dimensional matrix with rows and columns enumerated, respectively, by the weights and as they assume all possible values for the given .

The unitary irreducible representation functions in (a1) are given in terms of the polynomials by

 (a15)

that is, by choosing , , , , , so that is any integer or half odd integer, and for each such the so-called projection quantum numbers and , which are subgroup irreducible representation labels, assume the values . By convention, these values of and label the rows and columns of the -dimensional unitary matrix . (Conventionally, the rows are labelled from top to bottom by the greatest to the least value of , and the columns are similarly labelled from left to right by ).

Often, the irreducible representation functions (a15) are presented in a form in which is parametrized. A general way of doing this is to use the property that the unitary modular matrices are in one-to-one correspondence with the points on the -dimensional unit sphere :

 (a16)

One can then parametrize the points in any manner one chooses to obtain corresponding parametrizations of the representation functions.

The definitions and results given above are the basis relations underlying the origin of all coefficients for all . The general problem leads to beautiful results and unsolved problems involving labelled binary trees, Cayley trivalent trees, and cubic graphs. This subject cannot be developed here, but its flavour can be indicated by the special results for , which are presented in summary form below, focussing on these combinatorial aspects. The formulation of the problem can also be given in a purely Lie algebra setting, where the general procedure is known as addition of angular momenta.

There is an extensive literature on this subject. Classical references include [a1], [a25], [a26], [a2], [a3], [a4], [a5], [a6], [a7], [a8], [a9], [a10], [a11], [a12], [a13], [a14], [a15], [a16], [a17], [a18], with more recent work in [a19], [a20], [a21], [a22], [a23], [a24]. The notations in [a19], [a20] are followed.

## Vector space constructions.

On assumes as given a vector space with an inner product, denoted by , where is an arbitrary integer or half integer, . This vector space also has an orthonormal basis given by the abstract ket vectors

 (a17)

with an inner product

 (a18)

Spaces corresponding to distinct are also to be perpendicular. Finally, there is an action , for each , of the unitary group , defined on such that the action on the orthonormal basis is given by:

 (a19)

It is the tensor product space with orthonormal basis

 (a20)

that underlies the -fold Kronecker product in the left-hand side of (a1). The action of on the space is defined by its action on the basis (a17):

 (a21)

Concrete realizations of these spaces are provided by the vectors defined by (a8) and (a15) with inner product (a14):

 (a22)

which under left and right translations transform, in consequence of properties (a10) and (a11), as:

 (a23)
 (a24)

## coefficients.

### Relation to Kronecker product.

 (a25)

where the -coefficient is a WCG coefficient, which is an element of the real orthogonal matrix of dimension . The coefficient has the properties

 (a26)

unless ; . These WCG coefficients satisfy the orthogonality relations

rows:

 (a27)

columns:

 (a28)

### Vector space properties.

Relation (a25) is valid when is replaced by . Using the inner product (a14) gives:

 (a29)

This relation (with a sign convention) may be used to calculate the WCG coefficients explicitly. One of the principal uses of the WCG coefficients in physical applications is the construction of a basis of the tensor product space that transforms irreducibly under the action of :

 (a30)
 (a31)

A binary tree type of notation has been used to indicate the angular momentum coupling scheme.

### Generating function.

J. Schwinger [a2] and T. Regge [a11] discovered the generating function for the WCG coefficients to be the power of a -determinant:

 (a32)

where the summation is carried out over all magic square arrays having row and column sums . The coefficient is the restricted multinomial coefficient, given by

 (a33)

where the summation is to be carried out over all , , such that the restriction is met:

 (a34)

Because of the restriction in the summation in (a33), the summation can be reduced (asymmetrically) to a sum with only one index.

The WCG coefficient is given by:

 (a35)

### Symmetries.

It follows directly from the generating function that the coefficient, which is defined by

 (a36)

has the determinantal symmetries associated with row interchange, column interchange, and transposition of the -determinant of between the parentheses, which transfer directly to the array . The coefficient is either invariant or changes its sign under the transformations of the induced by the following transformations of the array : invariance under even permutations of the rows or columns of , and under transposition: multiplication by under odd permutations of the rows or columns.

## Binary coupling theory.

In the physics literature, the phrase "binary coupling theory" addresses the problem of reducing the multiple Kronecker product (a1) by repeatedly using the reduction result (a25) for two angular momenta. One encounters immediately the problem of how to associate pairs in multiple Kronecker products. For example, for , there are two such associations:

 (a37)

For , there are five such associations:

 (a38)

In addition, all permutations of the irreducible representation labels must be considered. Entire textbooks ([a14], [a17], [a22]) have been devoted to this subject, which leads to the representation of coefficients by pairs of labelled binary trees and cubic graphs ([a20], p. 435). Some limited aspects of this subject are presented here in the context of the and coefficients.

An important topic, but one that is only partially developed, is that of generating functions for the coefficients. The property of a coefficient that characterizes its presentation in terms of a pair of labelled binary trees or in terms of a cubic graph is the set of angular momentum triangles associated with it. This number is always , the number of vertices in the associated cubic graph. A key concept for the generating function of a coefficient is that of a triangle monomial. These monomials are defined as follows: Let denote three distinct indeterminates and three angular momentum quantum numbers constituting a triangle. The triangle monomial associated with these symbols is defined by

 (a39)

Let denote the set of triangles associated with a given coefficient. The triangle monomial for this coefficient is defined as

 (a40)

The indeterminates are coordinates associated with each of the points of the cubic graph corresponding to the coefficient. This is illustrated concretely below for the and coefficients.

It must be pointed out that coefficients for are qualitatively different objects than coefficients. The vector space with basis (a20) is the carrier space of the reducible representation of given by the -fold Kronecker product in (a1). This space, which is of dimension

 (a41)

may be written as a direct sum of perpendicular vector subspaces:

 (a42)

Each subspace is of dimension and has a basis of the form (a17) that transforms under the action of in the standard way given by (a19). The coefficients () are elements of real orthogonal matrices that transform between certain pairs of these subspaces that arise in binary coupling theory, and these coefficients, taken collectively, provide the transformation between all such pairs of subspaces. The coefficients provide a single such space, as a first step in the construction of the pairs in the binary coupling method.

One of the consequences of this qualitative difference is that no generating function for a coefficient () is a power of a determinant. It is known for the and coefficients ([a2], [a15], [a16], [a21]) that these coefficients have generating functions that can be presented in the following uniform manner [a22]: There exists a polynomial with integer coefficients associated with the cubic graph corresponding to a coefficient such that

 (a43)
 (a44)

where the symbol denotes the so-called triangle coefficient, defined by

 (a45)

## coefficients.

### Relation to the Kronecker product.

The coefficients defined by

 (a46)

are elements of the orthogonal matrix for in (a1) that completely reduces the Kronecker product in the first coupling scheme given in (a37).

### Vector space interpretation.

 (a47)

 (a48)

where the coefficient is called a Racah coefficient. In fact, one could take (a48) as the definition of the Racah coefficient. It is independent of the quantum number; that is, it is a invariant. All other non-trivial binary couplings of three angular momenta lead again to Racah coefficients, up to sign. For there is only one invariant, the Racah coefficient.

It was a great feat of G. Racah [a25], [a26] (see also [a9], p. 162) to reduce the summation over four WCG coefficients in (a48), each of which is itself a summation over multinomial coefficients, to an expression involving but a single summation index. In the Wigner notation, Racah's result is given by:

 (a49)

The triangles in the (Racah) coefficient are , , , , as inherited from the WCG coefficients in (a48), and , , , denote the triangle coefficients defined in (a45). The quantities and are the discrete vertex and edge functions associated with the tetrahedron:

 (a50)

See (a55), in which the following identifications are to be made:

 (a51)

The coefficient (now using labels throughout) labelled as

 (a52)

has four triangles, which are conveniently presented as the columns of a -array:

 (a53)

### Generating function.

For the description of the generating function, the real coordinates

 (a54)

are introduced, and these are displayed, analogously to (a53) in a -array, the columns of which are interpreted as the vertices, in Cartesian -dimensional space , of a tetrahedron:

 (a55)

The array of triangles in (a53) is obtained from the by setting .

The generating function of the coefficients is now obtained from the labelled tetrahedron in (a55) by the following rules. The function on the left-hand side of (a43) is given as follows. Interchange the and symbols. Then form

the vertex function:

the edge function:

 (a56)

the tetrahedral function:

Using the tetrahedral function in the general form (a43) for gives the with the labels (a52), where the variables in a given triangle monomial (a40) with exponents given by the columns of in (a53) are those in the corresponding columns of the array on the left hand side of (a55).

### Symmetries.

The symmetries of the coefficients may be verified directly from the explicit form (a49), or from the generating function. For the coefficient written in the form

 (a57)

the symmetries are best expressed in terms of the Bargmann -array

 (a58)

as follows: The coefficient (a57) is invariant under all transformations of induced by row or column permutations of the Bargmann array. This gives symmetry relations, some simple substitutions, and other simple linear transformations.

## coefficients.

### Relation to the Kronecker product.

The coefficients defined by

 (a59)

are the elements of the orthogonal matrix for in (a1) that completely reduces the Kronecker product in the bottom binary coupling scheme given in (a38).

### Vector space interpretation.

 (a60)

 (a61)

The bracket object is Wigner's notation for the coefficient, and this relation (a61) may be taken as its definition. The summation over six WCG coefficients coming from the inner product in (a61), using (a60), may be reduced to the following summation over coefficients (a switch to a notation has been made):

 (a62)

The six triangles in a coefficient are inherited from its expression in terms of WCG coefficients, or, equivalently, from the triangles in the coefficients in (a62) not involving the summation index. It is convenient to display these six triangles as the columns in a -array:

 (a63)

### Generating function.

For the description of the generating function, the real coordinates

 (a64)

are introduced, and these are displayed, analogously to (a63), in a -array, the columns of which are interpreted as the vertices, in Cartesian -dimensional space, , of a cubic graph on six vertices:

 (a65)

The array of triangles in (a63) is obtained from the in by setting . The generating function of the coefficients is now obtained from the labelled cubic graph by the following rules. The function in the left hand side of (a43) is obtained as follows. Interchange the and symbols. Then form

the vertex function:

 (a66)

the edge function:

 (a67)

the six point cubic graph function:

 (a68)

Using the function in the general form (a43) for gives the coefficient with the labels (a62), where the variables in a given triangle monomial (a40) with exponents given by the columns of in (a63) are those in the corresponding columns of the array on the left hand side of (a65).

### Symmetries.

The coefficient has (known) symmetries, and these are just those originating from the symmetries of the six coefficients implicit on the left hand side of (a61). In terms of the coefficient written in the form (a62), these symmetries are expressed by: The coefficient (a62) is invariant under even permutations of its rows or columns, under transposition of the array, and is multiplied by the factor under odd permutations of its rows or columns.

## Concluding remarks.

A great deal of work has been done on the relationship between cubic graphs and coefficients, and the results can not even be surveyed here. It is important to point out, however, that for there is a second non-isomorphic cubic graph on six vertices, the prism, or wedge, which leads to a simple product (with dimensional factors) of two coefficients. While this is important for transforming between the relevant coupling schemes, it does not lead to a new coefficient. Indeed, it can be proved that every coefficient is a sum over products of coefficients, and sometimes this sum may degenerate to a product of coefficients (), in which case it is not counted as new. For there are always fewer "new" coefficients than non-isomorphic cubic graphs. The general problem of the relation between coefficients and non-isomorphic cubic graphs of vertices is unsolved.

Relevant to the classification of coefficients, indeed, for the definition of what the term "classification" means, are three basic relations:

triangle transformation:

 (a69)

Racah sum rule:

 (a70)

Biedenharn–Elliot identity, [a4], [a5]:

 (a71)

Each of these relations has an interpretation in terms of fundamental operations in mathematics: The triangle transformation rule is a consequence of the associativity of three symplecton polynomials, which are polynomials of the form over the four non-commuting variables (or, equivalently, over two bosons and their conjugates) which transform irreducibly under a well-defined commutation action of . Racah's sum rule has an interpretation in terms of the commutativity of a diagram associated with the coupling of three angular momenta. The Biedenharn–Elliot identity is a consequence of the associative law for three unit tensor operators. For a discussion of each of these results, see [a20], pp. 243; 453; 30.

#### References

 [a1] E.P. Wigner, "On the matrices which reduce the Kronecker products of representation of S.R. groups" L.C. Biedenharn (ed.) H. van Dam (ed.) , Quantum Theory of Angular Momentum , Acad. Press (1965) pp. 87–133 (Original: 1940 (unpublished)) [a2] J. Schwinger, "On angular momentum" L.C. Bidenharn (ed.) H. van Dam (ed.) , Quantum Theory of Angular Momentum , Acad. Press (1965) pp. 229–279 (Original: U.S. Atomic Energy Commission Reports NYO–3071, 1952 (unpublished)) [a3] L.C. Biedenharn, J.M. Blatt, M.E. Rose, "Some properties of the Racah and associated coefficients" Rev. Mod. Phys. , 24 (1952) pp. 249–257 [a4] L.C. Biedenharn, "An identity satisfied by Racah coefficients" J. Math. Phys. , 31 (1953) pp. 287–293 [a5] J.P. Elliot, "Theoretical studies in nuclear spectroscopy. V: The matrix elements of non-central forces with an application to the -shell" Proc. Roy. Soc. A , 218 (1953) pp. 345–370 [a6] H.A. Jahn, J. Hope, "Symmetry properties of the Wigner symbol" Phys. Rev. , 93 (1954) pp. 318–321 [a7] A. Arima, H. Horie, Y. Tanabe, "Generalized Racah coefficient and its application" Progress Theor. Phys. (Kyoto) , 11 (1954) pp. 143–154 [a8] A.R. Edmonds, "Angular momentum in quantum mechanics" , Princeton Univ. Press (1957) [a9] M.E. Rose, "Elementary theory of angular momentum" , Wiley (1957) [a10] U. Fano, G. Racah, "Irreducible tensorial sets" , Acad. Press (1959) [a11] T. Regge, "Symmetry properties of Clebsch–Gordan coefficients" Nuovo Cim. , 10 (1958) pp. 544–545 [a12] T. Regge, "Symmetry properties of Racah's coefficients" Nuovo Cim. , 11 (1959) pp. 116–117 [a13] W.T. Sharp, "Racah algebra and the contraction of groups" , Thesis Princeton Univ. Press (1960) [a14] A.P. Yutsis (Jucys), I.B. Levinson, V.V. Vanagas, "Mathematical apparatus of the theory of angular momentum" , Gordon&Breach (1964) (In Russian) [a15] V. Bargmann, "On the representations of the rotation group" Rev. Mod. Phys. , 345 (1962) pp. 829–845 [a16] A.C.T. Wu, "Structure of the Wigner coefficients in the Bargmann approach" J. Math. Phys. , 13 (1972) pp. 84–90 [a17] D.A. Varshalovich, A.N. Moskalev, V.K. Khersonskii, "Quantum theory of angular momentum" , Nauka (1975) (In Russian) [a18] A.P. Yutsis (Jucys), A.A. Bandzaitis, "Angular momentum theory in quantum mechanics" , Molslas , Vilnius (1977) (In Russian) [a19] L.C. Biedenharn, J.D. Louck, "Angular momentum in quantum physics" , Encycl. Math. Sci. , 8 , Cambridge Univ. Press (1981) [a20] L.C. Biedenharn, J.D. Louck, "The Racah–Wigner algebra in quantum theory" , Encycl. Math. Sci. , 9 , Cambridge Univ. Press (1981) [a21] B.R. Judd, G.M.S. Lister, "A class of generalized coefficients for " J. Phys. A: Math. Gen. , 20 (1986) pp. 3159–3169 [a22] L.C. Biedenharn, W.Y.C. Chen, M.A. Lohe, J.D. Louck, "The role of coefficients in " T. Lulek (ed.) W. Florek (ed.) S. Walcerz (ed.) , Proc. 3rd SSCPM , World Sci. (1995) pp. 150–182 [a23] M. Danos, "??" , ?? (199?) [a24] J.D. Louck, "Unitary symmetry, combinatorics and generating functions" J. Discrete Math. , ?? (199?) [a25] G. Racah, "Theory of complex spectra. II" Phys. Rev. , 62 (1942) pp. 438–462 [a26] G. Racah, "Theory of complex spectra. III" Phys. Rev. , 63 (1943) pp. 367–382
How to Cite This Entry:
Racah-Wigner coefficients. Encyclopedia of Mathematics. URL: http://www.encyclopediaofmath.org/index.php?title=Racah-Wigner_coefficients&oldid=12856
This article was adapted from an original article by J.D. Louck (originator), which appeared in Encyclopedia of Mathematics - ISBN 1402006098. See original article