text:
Home > CFA Level 1 > Price, income, and cross elasticities of demand

# Price, income, and cross elasticities of demand

As the price of a good rises, its demand falls. This fundamental observation is called the law of demand. A demand function for a good is an equation that links demand with its determinants, i.e. the product’s price (called own price), price of substitutes/complements, consumer income, etc. The positive (negative) signs of different factors represent their direct (indirect) relationship with demand.

If we hold all factors other than own price constant, we arrive at a demand function (of the form Q = Constant – m × P) which shows the relationship between quantity demanded and the product’s own price. If the demand function is expressed such that price is the dependent variable and quantity is independent, it is called an inverse demand function (of the form P = C/m – (1/m) × D) and it helps in graphing a demand curve, which plots price on y-axis and quantity on the x-axis.

## Own-price elasticity of demand

Own-price elasticity of demand measures the sensitivity of quantity demanded of a product to a change in its own-price. It equals the percentage change in quantity divided by the percentage change in price:

$Own Price Elasticity = \frac{∆Q}{Q}÷\frac{∆P}{P} = \frac{∆Q}{∆P}×\frac{P}{Q}$

Where ∆Q/∆P is the slope of the demand function. It shows that elasticity depends on the slope of the demand function and the ratio of price P to quantity.

An elasticity of -n means that a 1% increase in price results in an n percent decrease in demand. Demand is elastic if, in absolute terms, price elasticity is greater than 1, unit elastic when it is equal to 1, and inelastic if it is less than 1.

### Elasticity of demand and demand curve

The elasticity of a product does not remain constant but changes as we move along the demand curve. It is because it depends not only on the slope of the demand curve but on the ratio of P/Q. Higher P/Q means elasticity is high, hence elasticity should be high on the curve close to the y-axis, and vice versa.

### Perfectly elastic and perfectly inelastic demand

Own-price elasticity of demand is constant only if it is either perfectly inelastic or perfectly elastic. Demand is perfectly inelastic if the demand curve is vertical, the own-price elasticity of demand is zero. Demand is perfectly elastic if the demand curve is horizontal and own-price elasticity of demand is infinite, for example in perfect competition.

### Determinants of price elasticity of demand

A product’s own-price elasticity of demand depends on:

• Existence of substitutes: if a product has more substitutes, its elasticity is high, and vice versa.
• Portion of the budget spent on the product: if the highest budget is spent, elasticity is high.
• Time allowed to respond to price change: low time means lower elasticity.
• Extent to which it is treated as necessary: necessities have low elasticity.

The elasticity of a product is higher over the long run, but it is opposite in case of durable goods.

When demand is elastic, change in price and change in total expenditure are opposite but if it is inelastic, they move in the same direction. Expenditure is maximum at the midpoint of the demand curve. This applies to all types of demand (individual vs market, etc.) curves and producers too.

## Income elasticity of demand

Income elasticity of demand refers to the percentage change in quantity demanded in response to a percentage change in income.

$Income Elasticity=\frac{∆Q}{Q}÷\frac{∆I}{I}=\frac{∆Q}{∆I}×\frac{I}{Q}$

While own-price elasticity of demand is typically negative and hence sign is generally ignored, the sign of income elasticity of demand matters. When the sign is positive (negative), it means that that the quantity demanded of the good increases (decreases) with an increase in income, and hence the good is a normal (inferior) good. In case of normal (inferior) good, an increase in income shifts demand outwards (inwards).

## Cross elasticity of demand

Cross elasticity of demand measures the sensitivity of quantity demanded of a good (say X) to change in the price of another good (say Y). A positive (negative) cross elasticity means that the products are substitutes (complements).

Substitutes are goods that can be replaced with each other, hence when the price of once increases, the quantity demanded of the other increases (because people move to the other good) and hence cross elasticity is positive.

Complements are goods which are consumed together, say car and gasoline, hence when the price of one good increases, the quantity demanded of the other good falls and hence it has negative cross elasticity of demand.

$Cross Elasticity=\frac{∆Q_x}{Q_x} ÷ \frac{∆P_y}{P_y} = \frac{∆Q_x}{∆P_y}×\frac{P_y}{Q_x}$

Own-price, income, and cross-elasticities can be calculated from demand function. If demand function is the form Q = M – a × Px + b × I − c × Py, the coefficient a, b and c represent the relevant differentials in each elasticity equation.

## Test

In case of a downward sloping demand curve, own-price elasticity of demand of a product:

1. is constant unless there is a change in income level, consumer preferences, etc.
2. is the highest close to the y-axis and the lowest close to the x-axis.
3. is a positive number.

format: plain


text:
DWI denoising¶

MRtrix includes the command dwidenoise, which implements dMRI noise level estimation and denoising based on random matrix theory. The method exploits data redundancy in the patch-level PCA domain ([Veraart2016a], [Veraart2016b] and [CorderoGrande2019]). The method uses the prior knowledge that the eigenspectrum of random covariance matrices is described by the universal Marchenko-Pastur (MP) distribution.

Patch size¶

The noise level in MRI is spatially varying, due to the proximity of the coil elements and parallel imaging. Noise level estimation and denoising therefore operates in image patches around each voxel, where the noise can be assumed to be approximately homoscedastic. The patch size can be chosen by the user with the option -extent. For maximal SNR gain (when using Exp2, see below) we suggest to choose $$N \approx M$$, where $$M$$ is the no. DW volumes and $$N$$ is the number of kernel elements. However, larger kernels also extend the required run time, so in large datasets it might be beneficial to select smaller sliding kernels. By default, the command will select the smallest isotropic patch size that exceeds the number of DW images in the input data, e.g., 5x5x5 for data with <= 125 DWI volumes, 7x7x7 for data with <= 343 DWI volumes, etc.

Noise level estimation¶

The noise level in each patch is experimentally estimated from the eigenvalue spectrum of the local data matrix. Assuming $$M<N$$, $$P$$ signal-carying components (also estimated), and $$M-P$$ noise components, the squared noise level is estimated as:

$\sigma^2 = \frac{\lambda_{P+1}-\lambda_M}{4\sqrt{\gamma}}$

where $$\lambda_i$$ are the eigenvalues of the covaliance matrix, sorted in decreasing order, and $$\gamma$$ is the matrix ratio.

dwidenoise implements two different versions of this estimator, based on a different definition of the matrix ratio $$\gamma$$:

• Exp1 uses the definition used in the original papers [Veraart2016a] and [Veraart2016b], namely $$\gamma = (M-P)/N$$.
• Exp2 uses $$\gamma = (M-P)/(N-P)$$ instead, which was shown in [CorderoGrande2019] to improve the estimation. This is now the default.

Complex data¶

Note that dwidenoise does not correct for non-Gaussian noise biases present in magnitude-reconstructed MRI images. Including MRI phase images can reduce such Rician bias [CorderoGrande2019], and the command now supports complex input data. To this end, users can run:


text:
Enter the system voltage (volts) and the system power (amps) into the Heat Strip Size Calculator. The calculator will evaluate the Heat Strip Size.

Heat Strip Size Formula

The following two example problems outline the steps and information needed to calculate the Heat Strip Size.

HSS = V * A / 1000* 3413

Variables:

• HSS is the Heat Strip Size (BTU)
• V is the system voltage (volts)
• A is the system power (amps)

To calculate the heat strip size, multiply the voltage by the power, divide by 1000, then multiply by 3413 to convert into BTUs.

How to Calculate Heat Strip Size?

The following steps outline how to calculate the Heat Strip Size.

1. First, determine the system voltage (volts).
2. Next, determine the system power (amps).
3. Next, gather the formula from above = HSS = V * A / 100 0* 3413.
4. Finally, calculate the Heat Strip Size.
5. After inserting the variables and calculating the result, check your answer with the calculator above.

Example Problem :

Use the following variables as an example problem to test your knowledge.

system voltage (volts) = 10

system power (amps) = 40

HSS = V * A / 100 0* 3413 = ?


text:
Search:

# The reduction of iron oxide

## The blast furnace

At high temperature, the oxygen of the air reacts with the coke (impure carbon) to produce carbon monoxide (a colourless and toxic gas): $2C$ $+$ $O_2$ $\longrightarrow$ $2CO$ The carbon monoxide reduces iron oxide to iron: $Fe_2O_3$ $+$ $3CO$ $\longrightarrow$ $2Fe$ $+$ $3 CO_2$ The molten iron (cast iron = impure iron) comes together at the bottom of the blast furnace. The liquid blast furnace slag consists of the impurities of the iron ore and the coke. It floats on top of the liquid iron.


text:
How can the Airy's equation $y'' - xy = 0$ be used to model diffraction of light?

Differential Equations with Boundary-Value Problems by Dennis G. Zill, Michael R. Cullen states that the equation is used to model diffraction of light. It doesn't explain how, it just goes on to solve it using a series solution.

Has anyone any idea how it is used or has any references? Or if anyone knows any other applications of this equation then that would be interesting also :)

• A survey of other physical applications of Airy equation can be found at: dlmf.nist.gov/9.16 :) – shamisen Nov 19 '17 at 17:54


text:
## Re: Parabola, ellipses, or hyperbolas help!

Originally Posted by topsquark
I'm going to slip this in here: It is better to give exact values rather than use decimals.

ie. $\displaystyle ( 0, ~ -1 + \sqrt{3} ); ( 0, -1 - \sqrt{3} )$
Lets repeat that use exact values rather than use decimals ! You have told that before.


text:
# American Institute of Mathematical Sciences

ISSN:
1937-1632

eISSN:
1937-1179

All Issues

## Discrete & Continuous Dynamical Systems - S

February 2015 , Volume 8 , Issue 1

Issue on numerical methods based on homogenization and two-scale convergence

Select all articles

Export/Reference:

2015, 8(1): i-vi doi: 10.3934/dcdss.2015.8.1i +[Abstract](3140) +[PDF](333.4KB)
Abstract:
In this note, a classification of Homogenization-Based Numerical Methods and (in particular) of Numerical Methods that are based on the Two-Scale Convergence is done. In this classification stand: Direct Homogenization-Based Numerical Methods; H-Measure-Based Numerical Methods; Two-Scale Numerical Methods and TSAPS: Two-Scale Asymptotic Preserving Schemes.
2015, 8(1): 1-27 doi: 10.3934/dcdss.2015.8.1 +[Abstract](2489) +[PDF](734.3KB)
Abstract:
We consider a nonlinear convex stochastic homogenization problem, in a stationary setting. In practice, the deterministic homogenized energy density is approximated by a random apparent energy density, obtained by solving the corrector problem on a truncated domain.
We show that the technique of antithetic variables can be used to reduce the variance of the computed quantities, and thereby decrease the computational cost at equal accuracy. This leads to an efficient approach for approximating expectations of the apparent homogenized energy density and of related quantities.
The efficiency of the approach is numerically illustrated on several test cases. Some elements of analysis are also provided.
2015, 8(1): 29-44 doi: 10.3934/dcdss.2015.8.29 +[Abstract](2269) +[PDF](2720.1KB)
Abstract:
Averaging coefficient in a second order elliptic equation is a well known and important model problem. Additional to non-periodic rapid oscillations, the coefficient may contain barriers and channels - long and narrow bodies with low or high values of the coefficient. When the length of such structures is comparable with the problem size - there is no scale separation.
In this article we consider coefficients with barriers. We show how the averaged coefficient may be inadequate near the barriers and propose a generalization which can detect the potential problems and improve the accuracy of the averaged solution.
2015, 8(1): 45-54 doi: 10.3934/dcdss.2015.8.45 +[Abstract](2905) +[PDF](1226.5KB)
Abstract:
This paper is in the continuity of a work program, initiated in Frénod & Goubert [4], Frénod & Rousseau [5] and Bernard, Frénod & Rousseau [2]. Its goal is to develop an approach of the paralic confinement usable from the modeling slant, before implementing it in numerical tools.
More specifically, we here deal with the multiscale aspect of the confinement. If a paralic environment is separated into two (or more) connected areas, we will show that is possible to split the confinement problem into two related problems, one for each area. At the end of this paper, we will focus on the importance of the interface length between the two subdomains.
2015, 8(1): 55-76 doi: 10.3934/dcdss.2015.8.55 +[Abstract](2100) +[PDF](490.4KB)
Abstract:
In the repository, multi-physics processes are induced due to the long-time heat-emitting from the nuclear waste, which is modeled as a nonlinear system with oscillating coefficients. In this paper we first derive the homogenized system for the thermal-hydro-mass transfer processes by the technique of two-scale convergence, then present some error estimates for the first order expansions.
2015, 8(1): 77-90 doi: 10.3934/dcdss.2015.8.77 +[Abstract](1960) +[PDF](207.7KB)
Abstract:
This paper introduces a new tool so called Multi-scales H-measures to analyse the effect of heterogeneities occurring at several scales. In a first place, it recalls the course that brought the introduction of new tools for homogenization and it recalls what are H-Measures. Then the paper gives the definition and the framework of Semi-Classical Measures, presents their capability, and illustrates some of their limitations. Finally, it introduces the concept of Multi-Scale H-measures.
2015, 8(1): 91-118 doi: 10.3934/dcdss.2015.8.91 +[Abstract](3297) +[PDF](2311.7KB)
Abstract:
The reduced basis finite element heterogeneous multiscale method (RB-FE-HMM) for a class of nonlinear homogenization elliptic problems of nonmonotone type is introduced. In this approach, the solutions of the micro problems needed to estimate the macroscopic data of the homogenized problem are selected by a greedy algorithm and computed in an offline stage. It is shown that the use of reduced basis (RB) for nonlinear numerical homogenization reduces considerably the computational cost of the finite element heterogeneous multiscale method (FE-HMM). As the precomputed microscopic functions depend nonlinearly on the macroscopic solution, we introduce a new a posteriori error estimator for the greedy algorithm that guarantees the convergence of the online Newton method. A priori error estimates and uniqueness of the numerical solution are also established. Numerical experiments illustrate the efficiency of the proposed method.
2015, 8(1): 119-150 doi: 10.3934/dcdss.2015.8.119 +[Abstract](2748) +[PDF](1889.8KB)
Abstract:
In this work we introduce and analyse a new adaptive Petrov-Galerkin heterogeneous multiscale finite element method (HMM) for monotone elliptic operators with rapid oscillations. In a general heterogeneous setting we prove convergence of the HMM approximations to the solution of a macroscopic limit equation. The major new contribution of this work is an a-posteriori error estimate for the $L^2$-error between the HMM approximation and the solution of the macroscopic limit equation. The a posteriori error estimate is obtained in a general heterogeneous setting with scale separation without assuming periodicity or stochastic ergodicity. The applicability of the method and the usage of the a posteriori error estimate for adaptive local mesh refinement is demonstrated in numerical experiments. The experimental results underline the applicability of the a posteriori error estimate in non-periodic homogenization settings.
2015, 8(1): 151-168 doi: 10.3934/dcdss.2015.8.151 +[Abstract](3238) +[PDF](2811.4KB)
Abstract:
In this paper we consider the model built in [3] for short term dynamics of dunes in tidal area. We construct a Two-Scale Numerical Method based on the fact that the solution of the equation which has oscillations Two-Scale converges to the solution of a well-posed problem. This numerical method uses on Fourier series.
2015, 8(1): 169-183 doi: 10.3934/dcdss.2015.8.169 +[Abstract](3088) +[PDF](667.3KB)
Abstract:
In the framework of a Particle-In-Cell scheme for some 1D Vlasov-Poisson system depending on a small parameter, we propose a time-stepping method which is numerically uniformly accurate when the parameter goes to zero. Based on an exponential time differencing approach, the scheme is able to use large time steps with respect to the typical size of the fast oscillations of the solution.
2015, 8(1): 185-221 doi: 10.3934/dcdss.2015.8.185 +[Abstract](2227) +[PDF](740.9KB)
Abstract:
We study a Lie Transform method for a charged beam under the action of a radial external electric field. The aim of the Lie transform method that is used here is to construct a change of variable which transforms the 2D kinetic problem into a 1D problem. This reduces the dimensionality of the problem and make it easier to solve numerically. After applying the Lie transform method, we truncate the expression of the characteristics of the Vlasov equation and the expression of the Poisson equation in the Lie coordinate system and we develop a numerical method for solving the truncated model and we study its efficiency for the simulation of long time beam evolution.
2015, 8(1): 223-241 doi: 10.3934/dcdss.2015.8.223 +[Abstract](3072) +[PDF](433.2KB)
Abstract:
We develop and we explain the two-scale convergence in the covariant formalism, i.e. using differential forms on a Riemannian manifold. For that purpose, we consider two manifolds $M$ and $Y$, the first one contains the positions and the second one the oscillations. We establish some convergence results working on geodesics on a manifold. Then, we apply this framework on examples.

2020 Impact Factor: 2.425
5 Year Impact Factor: 1.490
2020 CiteScore: 3.1


text:
(Granger) Causality

Granger (1969) proposed a concept of causality based upon prediction error: X is said to Granger-cause Y if Y can be forecast better using past Y and past X than just past Y. This is a seemingly minor criterion, which, as stated, really only tells us we can use a more restricted model for forecasting Y. However, Sims (1972) demonstrated that this was equivalent to a much more important criterion: that Xfails to Granger-causeY if and only if Y is econometrically exogenous in an X on Y dynamic regression. With the help of this result, the "Granger-" in Granger-cause has now largely been eliminated so that "cause" on its own now means Granger-cause, and an exogeneity test typically refers to a test for absence of causality (in the proper context).

There have been several tests proposed for Granger causality in addition to the obvious test of lags of X in a regression of Y on lags of X and Y (the "Granger" test). The "Sims test" is a direct test of the result in the Sims paper: regress X on lags, current and leads of Y and test the leads of Y. However, this is rarely used because it was found to reject non-causality too often (that is, the size of the test was wrong). There is also the Pierce-Haugh test which looks at cross-correlations between pre-whitened residuals, which was rather quickly eliminated from consideration for the opposite reason: it had very low power (in addition, it required an extra step of fitting ARIMA models to each of the series). A fourth test was proposed in Geweke, Meese and Dent(1982) which aimed to correct the problems with the direct Sims test by also including lags of X in the regression (thus X on lags of X, lags, current and leads of Y and test the leads of Y). This was rarely employed as it (apparently) had no real advantage over the simpler Granger test. However, it turns out to have some real statistical value despite that.

See causal.rpf for an example of the different forms of tests.

Causality with Three or More Variables

The Granger criterion can be (and often is) applied to one variable in a set of three or more variables. However, it turns out that that exclusion test has little actual meaning (beyond the possibility of simplifying the Y equation in the system). If Z fails to Granger-cause Y in a three variable system with X, Y and Z (that is, you fail to reject when testing for zeros on lagged Z's in a regression of Y on lagged Y's, X's, and Z's), there is nothing preventing Z from helping to predict Y at steps two or later if Z "Granger-causes" X instead. In other words, the "causality" or lack of it refers to an very narrow criterion that says little about the relationship among the variables. On the other hand, if Z fails to Granger-cause both X and Y, or, both Z and X fail to Granger-cause Y, then there is no route for Z to help forecast Y at any step. In both of those cases, you have a multivariate extension of the Sims(1972) result—in the first case, X and Y form an exogenous block (relative to Z) and in the second Y is exogenous relative to the block of X and Z.

See varcause.rpf for an example.

Causality with Series with Unit Roots

Sims, Stock and Watson(1990) analyzed the behavior of hypothesis tests in linear regressions in the presence of unit roots in some or all of the variables. Their results show that most hypotheses have "standard" asymptotics, that is, the usual use of t (for single coefficients) and F or chi-squared for joint tests are justified asymptotically. However, one very important exception to this is the Granger test—excluding all lags on a non-stationary regressor produces a non-standard asymptotic distribution. Not only is it non-standard, but it's effectively impossible to analyze in any meaningful way because it depends upon the behavior of the entire system. In practice, however, it's not so different from the standard distribution that an overwhelming rejection of the zero restriction would be overturned if this were taken into account. See varcause.rpf for an example of a test which is way out in the tails.

One possible way to handle this is to bootstrap the Granger test. See grangerbootstrap.rpf for an example of that. You can also use the Geweke-Meese-Dent(1982) variation of the Sims test which is included in causal.rpf. That avoids the non-standard asymptotics by testing only a subset of the lag/leads of a variable. (Note that the GMD test reverses the dependent variable from the Granger test—to test x causing y, you regress x on lagged x, and lagged, current and leads of y and test the leads of y).

Also, if you're willing to assume that each of the series has a unit root, but there is no cointegration among the variables in the system, then you can run the test on differenced data. (The VAR in differences is misspecified in the presence of cointegration, but not if each series has a separate unit root).

Note, by the way, that it's quite possible that you will do the test "carefully" and get almost the identical result—the effect of the unit roots on the test is unknown and could, in fact, be fairly minor.

One "non-fix" to this is from Toda-Yamamoto(1995). Despite there being quite a few usages of this in the literature, it is simply bad statistics. In short, it tests for causality by adding an "extra" lag to a VAR and then tests zero restrictions which don't include those added lags. This does provide a test which (under the null) will have the correct asymptotic distribution since it doesn't test all the lags of the non-stationary variable. However, it's not a test of Granger causality (which requires testing all lags). By adding extra lags and then not testing them, the bad behavior is shifted onto the untested lags. It will suffer badly from lack of power since, if the coefficients aren't, in fact, zero, the "causality" will get shifted fairly easily to the untested lag(s) since an integrated process is so highly autocorrelated. An even worse idea which has come up in the literature is bootstrapping the TY test. The only "good" feature of the TY test relative to the actual Granger test is that it has standard asymptotics. If one is bootstrapping, one should bootstrap the actual test (as in grangerbootstrap.rpf) and not a bad alternative.

Short- and Long-Run Causality

If (x,y) is a stationary process, then the effect of any shock to the system will eventually die out. If x causes y, then x(t)'s ability to help forecast y(t+h) for large values of h is effectively zero. (In fact, even y(t) itself doesn't really help forecast y(t+h)). In this case, any causality will, of necessity be short-run causality.

By contrast, if (x,y) are (both) non-stationary, in general, (almost) any shock to the system will have permanent effects. (The Blanchard-Quah calculation comes up with a single shock shape which converges to zero in the long-run—all other shocks have permanent effects). If x Granger causes y, the x(t) will help forecast y(t+h) at any h, no matter how large. This can be considered long-run causality.

However, if (x,y) are non-stationary, but cointegrated, it's possible to have only short-run causality. If we write the equation for y in error correction form:

$$\Delta y = \alpha \left( {{y_{t - 1}} - \beta {x_{t - 1}}} \right) + {\zeta _{y1}}\Delta {y_{t - 1}} + \ldots + {\zeta _{yp}}\Delta {y_{t - p}} + {\zeta _{x1}}\Delta {x_{t - 1}} + \ldots + {\zeta _{xp}}\Delta {x_{t - p}} + {\varepsilon _{yt}}$$

then x enters in two places: the loading α on the cointegrating vector (if β were zero, the two series wouldn't be cointegrated in the first place), and the ζ coefficients on its lagged differences. A test for causality would be a joint test that all those coefficients are zero—if you reject that, you would conclude that there is causality from x to y. There's a separate test for long-run causality by looking solely at α. If α=0, the ability of x to help predict y dies off with increasing horizon. If α=0, y is said to be weakly exogenous. A more complete term for that would be weakly exogenous for β—the y equation provides no information about β as all the adjustment to keep y and βx close to each other comes from adjusting x.

Note that some papers have done a test just on the lagged differences of x and called it a test for short-run causality. That gets the null and alternative confused. "Short-run causality" is shorthand for "causality but not long-run causality." The proper procedure is to do a joint test, and then, if you conclude that there is causality, test $$\alpha=0$$ to see if there's long-run causality. (You might want to do the long-run test regardless of the outcome of the overall test, since the power of the test might be diluted if you have a large number of lagged differences). You could also test $$\alpha=0$$ first, and if you conclude that there's no long-run causality, test the lagged differences imposing $$\alpha=0$$ (that is, run the regression without the error correction term). However, a test on the lagged differences without either jointly testing and imposing $$\alpha=0$$ has no useful interpretation.

Note that, because everything in this equation is stationary, you can use standard testing techniques. An example is provided in vecmcause.rpf.

Causality in VAR-GARCH Models

If you have a GARCH model (or any other non-linear model) which has a mean model that takes the form of a VAR or VECM, you can test for causality (in the mean!) using a Wald test. Note that it's possible for there to be causality in the variance (that is, "other" lagged residuals affect the variance) without having causality in the mean. The issues about testing causality in 3 or more systems apply here—you can't really conclude much from knocking out the lags of just one variable in one equation in a 3 variable or larger system. However, if it's bivariate, or if you are excluding a full block from a larger system as described above, the same basic interpretation applies even though you have a GARCH model for the variance.

It's easiest to set this up using Regression Tests, Exclusion Restrictions test wizard. See vecmgarch.rpf for an example (it's for short-and-long-run causality, but it's the same idea even if it's a VAR rather than a VECM).

Causality in ARDL Models

Several papers have described as "Granger causality" the test on the lagged value of x in the ARDL equation

$${y_t} = {\alpha _1}{y_{t - 1}} + {\beta _0}{x_t} + {\beta _1}{x_{t - 1}} + {\varepsilon _t}$$

While superficially similar (they both test lags in a bivariate dynamic regression), they are, in fact, not similar at all in the way they restrict the dynamic properties of the series. If the bivariate VAR for x and y has both represented as univariate autoregressions, with contemporaneously correlated innovations, the lagged x in the ARDL will have a non-zero coefficient, even though x (by definition) fails to Granger cause y. And, if the coefficient on the lag is zero in the ARDL, it's almost a certainty that x actually does Granger cause y if the coefficient on current x is non-zero. The test thus has no implications one way or the other for the causal relationship. Instead, it's the test of a particular coefficient in an ARDL model.

Causality in Panel Data

A Granger causality test is, in a bivariate setting, simply a restriction on the coefficients in one equation in a VAR. In a tightly parameterized model, this is straightforward: estimate the unrestricted model and do a Wald test on the lags as described above for the GARCH model.

More interesting is the application to small N-big T data sets, where homogeneity is both unreasonable and unnecessary. For a VAR on macroeconomic data, everything being heterogeneous would seem to be the right choice. With heterogeneity under the null and the alternative, the test would reject (theoretically) if there is Granger causality in any of the individual regressions, that is, the null is that there is no Granger causality in any individual, while the alternative is that there is Granger causality in at least one. Of course, the power of the test will be fairly low if there is only causality in a few individuals.

Allowing for full heterogeneity (plus independence across individuals), a likelihood ratio test is quite easy to compute. It is, in fact, just the sum of the individual likelihood ratios for Granger causality (with degrees of freedom summing as well). Since rejection of the null of non-causality means that causality is found in some (though not necessarily all) of the individuals, an obvious way to display the results is with both the joint test and the individual tests. Note, by the way, that it is possible for all the individual tests to be insignificant at conventional significance levels while the joint test is strongly significant. That's not unexpected, since the whole point of the joint test is to give us more and better information than is available in the individual samples.

For an example, see panelcause.rpf.

Rolling Sample Causality Tests

While this is certainly doable (see rollingcausality.rpf), it's not entirely clear what the point is. The causality tests will likely give quite different results from different subsamples just due to sampling errorin the example program there is no causality at all, and the model is completely stable, and yet the results range from solidly "significant" to almost zero. Note that bootstrapping the significance levels as part of this doesn't change this since bootstrapping won't change the (apparently) large causality tests that can be observed when you do a large number of test windows.


text:
# What are the disadvantages of using multiple inheritance to implement components?

I've been doing research on component-based game engines and would like to use that model for future game projects. From what I gather, objects in a component-based system are just collections of attributes and behaviors. The examples I've seen have a high-level interface such as Attribute<T> *Entity::getAttribute<T>(int id) but discussions about those systems often talk about performance problems. It seems like this could be implemented with greater efficiency in C++ using multiple virtual inheritance since the compiler could inline attribute accesses and behavior method calls:

// Layer 1: Base
struct Entity {
virtual ~Entity() {}
virtual void draw() {}
virtual void update(float seconds) {}
};

// Layer 2: Attributes each extend from Entity
struct Position : virtual Entity { Vector3 pos; };
struct Velocity : virtual Entity { Vector3 vel; };
struct Health : virtual Entity { int health; };
struct Target : virtual Entity { Position *target; };

// Layer 3: Behaviors extend from the attributes they need
struct Renders : virtual Position {
Model model;
void draw() { model.draw(); }
};
struct Moves : virtual Position, virtual Velocity {
void update(float seconds) { pos += vel * seconds; }
};
struct Seeks : virtual Moves, virtual Target {
void update(float seconds) {
if (target) vel = (target->pos - pos).unit();
Moves::update(seconds);
}
};

// Layer 4: Definitions extend from the behaviors they need
struct Rocket : virtual Health, virtual Renders, virtual Seeks {};

However, many component-based engine resources discount multiple inheritance without really saying why. I'm sure I'm missing something, but what are the disadvantages of using multiple inheritance like this over lists of components? I know calls to base classes when using multiple inheritance incur an additional constant offset, but that seems better than going through a run-time map for each attribute access. The only disadvantage that I can think of is not being able to swap out components at run-time.

Resources:

• Likely because you can't easily add or remove attributes during run time. Which you mention. But that's a fairly large one. Further, the entity/component frameworks are striving to remove themselves from inheritance structures. – MichaelHouse Apr 26 '12 at 21:39
• also I think this question is more suited to be asked at stackoverflow.com – Ali1S232 Apr 26 '12 at 22:07

Well, you pointed out The Big Disadvantage yourself:

The only disadvantage that I can think of is not being able to swap out components at run-time.

Its direct consequence makes it a no-go... One of the most interesting feature of a component-based system is that it can be data-driven. By using inheritance, creating a new entity kind means a recompile. Compiling can be, very, very long. And worse, you're limiting that to programmers only.

Gajet gave some other valid points too, but to me that's the #1 problem with the approach you expose.

A detail: I've hardly ever seen virtual inheritance used in a game engine. It might be plain ignorance/laziness, or maybe there's never a good reason to use it, but I also suspect poor compiler support on consoles.

• That makes sense. I didn't think about level editors, but one that can create new entity definitions is essential in large-scale game development. – constexpr Apr 27 '12 at 1:11

I can think of one or two reasons but I don't think they are not solid proof:

1. Using multiple inheritance as extensive at what you explained could easily get out of control. I know at first it seems it may help you along the way, but with a simple mistake you might end up with a bunch of code that generates a run-time error; Which you can't track down.
2. The whole multiple inheritance thing is based on too many memory jumps before calling each function. the same goes for each data lookup. So later when you need a high performance structure to do everything neat and fast you might end up with bunch of slow codes not allowing you to add any features.
3. Keeping the code simple is always the best strategy against large code bases. And games (specially in engine part) always end up having a large amount of code.
4. Though this might be the stupidest thing you've ever heard but working with an structure will lead somehow to being used to that structure. for example a person who works with C# almost always have a hard time switching to Java, though their syntax is very likely. I'm not saying he can't but he'll keep nagging about how good C# was and how bad Java is. multiple inheritance is something just a few languages implemented, so by using it you might later have a hard time switching to other languages.
5. With the exact same reason other languages doesn't support multiple inheritance yo might later get into trouble when porting your game to other languages. If you use common tools, you'll only need to change syntax while converting. But using multiple inheritance you need to convert the whole implantation method which takes as much time as writing a new code from scratch.

All that said I also think it would be nice if someone try that once and tell if he had a good experience with that kind of design. But you know existing mostly used structures are proved through the ages that can do any thing you want them to, so why do you want to change these well-proved mechanisms?

• I didn't think about portability at all, that's an excellent point. – constexpr Apr 27 '12 at 1:11
• I believe your written English skills are improving Gajet. This post has much better grammar than you previous posts. Well done. – MichaelHouse Apr 27 '12 at 17:49
• @Byte56 I don't think so, It's only the more effort I put to write this post. I usually answered question before sleep last times, while I gave this one in complete consciousness. – Ali1S232 Apr 27 '12 at 17:52


text:
# Theoretical notion of white-box

Is there any theoretically safe notion of white-box?

I have been reading about white-box [1, 2, 3] recently. It seems white-box deals with code obfuscation and its not known whether a perfect white-box exists.

I am curios about theoretical notion behind this. For a stream cipher, the theoretical notion is PRF. For block cipher it is PRP. For a hash function, it is one-way function. Is there anything comparable for white-box?

I am looking for something which is not necessarily practical, but we can actually show this achieves perfect white-box, like a really scrambled code or something.

UPDATE. I vaguely remember reading something on the line of

White-box would be possible if a super-huge memory exists. The memory could be loaded as a look-up table with the plaintexts as the look-up-keys and the ciphertexts the look-up-values. Since the encryption-key is not involved in the look-up table (it has been used previously to create the look-up table), it cannot be recovered but encryption would be still possible.

But I could not retrieve the source. Does anybody know anything about it?

• This isn't really a cryptography question. It's more reverse engineering. Although the answer is no there isn't. That's why DRM keeps getting broken by anyone willing to put in the effort and risk lawsuits. I would recommend this question be migrated to reverse engineering SE. – Serpent27 Oct 2 at 5:50
• Brecht Wyseur's PHD thesis seems to provide a theoretical model for white box cryptography. Unfortunately, I don't have time to read it and summarize is in an answer at the moment. – Vaelus Oct 2 at 16:44
• I am completely unfamiliar with white-box cryptography, but how does it differ from something like hard-coding the key to the algorithm, and then passing the algorithm to an indistinguishability obfuscator? – Mark Oct 3 at 5:20
• You could take a look at the videos/slides from cryptoexperts.com/whibox2016 and cryptoexperts.com/whibox2019 – j.p. Oct 3 at 9:37
• Note that I oppose migrating this question elsewhere as it clearly asks for the formal model used for white-box cryptography. Given that whitebox cryptography is a (more or less) accepted part of cryptography and even has seen some attacks using side-channel techniques, it seems plausible for such a model to exist - if one digs in the contexts. Also note that this question does not ask in any way about the general feasibility (though any potential impossibility results will probably not be unwelcome). – SEJPM Oct 5 at 15:37

Since I guess we're entertaining this as a crypto question, and not reverse engineering, I'll provide a formal answer.

The purpose of white-box crypto, as generally accepted, is to hide the key used to perform some cryptographic operation. The issue with such a system is that the algorithm itself must know the key; it's pretty difficult to successfully encrypt or decrypt something with a key you don't know.

In any instance where the algorithm knows the key it uses to perform cryptographic operations, a reverse engineer can simply grab the key from the algorithm's memory. You can try to hinder the reverse engineer's attempt to do so, but reverse engineering isn't an NP-complete problem; it's actually quite easy for someone with the necessary skills.

Maybe you don't load the key, but some one-way operation based on the key... Congratulations! You're simply using a different key, and have changed no security properties whatsoever.

Let's say you use some input, perform some indecipherable calculations on it, and use the resulting value as the key... Congratulations! You've also done nothing, since a reverse engineer's entire job is to decipher seemingly "indecipherable" code, and they tend to be quite good at it.

Also, there's nothing stopping them from simply running the calculations themselves. They don't need to understand code to run it. You can try various techniques to prevent them from doing so, and that's called anti-reverse-engineering. But it's neither theoretically, nor practically, able to stop any decent reverse engineer.

Just a couple days ago I was tasked with reverse engineering a malware sample that tried to use such a white-box system to prevent me from understanding what it does. I decrypted every encrypted string within the sample and am currently pending approval to upload the reverse-engineered sample to my public GitHub.

In short, White-box crypto doesn't work.

• -1: You could try to solve the winning entries of the last White-box competition whibox.cyber-crypt.com (without help from the published solutions) before making such bold claims. Of course, there are crappy solutions out there that are easy to break, and of course, code lifting is always an option. The best one can hope for with an WhiteBox-implementation is to use a symmetric key algorithm as public key algorithm that can be only broken by code lifting. – j.p. Oct 3 at 9:35
• -1: the answer is very misleading (especially since the question is about theory); it is true that current practical implementations are relatively easy to break; it is true that "software obfuscation" techniques provide some weak temporary security layer. However, there is much more on the scientific cryptographic field: there are generic side-channel-style attacks and there are countermeasures against them which started to evolve recently; there are theoretical notions of cryptographic obfuscation which recently had some breakthrough constructions from LWE. – Fractalic Oct 4 at 10:32
• @Fractalic You use the term "generic side-channel-style attacks" like a program can prevent me from reading my own RAM. Debuggers like IDA or Radare2 can't be mitigated, no matter how hard you try to pretend they can be. – Serpent27 Oct 5 at 2:09
• @j.p. If the data can't be decrypted there's no use for this anyway - we already have public-key crypto, and I don't need a 49MB program to do it. As soon as you implement the ability to decrypt you allow me to hijack the decryption function and break the security - key or no key. Math gives no shits about the context in which some function is run. If I can create valid decryption inputs I can decrypt. That's why this is a reverse engineering question and not a cryptology question. – Serpent27 Oct 5 at 2:10
• @Serpent27 say the program simply multiplies a ton of matrices (matrices depend on the input); this is one of ideas in cryptographic obfuscation. How is IDA or Radare2 going to help you? – Fractalic Oct 5 at 8:32

Caution: White Box Cryptography is out of my comfort zone, and I have not been following the latest developments in the field. The following is my current opinion, which I present in hope of seeing it challenged, and learning in the process.

As I see it, the traditional goal of White Box Cryptography (and the one the industry would like most) is to design software that computes a standard public keyed cryptographic transformation (such as a keyed PRP, ideally AES) with a particular instance of the secret key embedded in the software, such that leaking the software does not leak the key.

I know no serious claim that this is even close to be achieved. On the contrary, WBC competitions that focused on the above goal with AES as the PRP have AFAIK all ended with quick key extraction.

With respect to that goal, it seems we do not even have practically secure WBC, and thus much less theoretically secure WBC. Contrast with the better situation in symmetric crypto, where we have practically secure PRPs and PRFs, but arguably no theoretically secure construction from first principles.

Yet a variant of WBC as defined above is practically feasible if we allow to construct the keyed transformation with WBC in mind: for example it's trivial to make a practically secure WBC implementation of the AES-256 lookalike WES-256, defined as: \begin{align} \text{WES-256}:\quad&\{0,1\}^{256}\times\{0,1\}^{128}\to\{0,1\}^{128}\\ &P\mapsto\text{WES-256}(K,P)\underset{\text{def}}=\text{AES-256}(\text{SHA-256}(K),P) \end{align}

If we take that variant definition, security of WBC follows from that of more traditional constructs.

My conclusion is that I know no good definition of the theoretical goal of WBC, thus can't answer the question!

• WES is a good example to satisfy what is called "weak white-box/unbrekability", but not "strong white-box/onewayness". Weak WB typically comes with incompressibility so that the recovered "equivalent key" is at least worse in size. Here the equivalent key - SHA-256(K) - has the same size. Also note that weak WB of actual AES (i.e. without modifying the key) is much harder. – Fractalic Oct 6 at 12:37
• @Fractalic: It would be great if you added definition of Weak/Strong WB in your answer! Note: yes WES-256 is cutting corners, it theoretically looses 0.8272… bit of key! – fgrieu Oct 6 at 13:38
• Weak/strong WB are simply synonyms for unbreakability/onewayness, mentioned a few times in the answers linked by @hola, e.g. crypto.stackexchange.com/a/53361/9249 – Fractalic Oct 7 at 14:19

Not the main answer, but something useful.

There is a notion of incompressibility, which requires that it is hard to meaningfully compress an intentionally large white-box implementation. While hard to achieve for existing ciphers, it is easy to design new symmetric ciphers with incompressible implementations.

Why? The main idea probably is to prevent code-lifting attacks: extracting say, 1GB from a mobile phone is much harder than 128 bit of the secret key. Especially, in a massive attack, say, by malware. Of course, on practice, industry is reluctant to use such implementations, as nobody wants to eat 1GB of storage for nothing.

How? For example, consider a Feistel Network where Feistel functions are truncated AES instances (using the master key, or better deriving from it). In the incompressible implementation, we'll put this function as a look-up table (we truncate it to have any desired size). It is not hard to show that compressing the scheme implies non-randomness of AES, so the incompressibility is reduced to the AES security.

Some references:

1. Delerablée et al. White-box security notions for symmetric encryption schemes. https://ia.cr/2013/523
2. Biryukov et al. Cryptographic Schemes Based on the ASASA Structure: Black-box, White-box, and Public-key https://ia.cr/2014/474
3. Bogdanov et al. White-box cryptography revisited: Space-hard ciphers.
4. Bogdanov et al. Towards Practical Whitebox Cryptography: Optimizing Efficiency and Space Hardness. https://www.iacr.org/archive/asiacrypt2016/10031190/10031190.pdf
5. Fouque et al. Efficient and Provable White-Box Primitives. https://ia.cr/2019/329
6. Cho et al. WEM: A New Family of White-box Block Ciphers Based on the Even-Mansour Construction http://www.cs.haifa.ac.il/~orrd/crypt/WEM.pdf
7. Bock et al. Doubly half-injective PRGs for incompressible white-box cryptography https://ia.cr/2019/329
8. Koike et al. Galaxy: A Family of Stream-Cipher-Based Space-Hard Ciphers
• Do you have any documents, like research papers, that I can can read more about? – hola Oct 5 at 5:46
• @hola added references! – Fractalic Oct 5 at 9:13
• This sounds similar to big-key cryptography, where the ciphers' program itself is not large, but the key is (for essentially the same reason). I'm aware of Bellare's work on this topic (I believe there is at least one other paper precededing that). – Mark Oct 9 at 1:05


text:
# Measure weight of an object using a servo

Assuming a quality industrial servo, would it possible to calculate the weight/resistance of a load? Maybe by comparing current draw in a holding position, or by the time it takes to lift/lower an object. Could it accurately measure grams, kilograms? What kind of tolerance could be achieved?

I'm trying to eliminate the need for a dedicated weight measurement sensor.

## 1 Answer

This is going to depend on the style of motor in the servo and the style of gearbox. If the servo can't be back-driven when unpowered, then it's likely some form of a worm gear assembly that will prevent static force transmission back to the motor. This means that you won't be able to tell weight by current draw for holding position because the holding current draw will (probably) be zero.

You won't be able to tell anything about holding current draw if the motor is a stepper motor, either, because the stepper motor simply energizes a particular set of poles to full strength; any applied load under that holding torque is held, any applied load over causes the motor to slip.

In both of those cases, you may still be able to glean some information about the load based on the torque required to accelerate the load, by $\tau = I\alpha$, but then this gives you the moment of inertia of the load, and not its weight. This is an important distinction because the moment of inertia depends on the shape of the load as well as its mass.

If you know the shape of the load before hand, or if the load is something like a mass attached to a pulley (winch), then you can use the moment of inertia to calculate mass. If you don't know the shape, though, the moment of inertia alone doesn't get you enough information to find the mass.

Finally, even if you have a back-drivable servo that is actuated by a continuous rotation motor (not stepper), the holding current is going to be based on the torque applied to the servo, where $\tau = mgL\sin{\theta}$. If you get into a situation where $\sin{\theta} = 0$, then you'll wind up with a zero applied torque to hold the load, and you won't be able to get a load mass estimation.

In order to do what you want, you have to have a pretty specific situation setup where you have a lot of information in advance. That said, even if you do have all of that information, there are still other aspects that need to be taken into account: friction/damping losses in the gear box, gear box inertia, motor efficiency (input power (current@voltage) versus mechanical output power (torque@speed)), motor inertia, motor frictional and damping losses, etc.

None of this means it can't be done, but it means that you have to have the system modeled well enough that you can take a "snapshot" of motor inputs and speed and be able to turn that into a useful output torque. The accuracy you can achieve is entirely dependent on your ability to model everything pertinent to the system and the system's ability to stay as-modeled (oil/grease doesn't age/cake, bearings don't wear, motor feedback stays true, etc.).

You will probably find that the effort required to adequately model the servo system is more expensive (time and labor) than purchasing a weight sensor.


text:
# Upper limits on the rates of binary neutron star and neutron-star--black-hole mergers from Advanced LIGO's first observing run

https://scirate.com/arxiv/1607.07456


text:
# Electronic – Simplification of ideal op amp circuit

circuit analysisoperational-amplifiertransfer function

For an assignment at school I have an op amp circuit where I need to get the Transfer function of. I want to ask if my approach is correct. Because it feels I simplify it too much.(R1,R2 and R3 have the same value)

If I assume the op amp is ideal, I can say that V2 is equal to V+ because V+ and V- are equal and V- is V2.That would mean that I can simplify the circuit to this:

And then in turn to this:

And then I want to use the node voltage method to get the transfer function eventually. Is this simplification correct? Or am i making weird assumptions? (I dont know the answer so I cant check my eventual answer)

The reason for this is that the resistor $$\R_3\$$ creates an opportunity for the two nodes to influence each other. The original circuit only allows the output to influence the node between the two capacitances because the output of the opamp is an ideal voltage source (it forces current to flow via ground or a supply voltage). This is why buffers are typically used: to avoid the output influencing the input.
You will have no choice but to include an ideal (voltage-controlled) voltage source on the other side of $$\R_3\$$ that has the same voltage as $$\V_2\$$.


text:
# decompose_ang_len¶

solarbextrapolation.utilities.decompose_ang_len(qua_input, **kwargs)[source]

Function to help decompose quantities that have an equivilence between angles and length, such as photospheric observational angles and object sizes. The function uses an equivilence to convert into either length or angle physical_type units.

Parameters: The quantity you wish decomposed. working_units : astropy.units.quantity.Quantity, optional Unit that will be used for internal working and the returned quantity. Ensure that it is of the correct physical type, angle or length. equivalencies : astropy equivilence, Equivilence used to relate the length and angle units.


text:
## Algebra 2 (1st Edition)

Published by McDougal Littell

# Chapter 12 Sequences and Series - 12.1 Define and Use Sequences and Series - 12.1 Exercises - Mixed Review - Page 800: 75

-3

#### Work Step by Step

Solving the equation for x, we find: $$-3x=9 \\ x=-3$$ Plugging this back in, we verify that this is the correct value.

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:
Repositorio de producción científica de la Universidad de Sevilla

Extremal Graphs without Topological Complete Subgraphs

Extremal Graphs without Topological Complete Subgraphs
Cites

Show item statistics
Export to
 Author: Cera López, Martín Diánez Martínez, Ana Rosa Márquez Pérez, Alberto Department: Universidad de Sevilla. Departamento de Matemática Aplicada I (ETSII) Date: 2004 Published in: SIAM J. Discrete Math., 18(2),(2004), pp. 388–396. Document type: Article Abstract: The exact values of the function $ex(n;TK_{p})$ are known for ${\lceil \frac{2n+5}{3}\rceil}\leq p < n$ (see [Cera, Diánez, and Márquez, SIAM J. Discrete Math., 13 (2000), pp. 295--301]), where $ex(n;TK_p)$ is the maximum number of edges of a graph of order n not containing a subgraph homeomorphic to the complete graph of order $p.$ In this paper, for ${\lceil \frac{2n+6}{3} \rceil}\leq p < n - 3,$ we characterize the family of extremal graphs $EX(n;TK_{p}),$ i.e., the family of graphs with n vertices and $ex(n;TK_{p})$ edges not containing a subgraph homeomorphic to the complete graph of order $p.$
Size: 144.0Kb
Format: PDF

DOI: http://dx.doi.org/10.1137/S0895480100378677

This work is under a Creative Commons License:


text:
# Truncated cone 3

The surface of the truncated rotating cone S = 7697 meters square, the substructure diameter is 56m and 42m, determine the height of the tang.

Correct result:

h =  24.001 m

#### Solution:

$S=7697 \ \text{m}^2 \ \\ D_{1}=56 \ \text{m} \ \\ D_{2}=42 \ \text{m} \ \\ r_{1}=D_{1}/2=56/2=28 \ \text{m} \ \\ r_{2}=D_{2}/2=42/2=21 \ \text{m} \ \\ S_{1}=\pi \cdot \ r_{1}^2=3.1416 \cdot \ 28^2 \doteq 2463.0086 \ \text{m}^2 \ \\ S_{2}=\pi \cdot \ r_{2}^2=3.1416 \cdot \ 21^2 \doteq 1385.4424 \ \text{m}^2 \ \\ S_{3}=S - S_{1}-S_{2}=7697 - 2463.0086-1385.4424 \doteq 3848.549 \ \text{m}^2 \ \\ s=S_{3}/\pi/(r_{1}+r_{2})=3848.549/3.1416/(28+21) \doteq 25.0006 \ \text{m} \ \\ h=\sqrt{ s^2-(r_{1}-r_{2})^2 }=\sqrt{ 25.0006^2-(28-21)^2 }=24.001 \ \text{m}$

Our examples were largely sent or created by pupils and students themselves. Therefore, we would be pleased if you could send us any errors you found, spelling mistakes, or rephasing the example. Thank you!

Please write to us with your comment on the math problem or ask something. Thank you for helping each other - students, teachers, parents, and problem authors.

Tips to related online calculators
Pythagorean theorem is the base for the right triangle calculator.

#### You need to know the following knowledge to solve this word math problem:

We encourage you to watch this tutorial video on this math problem:

## Next similar math problems:

• Truncated cone
Calculate the height of the rotating truncated cone with volume V = 1115 cm3 and a base radii r1 = 7.9 cm and r2 = 9.7 cm.
• Area of the cone
Calculate the surface area of the cone, you know the base diameter 25 cm and a height 40 cm.
• Rotary cylinder
The rotating cylinder has a surface area 69.08 cm2. The area of the shell is 62.8 cm 2. What is the diameter of the cylinder?
• Roller
Cylinder shell has the same content as one of its base. Cylinder height is 15 dm. What is the radius of the base of the cylinder?
• Seat
How much m² of fabric do we need to sew a 50cm-shaped cube-shaped seat if 10% of the material we add to the folds?
• Surface of the cylinder
Calculate the surface of the cylinder for which the shell area is Spl = 20 cm2 and the height v = 3.5 cm
• Quatrefoil
Calculate area of the quatrefoil which is inscribed in a square with side 6 cm.
• Silver medal
To circular silver medal with a diameter of 10 cm is inscribed gold cross, which consists of five equal squares. What is the content area of silver part?
• Holidays - on pool
Children's tickets to the swimming pool stands x € for an adult is € 2 more expensive. There was m children in the swimming pool and adults three times less. How many euros make treasurer for pool entry?
• Equation of circle
find an equation of the circle with indicated properties: a. center at (-3,5), diameter 20. b. center at origin and diameter 16.
• Circle - AG
Find the coordinates of circle and its diameter if its equation is: ?
• Diameters of circles
How many percent of the area of a larger circle is a smaller circle if the smaller circle has a diameter 120 mm and a larger one has a diameter 300 mm?
• Coefficient
Determine the coefficient of this sequence: 7.2; 2.4; 0.8
• Algebra
X+y=5, find xy (find the product of x and y if x+y = 5)
• Expression with powers
If x-1/x=5, find the value of x4+1/x4
• Circle's chords
In the circle there are two chord length 30 and 34 cm. The shorter one is from the center twice than longer chord. Determine the radius of the circle.
• Compute 4
Compute the exact value of the area of the triangle with sides 14 mi, 12 mi, and 12 mi long.


text:
# functions convergence

$$f$$ is bounded function defined around $$x_0$$. For every monotonic sequence $$x_n \rightarrow x_0$$, $$f(x_n)$$ is convergent.

prove/disprove :

1. all $$f(x_n)$$ sequences converge to the same limit when $$x_n\rightarrow x_0$$ is monotonic increasing func.

2. one sided limits of $$f$$ exist at $$x_0$$.

I think 1 is not correct so I am trying to find 2 monotonic sequences $$x_n,y_n$$ that converge to $$x_0$$ s.t $$\lim f(x_n)$$ Differ from $$\lim f(y_n)$$, but no success so far.

• You might reconsider your intuition about #1. Given $x_n$ and $y_n$ and the associated limits $f(x_n)\to A$ and $f(y_n)\to B$, let $\{z_n\}$ be the union of $\{x_n\}$ and $\{y_n\}$ (sorted to be monotonic); what can you say about $\lim f(z_n)$? – Greg Martin May 25 at 20:20
• But the assumption is that it must converge. What does that tell you about the relationship between $A$ and $B$? – Greg Martin May 26 at 9:09


text:
# Posts tagged as “medium”

Given a binary tree, write a function to get the maximum width of the given tree. The width of a tree is the maximum width among all levels. The binary tree has the same structure as a full binary tree, but some nodes are null.

The width of one level is defined as the length between the end-nodes (the leftmost and right most non-null nodes in the level, where the null nodes between the end-nodes are also counted into the length calculation.

Example 1:

Input:

1
/   \
3     2
/ \     \
5   3     9

Output: 4
Explanation: The maximum width existing in the third level with the length 4 (5,3,null,9).

Example 2:

Input:

1
/
3
/ \
5   3

Output: 2
Explanation: The maximum width existing in the third level with the length 2 (5,3).

Example 3:

Input:

1
/ \
3   2
/
5

Output: 2
Explanation: The maximum width existing in the second level with the length 2 (3,2).

Example 4:

Input:

1
/ \
3   2
/     \
5       9
/         \
6           7
Output: 8
Explanation:The maximum width existing in the fourth level with the length 8 (6,null,null,null,null,null,null,7).

## Solution: DFS

Let us assign an id to each node, similar to the index of a heap. root is 0, left child = parent * 2, right child = parent * 2 + 1. Width = id(right most child) – id(left most child) + 1, so far so good.
However, this kind of id system grows exponentially, it overflows even with long type with just 64 levels. To avoid that, we can remap the id with id – id(left most child of each level).

Time complexity: O(n)
Space complexity: O(h)

## Python3

Given a rows * columns matrix mat of ones and zeros, return how many submatrices have all ones.

Example 1:

Input: mat = [[1,0,1],
[1,1,0],
[1,1,0]]
Output: 13
Explanation:
There are 6 rectangles of side 1x1.
There are 2 rectangles of side 1x2.
There are 3 rectangles of side 2x1.
There is 1 rectangle of side 2x2.
There is 1 rectangle of side 3x1.
Total number of rectangles = 6 + 2 + 3 + 1 + 1 = 13.

Example 2:

Input: mat = [[0,1,1,0],
[0,1,1,1],
[1,1,1,0]]
Output: 24
Explanation:
There are 8 rectangles of side 1x1.
There are 5 rectangles of side 1x2.
There are 2 rectangles of side 1x3.
There are 4 rectangles of side 2x1.
There are 2 rectangles of side 2x2.
There are 2 rectangles of side 3x1.
There is 1 rectangle of side 3x2.
Total number of rectangles = 8 + 5 + 2 + 4 + 2 + 2 + 1 = 24.

Example 3:

Input: mat = [[1,1,1,1,1,1]]
Output: 21

Example 4:

Input: mat = [[1,0,1],[0,1,0],[1,0,1]]
Output: 5

Constraints:

• 1 <= rows <= 150
• 1 <= columns <= 150
• 0 <= mat[i][j] <= 1

## Solution 1: Brute Force w/ Pruning

Time complexity: O(m^2*n^2)
Space complexity: O(1)

## C++

We have a wooden plank of the length n units. Some ants are walking on the plank, each ant moves with speed 1 unit per second. Some of the ants move to the left, the other move to the right.

When two ants moving in two different directions meet at some point, they change their directions and continue moving again. Assume changing directions doesn’t take any additional time.

When an ant reaches one end of the plank at a time t, it falls out of the plank imediately.

Given an integer n and two integer arrays left and right, the positions of the ants moving to the left and the right. Return the moment when the last ant(s) fall out of the plank.

Example 1:

Input: n = 4, left = [4,3], right = [0,1]
Output: 4
Explanation: In the image above:
-The ant at index 0 is named A and going to the right.
-The ant at index 1 is named B and going to the right.
-The ant at index 3 is named C and going to the left.
-The ant at index 4 is named D and going to the left.
Note that the last moment when an ant was on the plank is t = 4 second, after that it falls imediately out of the plank. (i.e. We can say that at t = 4.0000000001, there is no ants on the plank).

Example 2:

Input: n = 7, left = [], right = [0,1,2,3,4,5,6,7]
Output: 7
Explanation: All ants are going to the right, the ant at index 0 needs 7 seconds to fall.

Example 3:

Input: n = 7, left = [0,1,2,3,4,5,6,7], right = []
Output: 7
Explanation: All ants are going to the left, the ant at index 7 needs 7 seconds to fall.

Example 4:

Input: n = 9, left = [5], right = [4]
Output: 5
Explanation: At t = 1 second, both ants will be at the same intial position but with different direction.

Example 5:

Input: n = 6, left = [6], right = [0]
Output: 6

Constraints:

• 1 <= n <= 10^4
• 0 <= left.length <= n + 1
• 0 <= left[i] <= n
• 0 <= right.length <= n + 1
• 0 <= right[i] <= n
• 1 <= left.length + right.length <= n + 1
• All values of left and right are unique, and each value can appear only in one of the two arrays.

## Solution: Keep Walking

When two ants A –> and <– B meet at some point, they change directions <– A B –>, we can swap the ids of the ants as <– B A–>, so it’s the same as walking individually and passed by. Then we just need to find the max/min of the left/right arrays.

Time complexity: O(n)
Space complexity: O(1)

## Python3

Given an array of integers nums and an integer target.

Return the number of non-empty subsequences of nums such that the sum of the minimum and maximum element on it is less or equal than target.

Since the answer may be too large, return it modulo 10^9 + 7.

Example 1:

Input: nums = [3,5,6,7], target = 9
Output: 4
Explanation: There are 4 subsequences that satisfy the condition.
[3] -> Min value + max value <= target (3 + 3 <= 9)
[3,5] -> (3 + 5 <= 9)
[3,5,6] -> (3 + 6 <= 9)
[3,6] -> (3 + 6 <= 9)

Example 2:

Input: nums = [3,3,6,8], target = 10
Output: 6
Explanation: There are 6 subsequences that satisfy the condition. (nums can have repeated numbers).
[3] , [3] , [3,3], [3,6] , [3,6] , [3,3,6]

Example 3:

Input: nums = [2,3,3,4,6,7], target = 12
Output: 61
Explanation: There are 63 non-empty subsequences, two of them don't satisfy the condition ([6,7], [7]).
Number of valid subsequences (63 - 2 = 61).

Example 4:

Input: nums = [5,2,4,1,7,6,8], target = 16
Output: 127
Explanation: All non-empty subset satisfy the condition (2^7 - 1) = 127

Constraints:

• 1 <= nums.length <= 10^5
• 1 <= nums[i] <= 10^6
• 1 <= target <= 10^6

## Solution: Two Pointers

Since order of the elements in the subsequence doesn’t matter, we can sort the input array.
Very similar to two sum, we use two pointers (i, j) to maintain a window, s.t. nums[i] +nums[j] <= target.
Then fix nums[i], any subset of (nums[i+1~j]) gives us a valid subsequence, thus we have 2^(j-(i+1)+1) = 2^(j-i) valid subsequence for window (i, j).

Time complexity: O(nlogn) // Sort
Space complexity: O(n) // need to precompute 2^n % kMod.

## C++

Given an array of integers arr of even length n and an integer k.

We want to divide the array into exactly n / 2 pairs such that the sum of each pair is divisible by k.

Return True If you can find a way to do that or False otherwise.

Example 1:

Input: arr = [1,2,3,4,5,10,6,7,8,9], k = 5
Output: true
Explanation: Pairs are (1,9),(2,8),(3,7),(4,6) and (5,10).

Example 2:

Input: arr = [1,2,3,4,5,6], k = 7
Output: true
Explanation: Pairs are (1,6),(2,5) and(3,4).

Example 3:

Input: arr = [1,2,3,4,5,6], k = 10
Output: false
Explanation: You can try all possible pairs to see that there is no way to divide arr into 3 pairs each with sum divisible by 10.

Example 4:

Input: arr = [-10,10], k = 2
Output: true

Example 5:

Input: arr = [-1,1,-2,2,-3,3,-4,4], k = 3
Output: true

Constraints:

• arr.length == n
• 1 <= n <= 10^5
• n is even.
• -10^9 <= arr[i] <= 10^9
• 1 <= k <= 10^5

## Solution: Mod and Count

Count the frequency of (x % k + k) % k.
f[0] should be even (zero is also even)
f[1] = f[k -1] ((1 + k – 1) % k == 0)
f[2] = f[k -2] ((2 + k – 2) % k == 0)

Time complexity: O(n)
Space complexity: O(k)

## C++

Mission News Theme by Compete Themes.


text:
# Multiplication bloards after factorization

1. Nov 18, 2013

### yiorgos

Let a positive definite matrix A be factorized to P and Q, A=P*Q and let an arbitrary matrix B.
I am calculating the relative error of the factorization through the norm:

$\epsilon = \left\| \textbf{A}-\textbf{PQ} \right\| / \left\| \textbf{A} \right\|$

which gives

$\epsilon <1\text{e}-16$

so I assume factorization is correct.

But things go messy when I try to multiply the factorized form of A with B.
In particular, the relative error, r, of the product

$r = \left\| \textbf{AB}-\textbf{PQB} \right\| / \left\| \textbf{AB} \right\|$

now bloats, i.e. I get
$r>0.1.$

Note that B is arbitrary, in particular I have tried several different types: random, structured, all-ones matrix, even the identity matrix.
I'm confused. How come factorization is correct and then the multiplication bloats?
Has anything to do with condition number?

(Unfortunately I can't disclose the type of factorization but I can tell that P and Q are not triangular)

2. Nov 19, 2013

### yiorgos

Modification: I mistakenly added also "identity matrix" to previous post. Please ignore this from the list of matrices I have tried.

3. Nov 19, 2013

### AlephZero

It's hard to know exactly what you are doing since you won't tell us all the facts, but I think the basic issue is the difference between "forward" and "backward" error analysis.

If you are trying to solve $Ax = b$ numerically, you can estimate the error two different ways.

Forward error analysis: try to estimate the error in $x$, i.e assume the exact solution is $A(x + e) = b$ and find an estimate for the vector $e$.
Backward error analysis: consider you have the exact solution to the "wrong" equation, i.e. estimate the size of a matrix $e$ such that $(A+e)x = b$.

Backward error analysis (first proposed by Wilkinson in the 1960s) is generally more useful than the more "obvious" forward analysis.


text:
# Clustering of Pointclouds into Supervoxels - Theoretical primer

In this tutorial, we show how to divide a pointcloud into a number of supervoxel clusters using pcl::SupervoxelClustering, and then how to use and visualize the adjacency information and supervoxels themselves.

An example of supervoxels and adjacency graph generated for a cloud

Segmentation algorithms aim to group pixels in images into perceptually meaningful regions which conform to object boundaries. Graph-based approaches, such as Markov Random Field (MRF) and Conditional Random Field (CRF), have become popular, as they merge relational low-level context within the image with object level class knowledge. The cost of solving pixel-level graphs led to the development of mid-level inference schemes which do not use pixels directly, but rather use groupings of pixels, known as superpixels, as the base level for nodes. Superpixels are formed by over-segmenting the image into small regions based on local low-level features, reducing the number of nodes which must be considered for inference.

Due to their strong impact on the quality of the eventual segmentation, it is important that superpixels have certain characteristics. Of these, avoiding violating object boundaries is the most vital, as failing to do so will decrease the accuracy of classifiers used later - since they will be forced to consider pixels which belong to more than one class. Additionally, even if the classifier does manage a correct output, the final pixel level segmentation will necessarily contain errors. Another useful quality is regular distribution over the area being segmented, as this will produce a simpler graph for later steps.

Voxel Cloud Connectivity Segmentation (VCCS) is a recent “superpixel” method which generates volumetric over-segmentations of 3D point cloud data, known as supervoxels. Supervoxels adhere to object boundaries better than state-of-the-art 2D methods, while remaining efficient enough to use in online applications. VCCS uses a region growing variant of k-means clustering for generating its labeling of points directly within a voxel octree structure. Supervoxels have two important properties; they are evenly distributed across the 3D space, and they cannot cross boundaries unless the underlying voxels are spatial connected. The former is accomplished by seeding supervoxels directly in the cloud, rather than the projected plane, while the latter uses an octree structure which maintains adjacency information of leaves. Supervoxels maintain adjacency relations in voxelized 3D space; specifically, 26-adjacency- that is neighboring voxels are those that share a face, edge, or vertex, as seen below.

From right to left, 6 (faces), 18 (faces,edges), and 26 (faces, edges, vertices) adjacency

The adjacency graph of supervoxels (and the underlying voxels) is maintained efficiently within the octree by specifying that neighbors are voxels within R_voxel of one another, where R_voxel specifies the octree leaf resolution. This adjacency graph is used extensively for both the region growing used to generate the supervoxels, as well as determining adjacency of the resulting supervoxels themselves.

VCCS is a region growing method which incrementally expand supervoxels from a set of seed points distributed evenly in space on a grid with resolution R_seed. To maintain efficiency, VCCS does not search globally, but rather only considers points within R_seed of the seed center. Additionally, seeds which are isolated are filtered out by establishing a small search radius R_search around each seed and removing seeds which do not have sufficient neighbor voxels connected to them.

The various sizing parameters which affect supervoxel clustering. R_seed and R_voxel must both be set by the user.

Expansion from the seed points is governed by a distance measure calculated in a feature space consisting of spatial extent, color, and normals. The spatial distance D_s is normalized by the seeding resolution, color distance D_c is the euclidean distance in normalized RGB space, and normal distance D_n measures the angle between surface normal vectors.

Weighting equation used in supervoxel clustering. w_c, w_s, and w_n, the color, spatial, and normal weights, respectively, are user controlled parameters.

Supervoxels are grown iteratively, using a local k-means clustering which considers connectivity and flow. The general process is as follows. Beginning at the voxel nearest the cluster center, we flow outward to adjacent voxels and compute the distance from each of these to the supervoxel center using the distance equation above. If the distance is the smallest this voxel has seen, its label is set, and using the adjacency graph, we add its neighbors which are further from the center to our search queue for this label. We then proceed to the next supervoxel, so that each level outwards from the center is considered at the same time for all supervoxels (a 2d version of this is seen in the figure below). We proceed iteratively outwards until we have reached the edge of the search volume for each supervoxel (or have no more neighbors to check).

Search order in the adjacency octree for supervoxel cluster expansion. Dotted edges in the adjacency graph are not searched, since they have already been considered earlier in the queue.

Alright, let’s get to the code… but if you want further details on how supervoxels work (and if you use them in an academic work) please reference the following publication:

@InProceedings{Papon13CVPR,
author={Jeremie Papon and Alexey Abramov and Markus Schoeler and Florentin W\"{o}rg\"{o}tter},
title={Voxel Cloud Connectivity Segmentation - Supervoxels for Point Clouds},
booktitle={Computer Vision and Pattern Recognition (CVPR), 2013 IEEE Conference on},
month     = {June 22-27},
year      = {2013},
}

Oh, and for a more complicated example which uses Supervoxels, see pcl/examples/segmentation/supervoxel_clustering.cpp.

# The code

First, grab a pcd file made from a kinect or similar device - here we shall use milk_cartoon_all_small_clorox.pcd which is available in the pcl git here). Next, copy and paste the following code into your editor and save it as supervoxel_clustering.cpp (or download the source file here).

  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 #include #include #include #include #include #include //VTK include needed for drawing graph lines #include // Types typedef pcl::PointXYZRGBA PointT; typedef pcl::PointCloud PointCloudT; typedef pcl::PointNormal PointNT; typedef pcl::PointCloud PointNCloudT; typedef pcl::PointXYZL PointLT; typedef pcl::PointCloud PointLCloudT; void addSupervoxelConnectionsToViewer (PointT &supervoxel_center, PointCloudT &adjacent_supervoxel_centers, std::string supervoxel_name, boost::shared_ptr & viewer); int main (int argc, char ** argv) { if (argc < 2) { pcl::console::print_error ("Syntax is: %s \n " "--NT Dsables the single cloud transform \n" "-v \n-s \n" "-c \n-z \n" "-n \n", argv[0]); return (1); } PointCloudT::Ptr cloud = boost::shared_ptr (new PointCloudT ()); pcl::console::print_highlight ("Loading point cloud...\n"); if (pcl::io::loadPCDFile (argv[1], *cloud)) { pcl::console::print_error ("Error loading cloud file!\n"); return (1); } bool disable_transform = pcl::console::find_switch (argc, argv, "--NT"); float voxel_resolution = 0.008f; bool voxel_res_specified = pcl::console::find_switch (argc, argv, "-v"); if (voxel_res_specified) pcl::console::parse (argc, argv, "-v", voxel_resolution); float seed_resolution = 0.1f; bool seed_res_specified = pcl::console::find_switch (argc, argv, "-s"); if (seed_res_specified) pcl::console::parse (argc, argv, "-s", seed_resolution); float color_importance = 0.2f; if (pcl::console::find_switch (argc, argv, "-c")) pcl::console::parse (argc, argv, "-c", color_importance); float spatial_importance = 0.4f; if (pcl::console::find_switch (argc, argv, "-z")) pcl::console::parse (argc, argv, "-z", spatial_importance); float normal_importance = 1.0f; if (pcl::console::find_switch (argc, argv, "-n")) pcl::console::parse (argc, argv, "-n", normal_importance); ////////////////////////////// ////////////////////////////// ////// This is how to use supervoxels ////////////////////////////// ////////////////////////////// pcl::SupervoxelClustering super (voxel_resolution, seed_resolution); if (disable_transform) super.setUseSingleCameraTransform (false); super.setInputCloud (cloud); super.setColorImportance (color_importance); super.setSpatialImportance (spatial_importance); super.setNormalImportance (normal_importance); std::map ::Ptr > supervoxel_clusters; pcl::console::print_highlight ("Extracting supervoxels!\n"); super.extract (supervoxel_clusters); pcl::console::print_info ("Found %d supervoxels\n", supervoxel_clusters.size ()); boost::shared_ptr viewer (new pcl::visualization::PCLVisualizer ("3D Viewer")); viewer->setBackgroundColor (0, 0, 0); PointCloudT::Ptr voxel_centroid_cloud = super.getVoxelCentroidCloud (); viewer->addPointCloud (voxel_centroid_cloud, "voxel centroids"); viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE,2.0, "voxel centroids"); viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_OPACITY,0.95, "voxel centroids"); PointLCloudT::Ptr labeled_voxel_cloud = super.getLabeledVoxelCloud (); viewer->addPointCloud (labeled_voxel_cloud, "labeled voxels"); viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_OPACITY,0.8, "labeled voxels"); PointNCloudT::Ptr sv_normal_cloud = super.makeSupervoxelNormalCloud (supervoxel_clusters); //We have this disabled so graph is easy to see, uncomment to see supervoxel normals //viewer->addPointCloudNormals (sv_normal_cloud,1,0.05f, "supervoxel_normals"); pcl::console::print_highlight ("Getting supervoxel adjacency\n"); std::multimap supervoxel_adjacency; super.getSupervoxelAdjacency (supervoxel_adjacency); //To make a graph of the supervoxel adjacency, we need to iterate through the supervoxel adjacency multimap std::multimap::iterator label_itr = supervoxel_adjacency.begin (); for ( ; label_itr != supervoxel_adjacency.end (); ) { //First get the label uint32_t supervoxel_label = label_itr->first; //Now get the supervoxel corresponding to the label pcl::Supervoxel::Ptr supervoxel = supervoxel_clusters.at (supervoxel_label); //Now we need to iterate through the adjacent supervoxels and make a point cloud of them PointCloudT adjacent_supervoxel_centers; std::multimap::iterator adjacent_itr = supervoxel_adjacency.equal_range (supervoxel_label).first; for ( ; adjacent_itr!=supervoxel_adjacency.equal_range (supervoxel_label).second; ++adjacent_itr) { pcl::Supervoxel::Ptr neighbor_supervoxel = supervoxel_clusters.at (adjacent_itr->second); adjacent_supervoxel_centers.push_back (neighbor_supervoxel->centroid_); } //Now we make a name for this polygon std::stringstream ss; ss << "supervoxel_" << supervoxel_label; //This function is shown below, but is beyond the scope of this tutorial - basically it just generates a "star" polygon mesh from the points given addSupervoxelConnectionsToViewer (supervoxel->centroid_, adjacent_supervoxel_centers, ss.str (), viewer); //Move iterator forward to next label label_itr = supervoxel_adjacency.upper_bound (supervoxel_label); } while (!viewer->wasStopped ()) { viewer->spinOnce (100); } return (0); } void addSupervoxelConnectionsToViewer (PointT &supervoxel_center, PointCloudT &adjacent_supervoxel_centers, std::string supervoxel_name, boost::shared_ptr & viewer) { vtkSmartPointer points = vtkSmartPointer::New (); vtkSmartPointer cells = vtkSmartPointer::New (); vtkSmartPointer polyLine = vtkSmartPointer::New (); //Iterate through all adjacent points, and add a center point to adjacent point pair PointCloudT::iterator adjacent_itr = adjacent_supervoxel_centers.begin (); for ( ; adjacent_itr != adjacent_supervoxel_centers.end (); ++adjacent_itr) { points->InsertNextPoint (supervoxel_center.data); points->InsertNextPoint (adjacent_itr->data); } // Create a polydata to store everything in vtkSmartPointer polyData = vtkSmartPointer::New (); // Add the points to the dataset polyData->SetPoints (points); polyLine->GetPointIds ()->SetNumberOfIds(points->GetNumberOfPoints ()); for(unsigned int i = 0; i < points->GetNumberOfPoints (); i++) polyLine->GetPointIds ()->SetId (i,i); cells->InsertNextCell (polyLine); // Add the lines to the dataset polyData->SetLines (cells); viewer->addModelFromPolyData (polyData,supervoxel_name); }

# The explanation

We start by defining convenience types in order not to clutter the code.

typedef pcl::PointXYZRGBA PointT;
typedef pcl::PointCloud<PointT> PointCloudT;
typedef pcl::PointNormal PointNT;
typedef pcl::PointCloud<PointNT> PointNCloudT;
typedef pcl::PointXYZL PointLT;
typedef pcl::PointCloud<PointLT> PointLCloudT;

Then we load the input cloud based on the input argument

  PointCloudT::Ptr cloud = boost::shared_ptr <PointCloudT> (new PointCloudT ());
{
return (1);
}

Next we check the input arguments and set default values. You can play with the various parameters to see how they affect the supervoxels, but briefly:

• --NT Disables the single-view transform (this is the default for unorganized clouds, only affects organized clouds)
• -v Sets the voxel size, which determines the leaf size of the underlying octree structure (in meters)
• -s Sets the seeding size, which determines how big the supervoxels will be (in meters)
• -c Sets the weight for color - how much color will influence the shape of the supervoxels
• -z Sets the weight for spatial term - higher values will result in supervoxels with very regular shapes (lower will result in supervoxels which follow normals and/or colors, but are not very regular)
• -n Sets the weight for normal - how much surface normals will influence the shape of the supervoxels
  bool disable_transform = pcl::console::find_switch (argc, argv, "--NT");

float voxel_resolution = 0.008f;
bool voxel_res_specified = pcl::console::find_switch (argc, argv, "-v");
if (voxel_res_specified)
pcl::console::parse (argc, argv, "-v", voxel_resolution);

float seed_resolution = 0.1f;
bool seed_res_specified = pcl::console::find_switch (argc, argv, "-s");
if (seed_res_specified)
pcl::console::parse (argc, argv, "-s", seed_resolution);

float color_importance = 0.2f;
if (pcl::console::find_switch (argc, argv, "-c"))
pcl::console::parse (argc, argv, "-c", color_importance);

float spatial_importance = 0.4f;
if (pcl::console::find_switch (argc, argv, "-z"))
pcl::console::parse (argc, argv, "-z", spatial_importance);

float normal_importance = 1.0f;
if (pcl::console::find_switch (argc, argv, "-n"))
pcl::console::parse (argc, argv, "-n", normal_importance);

We are now ready to setup the supervoxel clustering. We use the class :pcl:SupervoxelClustering <pcl::SupervoxelClustering>, which implements the clustering process and give it the parameters.

Important

By default, the algorithm will use a special transform compressing the depth in Z if your input cloud is organized (eg, from an RGBD sensor like the Kinect). You MUST set use_transform to false if you are using an organized cloud which doesn’t have the camera at (0,0,0) and depth in positive Z. The transform is specifically designed to help improve Kinect data by increasing voxel bin size as distance from the camera increases. If your cloud is unorganized, this transform will not be used by default, but can be enabled by using setUseSingleCameraTransform(true).

  pcl::SupervoxelClustering<PointT> super (voxel_resolution, seed_resolution);
if (disable_transform)
super.setUseSingleCameraTransform (false);
super.setInputCloud (cloud);
super.setColorImportance (color_importance);
super.setSpatialImportance (spatial_importance);
super.setNormalImportance (normal_importance);

Then we initialize the data structure which will be used to extract the supervoxels, and run the algorithm. The data structure is a map from labels to shared pointers of :pcl:Supervoxel <pcl::Supervoxel> templated on the input point type. Supervoxels have the following fields:

• normal_ The normal calculated for the voxels contained in the supervoxel
• centroid_ The centroid of the supervoxel - average voxel
• voxels_ A Pointcloud of the voxels in the supervoxel
• normals_ A Pointcloud of the normals for the points in the supervoxel
  std::map <uint32_t, pcl::Supervoxel<PointT>::Ptr > supervoxel_clusters;

pcl::console::print_highlight ("Extracting supervoxels!\n");
super.extract (supervoxel_clusters);
pcl::console::print_info ("Found %d supervoxels\n", supervoxel_clusters.size ());

We then load a viewer and use some of the getter functions of :pcl:SupervoxelClustering <pcl::SupervoxelClustering> to pull out clouds to display. voxel_centroid_cloud contains the voxel centroids coming out of the octree (basically the downsampled original cloud), and colored_voxel_cloud are the voxels colored according to their supervoxel labels (random colors). sv_normal_cloud contains a cloud of the supervoxel normals, but we don’t display it here so that the graph is visible.

  boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer (new pcl::visualization::PCLVisualizer ("3D Viewer"));
viewer->setBackgroundColor (0, 0, 0);

PointCloudT::Ptr voxel_centroid_cloud = super.getVoxelCentroidCloud ();
viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE,2.0, "voxel centroids");
viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_OPACITY,0.95, "voxel centroids");

PointLCloudT::Ptr labeled_voxel_cloud = super.getLabeledVoxelCloud ();
viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_OPACITY,0.8, "labeled voxels");

PointNCloudT::Ptr sv_normal_cloud = super.makeSupervoxelNormalCloud (supervoxel_clusters);
//We have this disabled so graph is easy to see, uncomment to see supervoxel normals

Finally, we extract the supervoxel adjacency list (in the form of a multimap of label adjacencies).

  pcl::console::print_highlight ("Getting supervoxel adjacency\n");

Then we iterate through the multimap, creating a point cloud of the centroids of each supervoxel’s neighbors.

  std::multimap<uint32_t,uint32_t>::iterator label_itr = supervoxel_adjacency.begin ();
for ( ; label_itr != supervoxel_adjacency.end (); )
{
//First get the label
uint32_t supervoxel_label = label_itr->first;
//Now get the supervoxel corresponding to the label
pcl::Supervoxel<PointT>::Ptr supervoxel = supervoxel_clusters.at (supervoxel_label);

//Now we need to iterate through the adjacent supervoxels and make a point cloud of them
{
}

Then we create a string label for the supervoxel graph we will draw and call addSupervoxelConnectionsToViewer, a drawing helper function implemented later in the tutorial code. The details of addSupervoxelConnectionsToViewer are beyond the scope of this tutorial, but all it does is draw a star polygon mesh of the supervoxel centroid to all of its neighbors centroids. We need to do this like this because adding individual lines using the addLine functionality of pcl_visualizer is too slow for large numbers of lines.

    //Now we make a name for this polygon
std::stringstream ss;
ss << "supervoxel_" << supervoxel_label;
//This function is shown below, but is beyond the scope of this tutorial - basically it just generates a "star" polygon mesh from the points given
//Move iterator forward to next label

This results in a supervoxel graph that looks like this for seed size of 0.1m (top) and 0.05m (middle). The bottom is the original cloud, given for reference.:

# Compiling and running the program

Create a CMakeLists.txt file with the following content (or download it here):

  1 2 3 4 5 6 7 8 9 10 11 12 cmake_minimum_required(VERSION 2.8 FATAL_ERROR) project(supervoxel_clustering) find_package(PCL 1.8 REQUIRED) include_directories(${PCL_INCLUDE_DIRS}) link_directories(${PCL_LIBRARY_DIRS}) add_definitions(${PCL_DEFINITIONS}) add_executable (supervoxel_clustering supervoxel_clustering.cpp) target_link_libraries (supervoxel_clustering${PCL_LIBRARIES})

After you have made the executable, you can run it like so, assuming the pcd file is in the same folder as the executable:

\$ ./supervoxel_clustering milk_cartoon_all_small_clorox.pcd --NT

Don’t be afraid to play around with the parameters (especially the seed size, -s) to see what happens. The pcd file name should always be the first parameter!


text:
1. If you are a new user, please register to get an Indico account through https://login.ihep.ac.cn/registIndico.jsp. Any questions, please email us at helpdesk@ihep.ac.cn or call 88236855.
2. The name of any uploaded file should be in English or plus numbers, not containing any Chinese or special characters.
3. If you need to create a conference in the "Conferences, Workshops and Events" zone, please email us at helpdesk@ihep.ac.cn.
PKU HEP Seminar and Workshop (北京大学高能物理组)

"Dark" Series Colloquium 5# A Unified Program of Argon Dark Matter Searches: DarkSide-20k and The Global Argon Dark Matter Collaboration

by Prof. Cristiano Cristiano (Princeton University)

Thursday, September 16, 2021 from to (Asia/Shanghai)
 Description Experimenters from four different argon dark matter searches have joined their forces in the the “Global Argon Dark Matter Collaboration” to carry out a unified program for dark matter direct detection. The participants are researchers currently working on the ArDM experiment at LSC; on the DarkSide-50 experiment at LNGS; on the DEAP-3600 experiment at SNOLab; and on the MiniCLEAN experiment at SNOLab. In 2015/2016 the DarkSide-50 experiment at LNGS produced two zero-background science results, along with a comparison of the results obtained with both atmospheric and underground argon fills, demonstrating the ability of large experiments to eliminate background from betas/gammas at the tens of tonne-year exposure. Early in 2018, the DarkSide Collaboration announced results from a 2-years campaign with DarkSide-50, resulting again in a zero-background, null observation of heavy (>50 GeV/c2) dark matter and in the best exclusion limits for light (<10 GeV/c2) dark matter. The DEAP-3600 experiment at SNOLAB is the first tonne-scale experiment to achieve both stable operations and an extended physics run. DEAP-3600 has been collecting physics data with over 3 tonnes of argon since late 2016 and published its first results in 2017. Researchers from the four experiments will jointly carry out as the single next step at the scale of a few tens of tonnes the DarkSide-20k experiment. DarkSide-20k was approved in 2017 by the Italian INFN, by the host laboratory LNGS, and by the US NSF. DarkSide-20k is also officially and jointly supported by the three underground laboratories LNGS, LSC, and SNOLab. DarkSide-20k is a 20-tonne fiducial volume dual-phase TPC to be operated at LNGS with an underground argon fill, designed to collect an exposure of 100 tonne×years, completely free of neutron-induced nuclear recoil background and all electron recoil background. DarkSide-20k is set to start operating by 2021 and will have sensitivity to WIMP-nucleon spin-independent cross sections of 7.4×10−48 cm2 for WIMPs of 1 TeV/c2 mass, to be achieved during a 10 year run with an exposure of 200 tonne×years. DarkSide-20k will explore the WIMP-nucleon cross-section down to the edge of the ’neutrino floor’, where coherent neutrino-nucleus scattering from environmental neutrinos induce nuclear recoils in the detector. A second step in the program is the construction and operation of Argo, a detector with a fiducial mass of a few hundred tonnes, capable of collecting an exposure of several thousands of tonne×years, completely free of all backgrounds on top of CNNS. This follow-up experiment would also be capable of performing a set of very high precision measurement of several solar neutrino sources (location and laboratory t.b.d.). This includes exquisitely precise measurements of pep, CNO, as well as low energy 8B neutrinos, all in the region of transition between the vacuum- and matter-dominated regions of solar neutrino oscillations. Zoom： https://zoom.com.cn/j/96357968034?pwd=K2REeGF0V2dqOElRd09hVGVRcDk4Zz09 or https://cern.zoom.us/j/96357968034?pwd=K2REeGF0V2dqOElRd09hVGVRcDk4Zz09 Meeting ID: 963 5796 8034 Password: 125125


text:
## Basic statistics

| categories: statistics | tags: | View Comments

Given several measurements of a single quantity, determine the average value of the measurements, the standard deviation of the measurements and the 95% confidence interval for the average.

This is a recipe for computing the confidence interval. The strategy is:

1. compute the average
2. Compute the standard deviation of your data
3. Define the confidence interval, e.g. 95% = 0.95
4. compute the student-t multiplier. This is a function of the confidence

interval you specify, and the number of data points you have minus 1. You subtract 1 because one degree of freedom is lost from calculating the average. The confidence interval is defined as ybar +- T_multiplier*std/sqrt(n).

import numpy as np
from scipy.stats.distributions import  t

y = [8.1, 8.0, 8.1]

ybar = np.mean(y)
s = np.std(y)

ci = 0.95
alpha = 1.0 - ci

n = len(y)
T_multiplier = t.ppf(1-alpha/2.0, n-1)

ci95 = T_multiplier * s / np.sqrt(n-1)

print [ybar - ci95, ybar + ci95]

[7.9232449090029595, 8.210088424330376]

We are 95% certain the next measurement will fall in the interval above.