text stringlengths 49 10.4k | source dict |
|---|---|
c#, algorithm, .net, pathfinding, a-star
public static Path Search(Vector2i start, Vector2i target)
{
Location current = null;
SortedSet<Location> openList = new SortedSet<Location>();
HashSet<Location> closedList = new HashSet<Location>();
Location targetLocation = new Location(target);
openList.Add(new Location(start));
while (openList.Any())
{
current = openList.First();
closedList.Add(current);
openList.Remove(current);
if (current.Equals(targetLocation))
{
return CreateResultPath(current);
}
List<Location> possibleNeighbors = GetPossibleNeighbors(current);
foreach (Location neighbor in possibleNeighbors)
{
// neighbor must not be in closedSet
if (!closedList.Contains(neighbor))
{
// calculating neighbor
neighbor.g = current.g + neighbor.weight;
neighbor.h = CalcDistance(neighbor.pos, target);
neighbor.f = neighbor.g + neighbor.h;
neighbor.parent = current;
openList.TryGetValue(neighbor, out Location oldNeighbor);
if (oldNeighbor == null)
{
openList.Add(neighbor);
}
// neighbor is already in openList, checking if this path is better
else
{
if (neighbor.g < oldNeighbor.g)
{
openList.Remove(oldNeighbor);
openList.Add(neighbor);
}
}
}
}
}
return null;
}
private static Path CreateResultPath(Location result)
{
List<Vector2i> resultPath = new List<Vector2i>();
while (result != null)
{
resultPath.Add(result.pos);
result = result.parent;
}
resultPath.Reverse();
return new Path(resultPath.ToArray());
} | {
"domain": "codereview.stackexchange",
"id": 37909,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "c#, algorithm, .net, pathfinding, a-star",
"url": null
} |
meteorology, geomorphology, climatology, atmospheric-circulation
Source Commons Wikipedia.
The cold waters near the ocean surface results in a cool, stable coastal atmosphere. In this region, evaporation from the ocean is reduced and produces extremely low rainfall over land. Precipitation is limited to morning fog and produces some of the driest ecosystems on Earth. The Atacama desert is the best example of such environment with average rainfalls of 15 mm/year (the driest non-polar region). In some areas, they are trying to take advantage of the little moisture the fog (Camanchaca) brings to establish some agricultural zones. The fog droplets are too small (1-40 micrometers) to form water drops and precipitate, so they use fog-catchers to collect moisture from the fog.
Source: newatlas.com | {
"domain": "earthscience.stackexchange",
"id": 1045,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "meteorology, geomorphology, climatology, atmospheric-circulation",
"url": null
} |
astrophysics, neutron-stars, binary-stars, pulsars, white-dwarfs
Title: Pulsar-white dwarf binary In the paper from Hulse & Taylor 1975 on the first discovery of a pulsar in a binary system, they conclude that the companion to the pulsar must be
a compact object, probably a neutron star or black hole. A white dwarf companion cannot be ruled out, but seems unlikely for evolutionary reasons.
My question is why is a white dwarf companion unlikely, given that we have observed pulsar-white dwarf binary systems (e.g. PSR J1141-6545). It is difficult to read the authors' minds. I think back in 1975 it would not have been appreciated the extent to which binary interactions can influence the evolution of compact binary systems. So probably the authors thought that this was a neutron star formed from the very recent core collapse of a massive star (and they were probably right).
If that were the case then it seems unlikely that the companion could be a white dwarf, since the progenitor of a white dwarf would have been of lower mass and should have lived much longer than the combined lifetime of the pulsar and its massive progenitor.
Indeed, the pulsar you mention in your question is similar to that presented by Hulse & Taylor in terms of its spin period and orbital period. However the origins are probably different.
In PSRJ1141-6545 it is likely that the white dwarf companion formed first but transfered lots of mass to a companion that then became massive enough to undergo core collapse and form a neutron star (Davies et al. 2002). So the pulsar could still be "young" but its progenitor actually lived longer than that of the white dwarf companion. I guess this possibility was not considered by Hulse & Taylor.
In PSRJ1915+16 it is likely that one neutron star formed first then the massive secondary underwent Roche lobe over flow and the orbit shrank. But the core of the secondary continues to the core collapse stage and the result is a close neutron star binary. | {
"domain": "physics.stackexchange",
"id": 29131,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "astrophysics, neutron-stars, binary-stars, pulsars, white-dwarfs",
"url": null
} |
imu, navigation, odometry, ros-kinetic, robot-localization
covariance: [2.807622030235894e-05, -2.058458623309457e-05, -3.3721156419156076e-06, 0.997407028604045, -0.010309577671119459, -0.017732141221179724, -0.00803798318175729, -0.0, -0.05422256478599025, 6.95230206988004e-310, 5e-324, 1.91256606e-316, 6.95236747896094e-310, 6.95235731875666e-310, 6.95235117641476e-310, 6.95241666970836e-310, 6.9523573187701e-310, -3.02085629259538e+94, 6.95235117641476e-310, 6.95230206988004e-310, 6.95230206988004e-310, 6.95230206988004e-310, 5e-324, 1.91256606e-316, 6.95236747896094e-310, 6.95236735079744e-310, 2e-323, 6.9523573187598e-310, 6.95235731876377e-310, 6.9523573187527e-310, 7.65732518758802e-207, 6.9523573187602e-310, 6.95235731875666e-310, 6.9523573187551e-310, 6.95230206987925e-310, 6.95230206988004e-310] | {
"domain": "robotics.stackexchange",
"id": 30510,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "imu, navigation, odometry, ros-kinetic, robot-localization",
"url": null
} |
ros, buiding-errors, ros-indigo
Originally posted by gvdhoorn with karma: 86574 on 2017-03-05
This answer was ACCEPTED on the original site
Post score: 0
Original comments
Comment by nbro on 2017-03-05:
PS: could you please tell us where / how you got the impression that there "aren't yet any binary distribution of ROS for most of the operating system", especially for Ubuntu?
It's easy enough to get that impression even from the fact that ROS indigo has only binaries for Ubuntu 14.04.
Comment by gvdhoorn on 2017-03-05:
I was specifically asking about Ubuntu. The OS for which binaries will be build and which will be supported (even through from-source builds) are documented in REP-003, and also listed in the table at the top of the installation instructions.
Comment by nbro on 2017-03-05:
I still don't know the difference between ROS distributions, i.e. between Indigo and Kinetic, and thus how I should choose one over the other, and why. I will try to read something about that, if there is any useful article around.
Comment by gvdhoorn on 2017-03-05:
I think that is pretty well explained on the Distributions page.
But isn't the first thing to do -- before installing any software -- to figure out which version you'd like to install?
Comment by gvdhoorn on 2017-03-05:\
ROS indigo has only binaries for Ubuntu 14.04. | {
"domain": "robotics.stackexchange",
"id": 27203,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "ros, buiding-errors, ros-indigo",
"url": null
} |
tensor-calculus, spinors
$$
\varepsilon^{\delta \beta }h_{(\alpha \beta )} =
$$
$$
= -\frac{1}{8}\varepsilon^{\delta \beta }\varepsilon^{\dot {\alpha } \dot {\beta } }\left( (\sigma^{\mu})_{\alpha \dot {\alpha}}(\sigma^{\nu})_{\beta \dot {\beta}} + (\sigma^{\mu})_{\beta \dot {\alpha}}(\sigma^{\nu})_{\alpha \dot {\beta}} - (\sigma^{\mu})_{\beta \dot {\beta}}(\sigma^{\nu})_{\alpha \dot {\alpha }} - (\sigma^{\mu})_{\alpha \dot {\beta}}(\sigma^{\nu})_{\beta \dot {\alpha }}\right)M_{\mu \nu}.
$$
For first and second terms, for example,
$$
\varepsilon^{\delta \beta }\varepsilon^{\dot {\alpha } \dot {\beta } }(\sigma^{\mu})_{\alpha \dot {\alpha}}(\sigma^{\nu})_{\beta \dot {\beta}} = (\sigma^{\mu} )_{\alpha \dot {\beta }}(\tilde {\sigma}^{\nu})^{\dot {\beta }\delta } = (\sigma^{\mu}\tilde {\sigma}^{\nu})_{\alpha}^{\quad {\delta}},
$$
$$ | {
"domain": "physics.stackexchange",
"id": 9190,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "tensor-calculus, spinors",
"url": null
} |
# Math Help - Prime/Maximal Ideals
1. ## Prime/Maximal Ideals
I'm working on prime an maximal ideals. My partner and I are studying for our final exam and got conflicting answers.
The question was to find all of the prime and maximal ideals of $\mathbb Z_7$. My answer was that because a finite integral domain is a field, the prime and maximal ideals coincide, but that there are no prime and maximal ideals for $\mathbb Z_7$.
As for $\mathbb Z_3 \times \mathbb Z_5$ , what are the prime and maximal ideals, and more importantly, how in the world do we know that we have found them all?
2. Originally Posted by DanielThrice
I'm working on prime an maximal ideals. My partner and I are studying for our final exam and got conflicting answers.
The question was to find all of the prime and maximal ideals of $\mathbb Z_7$. My answer was that because a finite integral domain is a field, the prime and maximal ideals coincide, but that there are no prime and maximal ideals for $\mathbb Z_7$.
Right, since $\mathbb{Z}_7$ is a field all is easy.
As for $\mathbb Z_3 \times \mathbb Z_5$ , what are the prime and maximal ideals, and more importantly, how in the world do we know that we have found them all?
You may be overthinking this. You can clearly check for example that $\mathbb{Z}_3\times\{0\}$ and $\{0\}\times\mathbb{Z}_5$ which are prime? Are they maximal? Well suppose that $\mathbb{Z}_3\times\{0\}\subset I\subseteq \mathbb{Z}_3\times\mathbb{Z}_5$ then check that $\pi_2\left(I\right)$ is an ideal and since $\mathbb{Z}_5$ is a field.....
etc. | {
"domain": "mathhelpforum.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9799765552017674,
"lm_q1q2_score": 0.8478993227328648,
"lm_q2_score": 0.8652240895276222,
"openwebmath_perplexity": 482.0558033931497,
"openwebmath_score": 0.7614648342132568,
"tags": null,
"url": "http://mathhelpforum.com/advanced-algebra/177193-prime-maximal-ideals.html"
} |
waves, definition, phase-velocity
Title: Phase Velocity Derivation I spend few hours trying to derive phase velocity of sinusoidal wave $$\cos(kx - \omega t).$$ I know that it must be equal to $\omega \over k$ but after banging my head for few hours and trying to find solution on internet I gave up. The wave equation is $z(x,t)= \cos(kx - \omega t)$ and a graph of the displacement of a particle from its equilibrium position $z$ against the position of the particle from an origin $x$ at a given time $t$ is shown below.
You can liken the graph to a photograph of the wave taken at one instant of time; it is called a wave profile.
The graph actually shows shows two such photographs (wave profiles) taken at a time $t$ and at a later time $t+\Delta t$.
By inspection of the movement of the peaks $A$ and $A'$, or the troughs $C$ and $C'$, or the positions of zero displacement $B$ and $B'$ etc, you can surmise that the wave is travelling in the positive x-direction.
The important thing is that the displacements of the particle at different times which you considering are the same; peak and peak, trough and trough etc.
So you have $z(x,t) = z(x+\Delta x , t + \Delta t)$ or $\cos(kx - \omega t) = \cos(k[x+\Delta x] - \omega [t+\Delta t])$ and a solution of this equation is $kx - \omega t = k[x+\Delta x] - \omega [t+\Delta t] \Rightarrow \dfrac {\Delta x}{\Delta t} = \dfrac {\omega}{k}$ and this is called the phase velocity. | {
"domain": "physics.stackexchange",
"id": 54297,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "waves, definition, phase-velocity",
"url": null
} |
neural-network, weight-initialization
Title: Result of uniform weight initialization in all neurons Background
cs231n has the question regarding how to initialize weights.
Question
Please confirm or correct my understandings. I think the weight value will be the same in all the neurons with ReLU activation.
When W = 0 or less in all neurons, the gradient update on W is 0. So W will stay 0. When W = 1 (or any constant), the gradient update on W is the same value in all neurons. So W will be changing but the same in all neurons. When the weight is the same, o/p will be the same for all the Neurons in every Layer.
$\hspace{3cm}$
Hence, during backpropagation, all the Neurons in a particular layer will get the same Gradient portion. So, the weight will change by the same amount.
But, the very first layer (connected to input Features) will work normally as its input is the actual Features itself which is different always. | {
"domain": "datascience.stackexchange",
"id": 9041,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "neural-network, weight-initialization",
"url": null
} |
of "fictitious" temperatures which are outside the problem area. Math 201 Lecture 32: Heat Equations with Neumann Boundary Con-ditions Mar. INTRODUCTION ecently, new analytical methods have gained the interest of researchers for finding approximate solutions to partial differential equations. Dhumal and S. Math 201 Lecture 33: Heat Equations with Nonhomogeneous Boundary Conditions Mar. oT solve Richard's equation it is necessary to specify initial and boundary conditions. In this paper the problem of driving the state of a network of identical agents, modeled by boundary-controlled heat equations, towards a common steady-state profile is. The methods developed in this report worked well for the nonlocal boundary value problem with Neumann's boundary conditions. The following is a simple example of use of the Conduction application mode and the Convection and Conduction application mode in the Chemical Engineering Module. The Neumann boundary condition is a type of boundary condition, named after Carl Neumann (1832 - 1925, figure 3) $$^3$$. We either impose q bnd nˆ = 0 or T test = 0 on Dirichlet boundary conditions, so the last term in equation (2) drops out. The initial conditions are that the temperature is 1. (To simplify things we have ignored any time dependence in ρ. Welcome to Part 2 of my Computational Fluid Dynamics (CFD) fundamentals course! In this course, the concepts, derivations and examples from Part 1 are extended to look at 2D simulations, wall functions (U+, y+ and y*) and Dirichlet and Neumann boundary conditions. Purnaras; Singular regularization of operator equations in L1 spaces via fractional differential equations, Vol. That is, we need to find functions X. We will omit discussion of this issue here. Lecture 04: Heat Conduction Equation and Different Types of Boundary Conditions - Duration: 43:33. 2c) and boundary conditions. Specified Flux: In this case the flux per area, (q/A) n, across (normal to) the boundary is specified. Numerical solution of partial di erential equations Dr. Modelling with Boundary Conditions¶ We use the preceding example (Poisson equation on the unit square) but want to specify different boundary conditions on the four sides. We re-visit the moving domain problem considered in the previous example and solve it with a combination of spatial and temporal adaptivity. 2d Heat Equation Separation Of Variables. First Problem: Slab/Convection. Demonstrations | {
"domain": "auit.pw",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9886682478041813,
"lm_q1q2_score": 0.8128722891905571,
"lm_q2_score": 0.8221891327004133,
"openwebmath_perplexity": 666.6580393036137,
"openwebmath_score": 0.8180767297744751,
"tags": null,
"url": "http://qxvy.auit.pw/2d-heat-equation-neumann-boundary-conditions.html"
} |
machine-learning, neural-network, keras
Title: Very low Neural Network Accuracy for Titanic Survival Problem I am new to neural networks and have done a few projects but have got very low accuracy for all of them. I have included the code for titanic NN code here. Am I missing something or what? Can you help me with this?
'''
import numpy as np
import pandas as pd
train=pd.read_csv(r'E:\Learning Python\Kaggle Competition\TItanic\Dataset\train.csv')
test=pd.read_csv(r'E:\Learning Python\Kaggle Competition\TItanic\Dataset\test.csv')
train.head()
train.iloc[[60]]
train.info()
train.describe()
train.drop(['Name','Ticket','Cabin', 'PassengerId'], axis=1, inplace=True)
categorical_cols=[]
numeric_cols=[]
for col in train.columns:
if train[col].dtype=='object':
categorical_cols.append(col)
else:
numeric_cols.append(col)
print(categorical_cols)
print(numeric_cols)
for col in categorical_cols:
print(train[col].unique())
train['Survived'].unique()
train.isna().sum()
train.describe()
### Handling Missing Values
train['Age']=train['Age'].fillna(train['Age'].median())
train=train[~train['Embarked'].isna()]
train=train[~train['Survived'].isna()]
for col in categorical_cols:
train[col]=train[col].astype('category')
train.dtypes
### Encoding Categorical Values
categorical_cols
for col in categorical_cols:
print(train[col].unique())
print(train[col].isna().sum())
from sklearn.preprocessing import OneHotEncoder
ohe=OneHotEncoder(drop='first') | {
"domain": "datascience.stackexchange",
"id": 11821,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "machine-learning, neural-network, keras",
"url": null
} |
javascript, ecmascript-6, compression
The draw function is a bit long and difficult to read. You can make it much nicer by typing HTML markup directly instead of large numbers of setAttribute calls. (You wouldn't do this when you might be concatenating untrusted input, but it's fine when you know exactly what sort of things are being interpolated.) You can do it like this:
const lineHTML = `
<line
x1=${x + 25}
y1=${y + 50}
x2=${x + (i - 0.5) * space + 25}
y2=${y + 100}
strike-width=2
stroke=black
></line>
`;
tree.insertAdjacentHTML('beforeend', lineHTML);
You can follow the same pattern in the various places where you have to create elements with lots of attributes.
There are lots of other improvements that can be made, but this should be a good start.
You should strongly consider using a linter which will automatically prompt you to fix many of these potential mistakes/code smells.
Live demo of the mostly-fixed code:
'use strict';
let maxX, maxY, minX, maximumDepth;
const constructLettersObj = (inputString) => {
const lettersObj = {};
for (const char of inputString) {
if (!lettersObj[char]) {
lettersObj[char] = {
frequency: 0,
hasBeenUsed: false,
childrenNodes: [],
};
}
lettersObj[char].frequency++;
}
for (const letterObj of Object.values(lettersObj)) {
letterObj.probability = letterObj.frequency / inputString.length;
}
return lettersObj;
}; | {
"domain": "codereview.stackexchange",
"id": 38257,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "javascript, ecmascript-6, compression",
"url": null
} |
homework-and-exercises, kinematics, calculus
Title: How are the SUVAT equations derived? I hope everyone is doing well and staying safe. So instead of simply memorizing the SUVAT equations, I wanted to find out how the equations are derived to broaden my knowledge. I'm currently a high school student who is completing university-level mathematics and somehow ended up doing questions on SUVAT and constant accelerations (haha). Are there any mnemonics or easy way to memorize/understand the equations. Regardless, I am very keen to know how the SUVAT equations are derived. If the acceleration $a$ is constant, then from the calculus definition of acceleration as the time derivative of velocity
$$\frac{dv}{dt} = a$$
we see that integrating the left-hand side with respect to $t$ gives
$$\int_0^t \frac{dv}{dt} dt = \int_{v(0)}^{v(t)} dv = v(t) - v(0) = v - u,$$
where we set the initial time as $t = 0$ and initial velocity as $v(0) = u$, while on the right-hand side we have
$$\int_0^t a dt = a \int_0^t dt = at$$
so
$$v = u + at.$$
This is the first equation. Using the definition of velocity as the time derivative of position
$$
\frac{dx}{dt} = v$$
we see that integrating the left-hand side gives
$$ \int_0^t \frac{dx}{dt} dt = \int_{x(0)}^{x(t)} dx = x(t) - x(0) = s(t)$$
where we set $s(t) = x(t) - x(0)$ as the displacement, and integrating the right-hand side gives
$$
\int_0^t v(t) dt = \int_0^t [u + at] dt = u t + \frac{1}{2} at^2$$
so that
$$s(t) = u t + \frac{1}{2} at^2.$$ | {
"domain": "physics.stackexchange",
"id": 71264,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "homework-and-exercises, kinematics, calculus",
"url": null
} |
python, parsing, bioinformatics
# One or more lines of quality data, containing the same
# number of characters as the sequence data.
quality = []
n = sum(map(len, sequence))
while n > 0:
line = next(lines)
m = quality_re.match(line)
if not m:
raise line.error("Expected <quality> but found:")
n -= len(m.group(0))
if n < 0:
raise line.error("<quality> is longer than <sequence>:")
quality.append(m.group(0))
yield seqname, ''.join(sequence), ''.join(quality)
except StopIteration:
raise line.error("End of input before sequence was complete:") | {
"domain": "codereview.stackexchange",
"id": 4812,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "python, parsing, bioinformatics",
"url": null
} |
pca
Title: Performing PCA for the samples and for the genes I have 10 samples from a RNAseq experiment (5 control, 5 disease), I have performed a cluster analysis for the samples and for the genes (4000 genes aprox) to see how they cluster (to see which samples are similar and which genes have similar expressions).
I was wondering if in terms of statistics it makes any sense to perform a PCA of the samples instead of the genes?
thank you in advance! First of all, I am not a statistician but have been performing RNA-seq analysis for a while, here is my take:
I think performing PCA on the samples makes sense in terms of mathematics. What I mean is you can compute eigenvectors and subsequently principal components either on your genes or on your samples.
I don't think performing PCA on the samples makes sense in terms of statistics in RNA-seq context (and probably in any other context): Your genes (features) describe your samples and not the other way around. So the computed PCs should describe/explain your samples and not the other way around. You would not perform PCA on your samples (individual cells in scRNA-seq) even in the case of scRNA-seq, where number of samples sometimes exceeds the number of genes, there PCA is performed on genes and the resulting few PCs are used for downstream analysis, usually clustering and visualization, both used to infer about samples (cells). | {
"domain": "bioinformatics.stackexchange",
"id": 1592,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "pca",
"url": null
} |
If $S$ is real, symmetric and positive definite, consider its eigenvalue / eigenvector decomposition $S = X \Lambda X^T$ where $\Lambda$ is diagonal and $X$ is orthogonal. Because $S$ is positive definite, $\Lambda_{ii} > 0$ for all $i$. The unique symmetric and positive definite square root of $S$ is given by $S^{1/2} = X \Lambda^{1/2} X^T$, where $\Lambda^{1/2}$ is the diagonal matrix with the $\sqrt{\Lambda_{ii}}$ on its diagonal. Indeed, $$S^{1/2} S^{1/2} = X \Lambda^{1/2} X^T X \Lambda^{1/2} X^T = X \Lambda X^T = S,$$ because $X^T X = I$. So $S^{1/2}$ is indeed real.
• yes you're right it mostly depends on the eigenvalues. thanks Feb 25, 2013 at 2:48
• Actually if a matrix has at least one negative part eigenvalue then it won't have a real square root but for the case of positive semidefinite matrices all eigenvalues are positive hence real square root. Feb 25, 2013 at 2:51
• -1 What does this answer show at all? That the unique symmetric and positive definite square root is real. But "symmetric positive definite" implies real by definition, so this is no news (however, no news is good news). Also this fact was already stated as well known in the question. Apr 4, 2013 at 5:15 | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9683812327313545,
"lm_q1q2_score": 0.8090665795703942,
"lm_q2_score": 0.8354835391516133,
"openwebmath_perplexity": 152.0680003525417,
"openwebmath_score": 0.9148877263069153,
"tags": null,
"url": "https://math.stackexchange.com/questions/313564/square-root-of-a-real-matrix"
} |
c++, reinventing-the-wheel, c++17, stl
// assignment
template <class U>
using conv_ass =
std::enable_if_t<!std::is_same_v<optional<T>, std::decay_t<U>> &&
!(std::is_scalar_v<T> &&
std::is_same_v<T, std::decay_t<U>>) &&
std::is_constructible_v<T, U> &&
std::is_assignable_v<T&, U>, int>;
template <class U>
static constexpr bool conv_ass_common = conv_common<U> &&
!std::is_assignable_v<T&, optional<U>& > &&
!std::is_assignable_v<T&, const optional<U>& > &&
!std::is_assignable_v<T&, optional<U>&&> &&
!std::is_assignable_v<T&, const optional<U>&&>;
template <class U>
using copy_conv_ass =
std::enable_if_t<conv_ass_common<U> &&
std::is_constructible_v<T, const U&> &&
std::is_assignable_v<T&, const U&>, int>;
template <class U>
using move_conv_ass =
std::enable_if_t<conv_ass_common<U> &&
std::is_constructible_v<T, U> &&
std::is_assignable_v<T&, U>, int>;
// emplace
template <class U, class... Args>
using emplace_ilist =
std::enable_if_t<
std::is_constructible_v<T, std::initializer_list<U>, Args...>
, int>;
}; | {
"domain": "codereview.stackexchange",
"id": 35531,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "c++, reinventing-the-wheel, c++17, stl",
"url": null
} |
# Place $8$ rooks on a $10\times 10$ board.
The Problem:-
"In chess, a rook attacks any piece in the same row or column as the rook, provided no other piece is between them. In how many ways can $8$ rooks be placed on a $[8\times8]$ chessboard so that no two attack each other? What about $8$ rooks on a $10\times10$ board?"
I believe I have an answer for the first part of the question. When placing the first rook, there are 8 places on any particular column (or row) to place the rook, leaving just 7 places on a different column (or row) for the next rook, and so on, providing 8! possible ways to place the rooks in such a way that they cannot attack each other ($P(8,8) = 8!/(8-8)! = 8!$).
However, I am not sure I fully understand how this would work for a board where there are more rows and columns than pieces (such as on a 10x10 board). Does it become $P(10,8) = 10!/(10-8)! = 10!/2$ ? If so, why? If not, how should I approach this problem?
This problem was found in "Introduction to Combinatorics and Graph Theory" by David Guichard.
• Only one rook can go on each row and on each column. If there are two more rows and columns there are two rows and two columns with no rooks on them. just declare at the begininning that there will be 2 rows which won't be used. There are ${10 \choose 2}$ ways of doing that and ${10 \choose 2}$ ways of choosing the columns. So there are ${10\choose 2}^2 *D$ ways of doing this if $D$ is the number of ways to do it on an 8x8 board. – fleablood Nov 7 '17 at 18:45
So for the first question you need to place a rook in each column. The rook in the first column can go in $8$ places, the rook in the second column then has $7$ possible rows etc. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9814534382002797,
"lm_q1q2_score": 0.870749995963654,
"lm_q2_score": 0.8872045907347108,
"openwebmath_perplexity": 267.94312834352047,
"openwebmath_score": 0.6897656917572021,
"tags": null,
"url": "https://math.stackexchange.com/questions/2509485/place-8-rooks-on-a-10-times-10-board/2509519"
} |
error-handling, r
The intent is to be able to handle some errors perhaps differently (most likely in side-effect) but not necessarily catch all errors.
I'm particularly interested in these questions:
context of evaluating expr: I believe quote(eval(expr, envir = parentenv)) is sufficient for ensuring no surprises with namespace and search path, am I missing something?
context of the error: it would be ideal if traceback() of a not-caught error did not originate in myerror, is there a better way to re-throw the error with (or closer to) the original stack?
similarly handle warnings: I have another version of this that adds warnings in the same way, so it uses withCallingHandlers and conditional use of invokeRestart("muffleWarning"). The premise is that some warnings I don't care about (I might otherwise use suppressWarnings), some I want to log, and some indicate problems (that could also turn into errors with options(warn=2)). In developing shiny apps, I often use something like this (with a logger::log_* call instead of cat):
withCallingHandlers({
warning("foo")
99
}, warning = function(w) {
cat("caught:", conditionMessage(w), "\n")
invokeRestart("muffleWarning")
})
# caught: foo
# [1] 99
where it might be nice to "muffle" some warnings and not others. warning typically includes where the warning originated. Similar to the previous bullet, is there a way with warning to preserve (re-use) the original context?
assumptions: am I making an egregious false assumption in the code?
I think your evaluation context is correct; and yes, it’s convoluted. In particular it impacts your second point; and …
… unfortunately I’m not aware of a way to improve this. You can manually modify the stack trace by editing the base::.Traceback variable (!). However, this must happen after stop is called so I don’t think it’s helpful here.
Same answer.
I think your assumptions are sound. | {
"domain": "codereview.stackexchange",
"id": 35599,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "error-handling, r",
"url": null
} |
slam, navigation, odometry, realsense, robot-localization
Original comments
Comment by Marcus Barnet on 2016-08-28:
@matlabbe, thanks for your suggestions. I fixed the /tf problem and everything is OK since I checked all the frames under RVIZ and /laser and realsense_frame are aligned. This is a compressed bag file.
Comment by Marcus Barnet on 2016-08-28:
This is the control.launch file without /vo. The bag file includes the /tf topic since it is more easy for me to display it under RVIZ. Can you tell me if it is OK now and if it can be used with RTAB to obtain a 2D map and the projected 3d view, please?
Comment by Marcus Barnet on 2016-08-28:
I deleted the RTAB from control.launch file, but now the /odometry/filtered will not contain also the visual odometry. This can still be OK for what I would like to do? I mean, something like your demo.
Comment by Marcus Barnet on 2016-08-28:
The compressed bag file will be available in 30 minutes starting from now. It is in upload right now.
Comment by Marcus Barnet on 2016-08-28:
Now the file has been correctly uploaded.
Comment by Marcus Barnet on 2016-08-29:
@matlabbe: I tried to run your launch file, but I'm not able to build a map since RVIZ says me that: no map is received. If I set base_footprint or /odom as fixed frame, I can see the robot moving around, but no map. Do I have to run some other launch file, too?
Comment by Marcus Barnet on 2016-08-29:
I can select grid_map, cloud_map, mapData and mapGraph in RVIZ, but it always says that no map is received. In my TF frames, there is no map reference. It seems that no map is created. How this can be possible? Do you launch some other file in addition to your test.launch?
Comment by matlabbe on 2016-08-29:
Make sure light-tf-ok.bag is decompressed: $ rosbag decompress light-tf-ok.bag. It is only test.launch running.
Comment by Marcus Barnet on 2016-08-29: | {
"domain": "robotics.stackexchange",
"id": 25617,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "slam, navigation, odometry, realsense, robot-localization",
"url": null
} |
c#, performance, algorithm, linq
Title: Finding the minimum difference in a list of numbers I have written following code to find the minimum difference from a list of numbers.
Because I am using a loop once and LINQ again to find the minimum, the algorithm is O(N2).
Can you please tell me if I am using the framework in the most optimal way (speed and memory utilisation) to achieve this task:
using (StreamReader sr = new StreamReader("IN.in"))
using (StreamWriter sw = new StreamWriter("OUT.out"))
{
int T = int.Parse(sr.ReadLine());
for (int i = 1; i <= T; i++)
{
int N = int.Parse(sr.ReadLine());
List<int> intList = sr.ReadLine().Split(' ').Select(e => int.Parse(e)).ToList();
intList.Sort();
List<int> diff = new List<int>();
int leastDiff = int.MaxValue;
for (int k = 0; k < intList.Count - 1; k++)
{
int iDiff = intList[k + 1] - intList[k];
diff.Add(iDiff);
leastDiff = Math.Min(leastDiff, iDiff);
}
sw.WriteLine(leastDiff);
}
}
Benchmark
For 3 test case of 5 integers in each list where as for loop implementation takes 55±5 ms. Mr.Mindor LINQ implementation timing varies from 60±50 ms. Memory usage in both implementation is almost 8.3MB You're worrying about the wrong problems: there isn't a lot more performance to be squeezed out of your code, but you could make substantial improvements to readability. | {
"domain": "codereview.stackexchange",
"id": 2379,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "c#, performance, algorithm, linq",
"url": null
} |
windows, batch
Echo On
:warn_and_exit
echo Machine OS cannot be determined.
cls
pause
goto Control_Center
: Enable_legacy_Mode
bcdedit /set {default} bootmenupolicy legacy
pause
cls
goto Control_Center
: Smart_Status
wmic diskdrive get status
pause
cls
goto Control_Center
: Admin_Account
@echo off
SET /P ANSWER=What state do you want the admin account? (E) Enabled or (D) Disabled ...
echo You chose: %ANSWER%
if /i {%ANSWER%}=={E} (goto :Enable_Admin)
if /i {%ANSWER%}=={D} (goto :Disable_Admin)
:Enable_Admin
net user administrator /active:yes
Pause
cls
goto Control_Center
:Disable_Admin
net user administrator /active:no
Pause
cls
goto Control_Center
: UAC
mode con: cols=86 lines=38
color 9F&prompt $v
cls
echo.
echo.
echo.
echo.
echo User Account Controls
echo.
echo.
echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
echo º º
echo º º
echo º Please Make a Choice By typing the corresponding number... º
echo º º
echo º º
echo º 1. Turn Off UAC º
echo º 2. Turn on UAC º
echo º 3. Open UAC º
echo º 0. Cancel º
echo º º
echo º º
echo º º
Echo ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
echo.
echo.
echo.
set /p option= Enter Choice.....
echo.
echo.
if %option%==1 goto Turn_Off_UAC
if %option%==2 goto Turn_On_UAC
if %option%==3 goto Open_UAC
if %option%==0 goto Cancel
ECHO.
ECHO "%choice%" is not valid...please try again
pause
cls
goto UAC
: Open_UAC
C:\Windows\System32\UserAccountControlSettings.exe
pause
cls
goto UAC | {
"domain": "codereview.stackexchange",
"id": 11064,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "windows, batch",
"url": null
} |
C15 Working within the vector space {ℂ}^{3}, determine if b = \left [\array{ 4\cr 3 \cr 1 } \right ] is in the subspace W,
W = \left \langle \left \{\left [\array{ 3\cr 2 \cr 3 } \right ],\left [\array{ 1\cr 0 \cr 3 } \right ],\left [\array{ 1\cr 1 \cr 0 } \right ],\left [\array{ 2\cr 1 \cr 3 } \right ]\right \}\right \rangle
Contributed by Chris Black Solution [930]
C16 Working within the vector space {ℂ}^{4}, determine if b = \left [\array{ 1\cr 1 \cr 0\cr 1 } \right ] is in the subspace W,
W = \left \langle \left \{\left [\array{ 1\cr 2 \cr −1\cr 1 } \right ],\left [\array{ 1\cr 0 \cr 3\cr 1 } \right ],\left [\array{ 2\cr 1 \cr 1\cr 2 } \right ]\right \}\right \rangle
Contributed by Chris Black Solution [930]
C17 Working within the vector space {ℂ}^{4}, determine if b = \left [\array{ 2\cr 1 \cr 2\cr 1 } \right ] is in the subspace W,
W = \left \langle \left \{\left [\array{ 1\cr 2 \cr 0\cr 2 } \right ],\left [\array{ 1\cr 0 \cr 3\cr 1 } \right ],\left [\array{ 0\cr 1 \cr 0\cr 2 } \right ],\left [\array{ 1\cr 1 \cr 2\cr 0 } \right ]\right \}\right \rangle
Contributed by Chris Black Solution [931]
C20 Working within the vector space {P}_{3} of polynomials of degree 3 or less, determine if p(x) = {x}^{3} + 6x + 4 is in the subspace W below. | {
"domain": "ups.edu",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9912886163143679,
"lm_q1q2_score": 0.8081306774443168,
"lm_q2_score": 0.8152324803738429,
"openwebmath_perplexity": 1830.3624001576297,
"openwebmath_score": 0.9782329797744751,
"tags": null,
"url": "http://linear.ups.edu/jsmath/0230/fcla-jsmath-2.30li38.html"
} |
electrostatics, dipole, multipole-expansion
My answer is 0.223(rounded off from 0.222...) but the professor says that the answer is 0.125! To obtain my answer I directly used the formula of electric field of a point charge and superposition principle. But the professor says that since the monopole term of this charge distribution is zero, the question cannot be solved using two monopoles(like I did) but from the formula of field of a dipole, because the monopole term won't contribute to the field.
Is this correct? I mean, his argument is certainly correct but my method seems right too! I guess that the professor is using the wrong formula for a dipole's field. The most correct formula is after all from the multipole expansion with the monopole term neglected. But he uses the formula $\overrightarrow{E}(\overrightarrow{r})=-\nabla(\frac{1}{4\pi\epsilon_0}\frac{\overrightarrow{p}\cdot\hat{r}}{r^2})$, which is true only for an ideal point dipole, which does not apply to our dipole.
So which is correct: n=0.222... or 0.125? You are correct; this is almost a textbook example of a situation where superposition is appropriate. The dipole formula assumes that $x \gg 2x_0$, and if the question asked for the field at $x = 20x_0$ instead, your answers would be nearly the same. | {
"domain": "physics.stackexchange",
"id": 76407,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "electrostatics, dipole, multipole-expansion",
"url": null
} |
python, scikit-learn, distance, scipy
I'm not looking for a high level explanation but an example of how the numbers are calculated. Y = pdist(X, 'correlation')
Computes the correlation distance between vectors u and v. This is
$$ 1-\frac{(u-\overline{u})\dot{}(v-\overline{v})}{||u-\overline{u}||_2*||v-\overline{v}||_2} $$
where $\overline{u}$ is the mean of the elements of vector $u$, and $x\dot{}y$ is the dot product of $x$ and $y$.
The correlation between any vector which have ONLY TWO entries is always 0 (or nearly zero: $2*10^-16$), why? Because correlation distance measures the distance as the linearity between the data.
When I have [1,2] and [1,2] the equation $y=x$ fits perfectly, when I have [1,2] and [1,3] the equation $y=x+1$ also fits perfectly. The correlation distance says wheter a equation can be drawn for the data, in both cases the equation is perfect.
If you want to try getting a different result, try putting 2 vectors of three elements, and you will see changes.
Try with: [[1,2],[2,3],[3,4]] and [[1,4],[3,8],[-5,6]]. But first, plot them and you will comprehen what 'correlation' measures. | {
"domain": "datascience.stackexchange",
"id": 4996,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "python, scikit-learn, distance, scipy",
"url": null
} |
quantum-mechanics, quantum-information, quantum-entanglement, bells-inequality
These two definitions are not equivalent: the condition in definition 1 implies the condition in definition 2, but not conversely. Separability relates to definition 1. Discord relates to definition 2.
Separability and definition 1
Consider a given factorization of the Hilbert space, ${\cal H}={\cal H}_A\otimes{\cal H}_B$. A mixed state $\rho$ is called separable whenever it can be written as a weighted sum of separable pure states,
$$
\newcommand{\la}{\langle}
\newcommand{\ra}{\rangle}
\rho = \sum_{s} w_s |s\ra\,\la s|
\tag{1a}
$$
with
$$
|s\ra = |s_A\ra\otimes |s_B\ra.
\tag{1b}
$$
The first subsystem's states $|s_A\ra$ don't have to be mutually orthogonal, nor do the second subsystem's states $|s_B\ra$.
A state of the form (1) satisfies
$$
\text{trace}(\rho\, X\otimes Y) = \sum_{s} w_s
\la s_A|X|s_A\ra\,\la s_B|Y|s_B\ra.
\tag{2}
$$
Equation (2) can be used to construct a local hidden variables model for all quantities of the form $\text{trace}(\rho\, X\otimes Y)$, so separable states don't have non-classical correlations in the sense of definition 1.
Discord and definition 2
The precise definition of discord is a little complicated. To keep this answer short(er), instead of reviewing the precise definition, I'll quote a result that relates it to definition 2. | {
"domain": "physics.stackexchange",
"id": 66163,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "quantum-mechanics, quantum-information, quantum-entanglement, bells-inequality",
"url": null
} |
thermodynamics
$$ S = -\partial_T F, $$
with the free energy $F$. But in this ensemble the temperature is not defined in the way above, but is a property of the heat bath.
Note, that you already confuse the setting in your question, by assuming the single molecule has a temperature a priori (by defining its internal energy to be $U = \frac 1 2 kT$), this is the setting of the canonical ensemble this internal energy is actually the average value of the internal energy of the system, where the average is taken over the ensemble of systems. If you just had a single molecule in a tight box the internal energy would, in contrast, be a specific value, which is, as described above, not connected with a well defined temperature. | {
"domain": "physics.stackexchange",
"id": 26861,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "thermodynamics",
"url": null
} |
homework-and-exercises, newtonian-mechanics, classical-mechanics, lagrangian-formalism
First, assume the $x$ coordinate of the ball of mass $m$. Initially, it's at $x=0$, under the influence of Gravity it should fall (assuming the setup is in such a way that Gravity is acting from downwards.)
So, the cool equation says that :
$$\displaystyle{\boxed{\boxed{ \dfrac{d}{dt} \left ( \dfrac{\partial L}{\partial {x'} } \right) - \dfrac{\partial L}{\partial x} = 0 }} \quad \dots \quad (*)}$$
Where, $L = K.E. - P.E. = ( mg \sin \theta x) - (mg \sin \theta h)\quad \dots \quad (1)$
However using the Euler-Lagrange equation (*) with the Lagrangian (1) does not give me a sensible answer, so my question is where is my mistake?
So, I've calculated K.E. here as: $K = \frac 1 2 m v^2 = \frac 1 2 m (2(g \sin \theta) x) \quad \dots \quad (\text{As }v^2 = u^2 + 2as)$
and $P = mgh = mg\sin \theta(h - x )$
The issue might be to do with using $v^2=2as$ in the kinetic energy (as suggested in comments) but I don't see why this is improper.
So, Why I can't substitute the Velocity equations in that Lagrangian Equation (That Kinetic energy part).
OP's calculation (v7) violates the rule is that one is not allowed to use equations of motion in the Lagrangian $L(q,v,t)$ before all differentiations in Lagrange equations have been carried out. This is mainly because generalized positions $q^i$, generalized velocities $v^j$, and time $t$ are independent variables in the Lagrangian $L(q,v,t)$, cf. e.g. this Phys.SE post. | {
"domain": "physics.stackexchange",
"id": 57092,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "homework-and-exercises, newtonian-mechanics, classical-mechanics, lagrangian-formalism",
"url": null
} |
Proof: We have ##(f-g)'=0## and by your claim ##f-g## is constant. ##\quad \square##
Alright, let's see how this helps.
First, you have ##0'=0=f''=(f')'## so by the claim there is a constant ##a## such that ##f'=a##. Note that for all ##x\in I## we have ##(ax)'= a =f'(x)## so applying the claim a second time, you get that there is a constant b such that ##ax+b=f(x)## for all ##x\in I##.
You can do the other question by applying this claim three times. Let me know what you get.
EDIT: basically, the exercise is a good preparation for what you will see soon: indefinite integration.
Proof: We have ##f''' = 0'''##. So, there exists ##f'' = 2a## for some ##2a \in \mathbb{R}##. Now, ##f'' - (2ax)' = 0##. So there exists ##b \in \mathbb{R}## such that ##f' - 2ax = b## i.e. ##f' - 2ax - b = 0##. Now, ##(ax^2 + bx)' = 2ax + b##. So, ##f' - (ax^2 + bx)' = 0##. Thus, there exists ##c \in \mathbb{R}## such that ##f - (ax^2 + bx) = c##. This can be rewritten as ##f(x) = ax^2 + bx + c##. ## \square## | {
"domain": "physicsforums.com",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9664104982195785,
"lm_q1q2_score": 0.8271035315658206,
"lm_q2_score": 0.8558511451289037,
"openwebmath_perplexity": 4253.385735719792,
"openwebmath_score": 0.9974551200866699,
"tags": null,
"url": "https://www.physicsforums.com/threads/mean-value-theorem.982268/"
} |
transformer
Title: Are transformer decoder predictions computed in parallel during training? I've been studying the transformer from the original "Attention is all you need" paper and from various other sources. I have a question about the behaviour of the decoder during training that I cannot find the answer to anywhere.
During inference I understand that the decoder input is its own previously generated token from the prior time step. Tokens are fed into the decoder one-by-one and predictions made one-by-one.
However, during training the target sequence is known and I have read from several sources that the entire sequence is used as the decoder input to allow parallel processing and to improve training efficiency. To keep the decoder autoregressive, a masked attention sub-layer is introduced where a masking matrix is added to the scaled dot product attention mechanism.
So my question is, since during training the decoder input is the entire sequence, is the entire output sequence predicted in parallel (simultaneously), or are tokens predicted one-by-one, as in inference?
To me it makes sense that if the entire target sequence is used as the decoder input, then an entire sequence is output. If it wasn't, the decoder would be using the same input at every timestep whilst being expected to produce different tokens. In short, masking is just sequence padding in the decoder!
I'll try to slightly rephrase your question first to ensure I properly understood it. You are confused about:
The transformer is fed the whole sequence (during training) for efficiency,
But it needs to be autoregressive so it cannot look at the whole sequence,
So, how can it look at the whole sequence and not look at the whole sequence at the same time? | {
"domain": "ai.stackexchange",
"id": 3777,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "transformer",
"url": null
} |
newtonian-mechanics, angular-momentum, energy-conservation, conservation-laws
Title: Is angular momentum and mechanical energy is conserved or not A ball is aatached to a string that is attached to a pole . when the ball is hit, the string wraps around the pole and the ball spiral inwards sliding on frictionless surface . Neglecting air resistance .
I think mechanical energy is conservesd as there is no friction and I also think that angular momrntum about centre of pole is conserved when ball swings around the pole .
But in my book it is written as angular momentum about centre of pole is notconserved when ball swings around the pole .
I could not understand this . You need to consider the following given that the force on the ball is due to the tension in the string.
Does the ball have a component of its displacement in the direction of the tension in the string?
If it does then work is done on the ball and so the ball's kinetic energy is not constant whilst if not then no work is done on the ball and then kinetic energy is conserved.
Is there a torque on the ball about the centre of the pole due to the tension in the string?
If there is a torque the angular momentum is not conserved but if the torque is zero then angular momentum is conserved. | {
"domain": "physics.stackexchange",
"id": 39668,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "newtonian-mechanics, angular-momentum, energy-conservation, conservation-laws",
"url": null
} |
quantum-field-theory, operators, hamiltonian, time-evolution
$$ U(t,t^{\prime})~=~e^{iH_0(t-t_0)} e^{-iH(t-t^{\prime})}e^{-iH_0(t^{\prime}-t_0)} , \qquad t~\geq~ t^{\prime},\tag{4.25}$$
which satisfies
$$ U(t_1,t_2)U(t_2,t_3)~=~U(t_1,t_3) , \qquad t_1~\geq~ t_2~\geq~ t_3.\tag{4.26}$$
Here $t_0$ is an arbitrary but fixed fiducial initial instant where operators and states in the Schrödinger picture, the Heisenberg picture and the interaction picture all agree. For $t\neq t_0$, the three pictures are no longer the same, although they are still unitary equivalent.
For $t^{\prime}=t_0$, eq. (4.25) simplifies to
$$ U(t,t_0)~=~e^{iH_0(t-t_0)}e^{-iH(t-t_0)}. \tag{4.17}$$
It appears that OP mistakenly replaces $t_0$ in eq. (4.17) with an arbitrary time $t^{\prime} \leq t$. The resulting equation
$$ U(t,t^{\prime})~=~e^{iH_0(t-t^{\prime})}e^{-iH(t-t^{\prime})}. \qquad(\leftarrow \text{Wrong!})$$
is not correct.
References: | {
"domain": "physics.stackexchange",
"id": 21099,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "quantum-field-theory, operators, hamiltonian, time-evolution",
"url": null
} |
c++, c++20
Data(const char *str, size_t length = 0, bool copy = false) : _type(STRING)
#if INITIALIZE_COPY
,
_copy(copy ? vector<uint8_t>{reinterpret_cast<uint8_t *>(const_cast<char *>(str)), reinterpret_cast<uint8_t *>(const_cast<char *>(str)) + (length ? length : strlen(str))}
: vector<uint8_t>()),
_span(copy ? &_copy.front()
: reinterpret_cast<uint8_t *>(const_cast<char *>(str))
, length ? length : strlen(str))
#endif
{
print("const char* constructor");
#if !INITIALIZE_COPY
if (copy)
{
// _copy=vector<uint8_t>{reinterpret_cast<uint8_t*>(const_cast<char*>(str)), (uint8_t*) str+(length?length:strlen(str))};
std::copy_n(reinterpret_cast<uint8_t *>(const_cast<char *>(str)), length, back_inserter(_copy));
_span = span<uint8_t>(&_copy.front(), length);
}
else
{
// Rely on the implicit constructor of _copy.
_span = span<uint8_t>(reinterpret_cast<uint8_t *>(const_cast<char *>(str)), length ? length : strlen(str));
}
#endif
} | {
"domain": "codereview.stackexchange",
"id": 44907,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "c++, c++20",
"url": null
} |
gravitational-waves, statistics, ligo
First, lets use the lower bound: $p(\neg H)\approx10^{-4}$. From equation 3, then $p(H)\approx0.9999$. Also, GW150914 apparently matched prediction exactly. Therefore, probability of seeing such a signal given that H is false is $p(O|\neg H)\approx1$. Plugging in these values we get:
$$p(H|O)=\frac{0.9999\times2\times10^{-7}}{0.9999\times2\times10^{-7}+10^{-4}\times1}\approx0.002$$
Doing the same for the upper bound I get $p(H|O)\approx 1.8\times10^{-6}$. Now we can say "the probability GW150914 occurred due to chance ranges from $2\times10^{-3} \text{ to } 1.8\times10^{-6}$," which is quite different from the p-value. Any mistakes in this reasoning? I see where you are going with your question. Let me feed the flames.
The sigma value that is quoted is equivalent to a false alarm probability. It tells you how unlikely it is for your experiment, given your understanding (theoretically and empirically) of the noise characteristics, to have produced a signal that looked like GWs from a merging BH.
Personally, I prefer the statement in the text you quote. Such an event would have been seen (in both detectors) about once every 200,000 years. Given that the observations were for 16 days, that means an expectation there would be $2.2 \times 10^{-7}$ such events in the data. i.e a one in 4.6 million chance. | {
"domain": "physics.stackexchange",
"id": 28643,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "gravitational-waves, statistics, ligo",
"url": null
} |
solve $z^2 -6z + 25$ into complex conjugate
I need to solve this :$$z^2 -6z + 25 = 0$$
My book says 'complete the square' so :
1.$$(z - 6/2)^2 -36/4 + 25$$
2.$$(z - 3)^2 -9 + 25$$
3.$$(z - 3)^2 + 16$$
Now how exactly does the above turn into this:
$$3\pm 4\imath$$
Thanks so Much
Gideon
-
you cannot solve $z^2 - 6z + 25$ but you can solve $z^2 - 6z + 25 = 0$. – anon Oct 23 '10 at 13:47
thats what I meant, I edited it. – gideon Oct 23 '10 at 13:49
Well, it could have also been presented as "factor quadratic so-and-so into linear factors". – Guess who it is. Oct 23 '10 at 13:52
+1 for showing what you had tried – Ross Millikan Oct 23 '10 at 16:47
I think your confusion here stems from the fact you're working with an expression, not an equation. You can only solve equations; it makes no sense to 'solve' an expression!
Edit: You seem to have just edited your post so the first line is an equation. Best to keep it in equation form throughout however.
I'm presuming you have:
$$z^2 - 6z + 25 = 0$$
Then, completing the square:
$$(z - 6/2)^2 -36/4 + 25 = 0$$
$$(z - 3)^2 - 9 + 25 = 0$$
$$(z - 3)^2 = -16$$
$$z - 3 = \pm 4i$$
$$z = 3 \pm 4i$$ | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.960361158630024,
"lm_q1q2_score": 0.8124102592279115,
"lm_q2_score": 0.8459424373085146,
"openwebmath_perplexity": 754.3481324645604,
"openwebmath_score": 0.987479567527771,
"tags": null,
"url": "http://math.stackexchange.com/questions/7586/solve-z2-6z-25-into-complex-conjugate/7588"
} |
which, upon changing the variable back to $$x = (y-\mu)/\sigma,$$ produces
\eqalign{ H(Y) &= -\int_{-\infty}^{\infty} \log\left(\frac{1}{\sigma}f\left(x\right)\right) f\left(x\right) \mathrm{d}x \\ &= -\int_{-\infty}^{\infty} \left(\log\left(\frac{1}{\sigma}\right) + \log\left(f\left(x\right)\right)\right) f\left(x\right) \mathrm{d}x \\ &= \log\left(\sigma\right) \int_{-\infty}^{\infty} f(x) \mathrm{d}x -\int_{-\infty}^{\infty} \log\left(f\left(x\right)\right) f\left(x\right) \mathrm{d}x \\ &= \log(\sigma) + H_f. }
These calculations used basic properties of the logarithm, the linearity of integration, and that fact that $$f(x)\mathrm{d}x$$ integrates to unity (the Law of Total Probability).
The conclusion is
The entropy of $$Y = X\sigma + \mu$$ is the entropy of $$X$$ plus $$\log(\sigma).$$
In words, shifting a random variable does not change its entropy (we may think of the entropy as depending on the values of the probability density, but not on where those values occur), while scaling a variable (which, for $$\sigma \ge 1$$ "stretches" or "smears" it out) increases its entropy by $$\log(\sigma).$$ This supports the intuition that high-entropy distributions are "more spread out" than low-entropy distributions. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9928785697791989,
"lm_q1q2_score": 0.8358306525267349,
"lm_q2_score": 0.8418256551882382,
"openwebmath_perplexity": 286.0835478717325,
"openwebmath_score": 0.9901529550552368,
"tags": null,
"url": "https://stats.stackexchange.com/questions/415435/how-does-entropy-depend-on-location-and-scale"
} |
This means the derivative would be,
$$\frac{d}{dx}\left[ \int_0^x (x^2-x)\,dx \right] = \frac{d}{dx}\left[ \int_0^x (t^2-t)\,dt \right] = x^2 - x$$
• $\int_0^xf(x)~\mathrm dx=\int_0^xf(t)~\mathrm dt$ is quite a bad habit, and it will become especially ambiguous when your integrals contain multiple variables. – Simply Beautiful Art Jul 15 '17 at 23:12
Let $\phi$ be a continuous, real-valued function defined in some neighborhood of $0$. Writing $$f(x) = \int_{0}^{x} \phi(x)\, dx$$ is bad syntax: it uses the single letter $x$ for both
• The input value of the function $f$;
• The dummy variable of integration.
Setting $x = 2$, for example, invites the reader to ponder the meaning of $$f(2) = \int_{0}^{2} \phi(2)\, d2,$$ which is almost surely not intended. (The problem is "$d2$".)
Strictly speaking, "no", it is not okay to have a function $f$ defined by $$f(x) = \int_{0}^{x} (x^{2} - x)\, dx.$$
By contrast, equations such as $$g(x) = \int_{0}^{x} \phi(t)\, dt,\qquad h(x) = \int_{0}^{x} (x - t)\phi(t)\, dt,$$ do properly define functions. Note carefully that in the defintion of $h$, the input value $x$ appears in the integrand but is not the variable of integration. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9621075722839014,
"lm_q1q2_score": 0.8306756058021632,
"lm_q2_score": 0.8633916099737806,
"openwebmath_perplexity": 251.2043255797084,
"openwebmath_score": 0.8503768444061279,
"tags": null,
"url": "https://math.stackexchange.com/questions/2359339/defining-functions-with-integrals?noredirect=1"
} |
This is studied in reliability analysis. Basically, you have some subdevices (here: the two sites) which are operational which probability $p$. What is asked here is what is the probability that the entire device is operational.
If the devices are connected in series, then the probability is $p^n$ where $n$ is the number of devices.
If the devices are connected in parallel, then the probability is $1 - (1- p)^n$.
You can generalize this to $k$ out of $n$ systems where the device works if $k$ out of $n$ subdevices work. This requires the binomial distribution. Of course, you can go even more complicated than this. | {
"domain": "physicsforums.com",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9828232909876815,
"lm_q1q2_score": 0.8503623836957627,
"lm_q2_score": 0.8652240860523328,
"openwebmath_perplexity": 763.239704153066,
"openwebmath_score": 0.6657262444496155,
"tags": null,
"url": "https://www.physicsforums.com/threads/probability-question.876965/"
} |
c#, beginner, sql
con.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES";
SqlDataAdapter dbAdapter = new SqlDataAdapter(cmd);
DataTable dtRecords = new DataTable();
dbAdapter.Fill(dtRecords);
comboBox1.DataSource = dtRecords;
comboBox1.DisplayMember = "TABLE_NAME";
con.Close();
}
catch (Exception exx)
{
MessageBox.Show(exx.Message);
}
}
private void btnCreateTable_Load(object sender, EventArgs e)
{
ListTables();
dataGridView1.DataSource = bindingSource1;
GetData();
}
private void GetData()
{
try
{
SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=" + Application.StartupPath + "\\database.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True");
con.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "SELECT * FROM INFORMATION_SCHEMA.TABLES";
SqlDataAdapter dbAdapter = new SqlDataAdapter(cmd);
DataTable dtRecords = new DataTable();
dbAdapter.Fill(dtRecords);
comboBox1.DataSource = dtRecords;
comboBox1.DisplayMember = "TABLE_NAME";
con.Close();
}
catch { }
} | {
"domain": "codereview.stackexchange",
"id": 9007,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "c#, beginner, sql",
"url": null
} |
mathematics, density-matrix
Title: What is the probability that measurement finds it in the $|0\rangle$ state? Suppose that there is an ensemble with 60% of the states prepared in
$$|a\rangle=\sqrt{\frac{2}{5}}|+\rangle-\sqrt{\frac{3}{5}}|-\rangle$$
and 40% in:
$$|b\rangle=\sqrt{\frac{5}{8}}|+\rangle+\sqrt{\frac{3}{8}}|-\rangle$$
I've considered two ways to calculate this. For the first, one could replace the $|+\rangle$ and $|-\rangle$ and calculate the density matrix as usual in $0,1$ base. Another possibility would be to calculate the density matrix in $\{|+\rangle,|-\rangle\}$ basis and then to convert it into a corresponding $|0\rangle$ $|1\rangle$ density matrix. My question, how would you proceed here?
But I'm not sure if both ways come to the same result?
The density matrix in $\{|+\rangle,|-\rangle\}$ Base is:
$$\rho_a=\frac{2}{3}|+\rangle\langle+|-\frac{\sqrt{6}}{5}|+\rangle\langle-|-\frac{\sqrt{6}}{5}|-\rangle\langle+|+\frac{3}{5}|-\rangle\langle-|$$
$$\rho_b=\frac{5}{8}|+\rangle\langle+|+\frac{\sqrt{15}}{8}|+\rangle\langle-|+\frac{\sqrt{15}}{8}|-\rangle\langle+|+\frac{3}{8}|-\rangle\langle-|$$ | {
"domain": "quantumcomputing.stackexchange",
"id": 840,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "mathematics, density-matrix",
"url": null
} |
c++, c++11, ai
void Population::createNextGeneration()
{
this->runMatches();
this->prune();
this->procreate();
}
// ======================================================================================
// Resets the all the mechs' scores and executes several match rounds.
void Population::runMatches()
{
for (auto& mech : this->mechs)
{
mech->resetScore();
}
const static int rounds = 40;
for (int m = 0; m < rounds; m++)
{
this->runMatchRound();
}
}
// ======================================================================================
// Randomly pairs all the mechs up with an opponent and makes the pairs execute a match.
void Population::runMatchRound()
{
// Create an index queue that will contain indices [0 .. size] into the mech vector in
// a randomised order, then use this queue to pair up the mechs into their matches.
std::vector<size_t> queue;
for (size_t m = 0; m < this->mechs.size(); m++)
{
queue.push_back(m);
}
std::random_shuffle(queue.begin(), queue.end()); | {
"domain": "codereview.stackexchange",
"id": 5643,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "c++, c++11, ai",
"url": null
} |
subscribe, message-filters, approximatetime, message-filter, tf
Title: Subscribe to geometry_msgs/TransformStamped (tf) Message with message_filters ApproximateTime subscriber I am trying to use a message_filters::sync::ApproximateTime subscriber in a C++ node that must subscribe to 2 custom messages (which have a Header each), nav_msgs/OccupancyGrid Message, and a tf/tfMessage Message. The main point is I also want to subscribe to the /tf topic along with the other messages because my goal is to use data with approximate timestamp coherence; essentially get data at roughly the same time.
Edit: Why I want to subscribe to the tf topic simultaneously: I want to know the robot's pose with respect to the map frame because I detect landmarks in the map frame. I want to know if these landmarks are within the robot's 2D laserscanner's sensing radius. I understand that the /odom topic is the true position of the robot from Gazebo, and my SLAM layer is providing the transforms /tf, so I should use /tf instead of /odom.
However, I see that message_filters::sync::ApproximateTime can only work with messages which have a Header, and tf message does not have a header. I have 1 callback for the message_filters::sync::ApproximateTime subscriber and I want to also view the tf message at this time, how can I subscribe to the tf data? I am looking for ideas on how to program this in C++. So far I have 2 ideas:
Create a custom message which has the exact definition of tf but with a Header. Subscribe to /tf topic, modify the tf message by added a Header with a timestamp, and publish this custom message. The problem with this is I have more overhead, takes up more processing, and communication bandwidth between the nodes increases. | {
"domain": "robotics.stackexchange",
"id": 38617,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "subscribe, message-filters, approximatetime, message-filter, tf",
"url": null
} |
quantum-mechanics, definition
Title: Poles, wavefunctions, transmission Why is it said that $\operatorname{sech}x$ (a transmission amplitude) has a simple pole on the imaginary axis? To have a simple pole at $a$ means that $f(z) \sim 1/(z-a)^{n}$, with $n=1$. I.e., the function does not diverge with $1/z^2$ or a larger power.
For more details on the poles of $\operatorname{sech}(z)$, check out this answer. As simple as the poles of $\operatorname{sech}(z)$ may be, there is an infinite amount of them (as many as there are zeroes to $\operatorname{cosh}(z)$). | {
"domain": "physics.stackexchange",
"id": 1787,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "quantum-mechanics, definition",
"url": null
} |
machine-learning, gaussian, discriminant-analysis
&=\ln \frac{P(C_0)}{P(C_1)} + \frac12\left[x^T\Sigma^{-1}x-2x^T\Sigma^{-1}\mu_1+\mu_1^T\Sigma^{-1}\mu_1\right]\\& - \frac12\left[x^T\Sigma^{-1}x-2x^T\Sigma^{-1}\mu_0+\mu_0^T\Sigma^{-1}\mu_0\right]\\
&= (\mu_0-\mu_1)^T\Sigma^{-1}x+\ln \frac{P(C_0)}{P(C_1)} +\frac12\left[\mu_1^T\Sigma^{-1}\mu_1-\mu_0^T\Sigma^{-1}\mu_0\right] \\
\end{align} | {
"domain": "datascience.stackexchange",
"id": 5215,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "machine-learning, gaussian, discriminant-analysis",
"url": null
} |
Note that from $$|x_n-x|<\epsilon$$ you can write $$xtherefore $$a-\epsilonSince this holds for any $$\epsilon >0$$, we obtain $$a\le x\le b$$ This is where the $$\le$$ kicks in.
• Hi @Mostafa Ayaz isn't this just the same exact thing I showed? I don't see the difference, could you let me know the difference and where I messed up. But doesn't $a- \epsilon< x<b+\epsilon$ holding for any $\epsilon >0$ imply $a<x<b$? i don't see how it implies $a \leq x \leq b$. thank you – kemb Aug 24 '19 at 22:39
• Yes. This is almost exactly what you proved, except the last conclusion. For example let $$1-{1\over n}<x<2+{1\over n}$$ hold for any positive integer $n$. Does this mean $$x\in[1,2]$$ or $x\in (1,2)$? i.e. does $x=1$ or $x=2$ satisfy the inequality? – Mostafa Ayaz Aug 24 '19 at 22:49
• Hi @Mostafa Ayaz. thats what I don't understand. I don't understand why $1- \frac{1}{n}<x< 2+\frac{1}{n}$ holding for any positive integer n implies that $x \in [1,2]$. I thought it implied that $x \in (1,2)$. Could you explain why it implies that $x \in [1,2]$ as I don't understand this concept. Sorry for the basic questions – kemb Aug 24 '19 at 22:56
• It is OK. Do you agree that any $x_0$ for which the inequality holds for $n\in \Bbb N$, falls in the limit interval? – Mostafa Ayaz Aug 24 '19 at 22:57 | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9830850894589458,
"lm_q1q2_score": 0.8060249091569353,
"lm_q2_score": 0.8198933315126791,
"openwebmath_perplexity": 492.476360522778,
"openwebmath_score": 0.9999970197677612,
"tags": null,
"url": "https://math.stackexchange.com/questions/3333260/proving-limit-of-bounded-convergent-sequence-is-bounded"
} |
# Conditional probability exercise
Charlotte87
I have some problems getting conditional probability right... Does this look like it should?
## Homework Statement
Assume that there are bags of tulip bulbs in the basement, ant that they contain 25 bulbs each. yellow bags contain 20 yellow tulips and 5 red tuplips, and red bags contain 15 red and 10 yellow tulips. 60% of the bags in the basement are yellow, the others are red. One bulb is chosen at random from a random bag in the basement, and then planted
a) what is the probabilit that the tulip turns out yellow?
b) given that the tulip turns out yellow, what is the probability that it came from a yellow bag?
## Homework Equations
Let RB be redbag, YB yellowbag, RT red tulip and YT yellow tulip. Then as far as I can read from this exercise I have the following information:
P(YB)=0.6
P(RB)=0.4
P(YT|YB)=20/25=4/5
P(RT|YB)=1/5
P(YT|RB)=10/25=2/5
P(RT|RB)=3/5
## The Attempt at a Solution
a) $P(YT)=P(YB\cap YT)+P(RB\cap YT)=(0.6*4/5)+(0.4*2/5)=16/25$
b) $P(YB|YT)=P(YB \cap YT)/P(YT) = (0,6*4/5)/(16/25)=3/4$
It is particularly this last one I am unsure about.
Homework Helper
Gold Member
Staff Emeritus
Homework Helper
I have some problems getting conditional probability right... Does this look like it should?
## Homework Statement
Assume that there are bags of tulip bulbs in the basement, ant that they contain 25 bulbs each. yellow bags contain 20 yellow tulips and 5 red tuplips, and red bags contain 15 red and 10 yellow tulips. 60% of the bags in the basement are yellow, the others are red. One bulb is chosen at random from a random bag in the basement, and then planted | {
"domain": "physicsforums.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9759464513032269,
"lm_q1q2_score": 0.8001719894844797,
"lm_q2_score": 0.8198933337131076,
"openwebmath_perplexity": 3433.4336136426386,
"openwebmath_score": 0.9393706321716309,
"tags": null,
"url": "https://www.physicsforums.com/threads/conditional-probability-exercise.630465/"
} |
machine-learning, neural-networks
Title: Must Neural Networks always converge? Introduction
Step One
I wrote a standard backpropegating neural network, and to test it, I decided to have it map XOR.
It is a 2-2-1 network (with tanh activation function)
X1 M1
O1
X2 M2
B1 B2
For testing purposes, I manually set up the top middle neuron (M1) to be an AND gate and the lower neuron (M2) to be an OR gate (both output 1 if true and -1 if false).
Now, I also manually set up the connection M1-O1 to be -.5, M2-O1 to be 1, and
B2 to be -.75
So if M1 = 1 and M2 = 1, the sum is (-0.5 +1 -0.75 = -.25) tanh(0.25) = -0.24
if M1 = -1 and M2 = 1, the sum is ((-0.5)*(-1) +1 -0.75 = .75) tanh(0.75) = 0.63
if M1 = -1 and M2 = -1, the sum is ((-0.5)*(-1) -1 -0.75 = -1.25) tanh(1.25) = -0.8
This is a relatively good result for a "first iteration".
Step Two
I then proceeded to modify these weights a bit, and then train them using error propagation algorithm (based on gradient descent). In this stage, I leave the weights between the input and middle neurons intact, and just modify the weights between the middle (and bias) and output.
For testing, I set the weights to be and .5 .4 .3 (respectively for M1, M2 and bias)
Here, however, I start having issues. | {
"domain": "cs.stackexchange",
"id": 298,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "machine-learning, neural-networks",
"url": null
} |
ros
lucid-amd64 $ ls -al /usr/lib32/libGL.so
lrwxrwxrwx 1 root root 15 2012-02-01 17:46 /usr/lib32/libGL.so -> mesa/libGL.so.1
lucid-amd64 $ locate libGL.so
/usr/lib/libGL.so
/usr/lib/mesa/libGL.so
/usr/lib/mesa/libGL.so.1
/usr/lib/mesa/libGL.so.1.2
/usr/lib32/libGL.so
/usr/lib32/mesa/libGL.so.1
/usr/lib32/mesa/libGL.so.1.2
Originally posted by Kei Okada with karma: 1186 on 2012-05-20
This answer was ACCEPTED on the original site
Post score: 0 | {
"domain": "robotics.stackexchange",
"id": 9461,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "ros",
"url": null
} |
javascript, php, security, image, .htaccess
$allowedExts = array('png', 'jpeg', 'jpg');
$allowedExts2 = array('image/png', 'image/jpg', 'image/jpeg');
$fileinfo = finfo_open(FILEINFO_MIME_TYPE);
for($i=0; $i<count($array['name']); $i++)
{
if( is_array($array['name'][$i]) || is_array($array['tmp_name'][$i]) ||
is_array($array['error'][$i]) || is_array($array['size'][$i])
) { return [false, "Wrong array format"]; }
$ext = pathinfo($array['name'][$i], PATHINFO_EXTENSION);
if( !in_array($ext, $allowedExts) ) { return [false, "Only PNG JPEG JPG images are allowed"]; }
if(!file_exists($array['tmp_name'][$i]) || !is_uploaded_file($array['tmp_name'][$i])) { return [false, "File doesn't exists, try again"]; }
if(!is_uploaded_file($array['tmp_name'][$i])) { return [false, "File has to be uploaded using our form"]; }
if(!exif_imagetype($array['tmp_name'][$i])) { return [false, "Only images allowed"]; }
if(filesize($array['tmp_name'][$i]) < 12) { return [false, "All images has to be more than 11 bytes"]; } | {
"domain": "codereview.stackexchange",
"id": 32536,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "javascript, php, security, image, .htaccess",
"url": null
} |
python, queue
Title: Optimize BFS weighted search in python I have a weighted BFS search in python for networkx that I want to optimize:
def bfs(graph, node, attribute, max = 10000):
# cProfile shows this taking up the most time. Maybe I could use heapq directly? Or maybe I would get more of a benefit making it multithreaded?
queue = Queue.PriorityQueue()
num = 0
done = set()
for neighbor, attrs in graph[node].iteritems():
# The third element is needed because we want to return the ajacent node towards the target, not the target itself.
queue.put((attrs['weight'], neighbor, neighbor))
while num <= max and not queue.empty():
num += 1
item = queue.get()
if graph.node[item[1]].get(attribute, False):
return item[2]
for neighbor, attrs in graph[item[1]].iteritems():
if neighbor not in done:
queue.put((item[0] + attrs['weight'], neighbor, item[2]))
done.add(neighbor) Some things that might improve your code: | {
"domain": "codereview.stackexchange",
"id": 3515,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "python, queue",
"url": null
} |
ros, gazebo, ros-fuerte, overlay
File "/usr/lib/python2.7/urllib.py", line 436, in open_https
h.endheaders(data)
File "/usr/lib/python2.7/httplib.py", line 954, in endheaders
self._send_output(message_body)
File "/usr/lib/python2.7/httplib.py", line 814, in _send_output
self.send(msg)
File "/usr/lib/python2.7/httplib.py", line 776, in send
self.connect()
File "/usr/lib/python2.7/httplib.py", line 1161, in connect
self.sock = ssl.wrap_socket(sock, self.key_file, self.cert_file)
File "/usr/lib/python2.7/ssl.py", line 381, in wrap_socket
ciphers=ciphers)
File "/usr/lib/python2.7/ssl.py", line 143, in __init__
self.do_handshake()
File "/usr/lib/python2.7/ssl.py", line 305, in do_handshake
self._sslobj.do_handshake()
IOError: [Errno socket error] [Errno 8] _ssl.c:504: EOF occurred in violation of protocol
make[1]: se sale del directorio «/root/fuerte_workspace/simulator_gazebo/gazebo»
make[1]: *** [build/gazebo/unpacked] Error 1
CMake Error at CMakeLists.txt:21 (message):
Build of Gazebo failed
-- Configuring incomplete, errors occurred! | {
"domain": "robotics.stackexchange",
"id": 12545,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "ros, gazebo, ros-fuerte, overlay",
"url": null
} |
navigation, rviz, ros-kinetic, robot-localization, ekf-localization
at line 134 in /tmp/binarydeb/ros-kinetic-tf2-0.5.16/src/buffer_core.cpp
[ WARN] [1516664019.463331053]: Timed out waiting for transform from base_link to map to become available before running costmap, tf error: canTransform: target_frame map does not exist.. canTransform returned after 0.101917 timeout was 0.1.
Warning: Invalid argument "/imu_frame" passed to canTransform argument source_frame in tf2 frame_ids cannot start with a '/' like:
at line 134 in /tmp/binarydeb/ros-kinetic-tf2-0.5.16/src/buffer_core.cpp
Warning: Invalid argument "/imu_frame" passed to canTransform argument source_frame in tf2 frame_ids cannot start with a '/' like:
at line 134 in /tmp/binarydeb/ros-kinetic-tf2-0.5.16/src/buffer_core.cpp
Warning: Invalid argument "/imu_frame" passed to canTransform argument source_frame in tf2 frame_ids cannot start with a '/' like:
at line 134 in /tmp/binarydeb/ros-kinetic-tf2-0.5.16/src/buffer_core.cpp
Warning: Invalid argument "/imu_frame" passed to canTransform argument source_frame in tf2 frame_ids cannot start with a '/' like:
at line 134 in /tmp/binarydeb/ros-kinetic-tf2-0.5.16/src/buffer_core.cpp
Warning: Invalid argument "/imu_frame" passed to canTransform argument source_frame in tf2 frame_ids cannot start with a '/' like:
at line 134 in /tmp/binarydeb/ros-kinetic-tf2-0.5.16/src/buffer_core.cpp | {
"domain": "robotics.stackexchange",
"id": 29851,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "navigation, rviz, ros-kinetic, robot-localization, ekf-localization",
"url": null
} |
≈ f(a)+f′(a)(x−a) linear approximation • Quadratic approximation in one variable: Take the constant, linear, and quadratic terms from the Taylor series. Let us revise how to construct a program for Taylor Series. Suppose a set of standardized test scores are normally distributed with mean and standard deviation Use and the first six terms in the Maclaurin series for to approximate the probability that a randomly selected test score is between and Use the alternating series test to determine how accurate your approximation is. By intuitive, I mean intuitive to those with a good grasp of functions, the basics of a first semester of calculus (derivatives, integrals, the mean value theorem, and the fundamental theorem of calculus) - so it's a mathematical. These notes discuss three important applications of Taylor series: 1. Clicking the Draw button plots the polynomial of the selected degree; clicking the Next button increments the degree to the next odd integer and plots the polynomial of that degree. Suppose a set of standardized test scores are normally distributed with mean and standard deviation Use and the first six terms in the Maclaurin series for to approximate the probability that a randomly selected test score is between and Use the alternating series test to determine how accurate your approximation is. Lec 95 - Polynomial approximation of functions (part 1). Produces the result Note that function must be in the integrable functions space or L 1 on selected Interval as we shown at theory sections. You won’t use an infinite series to calculate the approximation. ) When , the series is called a Maclaurin series. So, I'm trying to create a program that calculates cos(x) by using a Taylor approximation. Using Taylor polynomials to approximate functions. Use the first two non-zero terms of an appropriate series to give an approximation of Z 1 0 sin we can replace x with t3 to get the Maclaurin series for cost3: 1. Problems on Taylor's Theorem. Taylor Polynomials Preview. Just calculate the values of the red bits and plug them into the Maclaurin series to give you the series expansion formula. Maclaurin expansion of B * (s), which involves four moments of the service-time distribution, gives a better approximation than the one involving two moments. Index 8 to get to my menu, scroll down to Maclaurin series there is it there then press enter …. 2 correct to five decimal places. Example: | {
"domain": "timstourenblog.de",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9938070091084549,
"lm_q1q2_score": 0.8634461298002867,
"lm_q2_score": 0.8688267660487572,
"openwebmath_perplexity": 390.82097345168205,
"openwebmath_score": 0.9073213934898376,
"tags": null,
"url": "http://enej.timstourenblog.de/maclaurin-series-approximation.html"
} |
java, linked-list
// reverse order of linked list
public void reverse(){
DoublyLinkedListNode<T> currentNode=head.getNextNode();
DoublyLinkedListNode<T> prevNode;
DoublyLinkedListNode<T> nextNode;
while(currentNode != null){
nextNode=currentNode.getNextNode();
prevNode=currentNode.getPrevNode();
currentNode.setNextNode(prevNode);
currentNode.setPrevNode(nextNode);
if(currentNode.getNextNode() == head){
currentNode.setNextNode(null);
}
if(currentNode.getPrevNode() == null){
currentNode.setPrevNode(head);
head.setNextNode(currentNode);
currentNode=null;
}else{
currentNode=currentNode.getPrevNode();
}
}
}
public int searchKey(T key){
T data=null;
int i=0;
DoublyLinkedListNode<T> node=head.getNextNode();
Boolean foundFlag=false;
while(node != null){
data=node.getDataItem();
if(data.equals(key)){
return i;
}
i++;
node=node.getNextNode();
}
return -1;
}
// return data item at particular node
public T dataAtIndex(int index)
{
DoublyLinkedListNode<T> nodes=nodeAtIndex(index);
if(nodes != null){
return nodes.getDataItem();
}else{
return null;
}
} | {
"domain": "codereview.stackexchange",
"id": 24091,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "java, linked-list",
"url": null
} |
quantum-field-theory, fermions, dirac-equation
\end{equation}
The reason is a scalar field doesn't carry any spin and so can just be described by an ordinary function (think quantum mechanics where we need two component spinors to describe particle spin).
On the other hand, a Dirac fermion is actually made up of two particles - a left chiral fermion and a right chiral fermion. Each of these two fields can be either spin up or spin down and hence requires 2 degrees of freedom. In total it needs $ 2 \times 2 =4$ components to describe it. | {
"domain": "physics.stackexchange",
"id": 14432,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "quantum-field-theory, fermions, dirac-equation",
"url": null
} |
newtonian-mechanics, classical-mechanics, rotational-dynamics, friction, rigid-body-dynamics
Title: Will a pure rolling cylinder stop on a rough surface? Will a disc or cylinder (rigid body) executing pure rolling on a rough surface stop, neglecting air drag and other heat losses and rolling friction but not static and kinetic friction? If yes, due to which friction it will stop, static or kinetic and how?
Assume surface has no rolling friction. As Yashas Samaga said, it will not stop on a smooth, but frictional surface. It will stop however on an actual rough surface (as it does in reality – e.g. a steel marble rolling on a rough stone surface will come to a halt quite quickly, although drag / rolling friction is as low as on a smooth glass plate, where the marble would indeed roll very far).
The reason is that a rough surface can in general not be continually tangent to the rolling body. Instead, if the object has rolled over a peak, it will not smoothly traverse the following trough but slightly collide with the next peak. If there's no rolling friction, then the collision will (ideally) be perfectly elastic, i.e. the cylinder will bounce off. When it hits the surface again, the vertical kinetic energy will regenerally not be fully reclaimed to movement in the original direction. In fact, while it has still some velocity in that direction, it will statistically more likely clash with yet another opposing front of the profile, thus losing yet more momentum.
So, I reckon ideally this would eventually lead to a random-walk kind of motion. In reality, this doesn't happen because the collisions are scarcaly sufficiently elastic – actually a good amount or kinetic energy is lost right when the roller hits the next peak. | {
"domain": "physics.stackexchange",
"id": 39007,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "newtonian-mechanics, classical-mechanics, rotational-dynamics, friction, rigid-body-dynamics",
"url": null
} |
mechanical-engineering, automotive-engineering, hydraulics
Title: Why excavators use Hydraulic motors for rolling or moving forward instead of diesel engine? I am currently studying How excavators work? and came to know that "In excavators diesel engine is used to drive the hydraulic pump. The high pressure fluid from hydraulic pump is used to run the hydraulic motors which rotates the wheel." Is there any specific reason for using hydraulic motors instead of directly using diesel engine? Yes, because many or most excavators can 360 rotate so getting a classic gearbox/ prop shaft drive to the wherls or tracks would be challenging.
Then sorting the ability to do forwards with one side and reverse at the same time with the other is also difficult without hydraulics. | {
"domain": "engineering.stackexchange",
"id": 5455,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "mechanical-engineering, automotive-engineering, hydraulics",
"url": null
} |
performance, sql, sql-server, stored-procedure
-- hours account
LEFT OUTER JOIN (
SELECT RefMitarbeiterId,
Stundensaldo,
Buchung,
IstStartBuchung,
Buchungsdatum
FROM MitarbeiterStundenkonto OUTERMSK
WHERE Buchungsdatum = (
SELECT MAX(Buchungsdatum)
FROM MitarbeiterStundenkonto
WHERE RefMitarbeiterId = OUTERMSK.RefMitarbeiterId
AND ( ( YEAR(Buchungsdatum) = YEAR(@Wann) AND MONTH(Buchungsdatum) <= MONTH(@Wann) )
OR YEAR(Buchungsdatum) < YEAR(@Wann) )
)
GROUP BY RefMitarbeiterId,
Stundensaldo,
Buchung,
IstStartBuchung,
Buchungsdatum
) MSK ON Mitarbeiter.MitarbeiterId = MSK.RefMitarbeiterId
-- Plan
--all Values from the last closed Plan
LEFT OUTER JOIN (
SELECT RefMitarbeiterId,
CurrentStundenKonto AS OldCurrentStundenKonto,
CurrentUrlaubskonto AS OldCurrentUrlaubskonto,
AusbezahltMonat AS OldAusbezahltMonat
FROM [Plan] OUTERPLAN
WHERE
Jahr = (
SELECT MAX(Jahr)
FROM [Plan]
WHERE Abgeschlossen = 1
AND RefMitarbeiterId = OUTERPLAN.RefMitarbeiterId
AND ( ( Jahr = YEAR(@oldDate) AND Monat <= MONTH(@oldDate) )
OR Jahr < YEAR(@oldDate) )
GROUP BY Jahr
)
AND Monat = (
SELECT MAX(Monat)
FROM [Plan] INNERPLAN
WHERE RefMitarbeiterId = OUTERPLAN.RefMitarbeiterId
AND Abgeschlossen = 1
AND Jahr = (
SELECT MAX(Jahr)
FROM [Plan]
WHERE Abgeschlossen = 1
AND RefMitarbeiterId = INNERPLAN.RefMitarbeiterId
AND ( ( Jahr = YEAR(@oldDate) AND Monat <= MONTH(@oldDate) )
OR Jahr < YEAR(@oldDate) )
GROUP BY Jahr
) | {
"domain": "codereview.stackexchange",
"id": 11013,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "performance, sql, sql-server, stored-procedure",
"url": null
} |
pressure, everyday-life, flow, air
Title: Why does the "air" close or open doors? Assume we have an empty room with two doors on the opposite sides of it. If we open one of the doors, the door on the opposite side automatically closes "harder", and if we close one of the doors the other door opens. Why does this happen? If a door opens outward, pulling it open creates a slight lowering of air pressure inside the room just for a moment. If the door on the other side opens inward, then the slightly greater air pressure on the outside of that door will push it open.
The reverse is true when you close that door by pushing it inwards. The air pressure in the room rises slightly because the door is pushing air into the room, and if the other door opens outward, then that slight increase in air pressure inside the room will push that door open. If it opens inward and is open, it will get pushed shut by the air pressure when you shut the other door. | {
"domain": "physics.stackexchange",
"id": 87225,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "pressure, everyday-life, flow, air",
"url": null
} |
ros, ardrone-autonomy
Originally posted by Allen Ayala with karma: 22 on 2017-06-28
This answer was ACCEPTED on the original site
Post score: 0 | {
"domain": "robotics.stackexchange",
"id": 28217,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "ros, ardrone-autonomy",
"url": null
} |
javascript, tree
Title: Follow-up zp-Tree to represent Trees as nested arrays: 3rd (final?) revision This is a follow-up on my previous post.
I have made modifications based on the feedback received on the previous post, hence I request a third (final?) review on the modified code if ok.
Note: review purpose is just to check good practices (code / performance wise) and see if anything's missing.
I did all updates as proposed by @EngineerDollery in the previous post.
Other than that I separated prototype methods (API) from private methods more clearly;
Thanks to @EngineerDollery for the reviews so far.
/**
* zp-Tree
* This Tree constructor is essentially a decorator for an array "tree of nodes" passed in.
* Purpose:
* - Enter tree as arrays of nested objects Format
* - Easily find / insert / delete Nodes
* - Find parent / child / next / previous Nodes
* - Respect nodes order: array will provide natural ranking
* Inspired by js-tree: https://github.com/wangzuo/js-tree/blob/master/index.js
*
* @author Kim Gysen
*/
/**
* @typedef Node
* @property{number} _cid The internal id used by zp-Tree
* @property{?Node} prev The previous Node in the tree
* @property{?Node} next The next Node in the tree
* @property{?Node} parent The node's parent Node
* @property{?Array} children The node's childe nodes
* @property{number} level The node's depth level
* @property{boolean} isLeaf The node is (not) a leaf
*/
var CONSTRUCT_MODE = Object.freeze({
DEEP: { value: 0, desc: "Construct all children", is: function( mode ){ return ( this === mode ) } },
SHALLOW: { value:1, desc: "Construct only top level", is: function( mode ){ return ( this === mode ) } }
}); | {
"domain": "codereview.stackexchange",
"id": 19840,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "javascript, tree",
"url": null
} |
quantum-mechanics, atomic-physics, orbitals, leptons
Title: Does substituting electrons with muons change the atomic shell configuration? Suppose we take an example of $\text{Be}^{2+}$ and we add two muons to it. Will they go into L shell or there will be two K shells - one each for muons and electrons?
If so, the system should have double noble gas ($\text{He}$) configuration? A nucleus with both bound muons and bound electrons will have separate shell structures for the distinguishable leptons. A useful comparison is the nuclear shell model, in which nucleons are arranged into shells according to their total angular momentum, but there are separate shell structures for the distinguishable neutrons versus protons.
The spectroscopy of a $
\rm Be^{4+} + 2\mu^- + 2e^-
$ system would be quite difficult to actually study. First there is the problem that getting two muons to capture on the same nucleus, on the microsecond timescale before the muons decay, would require an extremely large flux of cold muons. Second, it's probable that the x-rays released when the muon captures on the ion would be energetic enough to liberate the remaining electrons. If I were going to dig around in the literature for examples of the interaction between bound muons and bound electrons, I would expect to find data on muon capture by heavier targets. | {
"domain": "physics.stackexchange",
"id": 95360,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "quantum-mechanics, atomic-physics, orbitals, leptons",
"url": null
} |
complexity-theory
Title: Is it possible that $\mathsf{L} = \mathsf{NP}$? When I studied computer science 10 years ago, it was still an open question whether $\mathsf{L}$ and $\mathsf{NP}$ are truly different classes. Is that still the case or has the inequality been proven in the meantime?
(I know this is a somewhat stupid question, but there's nothing about it in the complexity zoo, and googling L and NP is surprisingly ineffective ;-)) $L \subseteq NL \subseteq P \subseteq NP \subseteq PSPACE \subseteq EXP$
From space hierarchy and time hierarchy theorems we can prove that
$L \subsetneq PSPACE$
$NL \subsetneq NPSPACE$
Note that we know $PSPACE = NPSPACE$.
$P \subsetneq EXP$
$NP \subsetneq NEXP$
Note that we don't know if $EXP \subsetneq NEXP$.
Whether the other inclusions are strict, are still open problems. Even though there are no proofs, many, but not all, believe most of the inclusions to be strict. | {
"domain": "cs.stackexchange",
"id": 6655,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "complexity-theory",
"url": null
} |
algorithm, c, binary-search-tree
int main() {
#define MAX 8
int n = MAX;
BST bst1 = bst_init;
Node* bst1_root = bst1.root;
int arr[MAX] = {15, 10, 20, 9, 13, 19, 22, 18};
if (!arr) return 0;
for (int i = 0; i < n; i++)
bst1_root = insert(bst1_root, arr[i]);
printf("height: %d \n", height(bst1_root));
printf("size: %d \n", size(bst1_root));
printf("depth of 13: %d \n", depth(bst1_root, 18));
printf("is_bst: %d \n", is_bst(bst1_root, -1000, 1000)); //assuming -1000 < data(bst) < 1000
printf("is_bst_balanced: %d \n", is_bst_balanced(bst1_root));
printf("min: %d \n", find_min(bst1_root)->data);
printf("max: %d \n", find_max(bst1_root)->data);
printf("element: %d found \n", find(bst1_root, 19)->data);
printf("level order ");
level_order(bst1_root);
printf("\n");
printf("preorder order ");
pre_order(bst1_root);
printf("\n");
printf("inorder order ");
in_order(bst1_root);
printf("\n");
printf("postorder order ");
post_order(bst1_root);
printf("\n");
printf("inorder successor of 9 is %d \n", in_order_suc(bst1_root, 9)->data); | {
"domain": "codereview.stackexchange",
"id": 44460,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "algorithm, c, binary-search-tree",
"url": null
} |
by 2 making LIVE CLASSES and VIDEO CLASSES completely free to prevent getting this in! Range ) Jangkauan data adalah selisih antara nilai kuartil atas dengan kuartil bawah then estimate how much spent she! The variability in your browser 20 hour class 0 50 100 150 200 0 5 10 the semi interquartile range for the data 3,4,6,9,11,12,14,15 20.! The range between the third quartile and the standard deviation of the data 3,6,5,4,2,1,7.! Improving their maths marks online with Siyavula Practice or dispersion, 1, 7 is distribution... 3 – Q 1 to the middle 50 % of the data, there are terms! = 26 range contains half the distance between the 97.5th percentile and the first and third.! Web store that divide the statistical data arranged in sequence into four groups by Asadalam989 30.09.2018 Log in add! The mid and semi quartiles for any given input values ️ semi interquartile range does take! 3 ( Q3 ) perform the computation, 40, 75 2019 Debabrata! They are closer 52 or 6 cloudflare, Please complete the security check to access you to determine the and. Significant robust measure of spread or dispersion 95 % of values range, IQR... Conditions of storing and accessing cookies in your dataset the center of the middle half of distribution... Equal to the web property by Asadalam989 30.09.2018 Log in to add a comment semi-interquartile is., 72, 96, 21, 58, 40, 75 called a semi Inter-quartile range = largest and... Solutions: the first quartile IQR=Q 3 –Q 1 code below one half scores... Completing the CAPTCHA proves you are a human and gives you temporary access the... Is computed as one half the scores in the dot plot below IP... The semi interquartile range is a significant robust measure of scale a human and you... Formula for semi interquartile range = upper quartile and the 25 th percentile of the distribution are to the.... Histogram. the frequency distribution histogram. input values | {
"domain": "cholhua.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9626731147976794,
"lm_q1q2_score": 0.8239048841449312,
"lm_q2_score": 0.8558511414521923,
"openwebmath_perplexity": 901.7410825750325,
"openwebmath_score": 0.560030460357666,
"tags": null,
"url": "http://www.cholhua.com/il1cixbo/f34e51-the-semi-interquartile-range-for-the-data-3%2C4%2C6%2C9%2C11%2C12%2C14%2C15"
} |
Difference between revisions of "2017 AMC 12A Problems/Problem 18"
Problem
Let $S(n)$ equal the sum of the digits of positive integer $n$. For example, $S(1507) = 13$. For a particular positive integer $n$, $S(n) = 1274$. Which of the following could be the value of $S(n+1)$?
$\textbf{(A)}\ 1 \qquad\textbf{(B)}\ 3\qquad\textbf{(C)}\ 12\qquad\textbf{(D)}\ 1239\qquad\textbf{(E)}\ 1265$
Solution 1
Note that $n\equiv S(n)\bmod 9$, so $S(n+1)-S(n)\equiv n+1-n = 1\bmod 9$. So, since $S(n)=1274\equiv 5\bmod 9$, we have that $S(n+1)\equiv 6\bmod 9$. The only one of the answer choices $\equiv 6\bmod 9$ is $\boxed{(D)=\ 1239}$.
Solution 2 | {
"domain": "artofproblemsolving.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9888419684230911,
"lm_q1q2_score": 0.8481970995912727,
"lm_q2_score": 0.8577681031721325,
"openwebmath_perplexity": 113.10468904608558,
"openwebmath_score": 0.8420091271400452,
"tags": null,
"url": "https://artofproblemsolving.com/wiki/index.php?title=2017_AMC_12A_Problems/Problem_18&diff=cur&oldid=83260"
} |
classical-mechanics, non-linear-systems, integrable-systems
Title: Idea of integrable systems I do not quite understand the idea of an integrable dynamical system. Does it mean that the EOMs are analytically and exactly solvable? What are the necessary and sufficient conditions such that a system is integrable? There has been extensive discussion on this here. Infact the question was posed by Gil Kalai, a well known mathematician. I hope it helps. | {
"domain": "physics.stackexchange",
"id": 20128,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "classical-mechanics, non-linear-systems, integrable-systems",
"url": null
} |
Again one equation one variable . So 2 is also sufficient.
No need to find value it will take your time.
So D.
Isnt xC3-(x-1)C3=15??
7C3= 35 and 6C3 =20, or am I wrong?
Retired Moderator
Joined: 22 Aug 2013
Posts: 1435
Location: India
Re: If 3 members are to be selected from a team of x members then what is [#permalink]
### Show Tags
08 Apr 2018, 04:33
1
truongvu31 wrote:
kunalcvrce wrote:
GMATinsight wrote:
If 3 members are to be selected from a group of x members then what is the value of x?
1) If team of 3 members is selected from the group of x members then 30 different combinations of 3 members can be formed with 2 specific members never being together on the team
2) There are a total of 35 ways to make team of 3 members out of team of x members.
Source: http://www.GMATinsight.com
we have to find x.
From1 : 2 specific members never being together=Total number of combinations- 2 specific members being together.
Total number of combinations=xC3
2 specific members being together=(x-1)C3
xC3-(x-1)C3=30
Since one equation one variable . So 1 is sufficient.
From2 : xC3=35
Again one equation one variable . So 2 is also sufficient.
No need to find value it will take your time.
So D.
Isnt xC3-(x-1)C3=15??
7C3= 35 and 6C3 =20, or am I wrong?
Actually, it shouldnt be (x-1)C3.. The no of ways of selecting 3 out of x, so that two specific members are together on the team = (x-2)C1.. this is because if we have already fixed two members, then we have to select remaining 1 more member out of (x-2). | {
"domain": "gmatclub.com",
"id": null,
"lm_label": "1. Yes\n2. Yes",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9334308036221031,
"lm_q1q2_score": 0.8206226751760153,
"lm_q2_score": 0.8791467690927438,
"openwebmath_perplexity": 2553.2128401709892,
"openwebmath_score": 0.2759699821472168,
"tags": null,
"url": "https://gmatclub.com/forum/if-3-members-are-to-be-selected-from-a-team-of-x-members-then-what-is-262420.html"
} |
homework-and-exercises, electromagnetism, newtonian-mechanics, magnetic-monopoles, textbook-erratum
with the boundary conditions:
$$r\left(0\right)=r_0\qquad\varphi\left(0\right)=0.$$
In order to solve (1) for $r\left(t\right)$, one has to use the fact that the kinetic energy $\frac{1}{2}m\vec{v}^2$ is conserved. This holds due to the vector potential $\vec{A}=\frac{1}{2}\vec{B}\times\vec{r}=0$.
Therefore,
$$\vec{v}^2=\dot{r}^2+r^2\dot{\varphi}^2\sin^2\vartheta\equiv u^2=\text{const}$$
Using this in (1) one gets the simplified differential equation:
$$r\ddot{r}=u^2-\dot{r}^2\qquad(4)$$
Does anyone know how to derive the following solution of (4)?
$$r\left(t\right)=r_0\sqrt{1+\left(\frac{ut}{r_0}\right)^2}\qquad(5)$$
Solving (2) for $\dot{\varphi}$:
$$\dot{\varphi}=\frac{eg}{mr^2\cos\vartheta}$$
and inserting (5) I obtain:
$$\varphi\left(t\right)=\frac{eg}{mr_0u\cos\vartheta}\arctan{\frac{ut}{r_0}}.$$
Now the solutions says:
$$r\left(\varphi\right)=\frac{r_0}{\cos\left(\varphi\sin\vartheta\right)}.$$
But I get something similar, but not equal: | {
"domain": "physics.stackexchange",
"id": 13727,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "homework-and-exercises, electromagnetism, newtonian-mechanics, magnetic-monopoles, textbook-erratum",
"url": null
} |
# Find symmetric matrix containing no 0's, given eigenvalues
I'm preparing for a final by going through the sample exam, and have been stuck on this:
$$Produce\ symmetric\ matrix\ A ∈ R^{3×3},\ containing\ no\ zeros.\ \\ A\ has\ eigenvalues\ λ_1 = 1,\ λ_2 = 2,\ λ_3 = 3$$
I know $A = S^{-1}DS$, where A is similar to the diagonal matrix D, and S is orthogonal.
The diagonal entries of D are the eigenvalues of A.
I also know that A & D will have the same determinant, eigenvalues, characteristic polynomial, trace, rank, nullity, etc. I am not sure where to go from here though. How cna A be found with only the two pieces of information? It seems like too little information is given...
• It isn't claimed that A be unique. I suppose any A that satisfies the given conditions will do. – Stefan Böttner Jul 5 '18 at 13:47
• Thanks for the answers everyone! I guess I was overthinking a little and should've just tried a few to see what happened. I appreciate all the guidance :) – Reccho Jul 5 '18 at 14:31
You are correct in observing that "too little" information is given in the sense that there are infinitely many such matrices. But you need to produce just one. So start with the diagonal matrix $D = \operatorname{diag}(1,2,3)$ and conjugate it by a simple (but not too simple) orthogonal matrix $S$. You don't want $S$ to be a block matrix because then $S^{-1} D S$ will also be a block matrix and so will have zeroes. For example, we can take | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9799765557865637,
"lm_q1q2_score": 0.8478993249416958,
"lm_q2_score": 0.865224091265267,
"openwebmath_perplexity": 351.2203718378225,
"openwebmath_score": 0.9017541408538818,
"tags": null,
"url": "https://math.stackexchange.com/questions/2841820/find-symmetric-matrix-containing-no-0s-given-eigenvalues"
} |
javascript, recursion, tree, json, promise
I'm wondering if there is a better, cleaner way to go about this? Let's separate it by responsibilities into renderKids, renderName, traverseTree so that:
the main function can start explicitly from where you want
functions become immutable, free of side-effects
less repeated code
a single return is used
hopefully, the intent and flow become more obvious
function renderTree(json) {
function renderKids(kids) {
const ul = document.createElement('ul');
for (const kid of kids) {
ul.appendChild(traverseTree(kid))
}
return ul;
}
function renderName(name) {
const span = document.createElement('span');
span.textContent = name;
return span;
}
function traverseTree(node) {
const li = document.createElement('li');
if (node.kids) {
li.appendChild(renderName(node.name));
li.appendChild(renderKids(node.kids));
} else {
li.textContent = node.name;
}
return li;
}
return renderKids(json.kids || []);
}
Usage: const output = renderTree(await readJson('./tree.json'))
Note, traverseTree is not asynchronous so there's no need for async keyword. | {
"domain": "codereview.stackexchange",
"id": 36470,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "javascript, recursion, tree, json, promise",
"url": null
} |
c++, object-oriented, design-patterns, datetime, polymorphism
if (num < 0 || num > 9)
throw std::runtime_error("Cannot assign Invalid digit must be: (0 < digit < 9)");
for (auto l = s_masks[num]; *l; l += 4) {
for (auto c = l; c < l+4; ++c)
_window.CUR_addch(y, x++, *c);
++y; x-=4;
}
}
};
Behold, a thing of beauty. One should never underestimate the value of self-explanatory code (if only the constants here).
The Main Application
All that remains to be done is the demo application itself. It sets up some factories, and starts an input event loop to receive keyboard shortcuts. Handling them is pretty straightforward.
The stopwatch-specific operations ([l]ap and [!]reset) are the only mildly complicated ones because they will have to filter for any running tasks that might be stopwatch tasks.
Launching a task without selecting one or more views to connect up will result in a beep() and nothing happening.
Note how clearing the _tasks or _views automatically destroys the right subscriptions (due to the use of scoped_connection).
struct DemoApp : NCursesApplication {
using TaskPtr = std::unique_ptr<TimerTask>;
using ViewPtr = std::unique_ptr<TimerView>;
using TaskFactory = std::function<TaskPtr()>;
using ViewFactory = std::function<ViewPtr()>;
using ViewFactoryRef = std::reference_wrapper<ViewFactory const>; | {
"domain": "codereview.stackexchange",
"id": 26303,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "c++, object-oriented, design-patterns, datetime, polymorphism",
"url": null
} |
Thanks.
Correct me if I'm wrong anyone but I think it might be true...
Here's some reasoning:
Suppose $\displaystyle mn=p_1^{a_1}p_2^{a_2}\cdots p_k^{a_k}$ and $\displaystyle m=p_1^{a_1}p_2^{a_2}\cdots p_i^{b_i}\cdots p_j^{b_j}$ and $\displaystyle n=p_i^{a_i-b_i}\cdots p_j^{a_j-b_j}p_{j+1}^{a_{j+1}}\cdots p_k^{a_k}$.
$\displaystyle \tau(mn)=\prod_{s=1}^k (a_s+1) = \tau(m)\tau(n)$
Omitting the simplification we get $\displaystyle \prod_{s=i}^j (a_s+1)=\prod_{s=i}^j (b_s+1)(a_s-b_s+1) = \prod_{s=i}^j (b_s(a_s-b_s)+a_s+1)$
But $\displaystyle b_r>0\implies a_r+1<b_r(a_r-b_r)+a_s+1$, so we're forced to have $\displaystyle b_s=0 \; \forall \; s$ if we want this equality to hold.
6. If you prove it, then it's true! | {
"domain": "mathhelpforum.com",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9773708026035287,
"lm_q1q2_score": 0.8402102445339619,
"lm_q2_score": 0.8596637451167997,
"openwebmath_perplexity": 287.19167889206534,
"openwebmath_score": 0.983521580696106,
"tags": null,
"url": "http://mathhelpforum.com/number-theory/147383-converse-statement-true.html"
} |
a horizontal line intersects a function's graph more than once, then the function is not one-to-one.. The horizontal line and the algebraic 1-1 test . { Why is there no horizontal-line test for functions? Using the Horizontal Line Test. Consider the horizontal lines in c If a graph of a function passes both the vertical line test and the horizontal line test then the … (i.e. Example Compare the graphs of the above functions Determining if a function is one-to-one Horizontal Line test: A graph passes the Horizontal line test if each horizontal line … Since the largest power underneath is bigger than the largest power on top, then the horizontal asymptote will be the horizontal axis. This test (if it is valid enough), provokes me to question why the trig functions cosine and sine have inverses, yet don't pass the horizontal line test because they are oscillating functions. Y Let's look at our relation, b that we used in our relations example in the previous lesson.. Is this relation a function? The Test seems to be more of a postulate than a theorem. 0 Wednesday - Steak 5. It fails the "Vertical Line Test" and so is not a function. Example #1: Use the Horizontal Line Test to determine whether or not the function y = x 2 graphed below is invertible. One way is to analyze the ordered pairs, and the other way is to use the vertical line test. To do this, draw horizontal lines through the graph. A relation is a function if there are no vertical lines that intersect the graph at more than one point. Once we have determined that a graph defines a function, an easy way to determine if it is a one-to-one function is to use the horizontal line test. is a way to determine if a relation is a function. 30 seconds . Then take a vertical line and place it on the graph. What did women and children do at San Jose? Are horizontal lines functions? c Answers 1-5: 1. However, horizontal lines are the graphs of functions, namely of constant functions. Any help would be appreciated, Thanks! {\displaystyle f\colon \mathbb {R} \to \mathbb {R} } What was the weather in Pretoria on 14 February 2013? I drew the vertical lines (output) on the graph to demonstrate what it would look like. Yes; | {
"domain": "zetta.lv",
"id": null,
"lm_label": "1. Yes\n2. Yes\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9808759654852756,
"lm_q1q2_score": 0.8277564177100399,
"lm_q2_score": 0.8438950966654772,
"openwebmath_perplexity": 252.62309892742837,
"openwebmath_score": 0.6703932285308838,
"tags": null,
"url": "http://zetta.lv/blitz-distribution-fioihc/pressure-switch-price-philippines-edff55"
} |
python, python-3.x, converting
Title: Numbers to English Strings in Python3 Inspired by the recent surge of questions dealing with changing numbers to their English equivalents (See here, here, and here), I decided to write my own version in Python.
zero_to_nineteen = (
"zero",
"one",
"two",
"three",
"four",
"five",
"six",
"seven",
"eight",
"nine",
"ten",
"eleven",
"twelve",
"thirteen",
"fourteen" ,
"fifteen",
"sixteen",
"seventeen",
"eighteen",
"nineteen"
)
tens = (
"zero",
"ten",
"twenty",
"thirty",
"forty",
"fifty",
"sixty",
"seventy",
"eighty",
"ninety"
) | {
"domain": "codereview.stackexchange",
"id": 9002,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "python, python-3.x, converting",
"url": null
} |
continuum-mechanics
It looks like you're trying to find the balance equations of a continuous medium using reference coordinates when you talk about Cauchy equation.
Namely, starting from the integral equation of mass and linear momentum for a material volume, expressed in physical space
$\dfrac{d}{dt}\displaystyle \int_{V} \rho = 0$
$\dfrac{d}{dt}\displaystyle \int_{V} \rho \mathbf{u} = \int_V \rho \mathbf{g} + \oint_{\partial V} \mathbf{t_n} = \int_V \rho \mathbf{g} + \oint_{\partial V} \mathbf{\hat{n}} \cdot \mathbb{T} = \int_V \rho \mathbf{g} + \int_{V} \nabla \cdot \mathbb{T} $,
being $\mathbb{T}$ Cauchy stress tensor. Changing coordinates from physical to reference space coordinates, it's possible to recast the integral equations as
$ \displaystyle \int_{V^0} \dfrac{\partial }{\partial t}\bigg|_{\mathbf{r_0}} ( \rho J ) = 0$
$\displaystyle \int_{V^0} (\rho J) \dfrac{\partial }{\partial t}\bigg|_{\mathbf{r_0}} \mathbf{u} = \int_{V^0} \rho J \mathbf{g} + \oint_{\partial V^0} \mathbf{\hat{n}^0} \cdot \mathbb{P} = \int_{V^0} \rho J \mathbf{g} + \int_{V^0} \nabla_0 \cdot \mathbb{P} $, | {
"domain": "physics.stackexchange",
"id": 92166,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "continuum-mechanics",
"url": null
} |
geology, volcanology, mineralogy, minerals
Title: Where can obsidian be found? Where is obsidian found?
Is it typically found on the surface or underground?
If underground, how far under (meters or feet would be perfect)?
Also, is it found everywhere on Earth, or just in areas where volcanic activity is (or was recently) high? Obsidian is formed when a rhyolitic (or felsic) lava flows cool rapidly. This must mean that it's mostly available on the surface (and I think if you go near volcanos you can find pieces of Obsidian on the ground) because molten rock cools much faster above ground than it does below, allowing the melt to cool with small crystals (as opposed to intrusive rocks which have larger crystals). This means that Obsidian is an extrusive igneous rock.
I am betting that Obsidian is very common around most active volcanos around the world! | {
"domain": "earthscience.stackexchange",
"id": 227,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "geology, volcanology, mineralogy, minerals",
"url": null
} |
navigation, turtlebot, costmap-2d, ubuntu, plugin
Title: I would like to use the same package with two different parameters
Hello. I am a ROS beginner. I am doing SLAM of turtlebot 2 in the ubuntu 14.04, ros (indigo) personal computer environment.
I am making a plugin for costmap _ 2 d.
So I would like to use two inflation layers with different parameters.
How can I duplicate the same package?
Thank you.
https://github.com/ros-planning/navigation/tree/indigo-devel/costmap_2d
I decided to create a package named inf_layer.
However, I feel that an error will occur because the namespace is intact.
Paste the source code.
https://github.com/yugogogogogo/inflayer/tree/master/inf_layers
Please tell me how to do it.
plugins:
- {name: simple_layer, type: "simple_layer_namespace::SimpleLayer"}
- {name: inf_layer, type: "costmap_2d::InflationLayer"}
- {name: obstacle_layer, type: "costmap_2d::VoxelLayer"}
- {name: inflation_layer, type: "costmap_2d::InflationLayer"}
inf_layer:
cost_scaling_factor: 1
inflation_radius: 1.2
enabled: true
inflation_layer:
cost_scaling_factor: 5 # exponential rate at which the obstacle cost drops off (default: 10)
inflation_radius: 0.5 # max. distance from an obstacle at which costs are incurred for planning paths. (default: 0.5)
enabled: true | {
"domain": "robotics.stackexchange",
"id": 32240,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "navigation, turtlebot, costmap-2d, ubuntu, plugin",
"url": null
} |
javascript, tree, reinventing-the-wheel, breadth-first-search, depth-first-search
Node.prototype.every = function(callback) {
return this.reduce((a, n) => a && callback(n), true);
};
Node.prototype.some = function(callback) {
return this.reduce((a, n) => a || callback(n), false);
};
Node.prototype.find = function(callback, mode) {
return this.reduce((a, n) => a || (callback(n)? n: false), false, mode);
};
Node.prototype.includes = function(value) {
return this.some(n => n.value === value);
}; This is overall well-thought-out, well-organized, and well-written.
There's at least one bug, and one oversight that I would consider a bug:
In traverse your recursive call is passing the wrong second parameter:
} else if (mode == Node.Traversal.DepthFirst) {
callback(this);
this.children.forEach(n => n.traverse(callback, false));
}
should read
} else if (mode == Node.Traversal.DepthFirst) {
callback(this);
this.children.forEach(n => n.traverse(callback, Node.Traversal.DepthFirst));
}
in add you don't declare child. Presumably is should read for (let child of children)
As to design decisions, there are several things you might want to consider.
add might be improved with return this.
I think a clone method might be a more common choice here than a static from function.
You might find the ES6 class syntax slightly more explicit. I wasn't a big fan of it when it was proposed, and I'm still not; I don't like the implication it suggests that JS OOP is particularly similar to Java/C# style OOP. But it does carry a bit less cruft than the constant repetition of Node.prototype. | {
"domain": "codereview.stackexchange",
"id": 35698,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "javascript, tree, reinventing-the-wheel, breadth-first-search, depth-first-search",
"url": null
} |
ideal-gas
$\frac{V}{n}$= The volume of a single nucleus (since we assume that's
where all mass is centered)
$V$ is not the volume of a single nucleus. $n$ is the number of moles of gas. So $\frac{V}{n}$ is volume per mole of gas. One mole of gas equals the mass of the gas divided by the molecular weight of the gas. Therefore, for example, one gram-mole of oxygen gas equals 32 grams of oxygen (molecular weight of oxygen gas being 32).
$\frac{V}{n}∝{M_r∝{m}}$ Since molecular density is constant
I'm not sure I even follow this. What is $M_r$? Is $m$ mass? What is meant by $\frac{V}{n}α$ $m$? The last relationship is, for a given molecular weight gas, equivalent to saying that volume divided by mass equals mass (????).
$m∝\frac{1}{2}{m}{v^2}∝{T}$ Since temperature is just equally
distributed kinetic energy
Mass is proportional to mass? What is the purpose of that? At least yes, temperature is proportional to kinetic energy (more accurately average kinetic energy). This is perhaps the one argument that makes sense since kinetic energy is not explicitly shown in the ideal gas equation, and the ideal gas equation is derived from the kinetic theory of gases.
Since pressure is just total force within a fixed volume.
No it isn't. For a fixed volume pressure is the force per unit area exerted on the walls of the container of gas.
Hope this helps. | {
"domain": "physics.stackexchange",
"id": 72475,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "ideal-gas",
"url": null
} |
star-systems, interstellar-medium, turbulence
Title: Sources of Turbulence in the ISM What sources of turbulence exist within the Interstellar medium (ISM)? Which ones are physically the most important for newly forming stellar systems? Turbulence sources:
There are numerous sources of turbulence in the interstellar medium, at all scales:
at large scales, there is the shear from galactic rotation. One way to sustain turbulence and to couple large and small scales would be the magnetorotational instability (MRI).
at large scales, gravitational instabilities can also play a significant role, through spiral structures.
outflows and jets from forming stars play an important role, releasing a lot of energy in the ISM.
in star forming regions, massive stars are also important. Radiation and stellar winds from massive stars are an important input of energy in the ISM. And eventually, the most massive ones will blow up in supernovæ, releasing even more energy.
Therefore, one could then regards separatly three processes related to massive stars:
stellar winds
ionizing radiation
supernova explosion
Importance for star formation:
They are all relevant to star formation, one way or another. One key property of turbulence is to cascade from large to small scales; therefore, even if you inject turbulence at large scales (galactic scale) you'll get turbulent motions down to the scale of a molecular cloud.
A nice illustration of the tubulent cascade is the Larson's relation (Larson 1981):
The Larson's relation shows the evolution of the velocity dispersion with the size of the structure you're looking at. Velocity dispersion is an indicator of turbulence. Indeed, these dispersions are non-thermal: knowing the typical temperature of the MIS (about 10 K), one can estimate the thermal velocity of, for example, the CO molecule ($v_th = \sqrt{2kT/\mu m_H}$, with $k$ the Boltzman constant, $T$ the temperature, $\mu$ the mean molecular wright and $m_H$ the hydrodgen atom mass) that is about 0.07 km s$^{-1}$. Measured velocity dispersions are of the order of 1 to 10 km s$^{-1}$, and these is interpreted as a turbulence signature (and estimate).
Details:
Energy rates: values are given (roughly) for the Milky Way | {
"domain": "astronomy.stackexchange",
"id": 91,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "star-systems, interstellar-medium, turbulence",
"url": null
} |
7,7),(1,8,7),(2,9,7),(8,0,8),(7,1,8),(9,1,8),(6,2,8),(5,3,8),(4,4,8),(3,5,8),(2,6,8),(1,7,8),(0,8,8),(1,9,8),(9,0,9),(8,1,9) | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9688561676667174,
"lm_q1q2_score": 0.8215587908256713,
"lm_q2_score": 0.8479677564567913,
"openwebmath_perplexity": 321.1737973788015,
"openwebmath_score": 0.765707790851593,
"tags": null,
"url": "https://math.stackexchange.com/questions/1410362/how-many-3-digit-numbers-can-be-formed-so-that-the-sum-of-two-digits-will-be-e"
} |
ros, inverse-kinematics, moveit
Originally posted by Sietse on ROS Answers with karma: 168 on 2016-09-09
Post score: 0
Original comments
Comment by cbames on 2016-09-12:
How are you determining that the poses are perfectly reachable?
Comment by Sietse on 2016-09-12:
I have a program (arbotix_gui) to set the joints and visualise with rviz.
From the ROS_by_example book I use get_arm_pose.py that gives the eef position.
I think that should work.
See also my comment below where trac_ik uses the ik_test program where 995 out of 1000 attemps succeed.
Comment by pbeeson on 2016-09-12:
I believe the trac_ik sample uises 1e-3 eps, which again points to the fact that your goal pose may be be exactly reachable after you round it to 3 significant digits.
As @Airuno2L stated, the numerical solvers are optimized for with >= 6 DOF. A solution that worked well for us in some applications is performing some slight modifications on trac_ik to make it work better with < 6 DOF systems. You can find a fork here: https://github.com/tu-darmstadt-ros-pkg/hector_trac_ik/commits/master
And a example robot configuration using the options here:
https://github.com/tu-darmstadt-ros-pkg/hector_tracker_planning/blob/master/hector_tracker_robot_moveit_config/config/kinematics.yaml
Originally posted by Stefan Kohlbrecher with karma: 24361 on 2016-09-12
This answer was ACCEPTED on the original site
Post score: 0 | {
"domain": "robotics.stackexchange",
"id": 25723,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "ros, inverse-kinematics, moveit",
"url": null
} |
neural-networks
So far, so good. Note that, as advised in the course, I've rescaled all inputs by dividing by 255. Next, I ran without any rescaling:
import tensorflow as tf
(Xtrain, ytrain) , (Xtest, ytest) = tf.keras.datasets.fashion_mnist.load_data()
model2 = tf.keras.models.Sequential([tf.keras.layers.Flatten(),
tf.keras.layers.Dense(128, activation="relu"),
tf.keras.layers.Dense(10, activation="softmax")]) | {
"domain": "ai.stackexchange",
"id": 1292,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "neural-networks",
"url": null
} |
= svd (A) returns numeric unitary matrices U and V with the columns containing the singular vectors, and a diagonal matrix S containing the singular values. This chapter describes functions for solving linear systems. QDWH-SVD performance results and compares against the state-of-the-art commer-cial and open-source high performance SVD solver implementations, and we conclude in Section 9. there is a clear need for a high quality SVD solver software that allows for additional flexibility, implements state-of-the-art methods, and allows for preconditioning. INTRODUCTION Singular value decomposition. I am looking for a fast Eigenvalue and SVD solver for small dense structured matrices (Hankel and Toeplitz). \\ \) (enter a data after click each cell in matrix) Matrix A {a ij} SVD. What happens if the matrix is not symmetric? It turns out that we can factorize A by Q1 QT 2, where Q1;Q2 are orthogonal and is nonnegative and diagonal-like. The Singular Value Decomposition (SVD) Right singular vectors v1 = 1 √ 2 1 1 v2 = 1 √ 2 −1 1. Inverting Matrix - SVD (singular value decomposition) Every once in a while you find yourself needing to solve a set of equations, or invert a matrix, or worse yet, invert a non-square matrix (eg: pseudo-inverse for manipulator inverse kinematics path control (See: Minerva IK control image on right, work I did at TUM) or kalman filtering). """ try: # find the intercepts using gaussian elimination M = extreme_points - ideal_point b = np. If you're behind a web filter, please make sure that the domains *. SVD of A is: 4 3 1 1 2 √ 125 0. Use of n_components == 'mle' will interpret svd_solver == 'auto' as svd_solver == 'full'. What happens if the matrix is not symmetric? It turns out that we can factorize A by Q1 QT 2, where Q1;Q2 are orthogonal and is nonnegative and diagonal-like. 2 Motivation Ux y Ly b LUx b A LU A: x x S b A S | {
"domain": "cesenaticoopen.it",
"id": null,
"lm_label": "1. Yes\n2. Yes\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9848109485172559,
"lm_q1q2_score": 0.8227933346453876,
"lm_q2_score": 0.8354835371034368,
"openwebmath_perplexity": 1043.0111490718846,
"openwebmath_score": 0.6158665418624878,
"tags": null,
"url": "http://yjcg.cesenaticoopen.it/svd-solver.html"
} |
# Proving $\Im\operatorname{Li}_2(\sqrt i(\sqrt 2-1))=\frac34G+\frac18\pi\ln(\sqrt2-1)$
$$\newcommand{\Li}{\operatorname{Li}_2}$$
I found, numerically, that $$\Im\Li(\sqrt i(\sqrt 2-1))=\frac34G+\frac18\pi\ln(\sqrt2-1).$$ How can we prove it? | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9867771790254151,
"lm_q1q2_score": 0.8044528227372135,
"lm_q2_score": 0.8152324960856177,
"openwebmath_perplexity": 3830.92304966492,
"openwebmath_score": 0.9300416111946106,
"tags": null,
"url": "https://math.stackexchange.com/questions/3029789/proving-im-operatornameli-2-sqrt-i-sqrt-2-1-frac34g-frac18-pi-ln-sqrt/3061998"
} |
c++, combinatorics
Title: A little next combination program in C++ An implementation of next combination function at Discrete Mathematics and Its Applications, Rosen p.438.
How it works:
Input:
The size n of a integer set {1, 2, ..., n}, which is where you choose objects from.
The size r of the subset of the integer set you currently have.
A pointer to the subset you currently have.
Output: The next subset in lexicographic order.
If you want to play around here is a link to ideone.com.
#include <iostream>
using std::cout;
// C(n, r) and provide the current subset a of size r.
bool nextCombination(int n, int r, int *a);
void printArray(int *a, int n);
int main() {
int a[] = {1,2,3}; // So the current subset is {1,2,3} of size 3.
int length = sizeof(a)/sizeof(*a);
int count = 0;
// The following example is C(7,3), start at {1,2,3}
do {
printArray(a, length);
count++;
} while (nextCombination(7, length, a));
cout << "Total: " << count << '\n'; // Since we start from {1,2,3}, all C(7,3) subsets are generated and counted. The answer should be 7!/(3!4!)=35
return 0;
} | {
"domain": "codereview.stackexchange",
"id": 29992,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "c++, combinatorics",
"url": null
} |
c++, object-oriented, game, playing-cards, sfml
target.draw(specialCardInformation);
}
VisualGame.hpp
#pragma once
#include <SFML/Graphics/RenderWindow.hpp>
#include "Player.hpp"
#include "FontsHolder.hpp"
#include "Renderer.hpp"
#include <vector>
std::string const defaultWindowName{ "MacaoGame" };
class VisualGame
{
public:
template <typename InputContainer>
VisualGame(InputContainer&& players, std::string_view pathToCardTextures
, std::string_view pathToFonts, std::size_t width, std::size_t height);
template <typename InputIterator>
VisualGame(InputIterator first, InputIterator last,
std::string_view pathToCardTextures, std::size_t width, std::size_t height);
void run();
private:
constexpr void validateNumberOfPlayers() const;
constexpr bool areCompatible(Card const& left, Card const& right) const noexcept;
void prepareGame() noexcept;
void dealInitialCardsToEachPlayer() noexcept;
void receiveCardsFromDeck(Player& player, std::size_t numberOfCards);
void putCardToPile(Player& player, std::size_t cardNumber) noexcept;
bool isSpecial(Card const& card) const noexcept;
void printInformationAboutThePlayerAndTheTopCardFromPile(Player const& player) noexcept;
void printInformationAboutThePlayerAndTheTopCardFromPile(Player const& player, Rank rank) noexcept;
void normalCardPlayerTurn(Player& player);
void specialCardPlayerTurn(Player& player);
std::unique_ptr<Player> findWinner() const noexcept;
auto receiveAndValidateInput() const noexcept->int; | {
"domain": "codereview.stackexchange",
"id": 31479,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "c++, object-oriented, game, playing-cards, sfml",
"url": null
} |
ros, navigation, mapping, tutorials
Comment by 2ROS0 on 2015-11-18:
@nightblue you're right - I figured that out, this thread is a bit outdated.
As for your question - the normal trend is to use rolling_window: true for local costmap since by definition that map is used for collision checking with the immediate robot.
Comment by 2ROS0 on 2015-11-18:
@nightblue so I would leave the global costmap as static and keep a rolling window for the local costmap unless you have a specific reason to diverge from this method.
Comment by automate on 2016-02-02:
@nightblue and @2ROS0 so whats the conclusion!? I do not want to use a map. So do i need to configure amcl or not? And do i need map->odom-> base_link -> laser or odom-> base_link -> laser is fine? | {
"domain": "robotics.stackexchange",
"id": 6033,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "ros, navigation, mapping, tutorials",
"url": null
} |
orbital-motion, planets, space-travel
y[3][0] == p[3][[2]], x[2]'[0] == v[2][[1]], y[2]'[0] == v[2][[2]],
x[3]'[0] == v[3][[1]], y[3]'[0] == v[3][[2]],
WhenEvent[
t == 173379, {x[3]'[t] -> 20785.020973205566` + Sqrt[(G m[2])/6.395400814228174`*^6]Sin[-0.7053105626554602`],
y[3]'[t] ->(*v[2][[2]]*)-11763.84750366211` -
Sqrt[(G m[2])/6.395400814228174`*^6]
Cos[-0.7053105626554602`]}]}, {x[2][t], y[2][t], x[3][t],
y[3][t]}, {t, 0, tmax}, StartingStepSize -> 0.001,
AccuracyGoal -> 17, PrecisionGoal -> 17,
Method -> "StiffnessSwitching", MaxSteps -> 10000000] | {
"domain": "physics.stackexchange",
"id": 13025,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "orbital-motion, planets, space-travel",
"url": null
} |
java, asynchronous, error-handling, http
public String getRemoteSecondaryHostname(final String remoteDataCenterPath, final int shardId) {
final String remoteSecondaryHostId = secondaryHostIdToPartitionMapping.get(remoteDataCenterPath).get(shardId);
final String remoteSecondaryHostname = getHostname(remoteDataCenterPath, remoteSecondaryHostId);
return remoteSecondaryHostname;
}
private String getHostname(final String dataCenterPath, final String hostId) {
final String hostname = hostIdToMachineMapping.get(dataCenterPath).get(
Integer.parseInt(hostId));
return hostname;
}
}
You can notice that
hostIdToMachineMapping is used by only getHostname,
primaryHostIdToPartitionMapping is used by only getLocalPrimaryHostname and getRemotePrimaryHostname and
secondaryHostIdToPartitionMapping is used by only getLocalSecondaryHostname and getRemoteSecondaryHostname.
They're three separate groups, three separate responsibilities, they should have three classes. (Single responsibility principle)
You could create PrimaryShardMapping, SecondaryShardMapping and HostIdToMachineMapping classes here. Logic in PrimaryShardMapping and SecondaryShardMapping is almost the same, so you probably could generalize that into one class (maybe you need to use two factories to fill their maps properly).
Anyway, there could be other stuff in the ShardMappings class, so I stop here. | {
"domain": "codereview.stackexchange",
"id": 12913,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "java, asynchronous, error-handling, http",
"url": null
} |
java
Now, while dealing with that stream, it's not really streaming things "right".... The System.out.println is out-of-place. You should be mapping the query in to a count in one step, and then outputting the count in a different step....
queries.stream()
.mapToInt(query -> corpus.stream()
.filter(p -> p.equals(query))
.count()
)
.forEach(System.out::println);
Now, there are ways to improve that performance still, for example, lots of println statements could be grouped in to just one print...
String output = queries.stream()
.mapToInt(query -> corpus.stream()
.filter(p -> p.equals(query))
.count()
)
.mapToObj(String::valueOf)
.collect(Collectors.joining("\n"));
System.out.println(output);
Finally, note that you are doing an \$O(n)\$ operation for each query. You should consider a way of improving that time-cost by front-loading the creation of a Map when loading up the words will improve the performance of querying things.
For example, consider this:
IntStream.range(0, N).forEach(n -> corpus.add(sc.next()));
First up, that inner part n -> corpus.add(sc.next()) is doint a "side-effect" operation that can be avoided. Functional-programming purists try to avoid side-effects in streasm as much as possible. SOmetimes it is unavoidable, but you could easily re-write that line as:
List<String> corpus = IntStream.range(0, N)
.mapToObj(n -> sc.next())
.collect(Collectors.toList());
That adds each word to a list. How about doing it this way:
Map<String, List<String>> data = IntStream.range(0, N)
.mapToObj(i -> sc.next())
.collect(Collectors.groupingBy(v -> v)); | {
"domain": "codereview.stackexchange",
"id": 24207,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "java",
"url": null
} |
def main():
if len(sys.argv) < 2:
print "usage: monty.py trials"
sys.exit(1)
t = int(sys.argv[1])
# Stick with door
stick_winners = 0
for i in xrange(t):
car = random.randint(1, 3)
choice = random.randint(1, 3)
if car == choice:
stick_winners += 1
print "(stick) won:", stick_winners, "out of", t, float(stick_winners) / float(t)
# Switch door
switch_winners = 0
for i in xrange(t):
car = random.randint(1, 3)
choice = random.randint(1, 3)
# If car != choice, open a goat door and switch, win the car
if car != choice:
switch_winners += 1
print "(switch) won:", switch_winners, "out of", t, float(switch_winners) / float(t)
if __name__ == "__main__":
main()
• Your code contains a nice way to think about the problem. Under the switch strategy you win the car if and only if your original choice was not the car, making it clear what the probability is. – Matthew Towers May 31 '12 at 18:10
Code I created based off of Peter Phipps pseudocode for school assignment (very helpful by the way):
n = int(input("Enter the number of iterations: "))
winswap = 0.0
winnoswap = 0.0
simcount = 0.0
for i in range(n):
simcount = simcount + 1
picked_door = random.randint(1,3)
car = random.randint(1,3)
g = random.randint(1,3)
completed = False
while not completed:
if g != car and g != picked_door:
completed = True
else:
g = random.randint(1,3)
swap = random.randint(1,2) | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9693242018339896,
"lm_q1q2_score": 0.8139744501912101,
"lm_q2_score": 0.8397339596505965,
"openwebmath_perplexity": 3369.8703658196855,
"openwebmath_score": 0.2874583601951599,
"tags": null,
"url": "https://math.stackexchange.com/questions/152006/how-to-simulate-monty-hall-problem-in-computer"
} |
ros, navigation, plugin, sbpl
Any thoughts?
Thanks
Originally posted by ROSCMBOT on ROS Answers with karma: 651 on 2014-11-28
Post score: 0
This works for me on Hydro. Are you sure you've sourced the setup.bash for the workspace containing sbpl_lattice_planner before you launch move_base?
Originally posted by ahendrix with karma: 47576 on 2014-11-28
This answer was ACCEPTED on the original site
Post score: 1
Original comments
Comment by ahendrix on 2014-11-30:
I guess the OP solved this, because he followed up with a question indicating that SBPL is working: http://answers.ros.org/question/198586/sbpllatticeplanner-and-pose_follower/
Comment by ROSCMBOT on 2014-11-30:
Yes, Thanks @ahendrix . I marked your comment as the correct response. | {
"domain": "robotics.stackexchange",
"id": 20190,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "ros, navigation, plugin, sbpl",
"url": null
} |
rosmake
Title: rosmake: error: no such option: --rosdep-install
i need help to solve this problem.. im using hydro
Originally posted by haider on ROS Answers with karma: 19 on 2014-05-14
Post score: 0
That option was removed in ROS Fuerte, and is no longer valid in ROS Hydro. Please search for duplicate answers before posting:
http://answers.ros.org/question/39571/rosmake-error-no-such-option-rosdep-install/
http://answers.ros.org/question/38291/no-such-option-rosdep-install/
Originally posted by jbohren with karma: 5809 on 2014-05-15
This answer was ACCEPTED on the original site
Post score: 2 | {
"domain": "robotics.stackexchange",
"id": 17950,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "rosmake",
"url": null
} |
probability-theory, information-theory, entropy
Title: Pointwise mutual information vs. Mutual information? I am learning about information theory and mutual information. However, I am quite confused with MI(Mutual information) vs. PMI(Pointwise mutual information) especially signs of MI and PMI values. Here are my questions.
Is MI values a non-negative value or it can be either positive or negative? If it is always a non-negative value, why is it ?
As I search online, the PMI can be positive or negative values and the MI is the expected value of all possible PMI. However, expected value can be positive or negative. If MI is really the expected value of PMI, why is it always positive ?
Did I misunderstand anything of MI and PMI here ? Thank you very much, PMI can clearly be negative, since if $p(x,y)<p(x)p(y)$, then taking $\log \frac{p(x,y)}{p(x)p(y)}$ gives a negative number.
But MI is always non-negative, as it can be written as $d_{KL}(p(x,y)||p(x),p(y))$, where $d_{KL}$ is the Kullback–Leibler divergence which is non-negative (the proof of the latter is not completely trivial).
Intuitively, this happens because if there is a point such that $p(x,y)<p(x)p(y)$, then the probability must "compensate" for this later, with a pair $p(x',y')>p(x')p(y')$. | {
"domain": "cs.stackexchange",
"id": 1136,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "probability-theory, information-theory, entropy",
"url": null
} |
ros, callback
...
void MikrokopterControl::genericCallback(const sensor_msgs::IMU& data)
{
function1(data);
function2(data);
}
Originally posted by DimitriProsser with karma: 11163 on 2012-06-06
This answer was ACCEPTED on the original site
Post score: 4 | {
"domain": "robotics.stackexchange",
"id": 38682,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "ros, callback",
"url": null
} |
ros, ros-kinetic
Title: Convience methods to convert rospy.Time to datetime.datetime
I couldn't find any convenience methods to convert rospy.Time to datetime.datetime. Timezones and other issues make this less trivial than it appears, especially for novice users.
Am I missing something obvious, or is this a textbook case of "nope, not done yet, please submit a patch?"
Thanks!
Originally posted by ivaughn on ROS Answers with karma: 76 on 2018-03-26
Post score: 1
Original comments
Comment by gvdhoorn on 2018-03-27:
I would say this is indeed something that just hasn't been done yet. Shouldn't be too difficult though: rospy.Time is a Unix stamp, so conversions should be against UTC, correct?
datetime.datetime to rospy.Time:
import datetime
import rospy
dt0 = datetime.datetime.strptime('2018-03-26-14:38:02.012345', '%Y-%m-%d-%H:%M:%S.%f').replace(tzinfo=datetime.timezone.utc)
rt0 = rospy.Time.from_sec(dt0.timestamp())
rospy.Time to datetime.datetime and back:
dt1 = datetime.datetime.utcfromtimestamp(rt0.to_sec())
rt1 = rospy.Time.from_sec(dt1.replace(tzinfo=datetime.timezone.utc).timestamp())
Originally posted by rgov with karma: 130 on 2020-11-11
This answer was ACCEPTED on the original site
Post score: 4 | {
"domain": "robotics.stackexchange",
"id": 30449,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "ros, ros-kinetic",
"url": null
} |
These type of questions can usually be tackled using recursion. In this case consider the following:
As Peter well pointed out, the probability of rolling an odd sum is always $$\frac{1}{2}$$, and you have probability 1 of the game ending at some point. So let's say that $$E$$ is the expected value of the game, while $$E_{n}$$ is the expected value of the game given that your starting turn is throwing $$n$$ dice. First time rolling, game will finish if you roll an odd number. This happens with probability $$\frac{1}{2}$$ and $$\mathbb{E}(\text{result}|\text{roll was odd})=3$$, while with probability $$\frac{1}{2}$$ we will roll an even number and now the expected result will be the expected result of a game with two dice (what we called $$E_{2}$$).
So we write down the following:
$$E = \frac{1}{2}.3+\frac{1}{2}.E_{2}$$
Next step is to work out $$E_{2}$$, which following our reasoning (you can run the cases), renders:
$$E_{2} = \frac{1}{2}.7+\frac{1}{2}.E_{3}$$
which we can replace in our previous expression for $$E$$ resulting in: $$E = \frac{1}{2}.3+\frac{1}{2}.\frac{1}{2}.7+\frac{1}{2}.\frac{1}{2}.E_{3}$$
It's easy to see from here that:
$$E = \frac{1}{2}.3+\sum_{n=2}^{\infty}\frac{\mathbb{E}\left( \text{sum of n dice}|\text{sum is odd}\right)}{2^{n}}$$ | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9867771782476948,
"lm_q1q2_score": 0.8135602132825311,
"lm_q2_score": 0.8244619263765707,
"openwebmath_perplexity": 383.48994471602134,
"openwebmath_score": 0.7098848223686218,
"tags": null,
"url": "https://math.stackexchange.com/questions/3145700/find-the-average-score-obtained"
} |
electrostatics, electric-circuits, electrical-resistance, capacitance, batteries
Title: Understanding voltage conservation by capacitive coupling At work we faced the following problem:
We are working with some high voltage batteries which are located inside a casing which isolates the batteries. This means you cannot get any significant current by short circuting the batteries by using the casing.
The production teams, hoewever faces problems. When touching the front and the back of the casing they experience a small shock due to capacitive coupling.
The electrical engineers reproduced the problem and measured exactly the voltage of the batteries between the front and the back.
They argued that this is completely expected and natural by this graphic (voltage source each 5 V):
On the left you see the 2 batteries, on the right the highohmian casing. The capacities show the coupling between capacities and casing.
I also understand that, but then I got thinking:
Why does the outside electric field of the batteries, which should be fairly low compared with the field inside the batteries generate the same voltage (U = $\int Eds$) as the two batteries do when connected directly.
Why does at all capacative coupling produce the same voltage?
In my opinion the electric field of the batteries should look like that:
(A very moderate estimation of the electric field produced by the batteries (stronger in the middle))
Edit: Improved field suggestion to make it look less confusing In comments you clarified that the heart of your question is,
I am saying that the potential energy (which voltage is) outside the batteries cannot possibly be the same as inside the batteries, since the electric field outside is much weaker.
The potential energy change caused by moving a charged particle through a field depends on two things:
How strong the field is
How far you moved the particle. | {
"domain": "physics.stackexchange",
"id": 99173,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "electrostatics, electric-circuits, electrical-resistance, capacitance, batteries",
"url": null
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.