text:
# Central Limit Theorem applied to a Bernoulli distribution

1. Jun 10, 2014

### TheOldHag

As I understand it, one result of the central limit theorem is that the sampling distribution of means drawn from any population will be approximately normal. Assume the population consist of Bernoulli trials with a given probability p and we want to estimate p. Then our population consist of zeros and ones and our sample means will be in the interval [0,1]. So I'm a bit confused how such a distribution of sample means can be approximated by a normal distribution which is never 0 in the interval (-infinity, infinity).

Is it because the probability is very small outside of [0,1] and thereby still a good approximation. Or am I not understanding the central limit theorem. I have googled a bit and most of what I have found is applying the central limit theorem to the binomial distribution. But this seems to be the easier case and my guess is having to estimate a proportion is very common. Any insight is appreciated.

2. Jun 10, 2014

### jbunniii

It is true that the sample mean $s_n = \sum_{k=1}^{n} x_n$ will be in the interval $[0,1]$. The central limit theorem says that $\sqrt{n}(s_n - \mu) \rightarrow N(0, \sigma)$ (convergence in distribution). Equivalently, the distribution of $s_n$ is approximated by $N(\mu,\sigma/\sqrt{n})$ for large $n$. As $n$ increases, $N(\mu, \sigma/\sqrt{n})$ becomes narrowly centered around $\mu$, and the tails (e.g. the portion of the pdf outside a narrow interval around $\mu$) become very small. This is reasonable because $s_n$ converges with probability 1 to $\mu$ by the law of large numbers, so we would expect that for large $n$, its pdf should largely confined to a narrow interval around $\mu$.

3. Jun 10, 2014

### Stephen Tashi

To add to what Jbunniii said, the technical definition of "will be approximately" involves the concept of convergence of a sequence of functions to a function and the further complication of defining a convergence of a sequence of random variables to another random variable. These concepts are more complicated than the concept of the convergence of a sequence of numbers to another number (i.e. the ordinary idea of limit studied in first semester calculus).

Of course, you can find an article about the convergence of sequences of random variables in the Wikipedia. If you want to pursue this, you should begin with an exact statement of what the Central Limit Theorem says.

4. Jun 10, 2014

### jbunniii

One more thing I would like to mention: observe that as long as the $x_n$ are independent and share a common mean $\mu$ and standard deviation $\sigma$, then $E[s_n] = \mu$ and $\text{var}(s_n) = \sigma^2/n$, and so
$$E[\sqrt{n}(s_n - \mu)] = \sqrt{n}(E[s_n] - \mu) = \sqrt{n}(\mu - \mu) = 0$$
and
\begin{align} \text{var}(\sqrt{n}(s_n - \mu)) &= E[n(s_n - \mu)^2] \\ &= n(E[s_n^2] - 2\mu E[s_n] + \mu^2) \\ &= n(E[s_n^2] - \mu^2) \\ &= n(\text{var}(s_n)) \\ &= n(\sigma^2/n) \\ &= \sigma^2\end{align}
So even without taking any limit, we know that $\sqrt{n}(s_n - \mu)$ must have mean $0$ and standard deviation $\sigma$ for every $n$. Thus it's no surprise that the limit distribution (if it exists) must also have this mean and standard deviation. So the real content of the CLT is that if we add the hypothesis that the $x_n$ are identically distributed, then (1) the sequence does converge in distribution and (2) the limit distribution is normal.

One last thing to note is that convergence in distribution means that the sequence of cdf's (cumulative distribution functions) converges pointwise. Thus the fact a Bernoullli random variable, or any finite sum of them, is discrete whereas a normal distribution is continuous, does not cause any difficulty. We do NOT claim that the sequence of probability mass functions of the Bernoulli sums somehow converges to
$$\frac{1}{\sqrt{2\pi}\sigma}\exp\left(-\frac{x^2}{2\sigma^2}\right)$$

5. Jun 10, 2014

### Hornbein

This isn't true. There is a condition that is easily met, so don't worry about it. A distribution that does not meet the condition is X/Y where both are standard normal variables with mean zero. When Y is close to zero you will get freakish results. This distribution doesn't even have a mean. But this sort of thing never seems to show up in real life.

If you meet that condition, then the sample means converge to a normal. It may take a long time for it to converge, but most people are interested in bounded distributions without extreme skew, so in practice things usually converge quite quickly.

The normal distribution is an abstract mathematical model. Real life NEVER matches it exactly. This is applied mathematics so when they say "the distribution is normal" they really mean approximately normal. So don't worry about it, unless you have a Bernoulli distribution with p close to 0 or 1. Then you have a skewed distribution and will have to have a large sample size. If p is close to zero then you need a sample size like 15/p. If p=10^-9 you will have extreme skew and will need a very large sample.

6. Jun 11, 2014

### micromass

The first thing I did was to simulate a basic Bernouilli(1/2) variable. So I generated 10000 data points which were distributed Bernouilli(1/2). This is the plot of the frequencies of the data points:

As we expect, about half of the data points are in 0, and half are in 1.

Then I took 2 data points who were Bernouilli(1/2) distributed and took the average of the two. I did this 10000 times. This is the plot of the frequencies:

I then took 5 data points who were Bernouilli(1/2) distributed and took the average of the 5. I did this 10000 times. This is the plot of the frequencies:

I then took 10 data points who were Bernouilli(1/2) distributed and took the average of the 10. I did this 10000 times. This is the plot of the frequencies:

I then took 100 data points who were Bernouilli(1/2) distributed and took their average. I did this 10000 times. This is the plot of the frequences:

I then took 1000 data points who were Bernouilli(1/2) distributed and took their average. I did this 10000 times. This is the plot of the frequencies:

As you see, the mean of the distribution translates to the right if I take enough data points in the average. You also see that I get very close to a normal distribution. Even if I only take averages of 10 data points, I'm already quite close! The variance also gets smaller each time (relative to the total population).

So while you are right that I can never generate negative values. We do see that the population translates to the right and since the variance gets (relatively) small. Thus the theoretical contribution from the negative values in the normal distribution gets closer and closer to 0.

#### Attached Files:

File size:
3 KB
Views:
476
File size:
2.9 KB
Views:
469
File size:
3.2 KB
Views:
471
File size:
3.6 KB
Views:
461
File size:
4.2 KB
Views:
475
• ###### Data1000.png
File size:
3.3 KB
Views:
459
7. Jun 11, 2014

### jbunniii

@micro - Based on the x-axis in your plots, I think your simulation is summing the Bernoulli trials, not averaging them, correct?

I also noticed that I omitted a $1/n$ scale factor in my definition of $s_n$ in post #2. It should have been
$$s_n = \frac{1}{n}\sum_{k=1}^{n} x_n$$
The rest of my remarks assumed we were talking about averages, not sums.

If we sum instead of averaging, we get similar results, except the mean and standard deviation of $\sum_{k=1}^n x_n$ are $n \mu$ and $\sqrt{n}\sigma$ instead of $\mu$ and $\sigma/\sqrt{n}$. However, the sums do NOT converge in distribution.

8. Jun 11, 2014

### micromass

Yes, that is correct. Here are the plots for the averages:

The averages of the above plots remain the same now (as 1/2). But the variances decrease each time. So the corresponding normal distributions have variances which decrease. So the negative points have probabilities which decrease to 0.

File size:
3 KB
Views:
474
File size:
3.1 KB
Views:
470
File size:
3.3 KB
Views:
473
File size:
3.6 KB
Views:
465
File size:
3.6 KB
Views:
465
File size:
3 KB
Views:
471


text:
# approaches to laying out a PCB

#### BobaMosfet

Joined Jul 1, 2009
1,606
@champ1

I strongly recommend using a 2-layer PCB if you can. Ground on bottom, and Vcc on top. Makes layout much easier. A couple of points (and some others here may have mentioned some of these):

• Consider PCB dimensions- the smaller it is, and the fewer vias, the less it costs (generally). It's going to take so many vias, regardless, so be smart about how you lay them out.
• Consider inductive and capacitive issues- these don't matter so much for slow stuff, but for signalling (like SPI, etc), this can cause an issue, so route those traces accodingly.
• Try to organize semiconductors always in the same orientation across the board. In fact, do this for most components- but only insofar as it makes sense to do so. Sometimes, rotating a component can make trace-routing far easier.
• Take advantage of space underneath through-hole components if you use any- That's a nice open space under a chip, or perhaps under a resistor that can help you route a trace that would otherwise be difficult to get from one point, to another.
• Be creative- but not crazy. Be aware of trace thickness, and corners, and the ability to use vias to jump from one side of a board to the other to and back gain to get around a choke-point.
• Check your schematic and PCB layout 3 times before submitting.
• When you get a PCB back, do a continuity test on one of them immediately between Vcc & Ground to be sure you haven't accidently connected the two somewhere.

One of the things I _always_ do on PCBs, is I always put an LED on it after the power-circuit. It is the first thing I solder on the border after power-circuitry, because it lets me know a) board is hot, and b) board power is working and planes are divided.

My $0.02-- Good luck and welcome to jumping into this exciting aspect of empowerment #### Irving Joined Jan 30, 2016 1,264 That way there's no sneak path for the noise around the capacitor. In a similar vein, if you have other pins on the chip pulled up to Vcc connect them to the Vcc pin and not the Vcc feed, to stop stray noise in or out of the chip. Similarly, don't 'borrow' Vcc from one chip to another. • Consider PCB dimensions- the smaller it is, and the fewer vias, the less it costs (generally). It's going to take so many vias, regardless, so be smart about how you lay them out. Smaller means more boards for your money - if you panel them up yourself. Vias are generally included these days though its wise to check upper limit; the allowance is pretty generous usually. #### KeithWalker Joined Jul 10, 2017 1,660 What template did you use (not that I'd use Visio for that)? I have an old version from 1996 (pre-dates Microsoft's acquisition of Visio) that now runs on Win10. The version I am using is Visio Technical 4.0 that I acquired in 1995. I copied the 3 1/2" floppies over to a CD about 10 years ago. I use it mostly in XP but it will run well in all versions of Windows. Over time I have made my own library of electronic device symbols and footprints that I built using the "Basic" stencils. I still haven't found a more useful technical drawing tool after all these years. I use it to design circuit schematics, PCBs, meter scales, front panels, labels for header strips and just about anything else I need a line drawing or diagram of. Last edited: #### nsaspook Joined Aug 27, 2009 8,239 With regard to ground planes: have a look at Rick Hartley He is an absolute Titan in the PCB design field currently. In this video he explains how to design modern high speed boards. Yes, he's great. The primary point is the signal energy is between the traces, in the plastic. When you think of the PCB as a electromagnetic wave-guide you build the intuition to see problems as the traces and groups of traces are moved. Don't avoid the auto-router (Topological Router) with modern CAD products or think it can do the whole job. Learn the ways it can help (set up rules for the auto router to handle critical nets) to make better boards. It won't do the whole job but it can let you concentrate on the important details that need hand routing. Eagle PCB layout example: Last edited: Thread Starter #### champ1 Joined Jun 4, 2018 133 I am posting my works. I want to know whether my layout is correct or there are mistakes in it #### Ian0 Joined Aug 7, 2020 1,842 Those tracks are awfully thin, for what is a power board. It might have to take 1Amp. You need to get yourself a freebie Digikey ruler!* (even the one where they got their own web address wrong) and it tells me that for 35um thick copper (a.k.a. 1oz copper, because it's 1oz per square foot) you need 0.5mm tracks for a 5 degree C temperature rise at 1Amp. But you clearly have room for 2mm tracks, so make them as thick as you can. Also there's little point in having a ground plane, if you don't connect it to something - 0V would be a suitable place. Whatever pcb software you're using, when you select "fill" it will probably ask you if you want it connecting to a net, and if so, which one, so select "0V" or "GND" or whatever you called it. Another thing that I seemed to take ages to learn: when placing your components near the fixing holes, you need to think not just of the size of the nuts that fix it, but the size of the nut runner that you will be using to tighten those nuts. *I think that when I mentioned the Digikey ruler once before, our friend @crutschow had a pdf of it. Last edited: #### MaxHeadRoom Joined Jul 18, 2013 22,814 You need to get yourself a freebie Digikey ruler!* (even the one where they got their own web address wrong) and it tells me that for 35um thick copper (a.k.a. 1oz copper, because it's 1oz per square foot) you need 0.5mm tracks for a 5 degree C They sent me a free one with an order a couple of years back, now I see they charge CAN$7.00 !
Very handy though.

#### Ian0

Joined Aug 7, 2020
1,842
They sent me a free one with an order a couple of years back, now I see they charge CAN\$7.00 !
Very handy though.
I thought that they had given them away because the web address was wrong!

#### click_here

Joined Sep 22, 2020
85
As IanO said, your tracks are too thin, and floating voltage levels on any track are a bad idea, let alone a whole plane!

You may want to put the 7805 up close to the edge to give you the option of screwing it to a heat sink or chassis

And most importantly, you are missing a header on the output

Other than that, it looks good

format: plain


text:
# Chapter R - Algebra Reference - R.7 Radicals - R.7 Exercises - Page R-29: 17

$4xy^2z^3\sqrt[3]{2y^2}$

#### Work Step by Step

Simplify by factoring the radicand so that one factor is a perfect cube to have: $=\sqrt[3]{64x^3y^6z^9(2y^2)} \\=4xy^2z^3\sqrt[3]{2y^2}$

After you claim an answer you’ll have 24 hours to send in a draft. An editor will review the submission and either publish your submission or provide feedback.


text:
# 8-Bit stereo audio R-2R DAC, is this a right way to do it?

I am new to electrical engineering and the first project I would like to do is making a digital to analog audioconverter. I've found out that a good way to do this is to use an R-2R structure for the conversion.

I'd like to challenge myself and start from scratch with the digital part of the circuit, besides the fact that I can't really find any solutions on the web to help building it. I've got a circuit simulation program and started designing, while searching the web for all different kinds of electronics you might use for it.

Now I think I might be somewhere in the neighbourhood of understanding the principle of a DAC, but it would be helpful if someone experienced could help me check if I do in fact get it. Is this a right place to ask for that?

If so, here's the circuit I've designed:

I have used a shift register with output latch for each channel and linked Q7S from one to the other to feed the data. Is it right that audio files alternate left and right channel, or vice versa, in blocks? e.g. in an 8-bit file: 0010 0111 for left following 0010 0110 for right?

The shift registers I've used here are 74HC595s. When shifting-in bits non of the pins will be (momentarily) be active. When the latch [STCP pin] is triggered the bits get transferred from the shift register into the storage register, where they will directly output their value to the corresponding pins and stay active until the next 16 bits are allowed in.

Then there is the crystal, for which I've used a square wave signal to imitate one with the right oscillating frequency: 24,576MHz. It feeds the counter in which the frequency gets divided to output the frequencies my DAC needs. In this case the sample frequency has to be 192.000kHz and therefore the frequency at which the data is shifted in has to be 3.02MHz (192.000 x 16 bit). The 192.000kHz clock speed is used to trigger STCP.

The next thing I want to do is to figure out how to load data from a source (Raspberry for example) through maybe I2C into a buffer in the DAC and from there clock the bits out into the circuit you see here.

If you think I am or I am not on the right way, it would be very helpful to let me know.

Thanks! Rogier

By the way, I forgot to mention that the DAC I would like to build is at least 24-bit per channel at 96kHZ. It just takes up a lot of space on this threat and shouldn't be difficult to add them afterwards. It's the same principle.

• Good, difficult project. I didn't go through all your maths but an 8-bit audio isn't going to sound too good. You're going to have to bias to half-supply which leaves you with 7-bit on each side. You may get away with this on compressed speech where dynamic range is severely limited but quiet passages of speech or music will have terrible distortion due to the coarse step size and the ear's logarithmic response. From memory, CD quality is 14-bit. – Transistor Jan 31 '16 at 0:24
• @transistor while it won't qualify has high fidelity, 8-bit audio can be surprisingly listenable if done right, especially if the sample rate is out of the audible range, which it seems to be in this case (with a high enough sample rate, you can even get away with 1-bit output...). A more serious concern is if the shift registers proposed are "double-buffered", or if bits will momentatarily show up on the wrong outputs while being shifted through, something that could cause substantial distortion. – Chris Stratton Jan 31 '16 at 0:37
• As to your comment about 24 bits per channel - forget it, forget it now, and don't waste any more time thinking about it. I'm not going to go in to the maths for that in this comment, but I'm sure it's come up here some time before. If not, here's what wikipedia has to say: en.wikipedia.org/wiki/… – pipe Jan 31 '16 at 9:47
• Using 1% resistors, you can get accurate 6-bit resolution (LSB=MSB/64, so 1% error < LSB/MSB value), but above that you'd need to cut the possible error per resistor in half for every additional bit (0.25% for 8-bit) too keep resistor error from possibly overpowering your least significant bit(s). – Robherc KV5ROB Jan 31 '16 at 10:57
• $2^{-23}$ is an awful small number. like 1 over 8 million. you will not be able to make a DAC, with any decent conversion speed, that has output as accurate as that spec. the honest number of bits is the Dynamic Range in dB (which is the S/N ratio in dB added to the number of dB of headroom) divided by 6.02 dB/bit. that will give you the number of honest bits. the best i have seen in the industry is still about 20 bits (or about 120 dB dynamic range). – robert bristow-johnson Feb 1 '16 at 17:44

• Yes, this is exactly the right place to ask your question.
• Yes, R-2R topography is the simplest to design (and I think best) way to make a homebrew DAC (wkthout using PWM).
• As for challenging yourself, it sounds to me like you may be about as masochistic as I am (kudos for having the guts!). This is a really involved project for a beginner.
• Your R-2R resistor strings (and arguably the attached op amps) actually ARE your 8-bit DACs

Here's what I'm thinking:

Unfortunately, the wikipedia page on R-2R ladder DACs is incorrect when it says that the R-2R ladder functions as a current divider in this application. While an R-2R ladder can be used as a current divider, it actually functions as a voltage divider here. Here's a detailed analysis.

Consider just the LSB of the ladder by itself:

simulate this circuit – Schematic created using CircuitLab

Regardless of the position of the switch, the Thevenin resistance of this simple voltage divider is just R. The value of the Thevenin voltage source is either 0V or 1/2 × Vref.

Now, consider what happens when you add the next stage of the R-2R ladder:

simulate this circuit

You can see that this is the same kind of voltage divider that we had in the first case, except that the number of voltage combinations has increased. However, the Thevenin resistance of this circuit is still just R, and the Thevenin voltage source is now 0/4, 1/4, 2/4 or 3/4 × Vref.

By induction, you can see that you can add any number of stages to the ladder, and the only effect is that the number of choices for the Thevenin voltage source value gets multiplied by 2 for each stage. The source resistance remains exactly the same for any number of stages.

If the load impedance is infinite, the output voltage of the ladder will exactly match the Thevenin voltage. But if the load has some finite value of resistance, the only effect will be to create a voltage divider with the Thevenin source resistance, scaling the output voltage by some fixed ratio, but having no other effect on the DAC's basic accuracy or linearity.

Note that in Rogier's original circuit (the one in the question), the opamps are in an inverting configuration, which means that the output of the R-2R ladder is tied directly to a virtual ground. This means that the output value is really the current flowing through Rth (which is just R), and this current also flows through the opamp's feedback resistor. The output voltage from the opamp is whatever voltage that is required to make those two currents equal, and works out to -Rfb/R × Vth. Since he uses a feedback resistor of 2R, the output ends up being -2 × Vth.

There seems to be some confusion over whether the R-2R ladder is being used as a voltage divider or a current divider, so here's an illustration of how the latter can work, in order to show the key differences between this and the OP's circuit.

simulate this circuit

Note that the currents flowing down through the 2R resistors are binary-weighted. This works because the effective resistance looking to the right from any of the triple junctions is also exactly 2R. Therefore, the current flowing from the left always divides equally between the down branch and the right branch.

Note that a key assumption here is that all of the legs are tied to the same voltage (zero, in this case). It is also interesting to note that the voltages at the junction nodes are also binary-weighted.

This can be used to build a current-output DAC as follows:

simulate this circuit

The currents in the resistors in this circuit are exactly the same as the previous diagram, because regardless of which position each of the switches is in, the corresponding resistor is connected either to a real ground on the $\overline{\text{Iout}}$ bus, or to a virtual ground on the $\text{Iout}$ bus. The currents on the two busses always add up to Iref. An opamp can convert the output current to a voltage, and the voltage range is simply -Iref × R7.

• To be honest, I still don't actually know what an opamp does and why I would need it here. What it does (according to the simulation software) is making the positive signal coming out of the R-2R ladder negative with a multiple of two: ~5V in, -9,96V out. Why would that be necessary? – Rogier Reerink Jan 31 '16 at 10:30
• Op Amps magnify the difference between 2 input voltages.so the software is saying you have your MSB attached to the inverting input (minus sign pin) of the op amp, causing the output to vary as the opposite of the input. The ratio of output signal voltage to input voltage is controlled by the feedback (you used 10K) resistor from op amp output to op amp inverting input; the higher the resistance, the more gain you get (shorting across that resistor, then moving the MSB connect to op amp + input & LSB connect to ground should fix this. – Robherc KV5ROB Jan 31 '16 at 10:41
• Not really. In the OP's diagram, the noninverting inputs of the opamps ARE grounded. All you're doing is switching to a voltage-follower configuration. Don't forget to include a 5k resistor in the feedback path of each one to balance the bias current offsets. Also, the bottommost resistor in each of your R-2R ladders needs to be 10K, not 5K. The OP had this right, too. – Dave Tweed Jan 31 '16 at 18:36
• Robherc, 1. i would ditch the coupling capacitors. 2. if you keeping with the non-inverting voltage follower circuit you have, then you need to add a 10K resistor from the + terminal of the op-amps to ground. and the 5K resistor on the bottom should be 10 K. imagine superposition and all bits OFF (or ground). when you're sitting at any of those nodes, it should be 10K of resistance to ground in all 3 directions. – robert bristow-johnson Jan 31 '16 at 19:53
• Diagram updated with corrected grounding. @robertbristow-johnson why would you get rid of the capacitors that block dc & center your output to protect the tranducers in an audio circuit? – Robherc KV5ROB Jan 31 '16 at 20:02


text:
Unit 5: Solubility Equilibrium

Unit 5 Objectives

By the end of this unit, you will be able to:

• Define solutions/solutes/solvent/solubility
• Describe the process by which ionic compounds dissolve in water
• Solve simple molar solubility problems from Ksp or concentration
• Describe how the common ion effect affects the solubility of ionic compounds
• Solve common ion effect and solubility problems
• Predict precipitation reactions using Q and Ksp
• Model complex ion equilibrium
• Model selective preciptiation experiments

• 5.1: Solubility Equilibria and the Solubility Product Constant
The solubility product (Ksp) is used to calculate equilibrium concentrations of the ions in solution, whereas the ion product (Q) describes concentrations that are not necessarily at equilibrium. The equilibrium constant for a dissolution reaction, called the solubility product (Ksp), is a measure of the solubility of a compound. Whereas solubility is usually expressed in terms of mass of solute per 100 mL of solvent, Ksp is defined in terms of the molar concentrations of the component ions.
• 5.2: Precipitation
A mixture of metal ions in a solution can be separated by precipitation with select anions. When a metal ion or a group of metal ions form insoluble salts with a particular anion, they can be separated from others by precipitation. We can also separate the anions by precipitating them with appropriate metal ions.
• 5.3: Qualitative Chemical Analysis
In qualitative analysis, the identity, not the amount, of metal ions present in a mixture is determined. The technique consists of selectively precipitating only a few kinds of metal ions at a time under given sets of conditions. Consecutive precipitation steps become progressively less selective until almost all the metal ions are precipitated. Other additional steps are needed to separate metal ions that precipitate together.
• 5.4: Complex Ion Equilibria
The formation of complex ions can substantially increase the solubility of sparingly soluble salts if the complex ion has a large Kf. A complex ion is a species formed between a central metal ion and one or more surrounding ligands, molecules or ions that contain at least one lone pair of electrons. Small, highly charged metal ions have the greatest tendency to act as Lewis acids and form complex ions. The equilibrium constant for the formation of the complex ion is the formation constant (Kf).

Unit 5: Solubility Equilibrium is shared under a not declared license and was authored, remixed, and/or curated by LibreTexts.


text:
# Collision detection: a bunch of special cases?

I'm writing a simple physics engine in 2D. My first goal is to get collision detection working. I know that my objects will eventually be made up of primitive shapes, but I was wondering - would a collision detection library be composed of a bunch of special case functions, like "rayAndLine", "rectangleRectangle", "rectangleCircle" etc, or is there a common, underlying framework for collision detection that works regardless of which primitives are used to make the shape?

• You ask about an underlying framework, but specifically state that you'd like to build this portion on your own. Can you clear up that last sentence where your actual question takes place, in order to more specifically separate your concern regarding building it yourself, from using someone else's framework that they've built. I'll provide an answer as well. Oct 17 '17 at 13:50
• Fair point. I meant underlying theory from which all of collision detection stems. In other words, if I'm writing a collision detection subsystem, do I need to write one function for each type of primitive/primitive collision, or is there a single generic function that works no matter what the primitive is? Oct 17 '17 at 13:58
• Sort of. I just answered it. There are some that generalize solutions really well, like SAT works for any convex polygon, and any concave polygon can be broken down into convex polygons, which makes it work for any polygon with some work. After that you'd have to specialize against curves, spheres, and ovals. I've outlined it below. It's a big topic to cover so it's long. Let me know if you have any questions on specifics or anything else Oct 17 '17 at 15:00
• This previous question on abstracting different shape types might also be useful. Oct 17 '17 at 15:53
• The more shared code, the better. If you ever find yourself using copy and paste, seriously check yourself! Oct 17 '17 at 19:34

Getting collision detection working is a great first goal for your 2D physics engine. It's good that you've decided that for now you're specifically working in 2D, as not every rule in 2D works in 3D, despite the amount of n-dimension related algorithms, at some point you have to specialize them (do a more specific variant like how cross product only satisfies the Jacobi identity in 3D).

Your question is inherently about architecture and framework design not about 2D physics, so the concern of what your building should be separate in your mind for how those pieces are used. Essentially, you need to separate the mentality of building the engine/library/framework from it's usage in another project.

Architecting solving engines: With any mathematics engine, we essentially want to put values into some function, and we expect the values that come out to be useful for making an interesting simulation.

The core elements of this process should be as abstract as possible while the atomic elements (smallest useful pieces of data/methods) should be specific to individual purposes and be useful to compose together. In our case nearly the only useful atomic is a 2D vector, which should be a single class of object which allows expression of an (x,y) structure, and has methods for all basic math operations that are useful for vector computations in 2D. Addition, subtraction, normalization, normal (perpendicular), cross product, dot product, magnitude/length, and whatever else you encounter that is specifically inherent to vector -> vector operations or vector -> real number operations. If you're using a class based language, a simple class Vector with each of these as a member function or operator overload would do very well.

After all atomic types are constructed, then you would compose their algorithms into another layer on top of our atomic type Vector. My go to's would be a Line and a Curve. We'll decide here that a Curve is out of scope for this and requires much specialization (the concept you refer to above as creating many special case functions). From Vector I would also compose a Rectangle as a 4 Vector primitive, compose Circle from vector using a Vector and a radius, and then I would compose a Polygon from Vector as well. Polygon should be made from Vector and not Line here because each line would share a duplicate point with the last line in the polygon.

Now you have shapes, but we don't know what to do with them.

Collision Detection Collision detection is not an exact science and there's not one single perfect algorithm (or any). There's many methods which can be used to achieve a variety of quality of effects or even have more accuracy than others. Basically though, it can be separated into a few different levels of concern and thus a few different processes.

Broad phase collision detection is the act of sectioning areas where we care about what might/could/does collide, and separate them for the narrow phase process. In 2D I would typically recommend using a quad tree for this. For that we'll need our Rectangle we built earlier and to provide it with a AABB collision detection. This stands for Axis Aligned Bounding Box and we'll use it to determin that for a non-rotating box A that no part of box B exists within A. It follows from the assumption that no part of B can exist within A that a collision exists if they do intersect.

A quad tree is a recursive process where you determine a maximum depth, or allow your object quantity to prevent infinite recursion depth instead. It groups physics bodies into 4 regions (hence the name) and should allow you to access each quad separately. You then would enter into each of those four quads, and perform the same process which I won't outline here for brevity but is available here: https://gamedevelopment.tutsplus.com/tutorials/quick-tip-use-quadtrees-to-detect-likely-collisions-in-2d-space--gamedev-374

Narrow phase collision is the process of going through your groups of shapes that we've already determined will/might/do collide and performing a more discrete collision check, at this point in time, we begin caring whether the objects are rotating or not (I won't cover this, when you get passed these collision phases look into detecting collision with angular momentum) and what shape their collision body actually is. To perform this part of the collision you would specialize your methods as you have described above (making specific functions for AABBvsCircle, OBBvsCircle, CirclevsCircle, PolygonvsPoint, PolygonvsCircle, PointvsCircle, etc.) However, these methods themselves can also be done in a layered manner as above. The key is to know what complexity of operations that you need at a given time to decide if you can use the most general form like the Separating Axis Theorem would be a great place to start for your narrow phase detection.

Your primitive separation checks are the discrete, specialized collision detection methods or general ones like SAT depending on use case and should all simply return either a true/false value, or return a relational object such as a Manifold, Joint, CollisionObject etc. which would have a connection with the two shapes found to be colliding, and any information about them necessary for resolving the collision, like how deep they're colliding or at what speed (what data you need in your manifold depends on what resolution method you use). That object you then pass to a Solver which should abstract away the differences between all of the different shapes that could collide, by only accepting a Manifold and not accepting any particular information about the shapes.

Summary The Solver will take the Manifold produced by colliding some primitive A with some primitive B, using first broad phase grouping (all vs world) and then narrow phase detection (A vs B) and if shapes are non-polygon must be specialized, the Solver then produces either new Vectors for the collided shapes positions and velocities, or an object which the PhysicsEnvironment or World can then use to resolve collision on it's children, then finally update the QuadTree and repeat this process on the next frame. If both colliding shapes are polygons then specialization should only be done with concerns to increased performance, otherwise simply using Separating Axis Theorem

• Great answer, thanks. I'm curious, though: I had originally considered basing my most primitive object on the point, then building a vector from there. I see from your answer that this wasn't necessarily the best choice. Why is that? Oct 17 '17 at 15:34
• The reason for that is because in 2 dimensions a vector and a point actually have the same definition. a Vector direction,Magnitude can be taken as a Point x,y if you simply ignore some of the operations the Vector provides. The best part about doing this, is just because you can ignore those operations now, when you want to determine things like angular momentum you're not changing object types. It's almost a matter of taste then, because what game developers call a "Point" mathematicians do indeed call a "Vector". So call it what you want, the important thing is what it offers. Oct 17 '17 at 15:45
• In a C style language, if I wanted to use the "Point" definition for readability in fact I would simply typedef it from a Vector, or alias the term "Point" to mean the same thing as "Vector". Oct 17 '17 at 15:46


text:
# “矛盾的證據”是否比其他證據弱？

## 最佳答案

With good reason, we mathematicians prefer a direct proof of an implication over a proof by contradiction, when such a proof is available. (all else being equal)


text:
# Page a day calendar problems

I am really new to the whole LaTeX thing, but it really interests me, so I'd like to learn more about it. I am also looking mostly to do just words, maybe a picture here and there but i just want words on the pages. I found http://blog.mattj.me/latex-page-a-day-calendar# this tutorial type thing on how to do so, I copied the LaTeX file onto the back page, and i finally got that working, a PDF with just the outline of a page-a-day sized calendar. But it is blank, the website says that the next thing needed is a Python script to run and generate the \daypages, but that doesn't make any sense to me, how will doing a python program(if i even knew how) even be inputted into LaTeX? So i guess i have 2 questions, does anyone know how to write up this python program, and how am i supposed to use it in LaTeX? thanks so much.

-
Does How to create Page-a-Day Calendar Template solve your problem? It uses datatool to read in a CSV file of dates (+ wording) and uses tikz to display the content. No Python required... – Werner Aug 30 '12 at 17:21
The website gives you the python script to use. Python is free to install on your computer as well. The python script generates a file call tex-days.tex as well, and it is automatically included in the pdf with the line \include{tex-days} – J M Aug 30 '12 at 17:28
J M, when i plug the Python script into python on my mac, it says that f is undefined. I'm not even sure what that means in the least. But that file does make sense. – Dustin Aug 30 '12 at 17:31
Werner, i'll have to attempt that, i'm not sure of exactly what you said, but i will do as much as i can to figure it out. – Dustin Aug 30 '12 at 17:32
@JM, I moved the file like you said, not it registered that file, but i am getting a different error message all together. It says, Printing TeX for year %s to %s % (sys.argv[1], sys.argv[2]) Index error: list index out of range. – Dustin Aug 31 '12 at 15:35

Steps for this to work:

1. Create the latex code, which you have compiled correctly
2. Have python, which you have done
3. Create a file called, generate_daypage.py
4. Copy the contents of the python code into generate_daypage.py
5. Type this exact command to run the python code

python generate_daypage.py 2012 tex-days.tex

6. The script will create a file called tex-days.tex, place this file in the same directory as your latex calendar code
7. Compile the latex calendar again

If you do not have any images to use right now, the line in the latex code that says:

\usepackage[final]{graphicx} change it to

\usepackage[demo]{graphicx} and it will provide a black box.

I have confirmed the entire script works and generates the pdf correctly.

-
That was an extremely well laid out answer, thank you very much. Although, when i open the terminal (im on a mac) and type python, it gives me confirmation that is understood that, i copy the exact python code onto it and it says Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'f' is not defined – Dustin Aug 31 '12 at 3:47
@Dustin you didn't follow the directions. I didn't say copy the script into the terminal. I said save it in a file called generate_daypage.py, then call python on that file. I promise if you follow those instructions exactly it will work. That error is because when you call the python file, it needs two parameters, which are in the command I gave you above. The year you want and the name of the output file. Follow the instructions EXACTLY and it will work – J M Aug 31 '12 at 13:12
I am very sorry, that was my fault. So i went into notepad, pasted that python code, and saved it as generate_daypage.py. it is now saved as a python file. I open up my Python (command line) and type in exactly what you put, and it gives me "File "<stdin>", line 1, syntax error: invalid syntax. – Dustin Aug 31 '12 at 14:09
p.s. i did switch to doing this on my pc, i wasnt sure how to save .py files on my mac, and my LaTeX file is on my PC too. – Dustin Aug 31 '12 at 14:13
@Dustin Download it here: filedropper.com/generatedaypage – J M Aug 31 '12 at 14:33


text:
# How do I solve a linear Diophantine equation with three unknowns?

Find one integer solution to the Diophantine equation
\begin{equation*}
18x+14y+63z=5.
\end{equation*}

If this were only a linear equation over $\mathbb{Z}^2$, then I could easily solve it by using the extended Euclidean algorithm… but I have no idea how to do this with more than 2 unknowns…

#### Solutions Collecting From Web of "How do I solve a linear Diophantine equation with three unknowns?"

You solve $18 u + 14 v = 2 = \gcd(18,14).$ Solve $2 w + 63 z = 1.$ Combine to get $18 x + 14 y + 63 z = 1.$ Then multiply all by $5.$

[For the following paragraphs, please refer to the figure at the end of the last paragraph (the figure is also available in PDF).]

The manipulations performed from steps (0) to (17) were designed to create the linear system of equations (0a), (5a), (11a) and (17a). The manipulations end when the absolute value of a coefficient of the latest equation added is 1 (see (17)).

Equation (0a) is given. It is possible to infer equations (5a), (11a) and (17a) from (0), (5) and (11) respectively without performing manipulations (0) to (17) directly. In every case, select the smallest absolute value coefficient, generate the next equation by replacing every coefficient with the remainder of the coefficient divided by the selected coefficient (smallest absolute value coefficient) – do the same with the right-hand constant – and add the new variable whose coefficient is the smallest absolute value coefficient. If the new equation has a greatest common divisor greater than one, divide the equation by the greatest common divisor (it may be necessary to divide this greatest common divisor from previous equations). Stop when the absolute value of a coefficient of the latest equation added is 1.
Then proceed to solve the linear systems of equations.

Hint $\ \color{#c00}{18\!-\!14}\,\mid\, 63\!+\!1$ $\, \Rightarrow\,16\,(18\!-\! 14)-63 = 1.\,$ Scale that by $\,5\,$ to finish.

Remark $\$ The idea is simply to search for a “small” linear combination $\,n = \color{#c00}{ia+jb}\,$ of two elements $\,a,b\,$ of $\,\{14,18,63\}\,$ such that the 3rd element satisfies $\ c\equiv \pm1 \pmod n,\,$ hence $\, \pm1 = c+kn = c + ki\,a + kj\,b\,$ thus scaling by $\pm n\,$ yields $n$ as a linear combination of $a,b,c.\,$ Above the first “small” number we see $\, n = \color{#c00}{18\!-\!14} = 4\,$ works since $63\equiv -1\pmod {\!4}.$

The reason for choosing $n$ “small” is that this increases the probability that $\,c\equiv \pm1\pmod{\! n},\,$ e.g. $100\%$ chance if $n = 2,\,$ $67\%$ if $n = 3.\,$ We know (by Bezout) that the smallest such $n$ is $\,\gcd(a,b)\,$ but – as we saw above – often simpler choices work such as $\,b-a.$

More algorithmically, we can use the Extended Euclidean Algorithm to compute $\rm\,gcd(63,18,14) = 1\,$ in a couple steps

$$\begin{array}{rrr} [1]&\ 63& 1& 0& 0\\ [2]&\ 18& 0& 1& 0\\ [3]&\ 14& 0& 0& 1\\ [2] -[3]\, =\, [4]& 4& \!\!0& 1& -1\\ 16[4] -[1]\, =\,[5]& 1& -1& 16& \!\!\!\!-16 \end{array}\qquad\qquad\qquad\quad$$

where the row $\ n\,\ a\,\ b\,\ c\,\ d\$ denotes that $\ n = 63a + 18 b + 14 c.\$ Thus the final row yields

$$\quad 1 = -63 +16(18) – 16(14)$$


text:
Lessons:21Length:2.7 hours
• Overview
• Transcript

# 4.1 Setting Up a Laravel Form

Creating and populating forms can be cumbersome to code. Laravel’s Form class helps you create and populate forms quickly and efficiently. This is a great help when you’re building an admin panel, for example. In this lesson we’ll look at how to set up a form, set the route for a form to post to, specify a form to use a PUT or DELETE HTTP request, and populate a form using form model binding.

Note: The Form builder class lives in vendor/laravel/framework/src/Illuminate/Html/FormBuilder.php.


text:
# pgfplotstable, multicolumn sp

I am trying to make a table (code below) that should contain three headings and five equally spaced sub columns but the one on the far right does not want to agree. If I make the really long heading on multiple lines then all is tidy but I'd rather have a nicely spaced wide table.

\documentclass[[a4paper,12pt]{article}
\usepackage{pgfplotstable}
\usepackage{booktabs}
\begin{document}
\begin{table}
\centering
\caption{Multicolumn Table}
\pgfplotstabletypeset[
every head row/.style={after row={\toprule\toprule \multicolumn{1}{c}{C} &     \multicolumn{1}{c}{B} & \multicolumn{3}{c}{A very Long Heading On One Line}\\}},
every first row/.style={after row=\midrule},
every last row/.style={after row=\bottomrule\bottomrule},
string type,
columns/0/.style={column name=},
columns/1/.style={column name=},
columns/2/.style={column name=},
columns/3/.style={column name=},
columns/4/.style={column name=},
columns/5/.style={column name=},
columns/6/.style={column name=},
col sep=comma, row sep=\\,
string type,
]{
,,d,e,f\\
1,4,2,8,1\\
5,5,5,8,6\\
2,6,4,6,2\\
3,7,5,6,5\\
9,8,3,3,3\\
7,9,1,5,1\\
7,7,4,9,2\\
6,1,3,7,7\\
2,7,1,3,8\\
7,9,5,5,7\\
9,4,6,5,7\\
Ans,,9,9,9\\
}
\end{table}

\end{document}

• When you span columns, the excess space goes into the last one. – egreg May 23 '16 at 17:52
• Is there a way to equally distribute the space? – kljadsfnzxcviasdfnk May 24 '16 at 10:28


text:
# What is the surface area of the solid created by revolving f(x) = (3x-1)^2 , x in [1,3] around the x axis?

May 28, 2018

The question seems rather odd.

#### Explanation:

The formula for computing the surface area is

$S = 2 \pi \setminus \int f \left(x\right) \setminus \sqrt{1 + {\left(f ' \left(x\right)\right)}^{2}} \mathrm{dx}$

In your case, $f \left(x\right) = {\left(3 x - 1\right)}^{2}$, which implies

$f ' \left(x\right) = 2 \left(3 x - 1\right) \setminus \cdot 3 = 6 \left(3 x - 1\right) = 18 x - 6$

Plug $f$ and $f '$ into to the formula:

$S = 2 \pi \setminus \int {\left(3 x - 1\right)}^{2} \setminus \sqrt{1 + {\left(18 x - 6\right)}^{2}} \mathrm{dx}$

This integral yields a very complicate solution, which I don't believe your homework could ever ask for. For completeness sake, you can check it from WolframAlpha


text:
# Tag Info

1

You do not follow the elementary indications given to you in comments hence it is a bit difficult to know what could help you (and the bounty is no substitute for that). Anyway, steps towards the solution could be as follows. The correct statement of the exercise involves $$Y_n = \frac{S_n/\tau_n - \lambda ... 0 An approach which requires zero knowledge about modified Bessel functions I_\nu and is valid for every nonnegative real number u is to expand the function$$\phi:t\mapsto\exp(-4u\sin^2t),$$using the identities 2-4\sin^2t=2\cos(2t)=\mathrm e^{2it}+\mathrm e^{-2it}, as$$\phi(t)=\mathrm e^{-2u}\exp(u\mathrm e^{2it})\exp(u\mathrm e^{-2it})=\mathrm ...

1

Hint: If $(X_k)_{1\leqslant k\leqslant n}$ is i.i.d. then $(Y_k)_{1\leqslant k\leqslant n}$ defined by $Y_k=X_{n+1-k}$ for every $1\leqslant k\leqslant n$ is distributed like $(X_k)_{1\leqslant k\leqslant n}$, in particular, $a_1X_1+a_2X_2+\cdots+a_nX_n$ and $a_1Y_1+a_2Y_2+\cdots+a_nY_n$ are identically distributed.

1

Hints: Since $t \mapsto e^{-k |t|^{\beta}}$ is integrable, it follows from the Riemann-Lebesgue lemma that the distribution admits a continuous density (with respect to Lebesgue measure), i.e. there exists $p_{k,\beta} \geq 0$ such that $$\int e^{\imath \, t x} p_{k,\beta}(x)\, dx = e^{-k |t|^{\beta}}. \tag{1}$$ Show that $$p_{k,\beta}(x) = k^{-d/\beta} ... 1 A compactly supported random variable has finite expectation. If \Psi_{\beta} were the characteristic function of a compactly supported random variable X, then \Psi_{\beta} would have to be differentiable at t=0 and$$E(X)=\frac{1}{i}\frac{d}{dt}\Psi_{\beta}(t) |_{t=0}\,.  But in case $0<\beta<1$, $\Psi_{\beta}$ is not differentiable at ...

Top 50 recent answers are included


text:
# Prime tower

$\Large 13^{13^{13}}$

Find the last two digits of the number given above.

Bonus: Generalize this.

×


text:
# Q: Why can’t we see the lunar landers from the Apollo missions with the Hubble (or any other) telescope?

Physicist: About why you’d expect: they’re just too damn small and too damn far away.  Nothing fancy.  That’s not to say that we can never get images, just that you need to be a lot closer.  The lunar landers are each about 4 meters across and about 384,400,000 meters away, which makes them about as hard to see as a single coin from a thousand miles away.  You gotta squint.

A picture of the Apollo 17 landing site taken by the Lunar Reconnaissance Orbiter which, as the name implies, was in orbit around the Moon when it took this presumably reconnaissance-related picture.  Those meandering lines are tracks left by a lunar rover.  Click to enlarge.

In fact, a big part of why we (humans) bother to go to the Moon, other planets, and space in general is that photographs from Earth leave a lot to be desired.  In addition to being far from everything else, here on the surface of Earth we’re stuck at the bottom of an ever-moving sea of air.  In exactly the same way that the surface of water scatters light, air makes it difficult for astronomers to practice their dread craft.

Also, not for nothing, telescopes are terrible at retrieving material samples.

The Apollo 17 landing site from even closer.

You and every telescope on Earth (and the Hubble Telescope in low Earth orbit) are all about a quarter million miles from the Moon and the landing sites thereon.  If we ever get around to building something bigger on the Moon, like mines or cities or president’s heads, then we shouldn’t have nearly as much trouble seeing it from Earth.

Answer Gravy: It turns out that the best/biggest telescopes we use today on Earth are can’t detect things the size and distance of the lunar landers using visible light.  This isn’t due to poor design; the devices we’re using now are, in a word, perfect.  They literally cannot be made appreciably better (at detecting visible light).  The roadblock is more fundamental.

The “resolving power” of a telescope, is described in terms of whether or not you can tell the difference between a pair of adjacent points.  If the two points are too close together, then you’ll see them blurred together as one point and they are “not resolved”.  If they’re far enough apart, then you see both points independently.

Whether it uses mirrors or lenses, the resolving power of every telescope is limited by some fundamental constraints determined by the wavelength of the light that’s being observed and by the size of the aperture.

Every point in every image is surrounded by a rapidly diminishing “Airy disk” which are a symptom of light being wave-like.  This is only a problem really close to the diffraction limit.  You don’t see these when you take a picture on a regular camera because these rings are smaller than the individual pixels in the camera’s CCD (by design).

Because light is a wave it experiences “diffraction” which makes it “ooze around corners” and generally end up going in the wrong directions.  But the larger a telescope’s opening, the more the light waves have a chance to interfere in such a way that they propagate in straight lines, which makes for cleaner images where the light ends up more-or-less where it’s supposed to be when it gets to the film or CCD or your retina or whatever.

It turns out that the relationship between the smallest resolvable angle, θ, the wavelength, λ, and the diameter, D, of the aperture is remarkably simple:

$\theta \approx 1.2\frac{\lambda}{D}$

Visible light has a wavelength of around 0.5 micrometers (about 2,000,000 per meter) and the largest visible-spectrum telescopes on Earth are about 10 meters across (Hubble is a more humble 2.4m across).  That means that the absolute best resolution that any of our telescopes can hope to achieve, under absolutely ideal circumstances, is about $\theta \approx 1.22\frac{0.5\times10^{-6}}{10} \approx 0.00000006 rad$.  Or, for the angle buffs out there, about 0.01 arcseconds.  This doesn’t take into account the scattering due to the atmosphere; we can do a little to combat that from the ground, but our techniques aren’t perfect.

By carefully looking at how the atmosphere distorts a laser beam shot upwards from a telescope on the ground, we can take into account how the atmosphere affects light coming into the telescope from space.

The lunar landers are a little over 4 meters across (seen from above) and are about 384,403,000 meters away.  That means that the landers subtend an angle of about 0.002 arcseconds.  In order to see this from Earth, we’d need a telescope that is, at absolute minimum, about 200 meters across.  If we wanted the image to be a more than a single pixel, then we’d need a mirror that’s a few miles across.

So, don’t expect that anytime soon.

This entry was posted in -- By the Physicist, Physics. Bookmark the permalink.

### 9 Responses to Q: Why can’t we see the lunar landers from the Apollo missions with the Hubble (or any other) telescope?

1. David says:

Good morning from the Big Island of Hawaii.

Nice post – and a question I get asked often (mostly by lunar lander hoax believers).

I work for a world class observatory (Subaru Observatory). I have one comment about your statement:

“It turns out that the best/biggest telescopes we use today on Earth are pretty close to being able to detect things the size and distance of the lunar landers. This isn’t due to poor design; the devices we’re using now are, in a word, perfect. They literally cannot be made appreciably better. ”

Subaru has, what is considered to be, the largest single piece mirror that can be practically made, at 8.2 meters (27 ft) and weighing a whopping 25 tons (try slewing that around quickly). Larger than that and the mirror properties themselves become problematic (as it is, we have servos in the mirror that correct for distortions that happen due to the weight at various angles).

So observatories such as Keck use segmented mirrors. One very large mirror made from a large number of smaller, hexagonal mirrors (they use software to remove the seams).

With such a design, there are no real limits to size (other than ability to move it).

This is why we have things coming along like TMT – a thirty meter telescope (98+ feet).

The light gathering power of a 98 ft mirror, versus our 27 ft mirror, is staggering.

Now let’s look at the Instruments. Modern telescopes are not like those of long ago, with aged scientists peering through long tubes.

Our telescopes are more like a giant tube waiting for something to happen. That is where the scientific instruments come in. We can hook various sensitive instruments to various areas (prime focus, cassegrain focus, and two nasmyth points). And these instruments can each be different (IR, Visible, spectrum, etc etc).

When an astronomer makes a proposal for viewing, not only do they tell us what target they want to view, but they specify which instruments they want to use to do the viewing.

Perhaps they are looking for exoplanets, and want a spectrograph. Or distant galaxies, so a dust busting IR detector should be involved, etc.

The instruments are constantly improving. We are deploying a new instrument right now that is magnitudes more sensitive than the one it is replacing.

And that gets us to Adaptive Optics. All the world class observatories are using Adaptive Optics for not only artificial guide stars, but also for removing atmospheric distortion (goodbye twinkle twinkle little star – no more twinkle).

We are now on our 3rd generation AO system, with the fourth being tested. Each generation is leaps and bounds better than the previous.

AO lets us take images that rival Hubble, which sits outside the atmospheric well.

So the comment “They literally cannot be made appreciably better” is vastly incorrect. They can, and are constantly being made appreciably better.

It is true that at some point, observatories on Earth will be mostly replaced by space based observatories. But at our current point the cost and practicality of such a goal remains in the future.

The good news is, things like segmented mirrors can be applied directly to space based solutions – making our new generation of telescopes a good test bed for technology that can be deployed in space.

Happy New Year!

2. Locutus says:

I’ve read that the same limitations exist in creating minimum feature sizes on computer processors. However, despite the fundamental limit being about 50 nanometers using their current wavelengths of light, they are able to decrease the size down significantly (current best in consumer technology is 14 nm). They use a process called computational photolithography. I don’t really understand the process, but it is there anything here that could enhance the resolving power of telescopes?

https://en.wikipedia.org/wiki/Photolithography#Resolution_in_projection_systems

https://en.wikipedia.org/wiki/Computational_lithography

3. David says:

Locutus:

“They use a process called computational photolithography. I don’t really understand the process, but it is there anything here that could enhance the resolving power of telescopes?”

Not unless you are looking down the wrong end of the telescope 🙂

I’m being serious in the glib answer too. Photolithography and similar techniques are extremely important in astronomy – but not perhaps where you were thinking.

These techniques are directly responsible for our constantly improving and enhanced detectors – the devices that do the actual observing.

Smaller and smaller pixels let us get more resolution and sensitivity in our light gathering area.

So yes, such techniques are very important in astronomy – though the research and end results are being carried out by companies not directly involved in astronomy (we merely reap the bounty).

4. Locutus says:

David:

So practically, what does this mean? Do we get better quality images maybe in terms of color (or less fuzz or something) without actually increasing the resolving power?

5. David says:

Locutus:

It can mean a number of things, depending on the detector. It can mean more pixels – so greater resolution packed into the same area. It can mean more sensitivity – so the ability to detect weaker photons. It can mean increased wavelength range (eg., ability to see IR better than before, etc).

As an example. I am currently part of a team redesigning one of our instruments. This version is so much more sensitive than previous versions that we are actually detecting alpha particles (radiation) from a coating on one of the lenses. Same lens, just a more sensitive detector than the previous version (since they are alpha particles, they are easy to block with a very thin sheet of glass).

Telescopes are all about light gathering. Larger mirrors mean more light. Better detectors mean more light.

6. Locutus says:

David:

Thank you. That’s very interesting.

7. Ikenna says:

Even the little mathematics you displayed here[tita is approx equal to 1.22(0.5*10^-6)approx equal to 0.00000006rads]puts me off balance talkless of the topics you discussed in the question segment which includes”how a scientist convert ideas into maths formula”.
THANKS ALOT!

8. Con says:

HA this is all rubbish. NASA hasn’t landed people on the moon but the Russians landed there in 1962 but decided to set up a nuke test site there. That’s what those Lunar Transient Phenomena are. Most of them are nuke tests on the moon. They have built their bases underground too so the orbiters can’t see them. By the way all these lander pics are fakes. All those moon rocks are fakes too.

9. David says:

Con:

As an ex-NASA scientist – I can assure you that we did land people on the moon. Multiple times.

But go ahead and believe the woo-woo if you want.


text:
# 14 Interactive dashboards with flexdashboard and Shiny

Dashboards allow to communicate large amounts of information visually and quickly, and are essential tools to support data-driven decision making. In Chapter 12 we introduced the R package flexdashboard which can be used to create dashboards that contain several related data visualizations. We also showed an example on how to build a dashboard to visualize global air pollution by means of a map, a table and a histogram.

In some situations, we may want to build dashboards that enable users to change options and see the updated results immediately. For example, we may want to build a dashboard showing results in a map and a table, and include a slider that the user can modify to filter the map areas and the table rows that contain the values in the range of values specified in the slider. We can add this functionality in a dashboard by combining flexdashboard with Shiny. Briefly, this is done by adding runtime: shiny to the YAML header of the R Markdown document, and then adding inputs that the user can modify (e.g., sliders, checkboxes), and outputs (e.g., maps, tables, plots) and reactive expressions that dynamically drive the components within the dashboard. Note that standard flexdashboards are stand-alone documents that can be easily shared with others. However, by adding Shiny to flexdashboard we create interactive documents that need to be deployed to a server to be shared broadly. Further details about how to use Shiny with flexdashboard can be seen in the flexdashboard website.

We can also create dashboards with Shiny by using the shinydashboard package . This package provides a number of color themes that make it easy to create dashboards with an attractive appearance. Information about shinydashboard can be seen on the shinydashboard website.

## 14.1 An interactive dashboard to visualize global air pollution

Here we create an interactive dashboard with flexdashboard and Shiny by modifying the dashboard we created in Chapter 12 showing global air pollution. This dashboard has a slider with the PM$$_{2.5}$$ values that the user can modify to filter the countries that he or she wants to inspect. When the slider is changed, the dashboard visualizations update and show the data corresponding to the countries that have PM$$_{2.5}$$ values in the range of values specified in the slider. A snapshot of the interactive dashboard created is shown in Figure 14.1.

To build this dashboard, we add runtime: shiny to the YAML header.

---
title: "Air pollution, PM2.5 mean annual exposure
(micrograms per cubic meter), 2016.
Source: World Bank https://data.worldbank.org"
output: flexdashboard::flex_dashboard
runtime: shiny
---

Then, we add a column on the left-hand side of the dashboard where we add the slider to filter the countries that are shown in the visualizations. In this column we add the .{sidebar} attribute to indicate that the column appears on the left and has a special background color. The default width of a {.sidebar} column is 250 pixels. Here we modify the width of this column and the other two columns of the dashboard as follows. We use {.sidebar data-width=200} for the sidebar column, {data-width=500} for the column that contains the map, and {data-width=300} for the column that contains the table and the histogram.

Column {.sidebar data-width=200}
-------------------------------------

Then, we add the slider using the sliderInput() function with inputId equal to "rangevalues" and label (text that appears next to the slider) equal to "PM2.5 values:". Then we calculate the variables minvalue and maxvalue as the minimum and maximum integers of the PM$$_{2.5}$$ values in the data. After that, we indicate that the slider minimum and maximum values (min and max) are equal to the the minimum and maximum values of the PM$$_{2.5}$$ values in the data (minvalue and maxvalue). Finally, we set value = c(minvalue, maxvalue) so initially the slider values are in the range minvalue to maxvalue.

Column {.sidebar data-width=200}
-------------------------------------

{r}
minvalue <- floor(min(map$PM2.5, na.rm = TRUE)) maxvalue <- ceiling(max(map$PM2.5, na.rm = TRUE))

sliderInput("rangevalues", label = "PM2.5 values:",
min = minvalue, max = maxvalue,
value = c(minvalue, maxvalue))

Then we modify the code that creates the map, the table and the histogram so they show the data corresponding to the countries with PM$$_{2.5}$$ values in the range of values selected in the slider. First we calculate a vector rowsinrangeslider with the indices of the rows of the map that are in the range of values specified in the slider. That is, between input$rangevalues[1] and input$rangevalues[2]. Then we use a reactive expression to create the object mapFiltered that is equal to the subset of rows of map corresponding to rowsinrangeslider.

{r}
mapFiltered <- reactive({
rowsinrangeslider <- which(map$PM2.5 >= input$rangevalues[1] &
map$PM2.5 <= input$rangevalues[2])
map[rowsinrangeslider, ]})

After that, we create the visualizations using mapFiltered() instead of map, and using render*() functions to be able to access the mapFiltered() object calculated in the reactive expression. Specifically, we enclose the map with renderLeaflet({}), the table with renderDT({}), and the histogram with renderPlot({}) so they are interactive.

Finally, to avoid the error that appears when the leaflet map is rendered with mapFiltered() that does not contain any country, we check the number of rows before rendering the map. If the number of rows of mapFiltered() is equal to 0 the execution stops returning NULL.

{r}
if(nrow(mapFiltered()) == 0){
return(NULL)
}

The complete code to build this interactive dashboard to global air pollution is shown below.

---
title: "Air pollution, PM2.5 mean annual exposure
(micrograms per cubic meter), 2016.
Source: World Bank https://data.worldbank.org"
output: flexdashboard::flex_dashboard
runtime: shiny
---

{r}
library(rnaturalearth)
library(wbstats)
library(leaflet)
library(DT)
library(ggplot2)

map <- ne_countries()
names(map)[names(map) == "iso_a3"] <- "ISO3"
names(map)[names(map) == "name"] <- "NAME"

d <- wb(indicator = "EN.ATM.PM25.MC.M3",
startdate = 2016, enddate = 2016)

map$PM2.5 <- d[match(map$ISO3, d$iso3), "value"]  Column {.sidebar data-width=200} ------------------------------------- {r} minvalue <- floor(min(map$PM2.5, na.rm = TRUE))
maxvalue <- ceiling(max(map$PM2.5, na.rm = TRUE)) sliderInput("rangevalues", label = "PM2.5 values:", min = minvalue, max = maxvalue, value = c(minvalue, maxvalue) )  Column {data-width=500} ------------------------------------- ### Map {r} pal <- colorBin( palette = "viridis", domain = map$PM2.5,
bins = seq(0, max(map$PM2.5, na.rm = TRUE) + 10, by = 10) ) map$labels <- paste0(
" Country:  ",
map$NAME, "
 ", " PM2.5:  ", map$PM2.5, "
 "
) %>%
lapply(htmltools::HTML)

mapFiltered <- reactive({
rowsinrangeslider <- which(map$PM2.5 >= input$rangevalues[1] &
map$PM2.5 <= input$rangevalues[2])
map[rowsinrangeslider, ]
})

renderLeaflet({
if (nrow(mapFiltered()) == 0) {
return(NULL)
}

leaflet(mapFiltered()) %>%
setView(lng = 0, lat = 30, zoom = 2) %>%
fillColor = ~ pal(PM2.5),
color = "white",
fillOpacity = 0.7,
label = ~labels,
highlight = highlightOptions(
color = "black",
bringToFront = TRUE
)
) %>%
pal = pal, values = ~PM2.5,
opacity = 0.7, title = "PM2.5"
)
})

Column {data-width=300}
-------------------------------------

### Table

{r}
renderDT({
DT::datatable(mapFiltered()@data[, c("ISO3", "NAME", "PM2.5")],
rownames = FALSE, options = list(pageLength = 10)
)
})

### Histogram

{r}
renderPlot({
ggplot(data = mapFiltered()@data, aes(x = PM2.5)) +
geom_histogram()
})


text:
Journal article

Model-independent search for the decay B+-> l(+)nu(l)gamma

Abstract:

We present a search for the radiative leptonic decay B+→≤+ v≤ γ, where ≤=e, μ, using a data sample of 465×106 BB̄ pairs collected by the BABAR experiment. In this analysis, we fully reconstruct the hadronic decay of one of the B mesons in Υ(4S)→B+B- decays, then search for evidence of B+→≤+ν≤γ in the rest of the event. We observe no significant evidence of signal decays and report model-independent branching fraction upper limits of B(B+→e+νeγ)<17×10-6, B(B+→μ+νμγ)<24×10-6, and B(B+→e+ν...

Publication status:
Published

Access Document

Publisher copy:
10.1103/PhysRevD.80.111105

Authors

Journal:
PHYSICAL REVIEW D
Volume:
80
Issue:
11
Publication date:
2009-12-05
DOI:
EISSN:
1550-2368
ISSN:
1550-7998
URN:
uuid:13b19270-162e-4e17-8767-ea0ca86e153a
Source identifiers:
211352
Local pid:
pubs:211352
Language:
English


text:
by

## Where communities thrive

• Join over 1.5M+ people
• Join over 100K+ communities
• Free without limits
• Create your own community
##### Activity
• Apr 21 06:21
csmith0289 commented #6
• Apr 20 22:02
Twiggled commented #6
• Apr 20 21:40
Twiggled commented #6
• Apr 20 05:51
csmith0289 commented #6
• Apr 18 01:32
Twiggled opened #6
• Feb 20 10:33
mgarland1988 commented #8
• Feb 20 00:41
YG-UK commented #8
• Feb 20 00:05
mgarland1988 commented #13
• Feb 19 23:58
mgarland1988 opened #8
• Feb 07 12:35
csmith0289 closed #5
• Feb 07 12:35
csmith0289 commented #5
• Feb 06 08:26
brunoais commented #5
• Feb 06 08:25
brunoais commented #5
• Nov 21 2019 13:04
brunoAlmeida-sky opened #17
• Jan 21 2019 22:21
csmith0289 edited #5
• Jan 21 2019 19:21
csmith0289 edited #5
• Jan 21 2019 19:21
csmith0289 opened #5
• Jan 20 2019 09:57
csmith0289 closed #4
• Jan 20 2019 09:57
csmith0289 commented #4
• Jan 20 2019 09:49
csmith0289 opened #4
john01925
@john01925
Sorry that's not particularly legible
var SkyPlusHD = require('../..');

var findABox = SkyPlusHD.findBox(process.argv[2] || undefined);

findABox.then(function(box) {
console.log();
console.log("Found a SkyPlusHD box!");
console.log("        IP:",box.ip);

box.channelList.init().then(function() {
box.setChannel(101).then(function() {
process.exit(0);
});
});
});

findABox.catch(function(err) {
console.log("Failed to find SkyPlusHD box",err);
});
This message was deleted
the error is :

C:\SKYHD\sky-plus-hd-1-dev\tools\monitor>node 101.js
Unhandled rejection TypeError: Cannot read property 'init' of undefined
at C:\SKYHD\sky-plus-hd-1-dev\tools\monitor\101.js:10:16
at tryCatcher (C:\SKYHD\sky-plus-hd-1-dev\node_modules\bluebird\js\main\util
.js:26:23)
at Promise._settlePromiseFromHandler (C:\SKYHD\sky-plus-hd-1-dev\node_module
s\bluebird\js\main\promise.js:489:31)
at Promise._settlePromiseAt (C:\SKYHD\sky-plus-hd-1-dev\node_modules\bluebir
d\js\main\promise.js:565:18)
at Async._drainQueue (C:\SKYHD\sky-plus-hd-1-dev\node_modules\bluebird\js\ma
in\async.js:128:12)
at Async._drainQueues (C:\SKYHD\sky-plus-hd-1-dev\node_modules\bluebird\js\m
ain\async.js:133:10)
at Immediate.Async.drainQueues [as _onImmediate] (C:\SKYHD\sky-plus-hd-1-dev
\node_modules\bluebird\js\main\async.js:15:14)
at processImmediate [as _immediateCallback] (timers.js:358:17)
Dal Hundal
@dalhundal
It's complaining because you're calling box.channelList.init() and box.channelList is undefined. So it seems like you're not using the latest code. Did you do a git pull on the v1-dev branch to get the latest stuff?
I made changes in the last few days so the stuff you checked out before is not up to date
Dal Hundal
@dalhundal
John - I assume the pull request you just sent me is in error??!
john01925
@john01925
yes sorry :(
Dal Hundal
@dalhundal
No prob - I just closed it :-)
john01925
@john01925

OMG Dal its only gone amd worked my friend!
AWESOME Amigo !

Guess what, I'm also a total nube at Git so had to do a quick crash course :smile:
It still seemed to pull down the wrong code with :
git clone https://github.com/dalhundal/sky-plus-hd.git c:/JRSKY01

BTW I often see this error and can't repeat the script for a while.

C:\SKYJR002\tools\monitor>node 101
Failed to find SkyPlusHD box [Error: Timeout searching for service urn:schemas-n
ds-com:service:SkyRC:2]
Unhandled rejection Error: Timeout searching for service urn:schemas-nds-com:ser
vice:SkyRC:2
at null._onTimeout (C:\SKYJR002\lib\sky-plus-hd_finder.js:56:12)
at Timer.listOnTimeout (timers.js:110:15)

Would extending the timeout somewhere help with that?

Dal Hundal
@dalhundal
I'll have to check it out - can't remember where I'm setting the timeout. generally speaking though the timeout is probably a decent value. The examples I've given aren't really geared up to quickly connect, run a command and then exit. They're more aimed at connecting to the box, staying connected and then waiting for commands.
That said, its not undo-able for it to quickly connect and run a command then exit - its just not the focus of what I've been doing
john01925
@john01925
Well its great anyway :clap: Hopefully I can use this to change channel and control the box with my Homeseer 3 setup. Just need to do some reading.
john01925
@john01925
They're more aimed at connecting to the box, staying connected and then waiting for commands.
Can it be accessed and used like this now Dal?
Just wondering which script it is that does that...
Dal Hundal
@dalhundal
^ the tools/cli example does that, though probably not in the way that you want. It waits for commands to be typed into the shell. The mqtt example I was going through with Lee above waits for commands to be published using the MQTT protocol. You could do something similar for any interface - accept commands by HTTP requests / running a script / pressing a button / twitter.
Lee Collings
@leecollings
Hey Dal, I don't suppose there's any news on my situation? I appreciate it's probably going to start getting quite difficult for you, with two different issues going on here.
Dal Hundal
@dalhundal
Hi lee - no nothing yet - I haven't really had the time to spend on this. That said, I can see that it's probably useful if I put something solid together that addresses both of your issues. Essentially, you're both after the same thing - some sort of interface to quickly send a command to the box and exit - which means having some sort of service running in the background that has previously connected to the box and kept the connection open. I could start doing that next to tide some people over, though the core code doesn't even deal with things like losing connection to the box yet so it'll be quite bodgy. Loose connection to the box? Need to manually restart the service. All of this is doable, its just a question of getting around to it and priorities.
Lee Collings
@leecollings
Do you reckon that would have be something custom written then? Or would this still being use node.JS and the forever service?
Dal Hundal
@dalhundal
It's all doable using nodejs, and whatever method you fancy of keeping it running in the background - forever is just one way. F
For what it's worth, I don't think it's worth you posting that around because like I said the problem isn't with forever. Code 0 just means our script exited without an error. (In Linux, non zero codes indicate an error, 0 means all good). But that doesn't mean there wasn't a problem because our script mqtt.js is just thrown together with no attention at all to trying to report errors. It's fixable, but it's not what I'm doing right now
If I get time I'll make it work on my Pi and post the results
Lee Collings
@leecollings
Hey Dal, any update yet?
Dal Hundal
@dalhundal
Nope - I'm not focusing on the mqtt stuff
waternexus
@waternexus
Any news on what's happening?
Dal Hundal
@dalhundal
Yep - I don't have time to work on it at the moment :-(
Feel free to pitch in though :-)
Dal Hundal
@dalhundal
Hey all - I have two new simpler modules up on github / npm which should cover many of your use cases.
http://github.com/dalhundal/sky-remote - sends remote control commands to a sky box (the same as the buttons on the remote control - including power). Just needs the IP of the box you want to control, and is fast.
http://github.com/dalhundal/sky-remote-cli - a command line interface to the above - great to use on the command line / from other scripts etc. As simple as calling "sky-remote-cli 192.168.0.40 pause"
Should cover alot of what people want without the complexity of the the sky-plus-hd module (though I still intend to develop that)
@leecollings @waternexus @john01925 - hope that comes in handy
Negan99
@Negan99
Excellent work Dal & much appreciated as I could never get the previous module to work correctly.
I have 2 questions
1) Is there any way to check to see whether the Sky box is in standby or if it's turned on? This would prevent me from turning it off by accident.
2) If not then is the code that you have shown for the Sky button correct? If I press that on my remote & the box is in standby it turns on but using it from the CLI it doesn't. When I checked in the js file you show both the TV & Sky buttons as having code 127 which doesn't see right.
john01925
@john01925
Wow that is fantastic, great work. I too had given up with the old version but this is brilliant :smile:
Dal Hundal
@dalhundal

Hey @Negan99

1) No, this module can't tell you whether the box is on or not - it's very much a one way street - you can send commands to the box but there is no feedback at all from the box about its status or whether it could perform the command. All you can tell is whether you managed to send the command or not. Its pretty much like a real life Sky remote control in that respect. To know whether the box is on or not, would need to do some stuff the other module was doing I suspect (they are completely different in how the communicate with the box)

2) I'm not sure about the Sky button, to be honest I'm not sure if I tried using it. The TV button shouldn't be in the code at all - I need to remove it. If you think about it, your sky box cannot control your TV - which is why there are no codes for volume buttons either.

@john01925 :-)
john01925
@john01925
Yep the SKY button doesn't seem to work. The SKY button normally always switches the box ON or returns to normal from a within any sub menu. Everything else however looks good.
Negan99
@Negan99
Out of interest where did the codes come from? Would it be a case of trial & error if we were to look for a different code should the Sky button prove to be incorrect?
john01925
@john01925
Think I found it. 241 works on my box. If you replace the 'sky: 127,' with 'sky: 241,' in sky-remote.js you get the correct operation of the Sky button. That means you can power ON from standby and return to normal viewing from all sub menus.
john01925
@john01925
On my Windows 7 PC that file is in C:\Users...\AppData\Roaming\npm\node_modules\sky-remote-cli\node_modules\sky-remote\sky-remote.js '...' = Your user directory
Negan99
@Negan99
The file is at /usr/local/lib/node_modules/sky-remote-cli/node_modules/sky-remote on my Linux box but I found something interesting.f I press the Sky button on the remote & the TV is turned off, the Sky box powering up also turns the TV on. If I use code 241 then it doesn't (but the Sky box does come out of standby) so maybe there still is another code
did you just use trial & error to find that code John or did you discover it elsewhere?
john01925
@john01925
Hi Negan99 - I just trial and error'ed it I'm afraid. I just counted down from 255 as I assumed it was between 255 and 127. Your TV powering up I assume is something to do with control over HDMI and happens on purpose right? Mine doesn't do that, probably because there are a number of HDMI switchers in the way.
Negan99
@Negan99
Looks like I have a project for tomorrow morning then :)
Only one of my TVs does it but it is cool that everything (soundbar included) all comes on at the same time. I proposed the change to the code
Dal Hundal
@dalhundal
I'll make the modification in a bit...
Dal Hundal
@dalhundal
Hey - I just checked on mine too. With the box + tv on standby, pressing 'SKY' turns on the box, but not the TV. I don't have any switches between them or anything like that - its a straightforward connection.
HDMI devices can control one another if they both support the HMDI CEC protocol. Some manufacturers give it other names - eg my Samsung TV calls it AnyNet, and it seems SKY call it "one touch play". Not all boxes support it - I have a DRX780 which is one that doesn't support it. I have another box which I don't have plugged in which should support it.
Dal Hundal
@dalhundal
"One-Touch-Play isn’t available on Sky+HD box models Samsung HD, Samsung 500, Pace and DRX780. "
So @john01925, I'm guessing either 1) you have one of the boxes that don't support one-touch-play 2) your TV doesn't support hdmi cec