text:
Posted by: Silvio Capobianco | 2014/05/15

## Random Settings in Cellular Automata Machines

In cellular automata machines such as the CAM8 and SIMP/STEP (which is CAM8’s software incarnation) memory is organized into planes: each plane represents a certain type of information. A single cell spans through planes.

Consider, for example, the HPP (Hardy, de Pazzis and Pomeau) lattice gas model. In HPP, gas particles travel along the lines of a square grid and collide in the nodes of the grid. The collision rule states that, if exactly two particle meet in a node, and they come from opposite direction, then they bounce with a $90^\circ$ angle; in all other cases, particles go straight ahead. In SIMP/STEP, we can construct the HPP lattice gas model by defining interaction as follows:

    def hpp_rule():
if north == south and east == west:
north._ = east
east._  = south
south._ = west
west._  = north
hpp_step = Rule(hpp_rule)

Suppose, however, that the update rule is not deterministic but randomized. For example, in the FHP lattice gas model, which has six direction on a triangular lattice, the principle is the same as for HPP, but the direction (clockwise or counter-clockwise) of the $60^\circ$ rotation is chosen at random. This can be done by initializing a single plane with $50\%$ zeros and ones, and have the cell read the corresponding bit and interpret it as the direction of the rotation. To ensure non-repetition, during the update the plane will be moved by a random offset. In SIMP/STEP, it would look more or less like the following:

    def fhp_rule():
if north == south and east == west and ne == sw:
if r: # rotate clockwise
north._ = west
west._  = sw
sw._    = south
south._ = east
east._  = ne
ne._    = north
else: # rotate counter-clockwise
north._ = ne
west._  = north
sw._    = west
south._ = sw
east._  = south
ne._    = east
fhp_step = Sequence([Stir([r]), Rule(fhp_rule)])

It might be the case, however, that we need different probability distributions in different points. In such a case, it would be anti-economical to set as many random planes as needed distributions: instead, one would want to set as few planes as possible with random distributions, and exploit the flexibility given by the application of boolean functions to said planes. Different cells might then have different types, and interpret differently the state of the random planes.

Let us make a quick example with a single plane, initialized with probability $p_0$. If we pass a bit, whose value is $1$ with probability $p_0$, to a boolean function $f$ of a single argument, then the output bit will have a Bernoulli distribution with parameter $p$ which depends on both $p_0$ and $f$. Specifically, $p$ will be 0 if $f$ is the constant function $0$, $p_0$ if $f$ is the identity, $1-p_0$ if $f$ is the negation, and 1 if $f$ is the constant function 1: which exhausts the possibilities of a single bit.

In general, $N$ random bits with independent Bernoulli distrinutions of parameters $p_0, p_1, \ldots, p_{N-1}$ can yield up to $2^{2^N}$ possible distributions for the output bit of an $N$-to-1 boolean function. It then becomes of interest to understand how to set the parameters $p_0, p_1, \ldots, p_{N-1}$ in order to obtain a convenient range of values for $p$ just by changing the specific $f$. In particular, we are interested in obtaining the uniform range

$0, \dfrac{1}{2^{2^N}-1}, \ldots, \dfrac{2^{2^N}-2}{2^{2^N}-1}, 1$

which minimizes the maximum distance between the value desired and the one which is actually obtained. A general solution to this problem was described by Mark Smith in his 1994 PhD thesis under the supervision of Tommaso Toffoli.

Before examining Smith’s method, let us observe that the denominator in the formula above is the $2^N$-th Mersenne number. The sequence of Mersenne numbers is defined by the formula

$M_n = 2^n - 1 \;\; \forall n \geq 1$

In general, Mersenne number are not primes: indeed, it is a standard exercise in elementary number theory that $M_m$ is a factor of $M_n$ if $m$ is a factor of $n$, so that a Mersenne number can be prime only if its index is prime: such condition is not sufficient, as $M_{11} = 2047 = 23 \cdot 89$.

Let us go back to the case $N=1$: we know that, in this case, given the value of the parameter $p_0$ we can get any of the values $0$, $p_0$, $1-p_0$, $1$. To have these values coincide with $0$, $1/3$, $2/3$, $1$ it is thus sufficient to set $p_0 = 1/3$.

Let us now consider the case $N=2$. We know that, in this case, the denominator should be $2^{2^2}-1 = 15$: so we are strongly tempted to set $p_0 = 1/3$ again, then $p_1 = 1/5$, which would give us $p = 1/15$ when $f(b_0, b_1) = b_0 \wedge b_1$ is the boolean AND. But how do we know that we may get the remeining values as well?

To prove this, let’s do a thought experiment. Suppose we have a rectangle, whose height and width are in $3:5$ ratio: let us make two cuts, one on the short side at $1/3$ of the heigth, the other on the long side at $1/5$ of the width. The sizes of the four pieces obtained are in proportion with each other as the numbers $1 = (1)_2$, $2 = (10)_2$, $4 = (100)_2$, and $8 = (1000)_2$. But every integer number between $0$ and $15$ has a unique writing as a sum of one or more of the fourn numbers above: and indeed, we can also choose the output probability $p$ with any given value of the form $k/15$ with $k$ an integer between $0$ and $15$. To decide which function $f$ we have to use to get probability $p = n/15$ for the output b, we proceed as follows:

1. We write $(n)_{10} = (b_3 b_2 b_1 b_0)_2$.
2. We choose $f$ so that $f(i) = 1-b_i$ for every $i = 0, 1, \ldots, n-1$.

For example, if we want $p = 7/15$, we take the function $f$ that takes value $1$ only on the pair $(1,1)$.

To generalize to arbitrary many bits, we introduce Fermat numbers, defined by the formula

$F_n = 2^{2^n} + 1 \;\; \forall n \geq 0$

We easily get

$F_n \cdot M_{2^n} = M_{2^{n+1}}$

that is, the product of the $n$-th Fermat number and the $2^n$-th Mersenne number is the $2^{n+1}$-th Mersenne number. This leads us to

Theorem. If the probability of bit $b_i$ is $1/F_i$, then all and only the probabilites $k/M_{2^{n+1}}$ with $k$ between $0$ and $M_{2^{n+1}}$ can be obtained. Such arrangement is the only one that allows recovering all said probabilities in output, up to a rearrangement of the bits.

That such arrangement of probabilities for the input bits allows to obtain every possible value in the range $0, 1/M_n, \ldots, (M_n-1)/M_n, 1$, is easily proven via a generalization of the reasoning we made for the case $n=2$. Uniqueness follows inductively from the relation $M_{2^{n+1}} / M_{2^n} = F_n$.


text:
# How can we edit a java program?

Java programs are simple text-based programs and can be edited using any text editor like notepad etc. The filename should be same as class name.

format: plain


text:
# 4.2.2.5. Counting constraints¶

These constraints count and restrict how many times certain values occur in an array of variables. MiniZinc will automatically generate the basic counting constraints below from expressions such as count(i in x)(i=c) <= d, so you can write models in this much more readable style instead of using these predicates. However, if your model contains multiple counting constraints over the same array, constraints like distribute or global_cardinality below may be useful.

## among¶

 1. predicate among(var int: n, array [$X] of var $$E: x, set of$$E: v) 2. function var int: among(array [$X] of var $$E: x, set of$$E: v)  Requires exactly n variables in x to take one of the values in v. Returns the number of variables in x that take one of the values in v.

## count_geq¶

 predicate count_geq(array [$X] of var $$E: x, var$$E: y, var int: c) predicate count_geq(array [$X] of var $$E: x,$$E: y, int: c)  Constrains c to be greater than or equal to the number of occurrences of y in x.

## count_gt¶

 predicate count_gt(array [$X] of var $$E: x, var$$E: y, var int: c) predicate count_gt(array [$X] of var $$E: x,$$E: y, int: c)  Constrains c to be strictly greater than the number of occurrences of y in x.

## count_leq¶

 predicate count_leq(array [$X] of var $$E: x, var$$E: y, var int: c) predicate count_leq(array [$X] of var $$E: x,$$E: y, int: c)  Constrains c to be less than or equal to the number of occurrences of y in x.

## count_lt¶

 predicate count_lt(array [$X] of var $$E: x, var$$E: y, var int: c) predicate count_lt(array [$X] of var $$E: x,$$E: y, int: c)  Constrains c to be strictly less than the number of occurrences of y in x.

## count_neq¶

 predicate count_neq(array [$X] of var $$E: x, var$$E: y, var int: c) predicate count_neq(array [$X] of var $$E: x,$$E: y, int: c)  Constrains c to be not equal to the number of occurrences of y in x.

## distribute¶

 1. predicate distribute(array [$X] of var int: card, array [$X] of var int: value, array [$Y] of var int: base) 2. function array [$X] of var int: distribute(array [$X] of var int: value, array [$Y] of var int: base)  Requires that card[i] is the number of occurrences of value[i] in base. The values in value need not be distinct. Returns an array of the number of occurrences of value[i] in base. The values in value need not be distinct.

## global_cardinality_closed¶

 1. predicate global_cardinality_closed(array [$X] of var int: x, array [$Y] of int: cover, array [$Y] of var int: counts) 2. predicate global_cardinality_closed(array [$X] of var opt int: x, array [$Y] of int: cover, array [$Y] of var int: counts) 3. predicate global_cardinality_closed(array [$X] of var int: x, array [$Y] of int: cover, array [$Y] of int: lbound, array [$Y] of int: ubound) 4. predicate global_cardinality_closed(array [$X] of var opt int: x, array [$Y] of int: cover, array [$Y] of int: lbound, array [$Y] of int: ubound) 5. function array [$Y] of var int: global_cardinality_closed(array [$X] of var int: x, array [\$Y] of int: cover)  Requires that the number of occurrences of cover[i] in x is counts[i]. The elements of x must take their values from cover. Requires that the number of occurrences of cover[i] in x is counts[i]. The elements of x must take their values from cover or be absent. Requires that for all i, the value cover[i] appears at least lbound[i] and at most ubound[i] times in the array x. The elements of x must take their values from cover. Requires that for all i, the value cover[i] appears at least lbound[i] and at most ubound[i] times in the array x. The elements of x must take their values from cover or be absent. Returns an array with number of occurrences of cover[i] in x. The elements of x must take their values from cover.


text:
# Chi-square in Mystery Island

This is a tale of statistics and probability, gaming, the pursuit of truth, and lockdown boredom.

In late March 2020, as lockdowns were being imposed by governments across the world and travel was no longer an option for many, gamers in their millions, from school-age children to millennials, were still able to fly away to the parallel universe that is the latest instalment of Nintendo’s Animal Crossing (full disclosure: this article is unfortunately not a paid partnership between Golden Square Tutors and Nintendo!).

If you – like yours truly – have yourself never had a chance to play, the game is about turning a deserted island into a thriving village, inhabited by cute humanoid animals. However, how the player does this is left entirely up to them, and the lack of defined objectives and the focus on day-to-day activities and simple tasks (things like fishing, talking walks on the beach, picking up a flower, visiting a shop), many of which had to be given up during lockdown, must have played an important part of the intergenerational success of the game.

One way to find new recruits to populate the village on your own island is to visit entrepreneurial raccoon dog Tom Nook’s shop and purchase a return ticket to an uncharted, randomly-generated island (named Mystery Islands). Each time they land on a Mystery Island, players are able to encounter a non-playable character who, when asked, will agree to return with them to their village. Animal Crossing players started sharing their gaming experiences online, and soon enough they realised that the new villager they met on a Mystery Island could be any of the 391 available characters in the game. However, they started wondering whether each character was equally likely. This is where statistics and probability finally comes into play in our story.

Some of the most committed players were keeping a record of which characters they had encountered during their Mystery Island travels. At this point, if you are not an Animal Crossing player yourself, you might be pausing and wondering why they were doing something like that in the first place. My sister Chiara, who, unlike me, is an Animal Crossing veteran, and who first told me about all of this, put it like this: ‘If you are really into Animal Crossing, chances are that you’re a bit of a compulsive collector. A lot of the game dynamics involve collecting items, and keeping records of everything is a natural part of being a collector.’

In any case, as they started pooling together their tidily kept records, they realised that some characters seemed to make an appearance a lot more often than others. The picture that emerged seemed to them to point in a different direction than the original assumption that each character was equally likely. However, not everyone was convinced, and they needed more than a hunch to say that this was the case.

## Animal Crossing villagers go binomial

The problem was something like this: I am given a coin and I want to know whether it’s fair (which would mean that the probabilities of my coin landing on its head or tail are both 50% – or as a mathematician would say, the probability of each of the two events equals 0.5); when I flip the coin once and I get tail, you will agree with me that that isn’t enough for me to say anything about whether the coin is fair; I then flip it 5 times and I get only tails, and I might start to get suspicious; once I have flipped my coin 30 times and got only tails, I will be very, very suspicious. However, it’s still not completely impossible for me to get tail 30 flips out of 30, even if the coin is fair: it’s just extremely unlikely. The sad truth of probability is that I can never be absolutely, completely certain that my coin is fair, doesn’t matter how many times I flip it: even a very unlikely result (like 30 tails out of 30) will still be, although unlikely, never completely impossible. What I can still say is that a result like getting tails 30 flips out of flip is extremely unlikely under the assumption that my coin is a fair one (how unlikely? The probability is $0.5^{30} \approx 0.0000000009$, or less than one in a billion).

I flip a coin five times. What is the probability of getting tails every time?
I flip a coin three times. What is the probability of getting tails exactly once?
I flip a coin four times. What is the probability of getting tails exactly twice?
I throw a die five times. What is the probability of getting a six exactly twice?

In general, the probability of getting a certain number of tails (or heads) is given by the binomial distribution. The probability of getting exactly $k$ times tail if I flip the coin $n$ times is given by:

$$P(K = k) = \binom{n}{k}p^k(1-p)^{n-k}$$

Where $\binom{n}{k}$ is the binomial coefficient n choose k which can be calculated as $\binom{n}{k} = \frac{n!}{k!(n-k)!}$ (or from Pascal’s triangle), and $n!$ is the product of the numbers up to $n$: $n! = n \times (n-1) \times \dots \times 2 \times 1$ (for instance $\binom{7}{3} = \frac{7!}{3!4!} = 35$). In the coin example $p$ (the probability of success) and $1-p$ (the probability of failure) are both equal to $0.5$, but in the die example (see the questions above) we had $p = \frac{1}{6}$ and $1 – p = \frac{5}{6}$.

Before I flip my coin, I do not know what the number of tails $K$ is going to be, all I know are the probabilities of the different possible outcomes $k$: that’s why mathematicians would say that the number $K$ is a random variable.

You can see that if the random variable $K$ follows a binomial distribution we can write it as a sum of random variables $B_1, B_2, \dots, B_n$:

$$K = B_1 + B_2 + \dots + B_n$$

where each $B_m$ can either be $1$ (with probability $p$) or $0$ (with probability $1-p$), and represents the number of tails I get in flip number $m$ (in other words the $B$s follow the simplest possible binomial distribution, the one with $n = 1$, also known as the Bernoulli distribution). This fact might seem obvious now, but it will become important in a bit.

If I flip 100 times a fair coin, I expect to get around 50 times tails. The expectation (also known as the mean) $\mathrm{E}[K] = \sum_{i=0}^n k_i \times P(K = k_i)$ or a binomial distribution is the number of successes I expect to have, and for a binomial distribution it’s (as you would expect) $\mathrm{E}[K] = np$ (although this makes intuitive sense, it can also be shown properly without long calculations like this: the expectation of a sum of independent random variables is just the sum of their expectations, and each Bernoulli random variable has expectation $\mathrm{E}[B] = 0 \times P(B =0) + 1 \times P(B =1)$ $= 0 + 1 \times p = p$) .

The variance $\mathrm{Var}[K]$ (which can be calculated in terms of expectations as $\mathrm{Var}[K] = \mathrm{E}[K^2] – \mathrm{E}[K]^2$) and its square root the standard deviation $\sigma = \sqrt{\mathrm{Var}[K]}$ tell us how spread out around the mean we expect our results to be (a higher value of $\sigma$ means that the data is more spread out). For a binomial distribution the variance is given by $\mathrm{Var}[K] = np(1-p)$ (how do we know? For each Bernoulli random variable $\mathrm{E}[B]^2 = p^2$ and $\mathrm{E}[B^2] = 0^2 \times P(B =0) + 1^2 \times P(B =1) = p$ so $\mathrm{Var}[B] = \mathrm{E}[B^2] – \mathrm{E}[B]^2$ $= p – p^2$ $= p(1 – p)$).

Below you can find an interactive applet (my own work, written in Python and Javascript) of the binomial distribution for different values of the number of trials $n$ and the probability of success $p$ (to view the probability of a given number of success hover your cursor over the corresponding bar). You can also see that as the number of trials $n$ becomes larger, the probability distribution looks more and more like a certain famous curve you are very likely already familiar with.

Bokeh Plot

In the questions below, you see that the probability of meeting a given character a certain number of times $k$ out of a total of $n$ journeys to Mystery Island also follows a binomial distribution (we’re making the important assumption that which character I meet on a given journey does not affect which character I’ll meet in the next one: we are assuming that the characters I meet on each journey are independent events).

In Animal Crossing: New Horizons you can meet one of 391 characters on a journey to Mystery Island. What is the probability of finding the cat Raymond on your first journey if each character is equally likely? (this is called a uniform distribution)
Of those 391 characters, 23 are cats. What is the probability of meeting a cat on my first journey if each character is equally likely?
You make 100 journeys to Mystery Island. What is the probability that you’re going to meet the cat Raymond exactly once if each character is equally likely?
You make 100 journeys to Mystery Island. What is the probability that you’re going to meet the cat Raymond (at least once) if each character is equally likely?

Many of those Animal Crossing players who believed that the 'each character is equally likely' hypothesis was wrong subscribed to their own alternative. They thought that the data they had collected matched a probability distribution where each species (instead of each character) was equally likely. If only there was some precise way to check how well (or how badly) the data they had collected matched either of those two hypotheses, so that the matter could be universally agreed once and for all! (if you want to find out what that way is you're going to have to keep on reading).

In Animal Crossing: New Horizons there are in total 35 character species, and 23 characters are cats. Assuming each species (instead of each character) is equally likely, what is now the probability of meeting the cat Raymond your first journey to Mystery Island?
You make 100 journeys to Mystery Island. What is the probability that you're going to meet the cat Raymond (at least once) if each species is equally likely?

## The most famous probability distribution in the world

The curve that you might already be familiar with, is, of course, the probability density function of the normal distribution. The normal distribution is possibly the most important probability distribution in statistics and probability. Unlike discrete probability distributions like the binomial distribution, it is a continuous distribution: this means that the possible outcomes are taken to be any real number ($0.5$, $0.0157$, $\sqrt{2}$, $\pi$) instead of simply whole numbers ($0$, $1$, $2$, $3$, $4$). Whilst in a discrete probability distribution there's a function that gives us the probability of every outcome, for a continuous probability distribution the probability can be calculated using a function called the probability density function.

I can find the probability of my outcome $X$ to have a value between any two numbers $a$ and $b$ by looking at the area (the blue area in the visualisation below) between the probability density function (the black curve in the visualisation below) and the x-axis from $x = a$ to $x = b$. That is, we need to evaluate an integral of the probability density function:

$$P(a \leq X \leq b) = \int_{a}^{b} f(x) \, dx$$

The probability density function for the normal distribution is:

$$f(x) = \frac{1}{\sigma \sqrt{2 \pi}} e^{-(x - \mu)^2 / 2 \sigma^2}$$

Where $e$ is a very famous number, Euler's constant $e \approx 2.718$, $\mu = \mathrm{E}[X]$ is the mean and $\sigma= \sqrt{\mathrm{Var}[X]}$ is standard deviation of the normal distribution I’m looking for. For a normal distribution, I need to know the values of $\mu$ and $\sigma$ in order to be able to calculate probabilities: they are the parameters of my distribution (just like the number of trials $n$ and the probability of success $p$ were the parameters for the binomial distribution). The constant $\frac{1}{\sigma \sqrt{2 \pi}}$ we put in front of the probability density function so that the probability of X being any possible value is equal to 1, that is to make $\int_{- \infty}^{+\infty} f(x) \, dx = 1$ (we say that it’s a normalisation constant).

Luckily, you don't need to calculate this integral yourself. Even if you are very good at calculating integrals, this is not one that can be solved exactly. You'd normally need to use some approximation method, or, more likely, a scientific calculator or computer software. To save you the bother, here's a visualisation of normal probability density functions for different values of $\mu$ and $\sigma$, where you can see the approximate value of the probability for $X$ to be found between two values of your choice.

Bokeh Plot

As you can see from the visualisation, although different values of $\mu$ and $\sigma$ correspond to different curves, these curves all look very much alike: in fact they’re all exactly the same curve, just translated (shifted to the right or left) as I increase or decrease the mean $\mu$, and rescaled (squashed down or squeezed up) as I increase or decrease the standard deviation $\sigma$. That’s why in order to calculate probabilities you might not want to bother with different curves at all, and just look at one of them: we can choose the one with $\mu = 0$ and $\sigma = 1$. This distribution is called the standard normal distribution.

If you give me any number $X$ that follows a normal distribution, the number $Z = \frac{X - \mu}{\sigma}$ will follow a standard normal distribution. If, for example, I wanted to find the probability that $X$ is larger than some number $x$, this will be the same as the probability that $Z$ is larger than the number $z = \frac{x - \mu}{\sigma}$ (we say that $z$ is the standard score of $x$: it tells me how far away $x$ is from the mean in units of standard deviations).

In the days of old people would have used a standard normal table (also called a Z-table) to find the value of $P(Z < z)$. Alternatively, you can use the applet below:

Bokeh Plot
The average height in the UK is around 5’ 7’’ (170 cm), with a standard deviation of around 3’’ (8 cm). What percentage of the UK population is 5’ 11’’ (180 cm) tall or more?
The average height for a male in the age group 18-25 in the UK is around 5’ 10’’ (178 cm), with a standard deviation of around 2’’ (5 cm). What percentage of males aged 18-25 are 5’ 11’’ (180 cm) tall or more?

## The central limit theorem: everything eventually turns out normal

One reason why the normal distribution is so important (and the reason why it comes into our story) is something called the central limit theorem. The central limit theorem (in one of its simplest versions) says that if I take the sum of a large number of independent random variables that all have the same distribution, the sum will approximatively follow a normal distribution (and as long as your distribution is not some weird distribution that doesn't even have a mean or variance).

Remember how we said earlier than a binomial random variable is a sum of $n$ Bernoulli random variables? The central limit theorem tells us that we can approximate it as a normal distribution (with the same mean $\mu = np$ and standard deviation $\sigma = \sqrt{np(1-p}$), and that this works best when $n$ is large.

And here's a visualisation of the normal approximation (blue area) to the binomial (red area): you can see that as the number of trials $n$ gets larger you get a better match between the binomial distribution and the corresponding normal distribution, and that the probabilities given by the normal distribution approximate well the ones given by the binomial.

Bokeh Plot

Why might we want to use the normal approximation anyway? In the questions below you can see an example of a case when it's quicker to make calculations using the normal approximation than it would be calculating the binomial probabilities directly.

In Animal Crossing: New Horizons you start off with only two villagers living on your island: one of them is always an "uchi" personality type, and the other one a "jock" personality type. There are only 24 characters with "uchi" personality type, and one of them is a pink rhino called Renée. If you restart the game 30 times in the hope of getting Renée as one of your first villagers, what's the probability of that happening at least 3 times out of 30? (hint: for this question you can use the binomial distribution applet above)
What is the probability of getting Renée as one of your first villagers at least 7 times out of 100? (hint: for this question you can use the standard normal distribution applet)

One way of showing why the central limit theorem is true is by looking at what happens to a function related to the probability density function called the characteristic function (if you know what a Fourier transform is: it's the Fourier transform of the probability density function) for a sum of independent random variables as the number of terms in the sum becomes large (spoiler alert: its gets closer and closer to the characteristic function of the corresponding normal distribution, meaning that the two distributions get more and more alike). If you're interested in cutting your teeth with slightly more involved maths, you can check out a more detailed outline of this story here.

## Finally, the chi-square distribution

However, the reason why the normal approximation and the central limit theorem come into the Mystery Island mystery has to do with yet another distribution, the chi-square distribution. If I have a bunch of $k$ random variables $Z_1, Z_2, \dots, Z_k$ that each follow a standard normal distribution and are also independent of each other, then the sum of their squares $Y$ will follow a chi-square distribution with $k$ degrees of freedom:

$$Y = Z_1^2 + Z_2^2 + \dots + Z_k^2$$

The probability density function for a chi-square random variable with $k$ degrees of freedom can be written as:

$$f(x) = \frac {1}{2^{k/2}\Gamma (k/2)} x^{k/2-1}e^{-x/2}$$

where $\Gamma(z)$ in the normalisation constant is a special function called the gamma function which generalises the factorial to the case where $z$ is not an integer (if $n$ is integer the gamma function is just a good old factorial $\Gamma(n) = (n - 1)!$ $= (n-1) \times (n-2) \times \dots \times 2 \times 1$.

For instance, the probability density function of a chi-square distribution with two degrees of freedom ($k = 2$) is simply an exponential:

$$f(x) = \frac{1}{2} e^{x/2}$$

You can see what this probability density function for different numbers of degrees of freedom looks like here:

Bokeh Plot


text:
## Elementary and Intermediate Algebra: Concepts & Applications (6th Edition)

Using the properties of inequality, the given expression, $-1\lt t,$ is equivalent to \begin{array}{l}\require{cancel} -1\lt t \\\\ -t\lt 1 \\\\ -1(-t)\lt -1(1) \\\\ t\gt -1 .\end{array} The inequality above is the same as the other given inequality, $t\gt-1.$ Hence, the given expressions are $\text{ equivalent .}$


text:
Lemma 31.28.1. Let $\varphi : X \to Y$ be a morphism of schemes. Let $\mathcal{L}$ be an invertible $\mathcal{O}_ X$-module. Assume that

1. $X$ is locally Noetherian,

2. $Y$ is locally Noetherian, integral, and normal,

3. $\varphi$ is flat with integral (hence nonempty) fibres,

4. $\varphi$ is either quasi-compact or locally of finite type,

5. $\mathcal{L}$ is trivial when restricted to the generic fibre of $\varphi$.

Then $\mathcal{L} \cong \varphi ^*\mathcal{N}$ for some invertible $\mathcal{O}_ Y$-module $\mathcal{N}$.

Proof. Let $\xi \in Y$ be the generic point. Let $X_\xi$ be the scheme theoretic fibre of $\varphi$ over $\xi$. Denote $\mathcal{L}_\xi$ the pullback of $\mathcal{L}$ to $X_\xi$. Assumption (5) means that $\mathcal{L}_\xi$ is trivial. Choose a trivializing section $s \in \Gamma (X_\xi , \mathcal{L}_\xi )$. Observe that $X$ is integral by Lemma 31.11.7. Hence we can think of $s$ as a regular meromorphic section of $\mathcal{L}$. Pullbacks of meromorphic functions are defined for $\varphi$ by Lemma 31.23.5. Let $\mathcal{N} \subset \mathcal{K}_ Y$ be the $\mathcal{O}_ Y$-module whose sections over an open $V \subset Y$ are those meromorphic functions $g \in \mathcal{K}_ Y(V)$ such that $\varphi ^*(g)s \in \mathcal{L}(\varphi ^{-1}V)$. A priori $\varphi ^*(g)s$ is a section of $\mathcal{K}_ X(\mathcal{L})$ over $\varphi ^{-1}V$. We claim that $\mathcal{N}$ is an invertible $\mathcal{O}_ Y$-module and that the map

$\varphi ^*\mathcal{N} \longrightarrow \mathcal{L},\quad g \longmapsto gs$

is an isomorphism.

We first prove the claim in the following situation: $X$ and $Y$ are affine and $\mathcal{L}$ trivial. Say $Y = \mathop{\mathrm{Spec}}(R)$, $X = \mathop{\mathrm{Spec}}(A)$ and $s$ given by the element $s \in A \otimes _ R K$ where $K$ is the fraction field of $R$. We can write $s = a/r$ for some nonzero $r \in R$ and $a \in A$. Since $s$ generates $\mathcal{L}$ on the generic fibre we see that there exists an $s' \in A \otimes _ R K$ such that $ss' = 1$. Thus we see that $s = r'/a'$ for some nonzero $r' \in R$ and $a' \in A$. Let $\mathfrak p_1, \ldots , \mathfrak p_ n \subset R$ be the minimal primes over $rr'$. Each $R_{\mathfrak p_ i}$ is a discrete valuation ring (Algebra, Lemmas 10.60.11 and 10.157.4). By assumption $\mathfrak q_ i = \mathfrak p_ i A$ is a prime. Hence $\mathfrak q_ i A_{\mathfrak q_ i}$ is generated by a single element and we find that $A_{\mathfrak q_ i}$ is a discrete valuation ring as well (Algebra, Lemma 10.119.7). Of course $R_{\mathfrak p_ i} \to A_{\mathfrak q_ i}$ has ramification index $1$. Let $e_ i, e'_ i \geq 0$ be the valuation of $a, a'$ in $A_{\mathfrak q_ i}$. Then $e_ i + e'_ i$ is the valuation of $rr'$ in $R_{\mathfrak p_ i}$. Note that

$\mathfrak p_1^{(e_1 + e'_1)} \cap \ldots \cap \mathfrak p_ i^{(e_ n + e'_ n)} = (rr')$

in $R$ by Algebra, Lemma 10.157.6. Set

$I = \mathfrak p_1^{(e_1)} \cap \ldots \cap \mathfrak p_ i^{(e_ n)} \quad \text{and}\quad I' = \mathfrak p_1^{(e'_1)} \cap \ldots \cap \mathfrak p_ i^{(e'_ n)}$

so that $II' \subset (rr')$. Observe that

$IA = (\mathfrak p_1^{(e_1)} \cap \ldots \cap \mathfrak p_ i^{(e_ n)})A = (\mathfrak p_1A)^{(e_1)} \cap \ldots \cap (\mathfrak p_ i A)^{(e_ n)}$

by Algebra, Lemmas 10.64.3 and 10.39.2. Similarly for $I'A$. Hence $a \in IA$ and $a' \in I'A$. We conclude that $IA \otimes _ A I'A \to rr'A$ is surjective. By faithful flatness of $R \to A$ we find that $I \otimes _ R I' \to (rr')$ is surjective as well. It follows that $II' = (rr')$ and $I$ and $I'$ are finite locally free of rank $1$, see Algebra, Lemma 10.120.16. Thus Zariski locally on $R$ we can write $I = (g)$ and $I' = (g')$ with $gg' = rr'$. Then $a = ug$ and $a' = u'g'$ for some $u, u' \in A$. We conclude that $u, u'$ are units. Thus Zariski locally on $R$ we have $s = ug/r$ and the claim follows in this case.

Let $y \in Y$ be a point. Pick $x \in X$ mapping to $y$. We may apply the result of the previous paragraph to $\mathop{\mathrm{Spec}}(\mathcal{O}_{X, x}) \to \mathop{\mathrm{Spec}}(\mathcal{O}_{Y, y})$. We conclude there exists an element $g \in R(Y)^*$ well defined up to multiplication by an element of $\mathcal{O}_{Y, y}^*$ such that $\varphi ^*(g)s$ generates $\mathcal{L}_ x$. Hence $\varphi ^*(g)s$ generates $\mathcal{L}$ in a neighbourhood $U$ of $x$. Suppose $x'$ is a second point lying over $y$ and $g' \in R(Y)^*$ is such that $\varphi ^*(g')s$ generates $\mathcal{L}$ in an open neighbourhood $U'$ of $x'$. Then we can choose a point $x''$ in $U \cap U' \cap \varphi ^{-1}(\{ y\} )$ because the fibre is irreducible. By the uniqueness for the ring map $\mathcal{O}_{Y, y} \to \mathcal{O}_{X, x''}$ we find that $g$ and $g'$ differ (multiplicatively) by an element in $\mathcal{O}_{Y, y}^*$. Hence we see that $\varphi ^*(g)s$ is a generator for $\mathcal{L}$ on an open neighbourhood of $\varphi ^{-1}(y)$. Let $Z \subset X$ be the set of points $z \in X$ such that $\varphi ^*(g)s$ does not generate $\mathcal{L}_ z$. The arguments above show that $Z$ is closed and that $Z = \varphi ^{-1}(T)$ for some subset $T \subset Y$ with $y \not\in T$. If we can show that $T$ is closed, then $g$ will be a generator for $\mathcal{N}$ as an $\mathcal{O}_ Y$-module in the open neighbourhood $Y \setminus T$ of $y$ thereby finishing the proof (some details omitted).

If $\varphi$ is quasi-compact, then $T$ is closed by Morphisms, Lemma 29.25.12. If $\varphi$ is locally of finite type, then $\varphi$ is open by Morphisms, Lemma 29.25.10. Then $Y \setminus T$ is open as the image of the open $X \setminus Z$. $\square$

In your comment you can use Markdown and LaTeX style mathematics (enclose it like $\pi$). A preview option is available if you wish to see how it works out (just click on the eye in the toolbar).


text:
SALES: 1-800-867-1380

Windows Azure Caching (Preview) not working...

Question

• I'm trying to get Azure Caching working witihn my Web Application without any luck.

I've upgraded to Azure June 2012 and enabled the Cache Tab, added the Nuget package, etc.

 DataCacheFactory cacheFactory = new DataCacheFactory();
DataCache cache = cacheFactory.GetDefaultCache();
// DataCache cachee = new DataCache();

This throws an exception

{"Unrecognized element 'autoDiscover'.     with the web.config file.

Web.config contains tihs bit :

<dataCacheClients>
<tracing sinkType="DiagnosticSink" traceLevel="Error" />
<dataCacheClient name="default">
<autoDiscover isEnabled="true" identifier="CacheWorkerRole" />
<localCache isEnabled="true" sync="TimeoutBased" objectCount="10000" ttlValue="300" />
</dataCacheClient>
</dataCacheClients>

However I was looking at the Azure Cache Example on MSDN which contains the same however I noticed the DataCache is called with just the following :

DataCache cachee = new DataCache();

This doesnt seem to work in my project. the definition of DataCache doesnt match :

#region Assembly Microsoft.ApplicationServer.Caching.Client.dll, v2.0.50727
#endregion

using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using System.Threading;

whereas my project definition is :

#region Assembly Microsoft.ApplicationServer.Caching.Client.dll, v2.0.50727
// C:\develop\Azure\packages\WindowsAzure.Caching.1.7.0.0\lib\net35-full\Microsoft.ApplicationServer.Caching.Client.dll
#endregion

using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;

namespace Microsoft.ApplicationServer.Caching

Any idea?

Thursday, June 28, 2012 11:59 AM

• Do you have AppFabric Server installed on the box where Windows Azure SDK 1.7 is installed, if so you would get into issues.

http://blog.elastacloud.com/2012/06/09/using-the-windows-azure-cache-preview-with-sdk-1-7/

Attach the debugger, look at modules window and see from which location the following DLLs are loaded.

Microsoft.ApplicationServer.Caching.Client.dll

Microsoft.ApplicationServer.Caching.Core.dll

Make sure the following properties hold:

Assembly File Version - 1.0.4655.0

Assembly Version - 1.0.0.0

Make sure that these DLLs are not in GAC by any chance.

Thanks,

Laxmi

Thursday, June 28, 2012 3:23 PM

All replies

• Do you have AppFabric Server installed on the box where Windows Azure SDK 1.7 is installed, if so you would get into issues.

http://blog.elastacloud.com/2012/06/09/using-the-windows-azure-cache-preview-with-sdk-1-7/

Attach the debugger, look at modules window and see from which location the following DLLs are loaded.

Microsoft.ApplicationServer.Caching.Client.dll

Microsoft.ApplicationServer.Caching.Core.dll

Make sure the following properties hold:

Assembly File Version - 1.0.4655.0

Assembly Version - 1.0.0.0

Make sure that these DLLs are not in GAC by any chance.

Thanks,

Laxmi

Thursday, June 28, 2012 3:23 PM
• Hmmmm....

Something weird in the SDK installation gone wrong or packaged incorrectly.

Basically had to reference the Assemblies in "C:\Program Files\Microsoft SDKs\Windows Azure\.NET SDK\2012-06\ref\CachingPreview".

But there is also a  version in C:\Program Files\Microsoft SDKs\Windows Azure\.NET SDK\2012-06\ref

Micatio Software Free IIS Azure Web Log App

Friday, June 29, 2012 9:11 AM
• Receiving this error now :

ErrorCode<ERRCA0021>:SubStatus<ES0001>:Server collection cannot be empty.

when calling this method:

DataCacheFactorycacheFactory = newDataCacheFactory();

Micatio Software Free IIS Azure Web Log App

Friday, June 29, 2012 11:45 AM
• This error is returned "ErrorCode<ERRCA0021>:SubStatus<ES0001>:Server collection cannot be empty" if the dataCacheClient name is incorrect, hence double check the Named Cache setting

<dataCacheClient name="default">

Micatio Software Free IIS Azure Web Log App

Saturday, June 30, 2012 5:25 AM
• The one in C:\Program Files\Microsoft SDKs\Windows Azure\.NET SDK\2012-06\ref are for 'Windows Azure Shared Caching'

The bits in C:\Program Files\Microsoft SDKs\Windows Azure\.NET SDK\2012-06\ref\CachingPreview are "Windows Azure Caching (Preview)" which is in-role caching.

To enable caching as part of your deployment itself, use the bits from CachingPreview folder

Monday, July 02, 2012 10:46 AM
• I've checked that I am indeed referencing the .dlls correctly (all 5 in CachingPreview folder).  I get exactly the same error message when I try to start my web role that is using the distributed cache (co-located) for session state.  I'm using "default" for the name, and I have double checked that my Role cache properties also has "default" for the name.  I still get this error.
Thursday, July 05, 2012 4:39 PM
• Im happy to see, Im not the only one with this problem!

https://www.windowsazure.com/en-us/develop/net/how-to-guides/cache/

Followed 3x times, step by step, but still get the same errors above.

• Edited by Thursday, July 05, 2012 7:49 PM
Thursday, July 05, 2012 7:46 PM
• If you're getting the exact error as in this thread then could you please check Windows Server AppFabric was installed in your system ?

It might have been GAC'ed in your system, so eventhough you're referencing dlls from CachingPreview - runtime picks up from GAC which are older resulting in this issue.

Please uninstall any server caching dlls in your system and then try again and post your experience.

Thursday, July 05, 2012 8:04 PM
• I do not have Windows Server AppFabric installed.  I do have Windows Azure SDK November 2011 and Windows Azure SDK June 2012 installed.
Thursday, July 05, 2012 8:12 PM
• Hi Simeon,

Removing Caching from your solution and then re-add again.

The error is to do with the framework not finding the Default Named Cache setting and/or datacacheclient setting correctly.

Check that all project references are pointing to the correct versions, some maybe using the local copy hence revert back to the GAC version.

Check that the web.config contains the following, note the identifier must match the web role name listed in your azure solution otherwise you will receive the same error as well.

	<dataCacheClients>
<tracing sinkType="DiagnosticSink" traceLevel="Verbose" />
<dataCacheClient name="default">
<autoDiscover isEnabled="true" identifier="[YourWebRoleName]" />
<localCache isEnabled="true" sync="TimeoutBased" objectCount="10000" ttlValue="300" />
</dataCacheClient>
</dataCacheClients>

Micatio Software Free IIS Azure Web Log App

Thursday, July 05, 2012 9:57 PM
• Hi Simeon,

If Ron's suggestion didn't solve your issue, please try figuring out the file version of the modules Caching.Core.dll and Caching.Client.dll loaded during runtime of your app, by attaching a debugger to your running solution ( as suggested by Laxmi above ) and post your results.

If it still didn't solve the issue, please compile your application once and pack the entire directory and share it with us. Will see if we can repro.

Friday, July 06, 2012 6:06 AM
• I also had the error:

ErrorCode<ERRCA0021>:SubStatus<ES0001>:Server collection cannot be empty.

I have my data layer in its own project. The config settings were in app.config. I managed to get it to work by adding the config settings to web.config in my web project which then gave an error of not finding the dlls. I added the dlls to the web project too and then it all worked.

Should I have to add all of that to the web project too? It would be nice to just leave it in the data project.

• Proposed as answer by Sunday, July 15, 2012 7:13 PM
• Unproposed as answer by Wednesday, September 05, 2012 8:44 PM
Sunday, July 15, 2012 7:13 PM
• For those getting assembly version mismatches from the GAC, make sure you are installing the Azure Caching PREVIEW package via NuGet, and not the "Azure Shared Caching" package.
Wednesday, July 25, 2012 6:07 PM
• First of all caching preview works on Azure Roles. You need to run on emulator and not stand alone web app in localhost. ( set the azure project as start up and run).

I had been using storageclient before but the caching preview pulled out new dlls for storageclient and diagnostics even when it was not referenced.

Felt like caching preview shipped old dlls(eg: 1.0.0.0 for caching core when sdk 1.6 had 101.0.0.0) but I was wrong.

Here is the fix which worked for me:

http://azuretable.blogspot.nl/2012/09/azure-caching-preview-fix.html

For  "ErrorCode<ERRCA0021>:SubStatus<ES0001>:Server collection cannot be empty", this is how I solved it:

http://azuretable.blogspot.nl/2012/09/errorcode-substatus-server-collection.html

PS: I did not have any anything to do with GAC or Windows Server AppFabric installation or removal

• Edited by Tuesday, September 11, 2012 9:16 AM
Tuesday, September 04, 2012 6:45 PM
• The one is the ref folder are the 'old' dlls used for shared caching model. The bits in 'CachingPreview' are the new dlls for the dedicated caching model ( in-role caching )

If you use the 'Nuget' package to add the reference for the cache clients, then it'll reference the proper dlls and you should be good to go. If you're manually adding the reference, adding from the CachingPreview bits should solve the issue, provided that you no longer have Windows Server Appfabric installed.

isEnabled attribute of <autoDiscover> needs to be true, otherwise client won't be able to find the cache server role.

Wednesday, September 05, 2012 4:16 AM
• I ran Nuget and the 101.0.0.0 dlls (core and client) were changed to 1.0.0.0 .

And becuase of the new dlls I had to change Microsoft.WindowsAzure.Diagnostics.dll and Microsoft.WindowsAzure.StorageClient.dll from 1.7.0.0(ref) to 1.1.0.0. is 1.1.0.0 latest than 1.7.0.0?

or are they not related(caching dlls and diagnostics)?

And <autoDiscover> isEnabled was false in my webconfig and I changed it to true to make it work. thanks for pointing out and I have changed the blog.

• Edited by Tuesday, September 11, 2012 9:17 AM
Wednesday, September 05, 2012 8:07 AM
• The blog information about changing isEnabled to false should work for dedicated cache is not correct.

Could you explain your scenario here ? Are you trying dedicated cache model ? Setting isEnabled to false actually breaks the client in finding the servers.

Wednesday, September 05, 2012 11:33 AM
• yes, isEnabled to false breaks the client . Like I said, it was a typo in the blog. isEnabled was 'false' and I changed it to true to make it work. I am trying caching preview itself. This is what is in my config now:

<dataCacheClients>
<dataCacheClient name="default">
<autoDiscover isEnabled="true" identifier="webRoleName" />
</dataCacheClient>
</dataCacheClients>

The blog is corrected. Thank you.

• Edited by Wednesday, September 05, 2012 12:41 PM
Wednesday, September 05, 2012 12:32 PM
• May I know what you would think about the dll mismatch I mentioned?
Wednesday, September 05, 2012 12:58 PM
• Hi All,

The solution is within this thread hence no point going over old ground.

Micatio Software Free IIS Azure Web Log App

Wednesday, September 05, 2012 8:43 PM
• I found out that 1.7.0.0 of Diagnostics and storageclient is used by caching preview. We could still make 1.1.0.0 work(worst case) with assembly redirect if we want.

complete solution

http://azuretable.blogspot.nl/2012/09/azure-caching-preview-fix.html

Tuesday, September 11, 2012 9:19 AM


text:
# Is the extension of a densely defined $1-1$ bounded linear operator on a Hilbert space still $1-1?$

If $H$ is a Hilbert space, $D$ is a dense subspace of $H$, $T:D\to H$ is a $1-1$ bounded linear operator, is the extension of $T$ to $H$ still $1-1?$

• Not necessarily. – Daniel Fischer Jan 2 '17 at 16:42
• @Nizar, please do not accept edits that perform only minor changes, such as adding pairs of dollar signs around some symbols. The edit that you have allowed above only turns "1-1" into "$1-1$". Such edits are to be discouraged. – Alex M. Jan 2 '17 at 16:42
• @SteamyRoot, please do not accept edits that perform only minor changes, such as adding pairs of dollar signs around some symbols. The edit that you have allowed above only turns "1-1" into "$1-1$". Such edits are to be discouraged. – Alex M. Jan 2 '17 at 16:43

Definitely not. You could construct example using an o.n. basis $\{e_n\}$ but let me give a different kind of example below.
Let $\mathcal{H} = L^2(\mathcal{D})$ be all square integrable complex value functions on the unit disk. Let $D\subset\mathcal{H}$ be the subspace of all complex polynomials in $z$ and $\overline{z}$, which is dense by the complex version of Stone-Weierstrauss. Finally, let $T$ be given by
$$T(f)(z) = \begin{cases} f(z) & if & Re(z) > 0 \\ 0 & if & Re(z) \leq 0 \end{cases}$$
This will be $1-1$ on polynomials but $T(f)=T(T(f))$ so it is not $1-1$ on the whole space.


text:
## dy/dx = 1/(x.sqrt(x^2-1))

Hi,

Can anyone help me here!

dy/dx = 1/(x.sqrt(x^2-1)) , x>0 Note y = pi when x = 2

Here is what I did:

Let u = x^2 - 1
x^2 = u + 1

Substituting this in the above yields:

dy/dx = 1/x.sqrt(u)

Differentiating: u = x^2-1

du = 2x.dx

x = du/2.dx

Then,

dy/dx= 2/sqrt(u).du

I don't know if this is rite.
Plz help me!
 PhysOrg.com science news on PhysOrg.com >> Ants and carnivorous plants conspire for mutualistic feeding>> Forecast for Titan: Wild weather could be ahead>> Researchers stitch defects into the world's thinnest semiconductor
 Blog Entries: 9 Recognitions: Homework Help Science Advisor What are u trying to do?Find the antiderivative of $\frac{1}{x\sqrt{x^{2}-1}} [/tex] ...?If so,then use a substitution involving [itex] \cosh u$... Daniel.
 Why is it that everyone has been taught about hyperbolic trig functions when we skipped it in high school and calc 1-3?

## dy/dx = 1/(x.sqrt(x^2-1))

I was trying to simplify the Right Hand side, before, I could integrate , by making a substitution.

Anyway what would be the hyperbolic sub, for this involving coshu.

I don't have my text book with me. I am at work, and I am trying to finish my homework.
 Blog Entries: 9 Recognitions: Homework Help Science Advisor Need i say that your initial approach is incorrect...? It also works with $\sec u$... Daniel.

Blog Entries: 9
Recognitions:
Homework Help
 Blog Entries: 9 Recognitions: Homework Help Science Advisor $$\int \frac{\sec u \ \tan u \ du}{\sec u \ \tan u} =\int du = u+C = \mbox{arcsec} \ x +C$$ Daniel.
 Blog Entries: 9 Recognitions: Homework Help Science Advisor "sec" (as "cosine") is multivalued.But your could take $$\sec^{-1} 2=\frac{\pi}{3}$$ Daniel.


text:
My Math Forum Joint Distribution help please

 April 22nd, 2012, 03:19 AM #1 Newbie   Joined: Apr 2012 From: Canada Posts: 7 Thanks: 0 Joint Distribution help please Can't get my head around this joint distribution problem. Suppose X and Y have joint distribution given by: $f(x,y) = \left\{ \begin{array}{l l} x+y & \quad \text{if x\geq 0, y\leq 1}\\ 0 & \quad \text{otherwise}\\ \end{array} \right.$ Find the distribution of X+Y Having difficulties finding the boundaries for my integration. I know that I need do declare a dummy variable t = X + Y Been stuck on this for a few hours now, help is much appreciated! Thanks.
April 22nd, 2012, 12:50 PM   #2
Global Moderator

Joined: May 2007

Posts: 6,787
Thanks: 708

Quote:
 Originally Posted by batman350z Can't get my head around this joint distribution problem. Suppose X and Y have joint distribution given by: $f(x,y) = \left\{ \begin{array}{l l} x+y & \quad \text{if x\geq 0, y\leq 1}\\ 0 & \quad \text{otherwise}\\ \end{array} \right.$ Find the distribution of X+Y Having difficulties finding the boundaries for my integration. I know that I need do declare a dummy variable t = X + Y Been stuck on this for a few hours now, help is much appreciated! Thanks.
f(x,y) cannot be either a density function or a distribution function without further limits on x and y. y can be negative giving negative values for f for y < -x. x can be arbitrarily large - distribution would eventually be > 1.

 April 22nd, 2012, 01:02 PM #3 Newbie   Joined: Apr 2012 From: Canada Posts: 7 Thanks: 0 Re: Joint Distribution help please Hmm, I might be misunderstanding the boundaries. The question actually has them written as, $0 \leq x,y\leq1$, so I am guessing that would be interpreted as $0 \leq x \leq1, \ 0\leq y \leq 1$ If the above is the case, how would i go about it?
 April 23rd, 2012, 02:50 PM #4 Global Moderator   Joined: May 2007 Posts: 6,787 Thanks: 708 Re: Joint Distribution help please First f(x,y) is a density function, not a distribution function. Let T = X + Y. What you want to calculate is P(T < t) = P(X+Y < t) = P(X < t and Y < t - X). To do this simply integrate the density function over the domain specified, 0 < x < t, 0 < y < t - x. The main thing you have to be careful of is the fact that f(x,y) = 0 outside the unit square (in x,y), so that you have to break up the integration into the parts where f(x,y) = x + y and f(x,y) = 0. For 0 < t < 1, there is no problem, but for 1 < t < 2 you need to do the breakup. For t > 2, the probability = 1. Post script: for t > 1, it is easier to work with P(T > t) and the use P(T < t) = 1 - P(T > t). In this case P(T > t) = P(X > t-1 and Y > t - X) so the integrals of f(x,y) is over t-1 < x < 1 and t-x < y < 1. For t < 1 the integral to get P(T < t) directly has 0 < x < t and 0 < y < t-x.

 Tags distribution, joint

 Thread Tools Display Modes Linear Mode

 Similar Threads Thread Thread Starter Forum Replies Last Post 450081592 Advanced Statistics 0 January 24th, 2012 07:44 PM xdeathcorex Probability and Statistics 0 April 22nd, 2011 07:55 AM allandmunja Advanced Statistics 1 April 4th, 2011 01:05 PM sletcher Calculus 18 December 15th, 2010 11:51 AM meph1st0pheles Advanced Statistics 1 March 23rd, 2010 05:47 PM

 Contact - Home - Forums - Cryptocurrency Forum - Top


text:
Lemma 10.167.2. Let $k$ be a field. Let $S$ be a Noetherian $k$-algebra. Let $K/k$ be a finitely generated field extension, and set $S_ K = K \otimes _ k S$. Let $\mathfrak q \subset S$ be a prime of $S$. Let $\mathfrak q_ K \subset S_ K$ be a prime of $S_ K$ lying over $\mathfrak q$. Then $S_{\mathfrak q}$ is Cohen-Macaulay if and only if $(S_ K)_{\mathfrak q_ K}$ is Cohen-Macaulay.

Proof. By Lemma 10.31.8 the ring $S_ K$ is Noetherian. Hence $S_{\mathfrak q} \to (S_ K)_{\mathfrak q_ K}$ is a flat local homomorphism of Noetherian local rings. Note that the fibre

$(S_ K)_{\mathfrak q_ K} / \mathfrak q (S_ K)_{\mathfrak q_ K} \cong (\kappa (\mathfrak q) \otimes _ k K)_{\mathfrak q'}$

is the localization of the Cohen-Macaulay (Lemma 10.167.1) ring $\kappa (\mathfrak q) \otimes _ k K$ at a suitable prime ideal $\mathfrak q'$. Hence the lemma follows from Lemma 10.163.3. $\square$

In your comment you can use Markdown and LaTeX style mathematics (enclose it like $\pi$). A preview option is available if you wish to see how it works out (just click on the eye in the toolbar).


text:
# Solve the following quadratic equations

Question:

If $\mathrm{e}^{\mathrm{y}}+\mathrm{xy}=\mathrm{e}$, the ordered pair $\left(\frac{\mathrm{dy}}{\mathrm{dx}}, \frac{\mathrm{d}^{2} \mathrm{y}}{\mathrm{dx}^{2}}\right)$ at $x=0$ is equal to :

1. $\left(-\frac{1}{\mathrm{e}}, \frac{1}{\mathrm{e}^{2}}\right)$

2. $\left(\frac{1}{\mathrm{e}}, \frac{1}{\mathrm{e}^{2}}\right)$

3. $\left(\frac{1}{\mathrm{e}},-\frac{1}{\mathrm{e}^{2}}\right)$

4. $\left(-\frac{1}{\mathrm{e}},-\frac{1}{\mathrm{e}^{2}}\right)$

Correct Option: 1

Solution:

$e^{y}=x y=e$

differentiate w.r.t. $\mathrm{x}$

$e^{y} \frac{d y}{d x}+x \frac{d y}{d x}+y=0$

$\frac{d y}{d x}\left(x+e^{y}\right)=-y,\left.\frac{d y}{d x}\right|_{(0,1)}=-\frac{1}{e}$

again differentiate w.r.t. $\mathrm{x}$

$e^{y} \cdot \frac{d^{2} y}{d x^{2}}+\frac{d y}{d x} \cdot e^{y} \cdot \frac{d y}{d x}+x \cdot \frac{d^{2} y}{d x^{2}}+\frac{d y}{d x}+\frac{d y}{d x}=0$

$\left(x+e^{y}\right) \frac{d^{2} y}{d x^{2}}+\left(\frac{d y}{d x}\right)^{2} \cdot e^{y}+2 \frac{d y}{d x}=0$

$e \frac{d^{2} y}{d x^{2}}+\frac{1}{e^{2}} e+2\left(-\frac{1}{e}\right)=0$

$\therefore \frac{\mathrm{d}^{2} \mathrm{y}}{\mathrm{dx}^{2}}=\frac{1}{\mathrm{e}^{2}}$


text:
# Revision history [back]

### Question about polar or radial angle calculation in the image coordinate system

Hi,

I have general questions, not explicitly about OpenCV, but related to image processing: The image coordinate system normally has the x-axis pointing from left to right, and the y-axis pointing DOWNWARDS. However, in math, normally, the y-axis points upwards. 1) Therefore, is a correction needed to account for the orientation of the y-axis, say, while doing tangentInverse(y, x) to get the radial angle of the pixel location? 2) Will doing y' = height - 1- y, and calling tangentInverse(y', x), solve the problem? (height = image height) 3) The confusion began after I had tried to relate to the formula for the principal value on the "Polar coordinate system" page of wikipedia (specifically, the one that deals with x and y being in different quadrants). I will appreciate, if any expert could clarify. Thank you.

 2 No.2 Revision Alexander Smorkalov 5862 ●2 ●22 ●58 http://alex-alchemist....

### Question about polar or radial angle calculation in the image coordinate system

Hi,

I have general questions, not explicitly about OpenCV, but related to image processing: The image coordinate system normally has the x-axis pointing from left to right, and the y-axis pointing DOWNWARDS. However, in math, normally, the y-axis points upwards. 1)

1. Therefore, is a correction needed to account for the orientation of the y-axis, say, while doing tangentInverse(y, x) to get the radial angle of the pixel location? 2)

2. Will doing y' = height - 1- y, and calling tangentInverse(y', x), solve the problem? (height = image height) 3)

3. The confusion began after I had tried to relate to the formula for the principal value on the "Polar coordinate system" page of wikipedia (specifically, the one that deals with x and y being in different quadrants). I will appreciate, if any expert could clarify. Thank you.

 3 retagged sturkmen 6772 ●3 ●48 ●79 https://github.com/stu...

### Question about polar or radial angle calculation in the image coordinate system

Hi,

I have general questions, not explicitly about OpenCV, but related to image processing: The image coordinate system normally has the x-axis pointing from left to right, and the y-axis pointing DOWNWARDS. However, in math, normally, the y-axis points upwards.

1. Therefore, is a correction needed to account for the orientation of the y-axis, say, while doing tangentInverse(y, x) to get the radial angle of the pixel location?

2. Will doing y' = height - 1- y, and calling tangentInverse(y', x), solve the problem? (height = image height)

3. The confusion began after I had tried to relate to the formula for the principal value on the "Polar coordinate system" page of wikipedia (specifically, the one that deals with x and y being in different quadrants). I will appreciate, if any expert could clarify. Thank you.


text:
# Algebra Quiz 1 for SSC, Railways Group D, RPF & ALP – Test Yourself Now!

3

Save

Algebra is a fairly diffivult topic and also a staple in the Quantitative Aptitude section in many exams. If you are preparing for SSC, Railways Exams and other Competitive Recruitment or Entrance exams, you will likely need to solve a section on Quant. Algebra Quiz 1 for SSC, Railways Exams will help you learn concepts on important topics in Quant – Identities, Linear Equations, Simultaneous Equations, Quadratic Equations etc. This Algebra Quiz 1 is important for exams such as SSC CGL, Railways Group D, RPF & ALP.

## Algebra Quiz 1 for SSC, Railways Exams –

Que. 1

If $$x + \frac{1}{x} = 1$$, then the value of $$\frac{2}{{{x^2} – x + 2}} = ?$$

1.
2/3
2.
2
3.
1
4.
4

Que. 2

If $${\left\{ {\frac{1}{2}\left( {a – b} \right)} \right\}^2} + ab = p{\left( {a + b} \right)^2}$$, then the value of p is (assume that a

≠ b)

b)

1.
1/8
2.
1
3.
1/2
4.
1/4

Que. 3

When 75 is added to 75% of a number, the answer is the number. Find the 40% of that number:

1.
100
2.
80
3.
120
4.
160

Que. 4

If $$x = \frac{{\sqrt 5 -\sqrt 3 }}{{\sqrt {5} + \sqrt 3 }}$$ and $$y = \frac{{\sqrt 5 + \sqrt 3 }}{{\sqrt {5} -\sqrt 3 }}$$ then the value of: $$\frac{{{x^2} + xy + {y^2}}}{{{x^{2}} – xy + {y^2}}} = ?$$

1.
65/63
2.
67/65
3.
63/61
4.
69/67

Que. 5

The sum of the ages of two brothers, having a difference of 8 years between them, will double after 10 years. What is the ratio of the age of the younger brother to that of the elder brother?

1.
10 : 13
2.
7 : 11
3.
3 : 7
4.
8 : 9

Que. 6

If p = 99, then the value of p (p2 + 3p + 3) is

1.
10000001
2.
9999999
3.
1000001
4.
999999

Que. 7

One year ago, a man was seven times the age of his son. Now his age is equal to the square of his son’s age. The present age of the man is

1.
49 years
2.
64 years
3.
81 years
4.
None of these

Que. 8

If x2 + x = 5. Then the value of $${\left( {x + 3} \right)^3} + \frac{1}{{{{\left( {x + 3} \right)}^3}}}$$

1.
120
2.
130
3.
140
4.
110

Que. 9

Price of 4 chairs and 7 tables is Rs 3780. The price of 1 chair is half the price of a table. Find the cost of 7 chairs and 4 tables.

1.
3250
2.
3350
3.
3150
4.
None of these

Que. 10

A boy pays off 3/20th of his debt every month. At the end of 5 months his balance debt is Rs. 725. How much debt (in Rupees) has he cleared off every month?

1.
500
2.
450
3.
435
4.
400

Did you like this Algebra Quiz 1 for SSC, Railways Exams? Let us know! You may also like –

Practice is the best tool to overcome your competition in exams. Attempt FREE tests on Testbook Practice.

4 years ago

4 years ago

4 years ago

4 years ago


text:
Tools for working with matrices and vectors.

## Overview

This module contains some tools for linear algebra. It contains classes to define matrices and vectors, and a number of functions for working on those matrices and vectors. It is intended for mathematical and scientific use. It saved me a lot of time in a linear algebra class.

## Classes

• vector: collection which defines a vector in Cartesian coordinates

• matrix: two-dimensional collection stored in row-major order

## Functions

• AxApproxB: solves Ax approximately equal to b; for use when the rows of matrix b are not in the column space of A

• axpy: ax+y where a is a scalar, and x and y are vectors

• bestfit: used to find a line of best fit from given points

• colVec: makes a matrix with one column

• det: returns the determinant of a square matrix. Can return a cross product if the top row contains the unit vectors.

• dot: returns the dot product of two vectors

• crossProduct: Returns a cross product

• GaussJordan: solves AX=B, where matrices A and B are known and X is returned. If B is not in the column-space of A, use AxApproxB.

• identityMatrix: makes an identity matrix of a given size

• linearCombination: returns a linear combination based on a list of scalars and a list of vectors

• mmMult: matrix-matrix multiplication

• mvMult: matrix-vector multiplication

• norm: takes the norm of a vector; defaults to 2 (Euclidian norm)

• permutationMatrix: makes a permutation matrix based on a given permutation vector

• proj: projection of one vector onto another

• rowVec: makes a matrix with one row

• transpose: transposes a matrix

• unitVector: constructs a unit vector

• v: wrapper around vector instantiation

• zeroMatrix: makes a zero matrix of a given size

• zeroVector: makes a zero vector of a given size

Help is available in the included help file.

## Project details

Uploaded source


text:
# Plotting difference between two Half Normal Distributions

I am new to Mathematica, and this question may reflect that.

I am trying to plot the probability density function of a random variable which equals the difference between two independent random variables that are Half Normal distributed.

Can someone help me out?

• If I made the wrong changes to your question, please change it back. – JimB Jan 5 '17 at 22:46
• Should be able to do PDF[TransformedDistribution[ x - y, {x \[Distributed] HalfNormalDistribution[\[Theta]], y \[Distributed] HalfNormalDistribution[\[Theta]]}], z], but it's taking a long time and returning unevaluated. – march Jan 5 '17 at 23:25
• @march: PDF and CDF return unevaluated (even with values assigned to $\theta$) but Expectation and RandomVariate work on the TransformedDistribution. Maybe one needs to brute force the integration of the joint probability distribution or take a large random sample and use SmoothKernelDistribution. – JimB Jan 5 '17 at 23:30
• @JimBaldwin. I wasn't aware of SmoothKernelDistribution. It ends up kind of nice: plotting the pdf of SmoothKernelDistribution@RandomVariate[dist /. \[Theta] -> 1, {1000000}] looks pretty good. I feel like an answer is in order there. – march Jan 5 '17 at 23:46
• @JimBaldwin : "...Maybe one needs to brute force the integration of the joint probability distribution..." - that's gonna be ugly... – ciao Jan 6 '17 at 0:34

Hmmm. Maybe it's not so hard (with Mathematica) after all. If the two independent and identically distributed half-normal random variables are labeled $u$ and $v$, then the difference is $d=u-v$. If we can find the CDF of $d$, then we can differentiate to get the density of $d$.

Suppose $d_0 \ge 0$. Then

$$Pr(d\le d_0)=Pr(u-v\le d_0)=\int_0^\infty{\int_0^{d_0+u}(\frac{2 \theta e^{-\frac{\theta ^2 v^2}{\pi }}}{\pi })(\frac{2 \theta e^{-\frac{\theta ^2 u^2}{\pi }}}{\pi })}dv du$$

So we can get the density with

D[Integrate[PDF[HalfNormalDistribution[θ], u] PDF[HalfNormalDistribution[θ], v],
{u, 0, ∞}, {v, 0, d + u}, Assumptions -> {θ > 0, d >= 0}], d]

(* (Sqrt[2] E^(-((d^2 θ^2)/(2 π))) θ Erfc[(d θ)/Sqrt[2 π]])/π *)

While the next step with $d_0<0$ can be made more justifiably, a bit of handwaving notes that the distribution is symmetric about 0 when the two half-normal distributions have the same parameter. That results in the density function of the difference being

(Sqrt[2] E^(-((d^2 θ^2)/(2 π))) θ (1 + Erf[(Abs[d] θ)/Sqrt[2 π]]))/π

A plot of this function against a huge random sample from the same distribution does not suggest the result is wrong. So borrowing from @march we have the following:

dist = TransformedDistribution[x - y, {x \[Distributed] HalfNormalDistribution[θ],
y \[Distributed] HalfNormalDistribution[θ]}]
sample = RandomVariate[dist /. θ -> 1, {1000000}];
f[z_] = PDF[SmoothKernelDistribution[sample, {"Adaptive", Automatic, Automatic}], z];
Plot[{(Sqrt[2] E^(-(d^2/(2 π))) Erfc[Abs[d]/Sqrt[2 π]])/π, f[d]}, {d, -5, 5},
PlotStyle -> {{Green, Thickness[0.015]}, Blue}]

UPDATE

I offer the following without proof for the case where the half-normal parameters differ.

g12[a_, b_] := (D[Integrate[PDF[HalfNormalDistribution[a], u] PDF[HalfNormalDistribution[b], v],{u, 0, ∞}, {v, 0, d + u}, Assumptions -> {a > 0, b > 0, d >= 0}], d]) /. d -> Abs[d]
g[a_, b_] = Piecewise[{{g12[a, b], d <= 0}, {g12[b, a], d > 0}}]

θ1 = 4;
θ2 = 0.75;
dist = TransformedDistribution[
x - y, {x \[Distributed] HalfNormalDistribution[θ1],
y \[Distributed] HalfNormalDistribution[θ2]}]
sample = RandomVariate[dist, {1000000}];
f[z_] = PDF[SmoothKernelDistribution[sample, {"Adaptive", Automatic, Automatic}], z];
Plot[{g[θ1, θ2], f[d]}, {d, -5, 5},
PlotStyle -> {{Green, Thickness[0.015]}, Blue}, PlotRange -> All]

So in general the density function when the half-normal paramaters are not equal is given by

• Aren't your two expressions for positive and negative d the same? – Eckhard Jan 6 '17 at 21:03
• @Eckhard. I don't think so. The numerators in the Erfc function differ in that one has $\theta1$ and the other has $\theta2$. – JimB Jan 6 '17 at 21:06
• Indeed. Hasty reading on my part. – Eckhard Jan 6 '17 at 21:09
• @Eckhard. Review comments are always welcome. I promise that I'll mess something up real soon. – JimB Jan 6 '17 at 21:11

To get the distribution, do

dist = TransformedDistribution[x - y, {x \[Distributed] HalfNormalDistribution[θ], y \[Distributed] HalfNormalDistribution[θ]}]

(Note: \[Distributed] can be quickly entered in Mathematica using Esc+dist+Esc.)

Ideally, we'd like to do

PDF[dist, z]

to get the pdf as a function of z, but this returns unevaluated, even in the case where you specify a value for θ.

For that reason, we take a numerical approach by generating a pseudo-random sample from the distribution and using SmoothKernelDistribution (as suggested by JimBaldwin in a comment under the OP) to generate a numerical approximation of the pdf, as follows.

sample = RandomVariate[dist /. θ -> 1, {1000000}];
f[z_] = PDF[SmoothKernelDistribution[sample], z];
Plot[f[z], {z, -5, 5}]

As suggested by a comment by the OP below, for different parameters, just do

dist = TransformedDistribution[x - y, {x \[Distributed] HalfNormalDistribution[θ1], y \[Distributed] HalfNormalDistribution[θ2]}];

and then

sample = RandomVariate[dist /. {\[Theta]1 -> 4, \[Theta]2 -> 0.75}, {1000000}];
f[z_] = PDF[SmoothKernelDistribution[sample], z];
Plot[f[z], {z, -5, 5}]

• Thank you, March. In the case you specify, the random variables have the same theta. Can you show the case where theta can be different? I note that in "dist", theta is identical, and that in your sampling, you specify "theta arrow 1". I suspect that if I add subscripts to the thetas, and add another "theta arrow", for example "theta arrow 0.5", I get the answer I am looking for, but I have been unable to find the correct syntax. So your help is much appreciated. – user120911 Jan 6 '17 at 9:04


text:
# Available Guidelines for Interrupt Driven Processing

Are there any available guidelines for the amount of code to have in a critical section of interrupt driven processing?

My personal rule of thumb is that the critical portion, (i.e. that between disable interrupts and enable interrupts), of any interrupt driven processing should be no more than about a dozen lines of code, (including those in any function/library/macro called), and that the processing should be as linear as possible.

I would expect something along the lines of:

disable_interrupts
if error_condition:
set_error_flag
else:
small_data_transfer
enable_interrupts

However I have been asked to look into an existing project where some of the interrupts have handlers where the call charts will not fit on a sheet of A1 (all in the critical section).

To clarify this is a "bare metal" project with no OS/Scheduler implemented - and all of the interrupt handlers start by disabling all interrupts - i.e. the original authors regarded every operation in every ISR as critical, (even the housekeeping is all inside of a disable/enable section). There are a multitude of interrupts and hardware dependencies but as far as I can see some of the ISRs will be executing thousands of lines within the "critical" section.

I know that this is a problem and really needs to be completely rewritten but I can not find any standards, including MISRA, that I can point to rather than just saying "in my experience" - to convince the project management I need to point to some accepted standards.

So hence my question - Can anybody point me towards any standards or guidelines that I can use to back up my experience? (Or of course am I totally wrong).

-
Do you only have a single interrupt priority? I know I've done a few projects where the entire application lived in the low-priority interrupt handler. It basically was acting like a interrupt-triggered main-loop. Assuming you have sufficient interrupt priority levels, I don't see why that type of structure is an issue. –  Connor Wolf Apr 10 at 10:53
Another comment would be that I've written some protocol decoders that were quite large, but the actual execution path through the decoder per-interrupt was short. A call-path chart for that would be disproportionately huge, I think, and rather mis-represent the actual interrupt efficiency. –  Connor Wolf Apr 10 at 10:56
Your terminology is confusing. On one hand, you seem to be talking primarily about the ISR (interrupt service routine). But you also keep mentioning "critical section", which is normally a term reserved for those sections of non-ISR code during which interrupts are disabled, preventing the ISR from running. Can you clarify your question a bit? –  Dave Tweed Apr 10 at 11:04
So you have a system that allows nested interrupts, and it sounds like the designers of the existing code did not plan this out very carefully. Sounds like a mess. If the critical sections in low-priority interrupts are long, then the response of the system to the presumably more important high-priority interrupts will be delayed. I would be tempted to set the existing code aside and come up with my own high-level architecture for the overall system based only on the external requirements. Only then would I go back to the existing code to see which parts might be reusable. –  Dave Tweed Apr 10 at 11:53
Anything you get off the web, including this site, is going to be viewed as "anecdotal" by management. The only way to get the hard data that they need is to stress-test the existing implementation to demonstrate the failures. –  Dave Tweed Apr 10 at 12:47

In general, the distribution of CPU time between ISR code and non-ISR code is very application-dependent.

If most of the work is being done in non-ISR code, then yes, you generally want to keep the ISRs as short as possible (but no shorter, to paraphrase a famous quote).

However, I have seen (and built) hard real-time DSP applications in which 90% of the work is done in the ISR, and the non-ISR code is only handling tasks that are not time-critical such as configuration, status and user interface.

Either approach is perfectly valid in deeply-embedded systems.

-

The general guideline is that critical sections should be as short as possible.

What you really need to do is account for the length of the critical section when you verify the schedulability of the task set. Doing that depends on how you are scheduling the tasks, but I think it could be as simple as adding the execution time of the critical section to the execution time of every lower-priority task.

-
Unfortunately this is a bare metal project, no OS/Scheduler and no priority handling system - everything is in critical sections - even housekeeping! –  Steve Barnes Apr 10 at 10:51
You don't need an OS or scheduler or priority handling system to perform schedulability analysis, it can be done on any set of tasks that use preemption. Maybe the question you need to ask about the length of the critical sections is...who cares? Does anything break if the critical sections are too long? –  Joe Hass Apr 10 at 10:59
Yes Joe - long lockouts to break things since the other interrupts are getting locked out, (even during housekeeping), they are being ignored and messages are getting corrupted/lost. –  Steve Barnes Apr 10 at 16:50
Then what you need is a schedulability analysis! You need to make sure that all tasks will respond in the desired time. –  Joe Hass Apr 10 at 17:27
And that of course is one of the problems with long complex ISRs - that it is often impractical to perform such analysis in a reasonable time scale because of the complexity. –  Steve Barnes Apr 10 at 17:49

I think you have to consider the execution time of the uninterruptible code wrt the fastest response time (latency) and variability of that time (jitter) you need from the microcontroller. It may not be intuitive what that is-- it may be something that is 'urgent' but not 'important'.

For example, a controller I designed some years back needed to deal with RS-232 inputs, to update the output using the control algorithm, to control the dual-slope ADC, to scan an LED display and keyboard (including debouncing), write to a slow EEPROM, and to control an electromagnetic beeper (and probably I couple of other things I've forgotten). Turned out the most critical response time was the beeper periodic interrupt (every 250usec), followed by the LED display, mostly for cosmetic reasons. So if 10% jitter in the beeper toggle was acceptable, that's 25usec of uninterruptable code (which wasn't many instructions, but enough to make certain things atomic). That particular processor supported nested interrupts, so IIRC I ended up making the periodic interrupt code re-entrant after the first section.

If you're deferring pending interrupts during long sections of code, it may be just fine, if your requirements for latency and jitter are fairly relaxed in relation to the execution time of the "critical portions".

My usual approach is to minimize the code execution time in ISRs and to get back as quickly as possible (perhaps stuffing things like debounced input event tokens into circular queues, set flags and get out). For example, if a complex control algorithm needs to be executed every 200msec with maximum 20msec jitter, I'd set a flag every 200msec in the timer interrupt and poll that flag outside the ISR.

Aside from meeting design requirements, reliability is enhanced by this approach.

As far as finding some kind of guideline that states this.. I suggest looking at some of the safety-critical software guidelines. You may not find it stated directly, but you may be able to infer it from other statements. UL1998 IEC 60730 etc. This FAA document states:

Interrupts and their effect on data must receive special attention in safety-critical areas. Analysis should verify that interrupts and interrupt handling routines do not alter critical data items used by other routines.

and

Of particular concern to safety is ensuring the integrity of safety critical data against being inadvertently altered or overwritten. For example, check to see if interrupt processing is interfering with safety critical data.

Both of which become more difficult as the size of the interrupt code increases.

Short (in relation to maximum jitter and latency) frequent interrupts can be analyzed as an effective decrease in processor speed rather than having to deal with worst-case stack-ups of long interrupts at the most critical times, which argues for fast execution as well as simple code within ISRs.

-

To me, avoiding nesting interrupts does not seem too bad or even absurd. In fact, nested interrupts may cause more problems than they solve.

I'm specifically referring to memory used to save/restore context when entering/exiting the ISR. Commonly on simple architectures each ISR will save all required context of the code it interrupted, for example on the processor's stack. When developing the software one needs to account for this memory.

If, for example, ISR A requires 10 bytes of context to be saved/restored, ISR B needs 15 and ISR C needs 12 bytes the calculation/estimation simply is:

Anywhere during the execution of non-critical sections any of the ISRs may be triggered. Now, if the ISRs are not allowed to be nested, the maximum memory required for the context is max( 10, 15, 12 ) = 15 bytes. If each of the ISRs may interrupt any other of those 3 ISRs, the worst case will be 10 + 15 + 12 = 37 bytes of context which need to be stored at the same time. So at every instant during execution (of non-atomic code), there must be at least enough memory available for those 37 bytes of context, vs. 15 in the non-nesting case.

Of course, the more ISRs join the "nesting game" the more the issue becomes visible.

If you have multiple tasks running concurrently and ISRs save context to the current stack of whatever code they're interrupting, you have to account for one worst-case context size per task.

This argument of course depends on the HW architecture you're using. It may not be applicable if the HW/Interrupt Controller is more advanced and has special features to handle context switching to/from ISRs.

Apart from that, complex ISRs tend to require more context data to be saved/restored than simple ones, so that small, concise ISRs are usually recommended because they provide multiple benefits:

1. quick execution time, possibly yielding
1. shorter critical sections and thus
2. less jitter
2. smaller context, resulting in
1. less worst-case memory usage and (architecture-dependent)
2. even less execution time (by not having to transfer as much state information from A to B to A)

In the end, if all ISRs are reduced to their minimum, like when only setting a flag, the question of whether or not to allow nesting ISRs may be answered clearly in favour of non-nesting because the benefit of nesting ISRs vanishes.

-


text:
Opuscula Math. 31, no. 4 (2011), 519-531
http://dx.doi.org/10.7494/OpMath.2011.31.4.519

Opuscula Mathematica

# Neighbourhood total domination in graphs

S. Arumugam
C. Sivagnanam

Abstract. Let $$G = (V,E)$$ be a graph without isolated vertices. A dominating set $$S$$ of $$G$$ is called a neighbourhood total dominating set (ntd-set) if the induced subgraph $$\langle N(S)\rangle$$ has no isolated vertices. The minimum cardinality of a ntd-set of $$G$$ is called the neighbourhood total domination number of $$G$$ and is denoted by $$\gamma _{nt}(G)$$. The maximum order of a partition of $$V$$ into ntd-sets is called the neighbourhood total domatic number of $$G$$ and is denoted by $$d_{nt}(G)$$. In this paper we initiate a study of these parameters.

Keywords: neighbourhood total domination, total domination, connected domination, paired domination, neighbourhood total domatic number.

Mathematics Subject Classification: 05C69.

Full text (pdf)


text:
# Understanding Parametric equations

#### Rido12

##### Well-known member
MHB Math Helper
I have a few trivial questions regarding finding equations of the tangent line:

1) Find an equation of the tangent line to the parametric curve:

x = 2 sin 2t y= 2 sin t

at the point $$\displaystyle (\sqrt{3}, 1)$$

The textbook says that point "corresponds to the parameter value $$\displaystyle t= \frac{pi}{6}$$"

How do they know that? After testing for a few minutes, I noticed that tan-1$$\displaystyle (\sqrt{3}/1)$$ = $$\displaystyle t= \frac{pi}{6}$$ Is that how they determined it?

2) Similar question but
x = t sin t
y = t cos t
point (0, -pi)

Using $$\displaystyle \frac{dy}{dx}$$ = $$\displaystyle \frac{\frac{dy}{dt}}{\frac{dx}{dt}}$$, I got
$$\displaystyle \frac{(cos t -sint)}{(sin t + cos t)}$$ = slope of tangent line

I then plugged the "0" from the point (0, -pi) into the equation...
(cos 0 - sin 0) / (sin 0 + cos 0) = 1

Is that right/am I on the right track?

Last edited:

#### MarkFL

Staff member
What I would do for the first one is use the chain rule as follows:

$$\displaystyle \frac{dy}{dx}=\frac{dy}{dt}\frac{dt}{dx}$$

Now, using the given parametric equations, we find:

$$\displaystyle \frac{dy}{dx}=\frac{2\cos(t)}{4\cos(2t)}= \frac{\cos(t)}{2\cos(2t)}$$

To determine the value of $t$, we could use:

$$\displaystyle y(t)=2\sin(t)=1\,\therefore\,\sin(t)=\frac{1}{2}$$

$$\displaystyle x(t)=2\sin(2t)=\sqrt{3}\,\therefore\,\sin(2t)= \frac{\sqrt{3}}{2}\,\therefore\, \cos(t)=\frac{\sqrt{3}}{2}$$

With no given restriction on $t$, we could state that these conditions correspond to:

$$\displaystyle t=\frac{\pi}{6}+2k\pi=\frac{\pi}{6}(12k+1)$$ where $$\displaystyle k\in\mathbb{Z}$$

However, the value of $k$ will not affect the equation of the tangent line, so we may as well let $k=0$, and use:

$$\displaystyle t=\frac{\pi}{6}$$

So, now you may compute the slope of the tangent line, and then using the given point, apply these to the point-slope formula to get the equation of the tangent line.

What do you find?

#### MarkFL

Staff member
...
2) Similar question but
x = t sin t
y = t cos t
point (0, -pi)

Using $$\displaystyle \frac{dy}{dx}$$ = $$\displaystyle \frac{\frac{dy}{dt}}{\frac{dx}{dt}}$$, I got
$$\displaystyle \frac{(cos t -sint)}{(sin t + cos t)}$$ = slope of tangent line

I then plugged the "0" from the point (0, -pi) into the equation...
(cos 0 - sin 0) / (sin 0 + cos 0) = 1

Is that right/am I on the right track?
You are using an incorrect value for $t$...does $y(0)=-\pi$?

#### Rido12

##### Well-known member
MHB Math Helper
What I would do for the first one is use the chain rule as follows:

$$\displaystyle \frac{dy}{dx}=\frac{dy}{dt}\frac{dt}{dx}$$

Now, using the given parametric equations, we find:

$$\displaystyle \frac{dy}{dx}=\frac{4\cos(2t)}{2\cos(t)}= \frac{2\cos(2t)}{\cos(t)}$$

To determine the value of $t$, we could use:

$$\displaystyle y(t)=2\sin(t)=1\,\therefore\,\sin(t)=\frac{1}{2}$$

$$\displaystyle x(t)=2\sin(2t)=\sqrt{3}\,\therefore\,\sin(2t)= \frac{\sqrt{3}}{2}\,\therefore\, \cos(t)=\frac{\sqrt{3}}{2}$$

With no given restriction on $t$, we could state that these conditions correspond to:

$$\displaystyle t=\frac{\pi}{6}+2k\pi=\frac{\pi}{6}(12k+1)$$ where $$\displaystyle k\in\mathbb{Z}$$

However, the value of $k$ will not affect the equation of the tangent line, so we may as well let $k=0$, and use:

$$\displaystyle t=\frac{\pi}{6}$$

So, now you may compute the slope of the tangent line, and then using the given point, apply these to the point-slope formula to get the equation of the tangent line.

What do you find?
Is it not

$$\displaystyle \frac{dy}{dx}=\frac{2\cos(t)}{4\cos(2t)}= \frac{\cos(t)}{2\cos(2t)}$$

Since,

$$\displaystyle \frac{dy}{dt} = 2 cost$$
(dy/dt [2 sin t] = 2 cos t)

$$\displaystyle \frac{dx}{dt} = 4\cos(2t)$$
(dy/dt [2 sin 2t] = 2 cos(2t) * 2)

#### MarkFL

Staff member
Is it not

$$\displaystyle \frac{dy}{dx}=\frac{2\cos(t)}{4\cos(2t)}= \frac{\cos(t)}{2\cos(2t)}$$...
Yes, I misread, and have fixed my post.

#### Rido12

##### Well-known member
MHB Math Helper
You are using an incorrect value for $t$...does $y(0)=-\pi$?
No, I guess I will try to use the same logic as 1)

x(t) = t sin t

y(t) = t cos t

We want the point (0, -pi)

Hence,

x(t) = t sin t = 0
therefore, t = 0

y(t) = t cos t = -pi
????

Question 1)

Got stuck here:

$$\displaystyle x(t)=2\sin(2t)=\sqrt{3}\,\therefore\,\sin(2t)= \frac{\sqrt{3}}{2}\,\therefore\, \cos(t)=\frac{\sqrt{3}}{2}$$

How does sin 2t = cos t?

#### MarkFL

Staff member
There are other values of $t$ which make $\sin(t)=0$. As you go around the unit circle, what is the next one?

#### Rido12

##### Well-known member
MHB Math Helper
There are other values of $t$ which make $\sin(t)=0$. As you go around the unit circle, what is the next one?
That would be at pi or 180 degrees.

#### MarkFL

Staff member
That would be at pi or 180 degrees.
Correct!

And what is $y(\pi)$?

#### MarkFL

Staff member
...
Question 1)

Got stuck here:

$$\displaystyle x(t)=2\sin(2t)=\sqrt{3}\,\therefore\,\sin(2t)= \frac{\sqrt{3}}{2}\,\therefore\, \cos(t)=\frac{\sqrt{3}}{2}$$

How does sin 2t = cos t?
$$\displaystyle \sin(2t)=2\sin(t)\cos(t)=\frac{\sqrt{3}}{2}$$

Now, from the other equation, we know $$\displaystyle 2\sin(t)=1$$, so we may write:

$$\displaystyle \cos(t)=\frac{\sqrt{3}}{2}$$

#### Rido12

##### Well-known member
MHB Math Helper
Correct!

And what is $y(\pi)$?
$y(\pi)$ = pi cos pi = -1 pi

- - - Updated - - -

$$\displaystyle \sin(2t)=2\sin(t)\cos(t)=\frac{\sqrt{3}}{2}$$

Now, from the other equation, we know $$\displaystyle 2\sin(t)=1$$, so we may write:

$$\displaystyle \cos(t)=\frac{\sqrt{3}}{2}$$
Very neat, you used the first equation to aid with the second. Is it always like this, (that we use the first equation to aid with the second)?

Last edited:

#### Rido12

##### Well-known member
MHB Math Helper
What I would do for the first one is use the chain rule as follows:

$$\displaystyle \frac{dy}{dx}=\frac{dy}{dt}\frac{dt}{dx}$$

Now, using the given parametric equations, we find:

$$\displaystyle \frac{dy}{dx}=\frac{2\cos(t)}{4\cos(2t)}= \frac{\cos(t)}{2\cos(2t)}$$

To determine the value of $t$, we could use:

$$\displaystyle y(t)=2\sin(t)=1\,\therefore\,\sin(t)=\frac{1}{2}$$

$$\displaystyle x(t)=2\sin(2t)=\sqrt{3}\,\therefore\,\sin(2t)= \frac{\sqrt{3}}{2}\,\therefore\, \cos(t)=\frac{\sqrt{3}}{2}$$

With no given restriction on $t$, we could state that these conditions correspond to:

$$\displaystyle t=\frac{\pi}{6}+2k\pi=\frac{\pi}{6}(12k+1)$$ where $$\displaystyle k\in\mathbb{Z}$$

However, the value of $k$ will not affect the equation of the tangent line, so we may as well let $k=0$, and use:

$$\displaystyle t=\frac{\pi}{6}$$

So, now you may compute the slope of the tangent line, and then using the given point, apply these to the point-slope formula to get the equation of the tangent line.

What do you find?
Back to question number 1!

Now that we determine t = pi/6, we can plug it back into the slope of the tangent line

$$\displaystyle \frac{\cos(t)}{2\cos(2t)} = \frac{\cos(pi/6)}{2\cos(pi /3 )}$$

Now that simplifies to root 3 / 2

Final Step:

Y2 - y1 = m (X2 - X1)
y2 - 1 = root 3 / 2 * (x2 - root 3)
y = (root 3 / 2) x - (1/2)

#### MarkFL

Staff member
$y(\pi)$ = pi cos pi = -1 pi

Finishing this question:

Plug this into the slope of the tangent line:

(cos pi - sin pi) / (sin pi + cos pi) = -1 / -1 = 1?

- - - Updated - - -

Very neat, you used the first equation to aid with the second. Is it always like this, (that we use the first equation to aid with the second)?

You need to find the value of $t$ that satisfies both equations with regards to the given point. For example, using the first equation:

$$\displaystyle t\sin(t)=0$$

We know then by the zero-factor property that:

$$\displaystyle t=k\pi$$ where $$\displaystyle k\in\mathbb{Z}$$

Now, using this value for $t$ in the second equation, we find:

$$\displaystyle k\pi\cos(k\pi)=-\pi$$

$$\displaystyle k\cos(k\pi)=-1$$

We now see that $$\displaystyle k=1$$ is the only viable value of $k$.

As far as always being able to use one equation to aid in solving the other, I can't say this is the case, but we can use whatever we find in one to help with the other when possible because they are in essence simultaneous equations.

#### Rido12

##### Well-known member
MHB Math Helper
I get it now! I guess we can use whatever tactic we want, as long as it satisfies both equations.

$$\displaystyle t=k\pi$$ where $$\displaystyle k\in\mathbb{Z}$$

What does Z refer to?

Last edited:

#### MarkFL

Staff member
Back to question number 1!

Now that we determine t = pi/6, we can plug it back into the slope of the tangent line

$$\displaystyle \frac{\cos(t)}{2\cos(2t)} = \frac{\cos(pi/6)}{2\cos(pi /3 )}$$

Now that simplifies to root 3 / 2

Final Step:

Y2 - y1 = m (X2 - X1)
y2 - 1 = root 3 / 2 * (x2 - root 3)
y = (root 3 / 2) x - (1/2)
Yes, that looks correct.

I would refrain from mixing uppercase and lower case variables. I would state:

We have the slope: $$\displaystyle m=\frac{\sqrt{3}}{2}$$

and the point: $$\displaystyle (\sqrt{3},1)$$

hence application of the point-slope formula gives us the tangent line:

$$\displaystyle y-1=\frac{\sqrt{3}}{2}\left(x-\sqrt{3} \right)=\frac{\sqrt{3}}{2}x-\frac{3}{2}$$

Arranging this in slope-intercept form, we have:

$$\displaystyle y=\frac{\sqrt{3}}{2}x-\frac{1}{2}$$

#### MarkFL

Staff member
I get it now! I guess we can use whatever tactic we want, as long as it satisfies both equations.

$$\displaystyle t=k\pi$$ where $$\displaystyle k\in\mathbb{Z}$$

What does Z refer to?

$$\displaystyle k\in\mathbb{Z}$$ just means that $k$ is an arbitrary integer.

The zero-factor property just means that if your have:

$$\displaystyle ab=0$$

then you know the equation is true when either $a=0$ or $b=0$, you are probably familiar with it when solving a quadratic by factoring, where you equate each factor in turn to zero to find the roots.

#### Rido12

##### Well-known member
MHB Math Helper

Plug this into the slope of the tangent line:

(cos pi - sin pi) / (sin pi + cos pi) = -1 / -1 = 1

putting it in point-slope formula gives us y = x - pi

y2 - y1 = m (x2 - x1
y + pi = m (x)
y = x - pi

Answer in the back of the textbook : y = (1/pi) x - pi

Did I make a mistake somewhere?

#### MarkFL

Staff member

Plug this into the slope of the tangent line:

(cos pi - sin pi) / (sin pi + cos pi) = -1 / -1 = 1

putting it in point-slope formula gives us y = x - pi

Answer in the back of the textbook : y = (1/pi) x - pi

Did I make a mistake somewhere?
Yes, check your differentiation again, recalling you need to apply the product rule.

#### Rido12

##### Well-known member
MHB Math Helper
Whoops, did it right on paper, but when I tried to type it on here, I mistakened "sint (t)" to be sin (t). Thanks a lot! You were of great help!


text:
# Tournaments with exactly one directed Hamiltonian path

Every tournament contains a directed Hamiltonian path (a path visiting every vertex exactly once).

Suppose that $T$ is a tournament on $[n]:=\{1,\ldots,n\}$ for some integer $n\geq 2$ with exactly one directed Hamiltonian path. Does this imply that $T$ is isomorphic to the tournament $([n], E)$ where $E = \{(i,j)\in [n]: i<j\}$?

It does. Suppose, wlog that the unique Hamiltonian path is $1\to 2\to\cdots\to n$. If $i\to n$ for all $i<n$ then you are done by using the inductive hypothesis on $[n-1]$, otherwise there exists an $i$ such that $n\to i$.
Pick the smallest such $i$ and notice that if $i=1$ then $n\to 1\to 2\to\cdots \to n-1$ is a new Hamiltonian path, and finally if $i>1$ then $1\to 2\to \cdots \to i-1\to n\to i\to \cdots \to n-1$ is a new Hamiltonian path.


text:
### David Robinson

Data Scientist at Stack Overflow, works in R and Python.

# Introducing stackr: An R package for querying the Stack Exchange API

There’s no end of interesting data analyses that can be performed with Stack Overflow and the Stack Exchange network of Q&A sites. Earlier this week I posted a Shiny app that visualizes the personalized prediction data from their machine learning system, Providence. I’ve also looked at whether high-reputation users were decreasing their answering activity over time, using data from the Stack Exchange Data Explorer.

One issue is that each of these approaches requires working outside of R to obtain the data (in the case of the Data Explorer, it also requires knowledge of SQL). I’ve thus created the stackr package, which can query the Stack Exchange API to obtain information on questions, answers, users, tags, etc, and converts the output into an R data frame that can easily be manipulated, analyzed, and visualized. (Hadley Wickham’s httr package, along his terrific guide for writing an API package, helped a lot!) stackr provides the tools to perform analyses of a particular user, of recently asked questions, of a particular tag, or of other facets of the site.

The package is straightforward to use. Every function starts with stack_: stack_answers to query answers, stack_questions for questions, stack_users, stack_tags, and so on. Each output is a data frame, where each row represents one object (an answer, question, user, etc). The package also provides features for sorting and filtering results in the API: almost all the features available in the API itself. Since the API has an upper limit of returning 100 results at a time, the package also handles pagination so you can get as many results as you need.

Here I’ll show an example of using the stackr package to analyze an individual user. We’ll pick one at random: eeny, meeny, miny… me. (OK, that might not have been random). Stack Overflow provides many summaries and analyses on that profile already, but the stackr package lets us bring the data seamlessly into R so we can analyze it however we want. Extracting all of my answers is done using the stack_users function with the extra argument "answers". We’ll take advantage of stackr’s pagination feature, and turn the result into a tbl_df from dplyr so that it prints more reasonably:

This lets me find out a lot about myself: for starters, that I’ve answered 732 questions. What percentage of my answers were accepted by the asker?

How has my answering activity changed over time? To find this out, I can use dplyr to count the number of answers per month and graph it:

Well, it looks like my activity has been decreasing over time (though I already knew that). How about how my answering activity changes over the course of a day?

(Note that the times are in my own time zone, EST). Unsurprisingly, I answer more during the day than at night, but I’ve still done some answering even around 4-6 AM. You can also spot two conspicuous dips: one at 12 when I eat lunch, and one at 6 when I take the train home from work.

(If that’s not enough invasion of my privacy, you could look at my commenting activity with stack_users(712603, "comments", ...), but it generally shows the same trends).

### Top tags

The API also makes it easy to extract the tags I’ve most answered, which is another handy way to extract and visualize information about my answering activity:

We could also view it using the wordcloud package:

This is just scratching the surface of the information that the API can retrieve. Hopefully the stackr package will make possible other analyses, visualizations, and Shiny apps that help understand and interpret Stack Exchange data.


text:
# Devilish fun

Algebra Level 4

The product of the real roots of the polynomial

$f(x) = x^4 - 4x^3 + 6x^2 -4x-666$

can be written as $$a - \sqrt{b}$$, where $$a$$ and $$b$$ are positive integers. What is the value of $$a+b$$?

×

Problem Loading...

Note Loading...

Set Loading...