text:
# How can I show a macro as text?

Say I want to make a file which has as text \documentclass{article} I found out I can do it like this:

\documentclass{article}
\begin{document}
\begin{verbatim}
\documentclass{article}
\end{verbatim}
\end{document}

That's fine. But what if I want to have as text \begin{verbatim} and \end{verbatim}?

-

You can use the fancyvrb package. This adds some nice features to the verbatim environment. Among other things it defines an environment Verbatim in which you can write \end{verbatim} since it won't match the \begin{Verbatim}.

\documentclass{article}
\usepackage{fancyvrb}
\begin{document}
\begin{Verbatim}
\begin{verbatim}
text
\end{verbatim}
\end{Verbatim}
\end{document}

-

Define a new verbatim environment with different delimitation strings:

\documentclass{article}

\usepackage{verbatim}
\newenvironment{xverbatim}{\verbatim}{\endverbatim}

\begin{document}

\begin{verbatim}
\documentclass{article}
\end{verbatim}

\begin{xverbatim}
\begin{verbatim}
\documentclass{article}
\end{verbatim}
\end{xverbatim}

\end{document}

Remember also that verbatim environments respect code indentation, so your code

  \begin{verbatim}
\documentclass{article}
\end{verbatim}

will result in four spaces in front of \documentclass{article}.

-


text:
# In how many ways can we split 6 boys and 6 girls to 6 tables such that in every table there's a boy and girl (only 2 seats per table)

In how many ways can we split 6 boys and 6 girls to 6 tables such that in every table there's a boy and girl (only 2 seats per table)?

I saw this post and I think it's kind of the same of my question

In how many ways if no two people of the same sex are allowed to sit together?

And the answer is $$2*(6!)^2$$

But then I saw this one (e) -

Discrete Mechatronics - sequences with repeats and no repeats

Which says the answer is $$2^6*(6!)^2$$

I would like to know which one is correct in my case and why? (like what are the differences)

• Do you count $BG$ and $GB$ as $1$ possibility or $2$? Dec 16, 2019 at 16:18
• 2 possibilities. Dec 16, 2019 at 16:19
• Can you have $BG$ at one table, then $GB$ at another table? The first assumes you can have either all girls on the left and boys on the right or all boys on the left and girls on the right. The second assumes that each table can be different with the gender of the person on the left and right, so long as there is a boy and girl at each table. Dec 16, 2019 at 16:20
• There are many ambiguities here. It is traditional to consider each person as being distinguishable. Now, as for the tables themselves, it is unclear whether these tables are distinguishable or not. If we have an arrangement where Amy and Adam are at a table and Bob and Bernadette are at another table, this might be considered the same outcome as where Bob and Bernadette are at a table and Amy and Adam are at another table or they might have been considered different. If, say, at one table they are serving fish and at another table they are serving chicken, if Amy has an allergy it matters Dec 16, 2019 at 16:32
• Then, it also matters whether we consider arrangement within a table to matter. If we have an arrangement where Amy and Adam are at a table, and so on, is this necessarily a different arrangement than an arrangement where Adam and Amy are at a table... Maybe one of the chairs at the table is 20 feet high and the other chair is very short. If Amy is scared of heights, it matters to her whether she is in the 20 foot chair or not. Dec 16, 2019 at 16:34

Fix a table. Choose a boy and a girl for the table. Choose an order for the boy and girl.

You have six boys and six girls to choose from. Then, you can order them in two ways. So, this is $$6\times 6\times 2$$ ways to arrange one boy and one girl at the first table.

For the second table, you have five boys left, five girls left, and two ways to arrange then, entirely independent from the arrangement of the first table (the only dependency is that you have one fewer boy and one fewer girl to choose from).

So, there are $$5\times 5\times 2$$ ways to arrange one boy and one girl at the second table (after a boy and girl were already arranged at the first table).

For the third table, you have $$4\times 4\times 2$$ ways to arrange them. For the fourth table, you have $$3\times 3 \times 2$$ ways to arrange them. For the fifth table, you have $$2\times 2\times 2$$ ways to arrange them. For the last table, you have $$1\times 1\times 2$$ ways to arrange them.

Because each table is arranged independently from the arrangements of the previous tables, you can apply the product principle. So, the total is:

$$(6\cdot 6\cdot 2)(5\cdot 5\cdot 2)(4\cdot 4\cdot 2)(3\cdot 3\cdot 2)(2\cdot 2\cdot 2)(1\cdot 1\cdot 2) = 2^6(6!)^2$$

• Perfect, thank you! Dec 16, 2019 at 16:47

In the first reference, the boys and girls are sitting in a line with no two people of the same gender are allowed to sit together. So there can be two cases. First in which a boy sits first and the second when a girl sits first. While in your case as you've mentioned in the comments there can be two possibilities for each table GB or BG. Thus you have a multiplier of 2 for each table along with every permutation of boys and girls.

In other words, $$2*(6!)^2$$ is equivalent to the case when each table should have the same layout i.e either all the table should be BG or GB, while $$2^6*(6!)^2$$ is the case where each table can BG or GB independent of the other.

• OK. So, can I think about it as dividing into pairs(6!6!) and then choosing a table? Dec 16, 2019 at 16:33
• Yes. That would be a good strategy here. Dec 16, 2019 at 16:35
• @Combinatoric It is not clear what you mean by dividing into pairs (6!6!) and then choosing a table... 6! is choosing which boy (or girl) sits at which table. Dec 16, 2019 at 16:39
• @InterstellarProbe can you find another way to explain it? I want to make sure I really get it. Dec 16, 2019 at 16:40
• @Combinatoric assuming tables are distinguishable, for table A, pick a boy ($6$ options) then pick a girl ($6$ options). Next, for table B pick a boy from those remaining ($5$ options) and then pick a girl from those remaining ($5$ options). Continue until all tables have the people picked, giving $6\cdot 6\cdot 5\cdot 5\cdots 1\cdot 1 = 6!\cdot 6!$ options for distributing the people. If we then care about which chair was used for each person at the tables themselves, for table A pick if the boy sat in the high chair or the low chair and let the girl sit in the other, for $2$ options, etc. Dec 16, 2019 at 16:42

format: plain


text:
# 259: Single Photon Interference - Fourth Version

This analysis of the operation of a Mach-Zehnder Interferometer (MZI) will use tensor algebra and the creation and annihilation operators.

An interferometer arm can be occupied or unoccupied. These states are represented by the following vectors.

$Unoccupied: | 0 \rangle = \begin{pmatrix} 1 \\ 0 \end{pmatrix}$

$Occupied: | 1 \rangle = \begin{pmatrix} 0 \\ 1 \end{pmatrix}$

After the first beam splitter the photon is in an even superposition of being in both arms of the interferometer. By convention a 90 degree phase shift is assigned to arm b to preserve probability. In terms of the concept of occupation, the superposition takes the following form in tensor algebra.

$|S \rangle \xrightarrow{i} \frac{1}{ \sqrt{2}} [|1 \rangle_a | 0 \rangle_b + i | 0 \rangle_a 1 | \rangle_b ] = \frac{1}{ \sqrt{2}} \bigg[ \begin{pmatrix} 0\\ 1 \end{pmatrix}_a \otimes \begin{pmatrix} 1\\ 0 \end{pmatrix}_b + i \begin{pmatrix} 1\\ 0 \end{pmatrix}_a \otimes \begin{pmatrix} 0\\ 1 \end{pmatrix}_b \bigg] = \frac{1}{ \sqrt{2}} \begin{pmatrix} 0\\ i\\ 1\\ 0 \end{pmatrix}$

$\Psi = \frac{1}{ \sqrt{2}} \begin{pmatrix} 0\\ i\\ 1\\ 0 \end{pmatrix}$

The matrix operators required for this analysis are as follows.

Creation:

$C = \begin{pmatrix} 0 & 0 \\ 1 & 0 \end{pmatrix}$

Annihilation:

$A = \begin{pmatrix} 0 & 0 \\ 1 & 0 \end{pmatrix}$

Number:

$N = \begin{pmatrix} 0 & 0 \\ 1 & 0 \end{pmatrix}$

Identity:

$I = \begin{pmatrix} 0 & 0 \\ 1 & 0 \end{pmatrix}$

The effect of the creation, annihilation and number operators on |0> and |1>:

$C \begin{pmatrix} 1\\ 0 \end{pmatrix} = \begin{pmatrix} 0\\ 1 \end{pmatrix}$

$A \begin{pmatrix} 0\\ 1 \end{pmatrix} = \begin{pmatrix} 1\\ 0 \end{pmatrix}$

$N \begin{pmatrix} 1\\ 0 \end{pmatrix} = \begin{pmatrix} 0\\ 0 \end{pmatrix}$

$N \begin{pmatrix} 0\\ 1 \end{pmatrix} = \begin{pmatrix} 0\\ 1 \end{pmatrix}$

The creation operator is the Hermitian adjoint of the annihilation operator and the annihilation operator is the Hermitian adjoint of the creation operator.

$\overline{(A^T)} = \begin{pmatrix} 0 & 0\\ 1 & 0 \end{pmatrix}$

$\overline{(C^T)} = \begin{pmatrix} 0 & 1\\ 0 & 0 \end{pmatrix}$

The number operator is the product of the creation and annihilation operators.

$CA = \begin{pmatrix} 0 & 0\\ 0 & 1 \end{pmatrix}$

$\overline{(A^T)} A = \begin{pmatrix} 0 & 0\\ 0 & 1 \end{pmatrix}$

$\overline{(C^T)} C = \begin{pmatrix} 0 & 0\\ 0 & 1 \end{pmatrix}$

The eigenvectors of the number operator are |0> and |1> with eigenvalues 0 and 1, respectively:

$eigenvecs(N) = \begin{pmatrix} 1 & 0\\ 0 & 1 \end{pmatrix}$

$eigenvals(N) = \begin{pmatrix} 0\\ 1 \end{pmatrix}$

There are two paths to each detector. This provides the opportunity for constructive and destructive interference. To arrive at D1 the a-arm photon state is reflected (90 degree phase shift) at BS2 and the b-arm photon state is transmitted at BS2. Therefore, photon detection requires the annihilation of the superposition of these paths to D1. The annihilation is achieved with the following operator.

$\frac{iA_a + A_b}{ \sqrt{2}}$

The product of this operator with its Hermitian conjugate (see above) creates the number operator for photon detection at D1.

$N_{D1} = \frac{iC_a + C_b}{ \sqrt{2}} + \frac{iA_a + A_b}{ \sqrt{2}}$

The D1 number operator is formed using Mathcad's kronecker command as follows:

ND1 = $$\frac{1}{2}$$ (-i kronecker (C, I) + kronecker (I, C)) (i kronecker (A,I) + kronecker (I, A))

To arrive at D2 the a-arm photon state is transmitted at BS2 and the b-arm photon state is reflected (90 degree phase shift) at BS2. Photon detection at D2 requires the annihilation of the superposition of these paths to the detector. The annihilation is represented the following operator.

$\frac{iA_a + A_b}{ \sqrt{2}}$

Therefore, the number operator for photon detection at D2 is:

$N_{D2} = \frac{C_a + iC_b}{ \sqrt{2}} \frac{A_a + iA_b}{ \sqrt{2}}$

The D2 number operator is formed using Mathcad's kronecker command as follows.

ND2 = $$\frac{1}{2}$$ (kronecker (C, I) - i kronecker (I, C)) (kronecker (A,I) + i kronecker (I, A))

We now show that the photon always arrives at D1 and never at D2 for an equal arm MZI.

Expectation value for photon detection at D1:

$\overline{ \Psi ^T} N_{D1} \Psi = 1$

Expectation value for photon detection at D2:

$\overline{ \Psi ^T} N_{D2} \Psi = 1$

Equivalent results can be obtained algebraically. Operating on $$\Psi$$ with the D1 number operator yields $$\Psi$$. In other words, $$\Psi$$ is an eigenfunction of ND1 with eigenvalue 1.

$\bigg[ \frac{-C_a + C_b}{ \sqrt{2}} \frac{iA_a + A_b}{\sqrt{2}} \bigg] \frac{1}{ \sqrt{2}} \big[ |1 \rangle_a |0 \rangle_b + i|0 \rangle_a |1 \rangle_b \big] = \frac{1}{ \sqrt{2}} \big[ |1 \rangle_a |0 \rangle_b + i|0_a |1 \rangle_b \big]$

Operating on $$\Psi$$ with the D2 number operator yields 0.

$\bigg[ \frac{C_a - iC_b}{ \sqrt{2}} \frac{A_a + iA_b}{\sqrt{2}} \bigg] \frac{1}{ \sqrt{2}} \big[ |1 \rangle_a |0 \rangle_b + i|0 \rangle_a |1 \rangle_b \big] = 0$


text:
# Metabelian group

(Redirected from Meta-Abelian group)

In mathematics, a metabelian group is a group whose commutator subgroup is abelian. Equivalently, a group G is metabelian if and only if there is an abelian normal subgroup A such that the quotient group G/A is abelian.

Subgroups of metabelian groups are metabelian, as are images of metabelian groups over group homomorphisms.

Metabelian groups are solvable. In fact, they are precisely the solvable groups of derived length at most 2.

## Examples

• Any dihedral group is metabelian, as it has a cyclic normal subgroup of index 2. More generally, any generalized dihedral group is metabelian, as it has an abelian normal subgroup of index 2.
• If F is a field, the group of affine maps ${\displaystyle x\mapsto ax+b}$ (where a ≠ 0) acting on F is metabelian. Here the abelian normal subgroup is the group of pure translations ${\displaystyle x\mapsto x+b}$, and the abelian quotient group is isomorphic to the group of homotheties ${\displaystyle x\mapsto ax}$. If F is a finite field with q elements, this metabelian group is of order q(q − 1).
• The group of direct isometries of the Euclidean plane is metabelian. This is similar to the above example, as the elements are again affine maps. The translations of the plane form an abelian normal subgroup of the group, and the corresponding quotient is the circle group.
• The finite Heisenberg group H3,p of order p3 is metabelian. The same is true for any Heisenberg group defined over a ring (group of upper-triangular 3 × 3 matrices with entries in a commutative ring).
• All nilpotent groups of class 3 or less are metabelian.
• The lamplighter group is metabelian.
• All groups of order p5 are metabelian (for prime p).MSE
• All groups of order less than 24 are metabelian.

In contrast to this last example, the symmetric group S4 of order 24 is not metabelian, as its commutator subgroup is the non-abelian alternating group A4.


text:
# Why Are Astronauts Weightless?

In this segment, the Veritasium guy asks why astronauts inwards the infinite station are weightless. The most mutual respond is because at that spot is no gravity inwards space. But of cast at that spot is gravity inwards space, peculiarly where the infinite station is located (only most 400km from Earth’s surface). So astronauts all the same sense a gravitational delineate – it’s only that they as well as the infinite station are inwards complimentary autumn as well as thus they are accelerating together towards the Earth. The infinite station doesn’t crash into the globe because of its orbital velocity – it’s going 28,000 km/h as well as thus equally it falls, the globe curves away from it.

Sumber http://bestphysicsvideos.blogspot.com/

Baca Juga:  Rotational Speed (Brightstorm)


text:
## siddhantsharan 2 years ago Find the Real Roots of: Equation in comment.

1. siddhantsharan

$1 + x + x^2 /2! + x^3 /3! ..........x^6/6! = 0$

2. Mikael

Obviously real roots - if exist at all - must be negative numbers.

3. siddhantsharan

Agreed.

4. Mikael

Noe we have a war on our screens - the great war between the Good Evens (pos) and the bad Odds (neg)

5. Mikael

clearly $\Sigma |Evens| < \Sigma |Odds|$ if x > 6 and we can improve this estim.

6. siddhantsharan

Haha. Yeah. Note that x^6 rises much faster than x^5 and so on the rest of the Good Evens And bad odds. So for some x no roots.

7. siddhantsharan

Okay. Same thing as you said.

8. Mikael

I rose faster than your treacherous spoiler "help"

9. Mikael

DO NOT "help" as long as not requested

10. siddhantsharan

Hmm. Although this estimate will help us calculate an approximate value, how will we actually find the roots?

11. siddhantsharan

Sorry. No help from now on.

12. siddhantsharan

addictive poisonous byproduct? I beg to differ. Okay, for now, shutted up. Continue.

13. siddhantsharan

Okay. Back to the problem if you may.

14. Mikael

well now I see two ways (thinking aloud ) 1 A fixed point transformation which is abit elusive 2 Some ad hoc trickery - I got it I thik...

15. Mikael

What you have is the head of Exonential series

16. KingGeorge

Just thinking about it, but this is the first part of the Taylor expansion of $$e^x$$ centered at $$x=0$$, and it has an even power, so I'm going to guess it has no real roots.

17. Mikael

Now these series are a generating function

18. Mikael

I beat you purple King as your other messenger

19. siddhantsharan

Haha. Good guess. My first thoughts too. However I think this is only till the degree is even. @KingGeorge

20. KingGeorge

If it's odd, by definition it must have at least one real root.

21. Mikael

Look @KingGeorge please let me do my try ? can you

22. siddhantsharan

@KingGeorge By definition? @Mikael Let everybody try.

23. KingGeorge

Perhaps not "by definition," but by "fundamental theorem of algebra." Any complex roots have to occur in pairs, and if you have an odd power, then no matter how you pair them up, you're always left with at least one not paired up, so it must be real.

24. siddhantsharan

Okay. Yes. Agreed.

25. Mikael

Soo, SOLVED !

26. Mikael

Here it is

27. Mikael

Your function diffrentiated is itself - last member

28. Mikael

f - f' = x^6/6!

29. Mikael

It is some sort of generating unction type argument with exp(x) and its derivatives

30. Mikael

If f(x_1) = 0 ==> f'(x_1) = = x^6/6!

31. Mikael

meant - x^6/6!

32. Mikael

So at the root the derivative (slope) must be negative

33. Mikael

But this is either my mistake or Impossibele- since we know that after the largest in absol-value negative root the function Must become Poistive fo all larger-abs-value negative x-s. ?...

34. Mikael

After all - at minus-infty it tends to +infty

35. Mikael

So the leftmost root - the crosiing MUST be from negative to positive.

36. Mikael

I am still claiming it does go +infty at x--> -infty and Wolfram approves it

37. Mikael

So it seems NO roots becomes quite closer to reality - dont you say ?

38. Mikael

Yes and so NO REAL roots is approved By Mister Stephan son of Hugo and Sybil

39. Mikael

@siddhantsharan No real roots to that one

40. Mikael

Mister @KingGeorge - some encouragement here ?

41. Mikael

@TuringTest @Algebraic! Please acknowlege I proved this not easy problem. Please - the guy who gave it turned out to be a fox - he logged out at the second of solution. And so did other moderator

42. TuringTest

I would give you acknowledgement if I had the time to check, but I don't right now sorry

43. Mikael

So $f(x) - f'(x) = \frac{x^6}{6!} \text{which means that at the root } f'(x) = - \frac{x^6}{720} \text{which IS NEGATIVE}$

44. Mikael

But it is clear that the coefficient of x^6 which is the largest power is positive ==> therefore $\lim_{x \to -\infty} f(x) = + \infty$

45. Mikael

So the last crossing of the x-axis MUST be from negative y-s to positive y-s ==> UPWARDS so that means that f'(x) at the last crossing should be Positive - while the above says it is negative. Contradiction to existence of such crossing. No real roots exist. Q.E.D.

46. Mikael

@TuringTest this is something of injustice. Please read the 20 lines I have rewritten clearly now. Is their some kind of problem acknowledging a solution of hard riddle ? The guy CALLED me to solve it after all.

47. Mikael

Thank You @demitris I hope @TuringTest will also see it was ingenious enough for his appreciation of the effort and the breakthrough

48. Mikael

Tahnks @TuringTest . Where are the people who asked the question in the first place ?... vanished JUST IN TIME don't you say ....

49. TuringTest

Okay I understand your solution, but I really would not clamor for appreciation like that People just drop out for various reasons frequently. I never have nor have most of the high-ranking people here. It just doesn't seem becoming.

50. TuringTest

it is a nice solution though :)

51. siddhantsharan

Sorry @Mikael It was just getting late so I shut down the pc. Doesnt mean I wont come back. I do appreciate the solution, nice reasoning. I didnt "vanish" knowing that you would have a solution. Sorry for the misunderstanding. Well done and cheers :)

52. siddhantsharan

@Mikael We could say that directly too. If f(x) has real roots, It must have at least 2 real roots ( Complex exist in pairs.) Since it's positive initially For two real roots, f'(x) must be zero when f(x) is negative. Clearly from f(x) - f'(x) > 0 that is not possible. Is this reasoning correct?

53. Mikael

Yes that's almost so. But once again you Must use the eqn f-f'=x^6 because technically there is a possibilty od Double real root. then f=f'=0 at this root and the impossibility stems from the x^6 contradiction. All correct - $\bf \color{brown}{BUT \,\,LONGER\,\,proof\, ,and\,\,HEAVY \,\, WEAPONS !}$ A) It uses the Fundamental Theorem of Algebra which is UNNECESSARY in my proof, AND usually unproovable, and often even unheard-of to high school / early college which is overwhelmingly the people on this site. B) Well it is longer. Of course all that is not mathematics but simply style and purpose.

54. RaphaelFilgueiras


text:
MarkFL
6 followers
6 followers
MarkFL's posts
Post has attachment
Floor Function Problem...
Solve the following equation: $\displaystyle \left\lfloor x+\frac{7}{3} \right\rfloor^2-\left\lfloor x-\frac{9}{4} \right\rfloor=16$ Note: $\displaystyle \lfloor x \rfloor$ denotes the largest integer not greater than $x$. This function, referred to as the ...
Post has attachment
Find The Area Of The Equilateral Triangle
Show that the curve $x^3+3xy+y^3=1$ has only one set of three distinct points, $P$, $Q$, and $R$ which are the vertices of an equilateral triangle, and find its area. My solution: The first thing I notice is that there is cyclic symmetry between $x$ and $y$...
Post has attachment
Find The Sum Involving The Inverse Tangent Function
We are given to evaluate: $S_n=\sum_{k=0}^n\left[\tan^{-1}\left(\frac{1}{k^2+k+1} \right) \right]$ My solution: Using the identity: $\tan^{-1}(x)=\cot^{-1}\left(\frac{1}{x} \right)$ we may write: $S_n=\sum_{k=0}^n\left[\cot^{-1}\l... Post has attachment Analytic Geometry: Orthogonal Trajectories The problem is as follows: a) Find the family of circles centered on the y-axis, that pass through the points (\pm a,0), where [math]0<a\le r\in\mathbb{R}$. b) Find the family of curves orthogonal to the family of circles found in part a). Hint 1:...
Post has attachment
Probability: Coin Tossing
A while back I helped a student with a probability problem, and I took the problem, generalized it a bit, and wish to post it here. Here is the problem: A coin has the probability $p$ of turning up heads when tossed. Suppose we toss the coin $2n$ times, whe...
Post has attachment
Trigonometric Inequality
Show that : $\left( {\sin x + a\cos x} \right)\left( {\sin x + b\cos x} \right) \leq 1 + \left( \frac{a + b}{2} \right)^2$ Let: $A=\tan^{\small{-1}}(a)$ $B=\tan^{\small{-1}}(b)$ Using a linear combination, we may write the i...
Post has attachment
Maximize The Area Of The Lune
In the $xy$ plane, there are two circles, a larger one of radius 1 unit and a smaller one of radius $r$. The two circle intersect such that the two points of intersection are on a diameter of the smaller circle. Find the value of $r$ which maximizes the are...
Post has attachment
Maximizing The Trajectory Of A Projectile
Suppose we are asked to compute the launch angle which will maximize the arc-length of the trajectory for a projectile, assuming gravity is constant and is the only force on the projectile after the launch. Eliminating the parameter $t$, we find the object'...
Post has attachment
Test Post: Embedding Desmos API
Here is an interactive graph Did it work?
Post has attachment
Minimize The Crease
Consider a rectangular piece of paper of width $W$ laid on a flat surface. The lower left corner of the paper is bought over to the right edge of the paper, and the paper is smoothed flat creating a crease of length $L$, as in the diagram: What is the minim...


text:
# Why are anticausal systems even defined?

I guess the same question is usually asked for complex numbers too, but the fact is that complex numbers are used all the time practically. However, at least on a quick google search, I couldn't find any applications of anticausal systems. So why define it in the first place?

• I prefer the term "noncausal". To a native speaker, "anticausal" implies a system whose response is only dependent on future inputs, where "noncausal" implies a system whose response is dependent on future and past inputs. – TimWescott Jan 18 at 18:03
• i might suggest the word "acausal" rather than "noncausal". Matt alludes to this point, but when doing non-realtime, offline processing (you are processing the sampled data of a signal stored in a file and outputing the resulting signal to another file), you can pretend the pointer to "the present" is wherever you want it to be if that makes your life simpler. For linear-phase filters, you have symmetrey in the impulse response about a common delay, but you can make that a zero-phase filter by making that location of common delay equal to the present time, when $t=0$. – robert bristow-johnson Jan 18 at 18:49
• @TimWescott, I was indeed referring to a system where the response is dependent only on future inputs – Pradyoth Shandilya Jan 18 at 19:00

Of course they don't exist. But we can stop time and use systems that would be non-causal if we hadn't stopped time. Stop time? Yes, just store your data and work offline / non-realtime. Or work on data that are not temporal but something else, for instance spatial. Of course, non-causal is a misnomer in that case, but the term is still used, in analogy with temporal signals and systems.

One common "non-causal" system that is used in offline mode is filtering followed by reversed filtering using IIR filters. This is done in order to eliminate phase distortions introduced by the conventional (causal/realtime) use of the filter. See this answer for the details.

First, because noncausal systems drop out of the math all the time, often when we're looking for some form of optimal filter.

Second, because if you don't mind adding delay to your system, or working offline, you can make a FIR noncausal system into a causal system simply by delaying it by the time span that it looks into the future. For an IIR noncausal system, you can truncate the anticausal part of the response, and then delay the response so that your result is causal.

I would first disagree on complex numbers. Even if they look odd (imaginary, impossible), they are very central, and some believe they are the most appropriate algebraic structure in many natural situations. Think again of the real numbers, do infinite sequences of decimals really exist?

Second, our human perception of time as a one-directional stream may be misleading. The fact that our brain and senses seem to perceive past only does not impede backward symmetry in physical laws. Some even model that antimatter could be matter moving backward in time (in some specific sense). Exotic theories can imagine that time might be two-dimensional. From a more pragmatic point of view, in simulation, one may consider to control a present state with future predicted values, which can be formalized by an anticausal system. Of course, in practice, those future estimations are obtained by past information.

So, they are defined not because one can exhibit one in reality, but because they are useful models, like instantaneous systems, or infinite precision computations, that are unlikely ("All models are wrong, but some are useful").

• I did say that complex numbers, although weird looking, are very useful in the question – Pradyoth Shandilya Jan 18 at 19:01
• They are more than "just useful" or practical. They are "real", IMO – Laurent Duval Jan 18 at 19:16


text:
# What loss function avoids overconfidence?

In the case of a neural net with a relatively small training data set, doing simple classification with categorical cross entropy (log loss), it is very easy for the results of the network to be "overconfident" because that improves log loss on the training data.

What I mean by overconfident (this is partly intuition and partly something that can be derived from Bayesian stats): given 1000 training examples in 2 equal classes, it is unreasonable for any classifier to give a probability of a new input as being in one class or the other which is substantially higher than (1-1/1000), even if the classifier is perfect on the training data. That is because if the training set was increased by just one more example, the 1001st example could break whatever rule seems to have been followed in the data set up to that point, and that would force all the predicted values/probability estimates to be updated accordingly.

However, in practice trained neural nets with log loss function will output values which are arbitrarily close to 0 or 1 given a long enough training run, because that continues improving their performance on the training data way past the point that it makes sense to do so based on the size of the training data.

The question: how can the usual log loss function be modified so that making predictions extremely close to 0 or 1 does not hugely improve log loss compared to predictions which are only somewhat close?

You could add a penalty by adding a small "distance" to every loss calculation. They you would have a "floor" below which no comparison could be below. The tricky decision is how large to make the penalty. There is a large literature on how to choose the "right" penalty that keep your overconfidence low but maximizes the predictive ability.

If you have a copy of "The Elements of Statistical Learning", then look at page 61 and the 10 + pages following that. There are also other items in the index covering penalized methods. The Wikipedia article on the Lasso methods is also a possible starting point.

When I type this into an R console on a new Linux box I'm outfitting:

 ??penalized

I get:

Help pages:

brglm::profileObjectives        Objectives to be profiled
mda::gen.ridge      Penalized Regression
mgcv::bam       Generalized additive models for very large datasets
mgcv::bam.update        Update a strictly additive bam model for new data.
mgcv::gam       Generalized additive models with integrated smoothness estimation
mgcv::jagam     Just Another Gibbs Additive Modeller: JAGS support for mgcv.
mgcv::null.space.dimension      The basis of the space of un-penalized functions for a TPRS
mgcv::pcls      Penalized Constrained Least Squares Fitting
mgcv::smooth.construct.bs.smooth.spec       Penalized B-splines in GAMs
mgcv::smooth.construct.cr.smooth.spec       Penalized Cubic regression splines in GAMs
mgcv::smooth.construct.tp.smooth.spec       Penalized thin plate regression splines in GAMs
quantreg::rq.fit.lasso      Lasso Penalized Quantile Regression
rms::pentrace       Trace AIC and BIC vs. Penalty
VGAM::sm.ps     Defining Penalized Spline Smooths in VGAM Formulas
VGAM::summarypvgam      Summarizing Penalized Vector Generalized Additive Model Fits

I would have gotten more if I were using my older machine ( a macpro that died recently) but I havent' installed an lasso-type packages yet. There are quite a few:

> rownames(available.packages()[  grep("lasso", available.packages()[,1]) , ])
[1] "biglasso"      "cglasso"       "CVglasso"      "DIFlasso"      "dpglasso"      "elasso"
[7] "extlasso"      "gglasso"       "glamlasso"     "glasso"        "glassoFast"    "GPCMlasso"
[13] "grplasso"      "hglasso"       "iilasso"       "ipflasso"      "lasso2"        "lassopv"
[19] "lassoscore"    "lassoshooting" "lmmlasso"      "nnlasso"       "palasso"       "ppmlasso"
[25] "prioritylasso" "PUlasso"       "sealasso"      "sglasso"       "Tlasso"

• Thanks! Could you give a few literature examples on how to choose the "right" penalty? I think it may need to be related to the size - and noisiness - of the training set... Dec 7, 2018 at 19:08
• There is a huge literature on this topic. See above. The penalty to apply to a particular feature depends on a host of factors. These come immediately to mind: the magnitude of the measurements (typically measurements are normalized to get them all on comparable scales), the degree of cross correlation in the signals, the dispersion and skewness of deviations from predictions, and the degree of non-linearity in the functional relationships between predictors and outcomes.
– 42-
Dec 7, 2018 at 20:31


text:
Lorena Beard

2022-07-06

How many different permutations can you make with the letters in the word seventeen?

Leslie Rollins

Expert

Step 1
A total of 7560 permutations are possible with the letters in the word Seventeen.
Explanation:
We can use the following formula:
If there are n objects with r types, then $\frac{n!}{\text{}{n}_{1}!{n}_{2}!{n}_{3}!{n}_{4}!......{n}_{r}!}$.
The word given is :
Seventeen
Observe that there is a total of 9 alphabets in the word.
The letter S appears 1 time
The letter E appears 4 times
The letter V appears 1 time
The letter N appears 2 times
The letter T appears 1 time
Step 2
We can calculate the different permutations as follows:
$\frac{\text{9 !}\phantom{\rule{1ex}{0ex}}}{\text{1 ! 4 ! 1 ! 2 ! 1 !}}$
$⇒\frac{\text{9 !}\phantom{\rule{1ex}{0ex}}}{\text{}1\cdot 24\cdot 1\cdot 2\cdot 1}$
$⇒\frac{362,880}{48}$
$⇒7560$
Hence, a total of 7560 permutations are possible with the letters in the word Seventeen.

Do you have a similar question?

Recalculate according to your conditions!


text:
January 25, 2022, 11:16:09 PM
Forum Rules: Read This Before Posting

### Topic: Christmas  (Read 8003 times)

0 Members and 1 Guest are viewing this topic.

#### Corvettaholic

• Guest
##### Christmas
« on: December 27, 2004, 12:05:22 PM »
So what did everyone get for Christmas? A million bucks? Coal?

#### jdurg

• Banninator
• Retired Staff
• Sr. Member
• Posts: 1366
• Mole Snacks: +106/-23
• Gender:
• I am NOT a freak.
##### Re:Christmas
« Reply #1 on: December 27, 2004, 03:31:29 PM »
Pretty much nothing.    I got a Sony DSC-P73 digital camera, but I wound up having to spend 130 bucks to get an AC Adapter and a memory stick that can hold more than one picture.  I then got some Seinfeld DVDs, a couple t-shirts, a pair of gloves, and a wool hat.  That was it.
"A real fart is beefy, has a density greater than or equal to the air surrounding it, consists

#### Corvettaholic

• Guest
##### Re:Christmas
« Reply #2 on: December 27, 2004, 04:05:54 PM »
I got a couple shirts, some cologne, and an AK-47. I'm fairly happy with the latter! Just need to get some ammo.

#### Donaldson Tan

• Editor, New Asia Republic
• Retired Staff
• Sr. Member
• Posts: 3177
• Mole Snacks: +261/-13
• Gender:
##### Re:Christmas
« Reply #3 on: December 27, 2004, 06:07:36 PM »
i got a creative muvo2 FM 5GB mp3 player..

I want a M16 for a present.. with plenty of 5.56mm rounds..
"Say you're in a [chemical] plant and there's a snake on the floor. What are you going to do? Call a consultant? Get a meeting together to talk about which color is the snake? Employees should do one thing: walk over there and you step on the friggin� snake." - Jean-Pierre Garnier, CEO of Glaxosmithkline, June 2006

#### Corvettaholic

• Guest
##### Re:Christmas
« Reply #4 on: December 28, 2004, 12:57:00 AM »
M16's are okay I suppose, but they jam easily! I found a legal way for me to own a rocket launcher (and use) in the state of Arizona! I love this lawless state!

#### limpet chicken

• Full Member
• Posts: 750
• Mole Snacks: +49/-27
• Gender:
• Vote Limpet for supreme emperor of the new order
##### Re:Christmas
« Reply #5 on: December 28, 2004, 01:03:50 AM »
I got a nice executice leather revolving chair for my PC, which is a great improvement over its predeccessor, an almost brokan plastic deck chair

A new hard drive, money, just general good stuff really

Talking of heavy weapons, I have been looking into grenade launchers myself recently, and thinking of buying and retrofitting a CO2 powered repeating rifle with an improvised M203 style undermounted grenade launcher
The light blinds
So behold darkness as our new light
In our darkness we can see
So with others blindness
We take flight.

#### Corvettaholic

• Guest
##### Re:Christmas
« Reply #6 on: December 28, 2004, 11:06:45 AM »
As much as I love improvised anything (experimentation IS fun), I would like to have a real M203. I can legally do it too, with enough money. There's the trick though. With half that money, I could just build my own. I think we toyed with the idea of electromagnetics, but that would be too much weight to launch a grenade. Better off using gas operated.

#### jdurg

• Banninator
• Retired Staff
• Sr. Member
• Posts: 1366
• Mole Snacks: +106/-23
• Gender:
• I am NOT a freak.
##### Re:Christmas
« Reply #7 on: December 28, 2004, 02:32:55 PM »
I just got a HORRIBLE gift from the Tax Collector of my town.    A $300 property tax bill on my car. They've had an entire f&#^$*@ year to send me this bill, but no.  The douche-bags wait until the final week of the year, just after Christmas when I have ZERO dollars with which to pay the bill for.  Even worse, because of the timing I won't be able to claim it on my tax return for next year since I don't have the money to pay it off until next week.  Merry f&#^\$*@ Christmas.
"A real fart is beefy, has a density greater than or equal to the air surrounding it, consists

#### Corvettaholic

• Guest
##### Re:Christmas
« Reply #8 on: December 28, 2004, 05:17:18 PM »
You get property tax on your car? Wow. You should move out west, and the weather is nicer! What part of PA are you from anyway? I was visiting Philly and Hatborough for a little bit 2 years ago, really pretty out there!

#### jdurg

• Banninator
• Retired Staff
• Sr. Member
• Posts: 1366
• Mole Snacks: +106/-23
• Gender:
• I am NOT a freak.
##### Re:Christmas
« Reply #9 on: December 29, 2004, 12:39:25 AM »
You get property tax on your car? Wow. You should move out west, and the weather is nicer! What part of PA are you from anyway? I was visiting Philly and Hatborough for a little bit 2 years ago, really pretty out there!

I'm not from PA.  I only went to school there in West Chester which is in the Southeastern corner of the state.  I currently reside in Southeastern, CT.
"A real fart is beefy, has a density greater than or equal to the air surrounding it, consists

#### Corvettaholic

• Guest
##### Re:Christmas
« Reply #10 on: December 29, 2004, 10:50:05 AM »
Doh! I knew that! Cause I looked at the member map a ways back. No idea why I said PA... heh.


text:
# Arithmetic function inequality

Fix integers $n$ and $k$. Why is $$\sum_{\substack{d < n\\(d, k) = 1}} \frac{\mu(d)^{2}}{\varphi(d)} \geq \sum_{\substack{d < n\\(d, k) = 1}}\frac{1}{d}?$$

-
Why do you think this is true? – Thomas Andrews Nov 26 '12 at 15:39

2nd try. I hope this works well.

Collect $d$'s that have prime divisors $\left\{p_1 , \cdots , p_k\right\}$.

Note that because $\mu$ is zero for non-square-free, the only surviving term on the LHS is $\frac{1}{\phi(p_1 \cdots p_k)}=\frac{1}{(p_1-1)\cdots (p_k-1)}$.

For RHS, the sum is less than $\frac{1}{p_1\cdots p_k}(1-\frac{1}{p_1})\cdots (1-\frac{1}{p_k})$.

Because $\frac{p}{p-1}>1>1-\frac{1}{p}$, we know that $LHS > RHS$ for any collection of primes $\left\{p_1 , \cdots , p_k\right\}$.

Well, now sum over the collection $\left\{p_1 , \cdots , p_k\right\}$.

Then there are many repeated terms on the RHS when we sum over $\left\{p_1 , \cdots , p_k\right\}$, of course, but that's irrelevant because each terms are positive.

Hence LHS $\geq$ RHS and equality holds only when $d=1$(i.e, there is no prime that divide some d's).

-


text:
Random relativity question.

1. Sep 19, 2011

DavidAlan

A friend and I had an interesting thought and would like to know if it has any consequences.

It is a well known fact that a time-varying electric field is non-conservative, it has a time-dependent Hamiltonian, blah, blah, blah, blah. I'll give this a standard treatment to set up the punchline,

Suppose you have some charged particle in this field, you traverse a closed loop and your net work is nonzero.
$\oint_{\partial S}\mathbf{E}\cdot d\mathbf{l}\neq0$.

However, while energy is NOT conserved, we have Maxwell's equations telling us that
$\mathbf{E}=-\nabla\phi-\partial_{0}\mathbf{A}$.

Now, if we define an analogous gradient operator in Minkowski space; I think this is just a covariant derivative with the Minkowski metric, then Stoke's theorem applied to a closed path readily shows that the time-varying electric field IS conservative (mathematically speaking) in Minkowski space. The closed loop integral should be zero because if we integrate with this metric, the gradient we have defined appears on the RHS of Maxwell's equation above. Mind you, you must consider the electric field as being the gradient of the four-potential.

Regardless, energy cannot be conserved. But something, fictitious or not, IS conserved. Does anyone know of any consequences of this?

If I recall, E=mc^2 is merely a consequence of Lorentz invariance. Would one expect to get this out of this song and dance? I think this would make for an interesting problem, and I cannot think of a way to work it out.
1. The problem statement, all variables and given/known data

2. Relevant equations

3. The attempt at a solution

2. Sep 19, 2011

Phrak

Yes, we can form an analogous gradient--or differential operator in Minkowski space, and even better, over generalized coordinates within special relativity. You should take a quick look at the Faraday tensor with lower indices in the wikipedia article, here.

http://en.wikipedia.org/wiki/Electromagnetic_tensor" [Broken]

$$F_{\mu \nu} = \frac{\partial A_\mu}{\partial x^\nu} - \frac{\partial A_\nu}{\partial x^\mu}$$

Here, A is four dimensional. $A_0$ is $\phi$. Zero indexes the temporal part of a four dimensional potential that units A and $\phi$ into a four dimensional vector. Indices 1 through 3 are the usual magnetic potentials with lower indices.

As you correctly surmised, these are covariant derivates of E as well as B.

I'm not sure how you think that the integral of E dot dl over a closed loop should be zero after substitution of E with its derivates in A, however.

In fact, I don't know how it should go. And thank you for the provocative quesiton. What do you get after substitution?

Last edited by a moderator: May 5, 2017


text:
What's new

# Duration will understate the position

#### rahul.goyl

##### Member
Hi David,

I am not sure if am getting this correct,
In the below post, Duration will overstate for Negative Yield shock (- 25 Bps) instead Understate & (Vica-Versa) Understate
for Positive Yield Shock (+25 Bps).

>> http://www.bionicturtle.com/wiki/FRM2009.L1.12/

12c. If the bond has no embedded options, given the yield shock of +25 bps, is the actual bond position likely to be greater than, equal to, or less than the anticipated by the formula that uses duration and convexity?
Greater than; i.e., the loss in value will be less than predicted so the position value will be greater than predicted. Duration (first order linear approximation) will understate the position; convexity improves with a second-order measure but, if the bond is plain-vanilla, there will still be a gap between the estimated position and the actual position.

Regards,
Rahul

#### David Harper CFA FRM

##### David Harper CFA FRM
Staff member
Subscriber
I made a mistake here, in regard to convexity (not in regard to duration).

In regard to duration, for vanilla bond as convexity adj is always positive, duration does give an estimate of bond price that underestimates the actual price.

the + yield shock (+ 25bps) gives the linear estimate of change. So, for example, perhaps duration alone gives an estimate of -2% change in bond price given a + 25 bps yield shock. As the price/yield curve has convexity, the actual bond price (at initial yield + 25 bps shock) is higher than predicted by the line. So, for + 25bps, loss in price is overstated and actual bond position is greater than predicted by duration only.

However, I goofed in regard to this question, which is about the error that convexity implies: as the third term Taylor series = 1/6*f'''(initial yield)*yield shock cubed (where f''' is third derivative, or first derivative of convexity), the subsequent adjustment, if we extended the taylor series would be:
duration + convexity +1/6*(a negative third derivative)*(yield shock)^3
i.e., if positive yield shock, a MINUS adjustment and if negative yield shock, a PLUS adjustment

... so, in regard to duration + convexity, a +25 bps understates the actual loss (i.e., b/c further taylor expansion would introduce a tiny MINUS) and so the actual is LESS THAN
... a -25 bps understates the gain, since (-)*(-) = (+), such that actual is greater than for a negative shock

so, thanks for pointing this out. Sorry if the language confuses: duration's error is correct, it always gives an estimated bond price that is below the actual price (i.e., underestimates the gain and overestimates the loss; as the line is always below the P/Y curve) but I was too simple re convexity's error: it is different in each direction.

Thanks for pointing this out! David


text:
## Precalculus (6th Edition)

The domain is $(-\infty, 0) \cup (0, \infty)$. The range is $(0, \infty)$.
The denominator is not allowed to be positive since dividing $0$ to any number gives an undefined expression. This means the value of $x$ cannot be zero. Thus, the domain is any real number except zero. In interval notation, the domain is $(-\infty, 0) \cup (0, \infty)$. The range is the set that contains all the possible values of $f(x)$ (or $y$). Note that the value of $\dfrac{1}{x^2}$ will never be equal to zero since when any non-zero number is divided to $1$, the quotient is always a non-zero number. Note further that, since the value of $x^2$ is always non-negative, then the quotient $\dfrac{1}{x^2}$ will always be non-negative as well. Thus, the range is the set of positive real numbers. In interval notation, the range is $(0, \infty)$.


text:
# Best Data Format for Video Processing

Posted under

## Table of Content

My humble Ph.D. project is emotion recognition on videos using deep learning. As a newbie, the three keywords, videos, deep learning, and emotion recognition, together make the data processing a real pain on my ass.

First, a video is usually "larger" than an image. Video data can be taken as arrays of 2D image data. They are usually more time- and space-consuming for saving and loading compared with image data.

Second, in the deep learning context, data are usually mini-batched for each epoch before feeding to neural networks. In the most ideal case, the data should be entirely loaded in the memory for mini-batching, resulting in a more neat and readable code. If the data is too large for the memory specs, one can only choose to slice the data into several groups and perform the loading one group at a time. The ideal and awkward cases are summaried in the pseudo pythonic code below.

# The ideal case
# do something

# The awkward case
for some_data in entire_data:

# do something

Third, in the context of emotion recognition and neural science, the data are usually subject-wise. Also, the process of downsampling, windowing, and cross-validation are usually required.

The following scenarios show how painful it could be when the three keywords appear together.

• Your dataset has 100 videos.
• Each video are sized as $10000\times3\times120\times120$ for dimension length, channel, width and height.
• Each video of uint8 type requires $10000\times3\times120\times120\times8=3.456$ Gb memory to be entirely loaded, theoretically.
• Each video will require $3.456\times4=13.824$ Gb memory in float32 type.
• Definitely you cannot load 100 videos into your memory even if you are using a fancy server with $250$ Gb memory.
• Usually you are not meant to load an entire video, but to load some frames of it, say, only the first frame for every $n$ frames, to meet the downsampling requirement.
• Should you load one video completely then indexing it?
• Should you preprocess the video to several pieces of smaller videos so that you can load some of them completely instead?
• You will have to generate an appropriate index for this idea.
• You will have to generate another index to restore the windowed output to the original shape for visualization and analysis, it can be much more complex in this case.

How to deal with all these complications with neat code while achieving an awesome spatial/temporal trade-off?

## Goal

In this post, I would compare several data formats in terms of:

• the disk space usage, and

Basically, the data will be created and loaded. For the latter, the disk space, memory, and time cost will be recorded.

The data formats include:

• static images,
• mp4,
• binary,
• mat,
• pickle,
• hdf5/h5 (they are literally the same),
• npy.

For the static images option, we simply create 10000 jpg images with random values. For other formats, a 4D numpy matrix (length, channel, width, height) will be randomly initialized.

For hdf5/h5 format, I will create the data with and without chunking. So that we can see if it's a good idea to chunk the data in a frame-wise manner.

For npy format, I will load it with and without memory mapping.

## Experiment

The code is shown at the end of the post.

#### Creating Data

I simply create a video of white noise in all the data formats mentioned above.

I assume that only the first frame of every four frames of each video format is needed. This is equivalent to downsampling the data so that only the ${0, 4, 8, \ldots, 9992, 9996}$-th frames are sampled.

## Result

##### Table 1. The disk, memory and time cost for loading a downsampled video in various format. The original video has 10000 frames. In the experiment, only the first frame for every 4 frames is sampled. The first column lists the data formats of the video (10000 images). The second column lists the disk usage of the video in each data format. The third and fourth columns list the memory and time usage to load part of the video (2500 images, i.e., $1/4$ of the video). h5 1 denotes the h5 file saved without chunking. h5 2 denotes the h5 file saved with frame-wise chunking. npy 1 denotes the npy file loaded without memory mapping. npy 2 denotes the npy file same as for npy 1 loaded with memory mapping.
Format Disk Space (Mb) Memory (Mb) Time (s)
jpg 118.000 102.0 4.358
mp4 36.088 102.6 1.578
binary 432.000 411.9 0.335
mat 432.000 412.1 0.358
pickle 432.000 412.0 0.864
h5 1 432.361 416.0 0.804
h5 2 442.021 881.1 2.644
npy 1 432.000 412.0 0.309
npy 2 432.000 ~0.0 0.004

## Conclusion

It is not possible to save memory usage by indexing part of the data matrix to be load. In the code, I attempted to load only the first frame for every $4$ frames, yet the binary, mat, pickle and h5 format all consumed around 412 Mb usage, which is exactly $400\%$ of that by frame-wise loading of jpg and mp4 format.

The npy format with memory map mode specified has an indescribably amazing performance on memory and time cost. We should use it more often!

When the mmap mode is enabled, the file is memory-mapped. A memory-mapped array is kept on disk. However, it can be accessed and sliced like any ndarray. Memory mapping is especially useful for accessing small fragments of large files without reading the entire file into memory.

In our context, the npy format with memory mapping is particular welcomed because no matter how large the data are in the disk, we can instantly load them into the memory, if only the disk space is affordable. In my Ph.D. project, a dataset in npy format is usually as large as $30-50$ Gb which is not an issue at all, even for a PC.

The jpg format can save memory usage because we manually controlled the loading in the forloop, the same achieved for mp4 format because I read it frame-by-frame and selectively load the needed frames. Though jpg and mp4 format can save disk space usage compared to the other formats, the time cost, however, is not cool at all.

The binary, mat, pickle, h5, npy formats all have the same disk space usage. Except for the npy format and inappropriately chunked h5 format, all of them have almost the same memory usage.

For h5 file, definitely, it is not a good idea to chunk the data for each frame. Considering the power-user-only instruction of chunking provided by the official h5py package, the brain-burning calculation of chunking size, and the changing downsampling interval, why should we use h5 format when there is npy format available? (Maybe I just made a bold claim but I choose to use npy format :)

## Endnote

I used to work with static images at the beginning and found that it was extremely slow to load the data. Most of the elapsed time was for data loading, not computing. Then I moved to mp4 format and was happy because it has amazingly small disk usage. Then I realized that it was also slow to load, and was memory-eager. I had to save the video of a trial as several small mp4 clips in the hard disk, and then load them according to a list. Later when the output was yielded I had to use another list to place the output on the original position with respect to the complete video of that trial.

My life was easier when I met the npy format. Thanks to it I can save a single video as a single npy file. I can load all the npy files into memory without any issue, and resample them according to a specific index for each data item. To restore, I do not need to calculate a new one but simply resort to the same index as the loading.

Overall, by using the npy format, the training is faster (about 2-3 times) and the code is dramatically simplified (hundreds of lines reduced). And I have spent nearly five months just to figure this out...

#### Appendix

The following packages are installed by pip in a virtual environment of Python 3x:

pip install pillow numpy scipy opencv-python memory_profiler h5py

The following is the code.

import cv2
import numpy as np
import os
import pickle
import time
import h5py
from PIL import Image
from tqdm import tqdm
import scipy.io as sio
from memory_profiler import profile

def creating_data(num_image=10000, dim=120, channel=3):

# Create 10000 static images
for i in tqdm(range(num_image)):
image = np.random.randint(0, 254, (dim, dim, channel), dtype=np.uint8)
image = Image.fromarray(image)
image.save("data/static/" + str(i) + ".jpg")
print("Data in static jpg format has been created!")

# Create a video with 10000 frames
# In mp4 format
codec = cv2.VideoWriter_fourcc('m', 'p', '4', 'v')
writer = cv2.VideoWriter(filename="data/mp4.mp4", fourcc=codec, fps=64, frameSize=(dim, dim), isColor=True)
for i in tqdm(range(num_image)):
frame = np.random.randint(0, 254, (dim, dim, channel), dtype=np.uint8)
writer.write(frame)
writer.release()
print("Data in mp4 format has been created!")

# In plain hdf5/h5 format
video = np.random.randint(0, 254, (num_image, channel, dim, dim), dtype=np.uint8)
with h5py.File("data/h5_plain.h5", "w") as data_file:
data_file.create_dataset(name="video", data=video, compression="gzip", compression_opts=9)
print("Data in plain hdf5/h5 format has been created!")

# In chunked hdf5/h5 format
hdf5_file = h5py.File('data/h5_chunked.h5', 'w')

first_frame = np.random.randint(0, 254, (channel, dim, dim), dtype=np.uint8)
hdf5_dataset = hdf5_file.create_dataset('video', data=first_frame[None, ...], maxshape=(
None, first_frame.shape[0], first_frame.shape[1], first_frame.shape[2]), chunks=True, compression="gzip", compression_opts=9)

for i in tqdm(range(num_image-1)):
image = np.random.randint(0, 254, (channel, dim, dim), dtype=np.uint8)
hdf5_dataset.resize(hdf5_dataset.len() + 1, axis=0)
hdf5_dataset[hdf5_dataset.len() - 1] = image
hdf5_file.close()
print("Data in chunked hdf5/h5 format has been created!")

# In mat format
sio.savemat("data/mat.mat", {'video': video})
print("Data in mat format has been created!")

# In binary format
with open("data/binary.bin", "wb") as file:
bytes(video)
file.write(bytes(video))
print("Data in binary format has been created!")

# In pickle format
with open('data/pickle.pkl', 'wb') as handle:
pickle.dump(video, handle, protocol=pickle.HIGHEST_PROTOCOL)
print("Data in plain pickle format has been created!")

# In npy format
np.save('data/npy.npy', video)
print("Data in npy format has been created!")

@profile
data_matrix = np.zeros((2500, 3, 120, 120), dtype=np.uint8)
for i, file in enumerate(os.listdir("data/static")):
if i % 4 == 0:
filename = os.path.join("data/static", file)
data_matrix[i //4] = np.asarray(Image.open(filename)).transpose((2, 0, 1))

@profile
data_matrix = np.zeros((2500, 3, 120, 120), dtype=np.uint8)
cap = cv2.VideoCapture('data/mp4.mp4')
for i in range(10000):
if i % 4 == 0:
data_matrix[i // 4] = frame.transpose((2, 0, 1))

@profile
with h5py.File("data/h5_plain.h5", "r") as f:
data_matrix = f['video'][()][::4]

@profile
with h5py.File("data/h5_chunked.h5", "r") as f:
data_matrix = f['video'][()][::4]

@profile
with open('data/pickle.pkl', 'rb') as f:

@profile
data_matrix = mat_content['video'][::4]

@profile
data_matrix = np.fromfile("data/binary.bin")[::4]

@profile

@profile

if __name__ == '__main__':
# creating_data(num_image=10000, dim=120, channel=3)

start = time.time()
elapsed = time.time() - start

start = time.time()
elapsed = time.time() - start

start = time.time()
elapsed = time.time() - start

start = time.time()
elapsed = time.time() - start

start = time.time()
elapsed = time.time() - start

start = time.time()
elapsed = time.time() - start

start = time.time()


text:
# Why are Group 11 elements unreactive?

Group 11 metals namely $\ce{Cu, Ag, Au}$ are known for their low reactivities. They are thus rightly called coinage metals and have been historically used to make currency owing to this very property of theirs. My question is, what is the reason behind this behaviour?

Is it because of the stability of fully filled and half filled orbitals? But then the counterexample of $\ce{Cu-Zn}$ presents itself. These are neighbours in the periodic table, and the differentiating electron in each goes completes a full or half-filled orbital, yet $\ce{Zn}$ is quite reactive.

This behaviour can be seen (sort of) between $\ce{Hg-Au}$ as well which differ in one electron and yet are completely different in terms of their properties.

EDIT: The other two questions referred to as duplicates of this one cite different properties of the elements that make them unreactive. Gold has strong $\ce{Au-Au}$ bonds (due to relativistic effects) and $\ce{Zn}$ is more reducing than copper due to factors like hydration energy and the enthalpy of atomization. But this does not answer my question because:

• I was looking for the root cause of this behaviour. If gold is stabilized by relativistic effects, why don't these effects operate on other transition metals? If zinc has high hydration enthalpy, what is the reason?

• Since all the coinage metals occur in a single group, I really wanted an explanation that could apply to all of them, such as a peculiarity of their electronic configuration that renders them inert to most available reagents.

• Jun 5 '15 at 16:47
• Yeah...$\ce{Zn^{2+}}$ is a pseudo-inert ion...due to filled orbital Jun 11 '15 at 4:07

The first step toward answering this question is understanding the extent to which the statement "Group 11 metals are unreactive" is or isn't true.

As stated in How do plants respond to copper deficiency? Plant Signaling and Behavior vol. 3, pages 231-232:

The transition metal copper is essential for all organisms.

It is not just that copper is present in every living thing. Copper is reacting in every living thing. Copper ions cycle between the +1 and +2 oxidation states in Plastocyanin, Copper/zinc superoxide dismutase and cytochrome oxidase. So as you are saying copper is unreactive, it as reacting in cytochrome oxidase in every mitochondrion of your body, and in Cu/Zn superoxide dismutase in the cytosol of cells through your body.

One way to quantify the reactivity of metal ions in through reduction potential, here listed for reduction of the ion to the zero oxidation state metal. (limiting to d-block metals at least as unreactive as Cu)

\begin{array}{c @{:} c} \\ \color{blue}{\text{Ion}} & \color{blue}{\text{Reduction potential}} \\\hline \mathbf{\color{red}{Cu^{2+}}} & 0.3419 \\\hline \ce{Tc^2+} & 0.400 \\\hline \ce{Ru^2+} & 0.455 \\\hline \ce{Cu+} & 0.521 \\ \hline \ce{Rh+} & 0.600 \\ \ce{Rh^2+} & 0.600 \\ \ce{Rh^3+} & 0.758 \\ \hline \mathbf{\color{red}{Ag^+}} & 0.7996 \\\hline \ce{Os^2+} & 0.85 \\\hline \ce{Hg^2+} & 0.851 \\\hline \ce{Pd^2+} & 0.951 \\\hline \ce{Ir^3+} & 1.156 \\\hline \ce{Pt^2+} & 1.18 \\\hline \mathbf{\color{red}{Au^{3+}}} & 1.498 \\ \ce{Au+} & 1.692 \\ \end{array}

Looking at this list, we see that there are a substantial number of d-block metals that are less reactive than copper. A few are less reactive than silver, and gold is the least reactive on the basis standard reduction potential.

The overall trend in d-block metals, is down and to the right in the block is less reactive. The exception is that, for a given row, the group 12 metal is more reactive than the group 11 metal, but due to the formation of a 2+ ion, not a 1+ ion.

Next we should look at ionization energies of d-block metals to see how much of the reduction potential corresponds to properties of an individual atom, versus bulk or solvent effects.

Looking at first-ionization energies, for each row of the d-block, the highest ionization energy is always the group 12 element (Zn, Cd, Hg). This corresponds well with the fact the Zn, Cd and Hg do not form +1 ions. The group 11 elements have significantly lower first-ionization energies, and do form +1 ions.

Then looking at second-ionization energies, group 11 has the highest second-ionization energies for every row of the d-block!

Much of the reactive/unreactivity of d-block is explained by the increase of nuclear charge to the right and down the d-block. The complete d-shell of neutral group 11 atoms shields the valence s electron well enough that it may be removed to react. However, to lose 2 electrons, the group 11 elements would need to lose a d-electron from a completed d-shell, which is difficult. For group 12, two s valance electrons can be lost, and the complete d-shell maintained.

• I see your point. Even if their unreactivity isn't anything exceptional, there must be something special about the group 11 elements. These are widely used for many applications, whereas their neighbours are relatively unknown by comparison. Jun 17 '15 at 14:41
• @Gerard Ag, Cu and Au are the top 3 best electrical conductors at room temperature. This is probably the main reason for the high production rate of copper today. Jun 17 '15 at 15:16
• @Gerard Also, Cu, Ag, Hg, and Au were the least reactive metal known to ancient people (before 1500). The other metals listed in my answer: Ru, Rh, Os, Pd, Ir, Pt, Tc, were first understood to exist generally in the 1740-1940 time period. Jun 17 '15 at 15:30

The classic paper of Dr. Norskov explained this phenomenon very well. (Off topic: Dr. Norskov is like the godfather of catalysis and I had a chance to meet him at a summer school and that was a great experience for me.)

The inertness of metal surface to adsorb depends on two factors:

1. Degree of filling of $d$ orbital
2. Degree of overlapping of orbital

Gold and Copper both has filled $d$ orbital ($d^{10})$. That means the main contributor to the reactivity of transition metal is totally absent here.

Now the second factor is very crucial to explain the inertness. In case of hydrogen adsorption on $\ce{Au}$ and $\ce{Cu}$ the anti-bonding orbital is below Fermi level, that means anti-bonding is filled for the adsorption of $\ce{H}$ on $\ce{Au}$ and $\ce{Cu}$.

From the first picture, we can see that for noble metals Fermi level is too high and in the second (actual SCF DOS) picture we can see that $\ce{Au}$, $\ce{Cu}$ had anti-bonding DOS which is below the Fermi level. Now, How it can explain the inertness? Fermi level is almost analogous to HOMO.

Fermi level is the energy level where the orbital has equal probability of being filled or unfilled (Fermi-Dirac statistics). From the left picture of the 1st picture you can see the energy profile. To better explain I tried to use some abstract numerical number to define the importance of anti-bonding orbital.

Suppose you want orbitals $A$ and $B$ to form the MO $AB$. Now $A$ has energy -10 and $B$ has energy -15, so they have total -25 unit energy. Now for the stability, the system will always try to minimize energy. The bonding orbital has -30 unit energy and anti-bonding orbital has 7 unit energy. So they have total -23 unit energy.

So the question is why the bonding + the anti-bonding energy > $A + B$. The reason is when an atomic orbital forms a molecular orbital, there is an energy penalty associated due to the orthogonalization of the orbitals. So, in case of $\ce{H2}$ formation, there is no electron in antibonding orbital, so total energy is reduced and that's why $\ce{H_2}$ is more stable than $\ce{H}$ atom; while in the case of $\ce{He}$, both bonding and anti-bonding orbitals are filled, so it's energetically more favorable for it to be in an isolated state.

Now, In $\ce{Cu}$ and $\ce{Au}$ the antibonding state is below the Fermi level, that means anti-bonding states are filled and that's why it is energetically unfavorable. But in case of $\ce{Ni}$ and $\ce{Pt}$ antibonding orbital is above Fermi level and hence the adsorption process is more favorable. There are some other terms to explain it from the quantum mechanics viewpoint (like the overlap matrix $V_{sd}^2$ and some other fundamental terms) but the basic idea is the DOS of bonding and anti-bonding orbitals are the main reason for this inertness.

I'm taking a stab at this.

Ok, so the issue with the group 11 metals, as far as I can see, is that while, yes, their s orbitals are not filled, they do not exist in isolation: they have neighbors who all have only 1 electron in them. So, they form very strong allotropes. In other words, gold would have been reactive, but there are other golds right there it can bond with and so share electrons with it. So the group 11 elements form large networks of allotropes, where electrons freely flow and are shared with other atoms of their kind. These bonds are very stable, and ergo, very hard to break. In fact, Au-Au bonds have been found to stabilize some very strange molecules: see here.


text:
# If $M$ is a compact, contractible $n$-manifold (with boundary) then $\partial M$ is a homology (n-1)-sphere.

This is exercise 3.3.33 in Hatcher.

Show that if $$M$$ is a compact contractible $$n$$-manifold then $$\partial M$$ is a homology $$(n-1)$$-sphere; that is, $$H_i(\partial M; \mathbb{Z}) \approx H_{i}(S^{n-1}; \mathbb{Z})$$ for all $$i$$.

I have a proof for this in the case that $$M$$ is orientable using Lefschetz duality. I don't know how to prove it in the case that $$M$$ is not orientable.

Is there some reason that a compact contractible manifold (with boundary) needs to be orientable?

If not, how should I go about proving this without orientability?

• Hint: Contractibility says something about $\pi_1$. Non-orientability says something different about $\pi_1$. – Jason DeVito Oct 6 '18 at 1:13
• @JasonDeVito Jason, I thought about that earlier. I know the theorem for manifolds without boundary but does it for sure hold with boundary? – TuoTuo Oct 6 '18 at 1:44
• The theorem is for any topological space where the "usual" covering space theory applies. So, semi-locally simply connected, locally path connected, etc. Whatever those usual hypotheses are. Certainly all topological manifolds have them, as do all CW complexes, etc. (maybe I need to assert finitely many cells in each dimension? probably not - but I don't usually think of things nastier than that) – Jason DeVito Oct 6 '18 at 1:49
• @JasonDeVito I don't really know what it means for a space that is not some sort of manifold to be orientable, but it sounds right that a manifold with boundary should be orientable if it's simply connected. – TuoTuo Oct 6 '18 at 1:54
• Yeah, good point about the orientability requiring a nice space. In fact, now that I think about it more, I'm not positive about the connection between $\pi_1$ and orientability when there is a boundary involved.... – Jason DeVito Oct 6 '18 at 2:09

A manifold with boundary is defined to be orientable if $$int(M) = M \setminus \partial M$$ is orientable. Since simply connected manifolds are orientable, it suffices to show that $$int(M)$$ is simply connected.
In fact $$int(M)$$ is contractible. It is known that $$\partial M$$ has an open collar neighborhood $$N$$ in $$M$$ (see Hatcher, Proposition 3.42). Let $$h : \partial M \times [0,1) \to N$$ be a homeomorphism such that $$h(x,0) = x$$ for all $$x$$. Define $$M' = M \setminus h(\partial M \times [0,1/2)) \subset int(M)$$. This is a homeomorphic copy of $$M$$. But obviously $$M'$$ is a strong deformation retract of $$int(M)$$, hence $$int(M) \simeq M' \simeq \ast$$.
• @MikeMiller You are right, that is the better approach, at least for differentiable manifolds. For topological manifolds without boundary one can use the tangent microbundle instead. For topological manifolds with boundary this approach requires to consider collars, and an orientation of $M$ in the micro-bundle sense is essentially the same as an orientation of $int(M)$. Anyway, Hatcher avoids the use of bundles and defines an orientation of $M$ to be one of $int(M)$ (see p. 253 of his book).. – Paul Frost Oct 6 '18 at 15:22
• @PaulFrost Interesting, good point. I think one could hack together some notion of local homology at a point $x \in A$ of a pair $(X,A)$ and use this to define boundary orientation more like the interior case. But of course this is wholly unnecessary. – user98602 Oct 7 '18 at 19:22