text stringlengths 1 1.11k | source dict |
|---|---|
quantum-field-theory, renormalization, path-integral, discrete, dirac-delta-distributions
Title: Where does the delta of zero $\delta(0)$ come from? It is common when evaluating the partition function for a $O(N)$ non-linear sigma model to enforce the confinement to the $N$-sphere with a delta functional, so that
$$
Z ~=~ \int d[\pi] d[\sigma] ~ \delta \left[ \pi^2 + \sigma^2 -1 \right]
\exp (i S(\phi)),
$$
where $\pi$ is an $N-1$ component field. Then, one evaluates the integral over $\sigma$, killing the delta functional. In my understanding, this gives rise to a continuous product of Jacobians,
$$
\prod_{x=0}^L \frac{1}{ \sqrt{1 - \pi^2}} ~=~
\exp \left[- \frac{1}{2} \int_0^L dx \log (1 - \pi^2) \right]
$$
(where I have now put everything in one dimension). Now, obviously this is somewhat non-sense, at the very least because there are units in the argument of the exponential. The way I actually see this written is with a delta function evaluated at the origin,
$$
\exp \left[- \frac{1}{2} \int_0^L dx \log (1 - \pi^2) \delta(x-x) \right].
$$ | {
"domain": "physics.stackexchange",
"id": 15087,
"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, renormalization, path-integral, discrete, dirac-delta-distributions",
"url": null
} |
Your work looks good so far. Here is a hint:
$$\frac{1}{n^2} \le \frac{1}{n(n-1)} = \frac{1}{n-1} – \frac{1}{n}$$
To elaborate, apply the hint to get:
$$\frac{1}{2^2} + \frac{1}{3^2} + \frac{1}{4^2} + \cdots + \frac{1}{n^2} \le \left(\frac{1}{1} – \frac{1}{2}\right) + \left(\frac{1}{2} – \frac{1}{3}\right) + \left(\frac{1}{3} – \frac{1}{4}\right) + \cdots + \left(\frac{1}{n-1} – \frac{1}{n}\right)$$
Notice that we had to omit the term $1$ because the inequality in the hint is only applicable when $n > 1$. No problem; we will add it later.
Also notice that all terms on the right-hand side cancel out except for the first and last one. Thus:
$$\frac{1}{2^2} + \frac{1}{3^2} + \frac{1}{4^2} + \cdots + \frac{1}{n^2} \le 1 – \frac{1}{n}$$
Add $1$ to both sides to get:
$$a_n \le 2 – \frac{1}{n} \le 2$$
It follows that $a_n$ is bounded from above and hence convergent. | {
"domain": "bootmath.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9888419703960399,
"lm_q1q2_score": 0.8660149440859115,
"lm_q2_score": 0.8757870013740061,
"openwebmath_perplexity": 209.7219452408486,
"openwebmath_score": 0.9254652857780457,
"tags": null,
"url": "http://bootmath.com/need-to-prove-the-sequence-a_n1frac122frac132cdotsfrac1n2-converges.html"
} |
There's a nontrivial theorem going on here: one must prove that the Euler number is well-defined independent of choice (the main choice being the trivialization of $$E^{(1)}$$), and that two oriented circle bundles over $$T$$ are isomorphic as oriented bundles if and only if they have the same Euler number. Those proofs are where the true "obstruction theory" arguments take place. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9852713891776498,
"lm_q1q2_score": 0.8055327486743871,
"lm_q2_score": 0.8175744850834648,
"openwebmath_perplexity": 125.52985713975177,
"openwebmath_score": 0.9670451283454895,
"tags": null,
"url": "https://math.stackexchange.com/questions/3790888/fundamental-group-of-the-total-space-of-an-oriented-s1-fiber-bundle-over-t2?noredirect=1"
} |
ros, multi-thread, nodelet
Title: Nodelet multi-threading example
Hi all,
I am finding a way to separate some heavy load process into some standalone threads so that I could get other callbacks in time using nodelet. I looked at the nodelet wiki page but it has few description about its multi-threading model and usage, so I am wondering where I could find such usage examples or projects already doing this?
BTW, is creating my own threads using boost inside a nodelet a bad idea?
Thanks for any help.
Originally posted by K Chen on ROS Answers with karma: 391 on 2011-12-18
Post score: 2
The camera1394 nodelet is an example of using multiple threads: source.
Originally posted by tfoote with karma: 58457 on 2011-12-22
This answer was ACCEPTED on the original site
Post score: 2
Original comments
Comment by K Chen on 2011-12-24:
Thanks! This helped me a lot. | {
"domain": "robotics.stackexchange",
"id": 7680,
"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, multi-thread, nodelet",
"url": null
} |
java, design-patterns, mvc, android
private final ColorMatrixView colorMatrixView;
private final ImageButton startButton;
private final ImageButton stopButton;
private final SoundLightsController controller;
private final ImageButton prevButton;
private final ImageButton nextButton;
private final RelativeLayout rootLayout;
public SoundLightsViewImpl(Activity activity, SoundLightsController controller) {
activity.setContentView(R.layout.soundlights_activity);
this.controller = controller;
colorMatrixView = (ColorMatrixView) activity.findViewById(R.id.colorMatrixView);
startButton = (ImageButton) activity.findViewById(R.id.startButton);
stopButton = (ImageButton) activity.findViewById(R.id.stopButton);
prevButton = (ImageButton) activity.findViewById(R.id.prevButton);
nextButton = (ImageButton) activity.findViewById(R.id.nextButton);
rootLayout = (RelativeLayout) activity.findViewById(R.id.rootLayout); | {
"domain": "codereview.stackexchange",
"id": 5060,
"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, design-patterns, mvc, android",
"url": null
} |
machine-learning, r, neural-network, predictive-modeling, forecast
Title: R - Interpreting neural networks plot I know there are similar question on stats.SE, but I didn't find one that fulfills my request; please, before mark the question as a duplicate, ping me in the comment.
I run a neural network based on neuralnet to forecast SP500 index time series and I want to understand how I can interpret the plot posted below:
Particularly, I'm interested to understand what is the interpretation of the hidden layer weight and the input weight; could someone explain me how to interpret that number, please?
Any hint will be appreciated. As David states in the comments if you want to interpret a model you likely want to explore something besides neural nets. That said it you want to intuitively understand the network plot it is best to think of it with respect to images (something neural networks are very good at). | {
"domain": "datascience.stackexchange",
"id": 641,
"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, r, neural-network, predictive-modeling, forecast",
"url": null
} |
c++, recursion, lambda, boost, c++20
template<typename T>
using recursive_iter_value_t = typename recursive_iter_value_t_detail<T>::type;
// Equal operator for std::ranges::input_range
template<std::ranges::input_range Range1, std::ranges::input_range Range2>
bool operator==(const Range1& input1, const Range2& input2)
{
if (input1.size() != input2.size())
{
return false;
}
for (size_t i = 0; i < input1.size(); i++)
{
if (input1.at(i) != input2.at(i))
{
return false;
}
}
return true;
}
// Not equal operator for std::ranges::input_range
template<std::ranges::input_range Range1, std::ranges::input_range Range2>
bool operator!=(const Range1& input1, const Range2& input2)
{
if (input1.size() != input2.size())
{
return true;
}
for (size_t i = 0; i < input1.size(); i++)
{
if (input1.at(i) != input2.at(i))
{
return true;
}
}
return false;
} | {
"domain": "codereview.stackexchange",
"id": 40259,
"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++, recursion, lambda, boost, c++20",
"url": null
} |
python, object-oriented
elif score == "intelligence":
self.intelligence = self.intelligence + 1
elif score == "wisdom":
self.wisdom = self.wisdom + 1
elif score == "charisma":
self.charisma = self.charisma + 1
else:
self.constitution = self.constitution + 1
score_two = raw_input("which second ability do you want to increase?")
if score_two == "strength":
self.strength = self.strength + 1
elif score_two == "dexterity":
self.dexterity = self.dexterity + 1
elif score_two == "intelligence":
self.intelligence = self.intelligence + 1
elif score_two == "wisdom":
self.wisdom = self.wisdom + 1
elif score_two == "charisma":
self.charisma = self.charisma + 1
else: | {
"domain": "codereview.stackexchange",
"id": 30978,
"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, object-oriented",
"url": null
} |
energy, vacuum
Title: Can energy be "subtracted" from vacuum? It probably sounds absurd, but I heard such expressions as "subtracting a particle from vacuum", or from squeezed vacuum, in the context of quantum experiments, or quantum optics, (not black holes). Can someone give me an example of situation in which a particle is subtract from vacuum? Further, if such a phenomenon is possible, are there processes made possible due to energy taken from the vacuum?
Again, classically it seems absurd, but is there any quantum process I which the answer is "yes"?
(I looked at other questions that seem related, but I didn't see a sufficient analogy with mine.)
I would appreciate answers as phenomenological as possible, not formulas and formulas. You are probably referring to the phenomenon where pairs of particles can appear and disappear randomly inside a vacuum. | {
"domain": "physics.stackexchange",
"id": 18187,
"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": "energy, vacuum",
"url": null
} |
thermodynamics
My question is threefold:
Is the above calculation and conclusion correct?
Am I correct when I claim the assumptions are optimistic and in real life the heat increase would be smaller?
How can this calculation be improved to be more representative of real life? You calculation seems valid as a rough approximation, giving the highest reasonable number.
The actual number will be somewhat smaller, because you assumed that all the energy used in converted into heat and all the heat goes into the juice.
Some points to see why the actual number should be smaller (but actual approxiations for these are hard to do!): | {
"domain": "physics.stackexchange",
"id": 23036,
"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
} |
quantum-mechanics, angular-momentum, schroedinger-equation, approximations, semiclassical
IV) The semiclassical approximation (F) behaves as
$$ u(r)~\propto~ r^{\sqrt{C_{\ell}}+\frac{1}{2}}\quad\text{for}\quad r~\to~ 0^{+}, \tag{G}$$
while the well-known exact behavior is
$$ u(r)~\propto~ r^{\ell+1}\quad\text{for}\quad r~\to~ 0^{+}. \tag{32.15}$$
Hence, the semiclassical approximation would have the correct behavior at the origin $r=0$ if we replace (E) with $\ell+\frac{1}{2}$.
V) Alternatively, in the free case $U(r)=0$, the semiclassical approximation (48.1) behaves as$^1$
$$ u(r)~\propto~\sin\left[\sqrt{C_{\ell}}\left(\frac{r}{r_0}-\frac{\pi}{2}\right)+\frac{\pi}{4}\right] \quad\text{for}\quad r~\to~\infty, \tag{H} $$
while the well-known exact behavior is
$$ u(r)~\propto~\sin\left[\sqrt{C_{\ell}}\frac{r}{r_0}-\ell\frac{\pi}{2}\right] \quad\text{for}\quad r~\to~\infty. \tag{33.12} $$
This again suggests to replace (E) with $\ell+\frac{1}{2}$.
References: | {
"domain": "physics.stackexchange",
"id": 17968,
"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, angular-momentum, schroedinger-equation, approximations, semiclassical",
"url": null
} |
quantum-mechanics, mathematical-physics, operators
Title: How to express a convex function of a Hermitian operator in terms of its eigenvalues and eigenvectors? The Hermitian operator $\hat O$ can be expressed as
$$\hat{O}=\sum_i O_i|O_i\rangle\langle O_i|.$$
How to prove that a convex function $f(\hat O)$ can be expressed like
$$f (\hat O)=\sum_i f(O_i)|O_i\rangle\langle O_i|~ ?$$ The proof is given in great generality by the beautiful and powerful spectral theorem; in its functional calculus form.
This theorem clarifies the meaning of your first expression, and specifies the functions for which you can write the second (that however are many). In addition, it applies to any self-adjoint operator, bounded or unbounded. | {
"domain": "physics.stackexchange",
"id": 23531,
"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, mathematical-physics, operators",
"url": null
} |
evolution, species
Feeling that we talk about improvement over another species
I think that much of the issue in saying that the dog descend from the wolf is that some people would understand things like "dog is more evolved than the wolf", which makes no sense. Both the current wolf and the current dog has evolved for exactly the same amount of time. Any living species on earth has evolved for exactly the same amount of time (almost 4 billion years).
Temporal constraint in the definition of species | {
"domain": "biology.stackexchange",
"id": 4056,
"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": "evolution, species",
"url": null
} |
which is different from our first attempt.
So, why are the results are different? Is there a "correct" way of selecting the parameters to get a "nice" formula like $$\lVert A \rVert_F^2 / n$$?
• The first parametrization induces a uniform measure (Haar measure) on the unit circle, the second one doesn't. Jan 2 at 20:39
• Possibly related: this and this and this Jan 2 at 21:54
• Rewrite the problem as $$\frac{\|Ax\|^2}{\|x\|^2} \;=\; A^TA:\left\langle \frac{xx^T}{x^Tx}\right\rangle \;=\; A^TA:\oint nn^T d\Omega$$ Then utilize the results of this answer to confirm your initial result $$\frac{\|Ax\|^2}{\|x\|^2} \;=\; A^TA:\left(\frac In\right) \;=\; \frac{A:A}{n} \;=\; \frac{\big\|A\big\|_F^2}{n}$$ The caveat is that the linked post is for ${\mathbb R}^n \;$
– greg
Jan 4 at 9:42
Equip $$S^{n - 1} = \{x \in \mathbb{R}^n : |x| = 1\}$$ with it's usual surface measure, normalized to be a probability measure. Then you seek $$\int_{S^{n - 1}}|Ax|^2\,dS(x)$$. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9895109062654985,
"lm_q1q2_score": 0.8370692620247724,
"lm_q2_score": 0.8459424314825853,
"openwebmath_perplexity": 173.08699977357705,
"openwebmath_score": 0.9992341995239258,
"tags": null,
"url": "https://math.stackexchange.com/questions/4347275/average-square-gain-of-a-matrix-over-all-possible-vectors"
} |
javascript
}
else if (numbers.includes(value)){ // Checks if current button is one of numbers stored in array
if (screen.value == 0 || operatorUsed == true ){ // It worsk so the output(screen) previous value is being replaced
screen.value = value;
operatorUsed = false;
}
else{ // adding 2 digits and more numbers like 22, 123 etc.
screen.value += value;
}
currentNumber = value; // Store current number which is needed for clicking '=' multiple times | {
"domain": "codereview.stackexchange",
"id": 38820,
"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",
"url": null
} |
c, calculator, integer, curses
int return_value = sprintf(total_string, "Total: %" PRIu64, height * length * width);
// sprintf returns a negative value if it fails, so check it
if (return_value < 0) {
errno = EIO;
perror("Cannot multiply height * length * width");
return errno;
}
printw(total_string);
free(total_string);
refresh();
getch();
endwin();
return 0;
}
/**
* Converts input_str to uint64_t -> returns 0 on success
* Adapted from: https://codereview.stackexchange.com/a/206773/78786
*/
int my_strto64(uint64_t *dest, const char *input_str) {
char *endptr;
errno = 0;
unsigned long long parsed_long_long = strtoull(input_str, &endptr, 10);
#if ULLONG_MAX > UINT64_MAX
if (y > UINT64_MAX) {
uint64_t *dest = UINT64_MAX;
errno = ERANGE;
return errno;
}
#endif
*dest = (uint64_t) parsed_long_long;
if (errno == ERANGE) {
return errno;
} | {
"domain": "codereview.stackexchange",
"id": 32988,
"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, calculator, integer, curses",
"url": null
} |
terminology, programming-languages
Title: Term for programming languages that read like sentences? Is there a term for programming languages that read like written sentences? I'm thinking of languages like Python, where you can almost read the code aloud as a sentence, as opposed to C++ which is really arcane.
For example, in Python if 'pizza' not in animals is very clear when read aloud.
Seems like maybe there's a formal term for this? I know of no standard term for that aspect of PL. Maybe you can use "human-readable syntax" or "human-friendly syntax".
In PL theory, we (unapologetically) tend to disregard syntactic issues (e.g., look at LISP), and focus more on language features / semantics / types and more math-y stuff.
I mean: if you asked me what are the main differences between C++ and Python, I would probably spend a long time before mentioning some syntactic difference. | {
"domain": "cs.stackexchange",
"id": 13406,
"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": "terminology, programming-languages",
"url": null
} |
python
#112
ip_list = ['espn.com']
for item in ip_list:
status,result = subprocess.getstatusoutput("ping -c 1 -W 1 %s" % item)
if status == 0:
print('ok')
draw.rectangle((295,862,350,889), fill='green')
else:
print('damn')
draw.rectangle((295,862,350,889), fill='red')
#126
ip_list = ['espn.com']
for item in ip_list:
status,result = subprocess.getstatusoutput("ping -c 1 -W 1 %s" % item)
if status == 0:
print('ok')
draw.rectangle((567,181,619,204), fill='green')
else:
print('damn')
draw.rectangle((567,181,619,204), fill='red')
#128
ip_list = ['espn.com']
for item in ip_list:
status,result = subprocess.getstatusoutput("ping -c 1 -W 1 %s" % item)
if status == 0:
print('ok')
draw.rectangle((571,361,616,385), fill='green')
else:
print('damn')
draw.rectangle((571,361,616,385), fill='red') | {
"domain": "codereview.stackexchange",
"id": 24217,
"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",
"url": null
} |
# Domain of an absolute value
How do we solve for a domain of a function, when it involves absolute values? For example (I created the example myself, so it might be a bit weird):
$$f(x) = \frac{1}{\sqrt{|2x+1| - |x-3|}}$$
Thank you!
-
Not at all weird, very nice example!
What I would suggest as a general approach is this. Imagine you have a value of $x$ in a calculator and you want to compute your expression one step at a time. What, if anything, could go wrong? This takes a lot of time to write out but once you get used to doing it in your head it's not so bad. So for your example we have $x$. Now
• calculate $2x$ - this will always work and there will be no problems
• calculate $2x+1$ - still no problems
• $|2x+1|$ - no problems
• similarly, $|x-3|$ will give no problems
• and now $|2x+1|-|x-3|$ will give no problems
• now for $\sqrt{|2x+1|-|x-3|}$: this will fail if $|2x+1|-|x-3|<0$ | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.965381162156829,
"lm_q1q2_score": 0.8205461576872838,
"lm_q2_score": 0.8499711718571774,
"openwebmath_perplexity": 156.44668356125638,
"openwebmath_score": 0.9300058484077454,
"tags": null,
"url": "http://math.stackexchange.com/questions/684205/domain-of-an-absolute-value"
} |
javascript
function getNumberOfElementsInWidth(elements, maxWidth) {
var totalSize = 0;
elements = elements.filter(element => {
if (element.width > maxWidth || element.width < 0) { return false }
totalSize += element.width;
return true;
});
if (totalSize <= maxWidth) { return elements.length }
elements.sort((a, b) => a.width - b.width);
count = elements.length;
while (totalSize > maxWidth) { totalSize -= elements[--count].width }
return count;
}
//=========================================================================
// Single test to show correct solution
console.log("Find max items of widths 1, 2, 5, 1, 1 to fit a width of 8")
console.log("Solution " +
getNumberOfElementsInWidth(
[{ width: 1}, {width: 2}, {width: 5}, {width: 1}, {width: 1}],
8
) + " items"
); | {
"domain": "codereview.stackexchange",
"id": 30305,
"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",
"url": null
} |
I think that what confuses you is the difference between "solving the algebraic expression", and "finding the limit". Given:
$$f_1=\frac{x^2-25}{x-5} \quad f_2 = (x+5)$$
Then, $f_1$ and $f_2$ are most definitely NOT the same function. This is because they have different domains: 5 is not a member of the domain of $f_1$, but it is in the domain of $f_2$.
However, when we go from: $$\lim _{x\rightarrow 5}\frac{x^2-25}{x-5} \quad to \quad \lim _{x\rightarrow 5}\frac{(x-5)(x+5)}{x-5} \quad to \quad \lim_{x\rightarrow 5} (x+5)$$
We are not saying that the expressions inside the limits are equal; maybe they are, maybe they are not. What we are saying that they have the same limit. Totally different statement.
Above, the transformation of the second expression to the third one allows us to find a different function for which a) we know that the limit is the same, and b) we know how to trivially calculate that limit. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9820137942490252,
"lm_q1q2_score": 0.8566571569404339,
"lm_q2_score": 0.8723473763375643,
"openwebmath_perplexity": 255.68626743071,
"openwebmath_score": 0.8391028046607971,
"tags": null,
"url": "https://math.stackexchange.com/questions/462199/why-does-factoring-eliminate-a-hole-in-the-limit"
} |
node.js
if ( app.datapoint ) {
strapi.query('subscription').update({ ApplicationSlug: app.name }, { DiskUsage: Math.ceil(app.datapoint[0]) });
}
});
}).catch((res3) => {
console.log(res3.response.data);
});
}); | {
"domain": "codereview.stackexchange",
"id": 38951,
"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": "node.js",
"url": null
} |
algorithm, php, programming-challenge, complexity, k-sum
Title: Algorithm for twoSum This is my PHP algorithm for the twoSum problem in leetCode:
function twoSum($nums, $target) {
foreach($nums as $key1 => $num1) {
foreach(array_slice($nums, $key1 + 1, null, true) as $key2 => $num2) {
if ($num1 + $num2 === $target) {
return [$key1, $key2];
}
}
}
}
Its purpose is to take an array and check if the sum of two distinct elements can result in the $target. Just like:
twoSum([2,7,11,15], 9);
// this sould return [0, 1] because 2 + 7 is 9
Initially I created an algorithm that compare the elements in $nums through brute force. Knowing that O(N2) is not that good for time complexity, I tried to refactor it and came up with the solution above. I don't think that the code still with O(N2) time complexity, but I can't think how I could calculate this algorithm in Big O Notation, I would like to know if: | {
"domain": "codereview.stackexchange",
"id": 43203,
"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, php, programming-challenge, complexity, k-sum",
"url": null
} |
tensor-calculus, covariance
Title: Invariance of a tensor under coordinate transformation I know, that a tensor is a mathematically entity that is represented using a basis and tensor products, in the form of a matrix, and changing a representation doesn't change a tensor, is kind of obvious.
So does the invariance of a tensor under coordinate transformation mean what I stated above or does it mean that under a set of particular transformation the representation of a particular tensor also doesn't change.
Quoted from Wikipedia:
A vector is invariant under any change of basis, so if coordinates transform according to a transformation matrix $L$, the bases transform according to the matrix inverse $L^{−1}$, and conversely if the coordinates transform according to inverse $L^{−1}$, the bases transform according to the matrix $ L$. | {
"domain": "physics.stackexchange",
"id": 26409,
"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, covariance",
"url": null
} |
electromagnetism, electrostatics, electromagnetic-radiation, everyday-life
Radio waves are (partially) reflected by any discontinuity in dielectric constant of the medium they propagate through. The ones that propagate (through walls etc) will also experience attenuation.
A faraday cage is a continuous conducting structure with no openings that are "large compared to the wavelengths of interest". Your building has windows that are much larger than that. The wavelength of a cell phone signal (typical frequency 1800 or 1900 MHz so around 15 cm) is small compared to windows and signal would penetrate - meaning that it is not a Faraday cage.
On the other hand walls do provide significant attenuation depending on the material - and waves that have to diffract through the window would also be much weaker when they got to you. If the gym was sufficiently far from the nearest cell tower it is easy to get a "dead spot" in reception. | {
"domain": "physics.stackexchange",
"id": 25982,
"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": "electromagnetism, electrostatics, electromagnetic-radiation, everyday-life",
"url": null
} |
ros, ros-melodic, rospkg
Originally posted by Ivan4815162342 on ROS Answers with karma: 5 on 2021-08-25
Post score: 0
Original comments
Comment by Ranjit Kathiriya on 2021-08-25:
Hello @Ivan4815162342,
This is a duplicated question of : #q382798, #q256565
I am closing this question. If you think that you couldn't find a solution feel free to re-open this.
Comment by Ivan4815162342 on 2021-08-25:
I have the paths mentioned in the first link, but that doesn't help. The second link is about the C++ library that is not my case. I should also say that other python imports like rospy, roslaunch, rosnode are not underlined.
Hello @Ivan4815162342,
I think that you have not updated the python interpreter path in VS code.
When I try to run node with this import, rospkg works fine. | {
"domain": "robotics.stackexchange",
"id": 36844,
"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-melodic, rospkg",
"url": null
} |
ros, p3at
Originally posted by sumant with karma: 77 on 2016-09-16
This answer was ACCEPTED on the original site
Post score: 0 | {
"domain": "robotics.stackexchange",
"id": 25754,
"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, p3at",
"url": null
} |
pharmacology, blood-brain-barrier
nigra of the brain.
Another major system that is used in normal mammalian physiology to
enable needed molecules to cross the BBB is receptor-mediated
transport (RMT). The brain uses RMT to transport proteins, peptides,
and lipoproteins that are needed for brain function across the BBB.
Examples of biomolecules that are transported into the brain via RMT
include insulin, insulin-like growth factor (IGF), leptin,
transferrin, and low-density lipoprotein (LDL).
In RMT, molecules in the circulation may bind to specific receptors on
the luminal surface of brain capillaries (i.e., the surface that
interfaces with the bloodstream). Upon binding, the receptor-ligand
complex is internalized into the endothelial cell by a process called
receptor-mediated endocytosis. The ligand may then be transported
across the abluminal membrane of the endothelial cell (i.e., the
membrane that interfaces with brain tissue) into the brain. This whole | {
"domain": "biology.stackexchange",
"id": 116,
"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": "pharmacology, blood-brain-barrier",
"url": null
} |
Mathematica computed the exact solutions quoted here. The following R code also computes them (in double precision rather than exactly) and runs simulations to evaluate the correctness of the analytical solutions. These simulations conduct repeated z-tests of the solutions. The mean of the z-values should be zero, but will differ slightly due to random variation. The distribution of the z-values should be approximately Standard Normal (with a little allowable deviation due to the small finite values of $n$ and $k$). Here they are (for 999 iterations each), demonstrating the accuracy of these answers: | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9658995713428387,
"lm_q1q2_score": 0.8110986716685358,
"lm_q2_score": 0.8397339596505965,
"openwebmath_perplexity": 1177.977499174778,
"openwebmath_score": 0.8003143668174744,
"tags": null,
"url": "https://stats.stackexchange.com/questions/139397/probability-of-rolling-one-die-by-two-persons-3-times-each-and-problem-with-pul?noredirect=1"
} |
quantum-field-theory, path-integral, perturbation-theory
Title: Gaussian integral extended to multi-dimensions In Quantum Field Theory in a Nutshell by A. Zee, the following integral
$$Z(J)=\int_{-\infty}^{+\infty} d q e^{-\frac{1}{2} m^{2} q^{2}-\frac{\lambda}{4!} q^{4}+J q}$$
is solved perturbatively by expansion of the $\lambda$ and the $J$ term.
For example expanding the $J$ term we obtain:
$$Z(J)=\displaystyle\sum_{s=0}^{\infty} \frac{1}{s !} J^{s} \int_{-\infty}^{+\infty} d q e^{-\frac{1}{2} m^{2} q^{2}-\left(\lambda / 4!) q^{4}\right.} q^{s} .\tag{1}$$
This method is extended to a multidimensional integral
$$Z(J)=\displaystyle\int_{-\infty}^{+\infty} \int_{-\infty}^{+\infty} \cdots \int_{-\infty}^{+\infty} d q_{1} d q_{2} \cdots d q_{N} e^{-\frac{1}{2} q \cdot A \cdot q-(\lambda / 4!) q^{4}+J \cdot q}$$
where $q^4\equiv\sum_i q_i^4$ and $A$ is an $N\times N$ matrix.
We can expand the $J$ term, obtaining the following according to A. Zee : | {
"domain": "physics.stackexchange",
"id": 61325,
"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, path-integral, perturbation-theory",
"url": null
} |
thermodynamics, energy, states-of-matter
If I were to rephrase the question above, why is the latent heat of vaporization of water greater than the latent heat of fusion of water? The reason is that occasionally there are much more differences between the liquid phase and the gaseous phase of a system than the differences between the liquid and solid phases of the same system. In the liquid phase although the translation symmetry doesn't exists in contrast to the solid phase, the molecules are yet close enough to each other that the interactions among them is significant(however they are relatively weaker than in the solid phase and so the melting's latent heat is non-zero). But in the gaseous phase the typical distance between molecules are much more larger than the solid and liquid phase and hence the interactions among them are by far weaker than the liquid phase and therefore the vaporizing's latent heat is significantly larger than the one in the melting process. | {
"domain": "physics.stackexchange",
"id": 34934,
"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, energy, states-of-matter",
"url": null
} |
filter-design, linear-systems, digital-filters
Title: Why can adding delay improve the phase fit in fitting complex transfer functions? When you fit an IIR filter to a complex transfer function you can use a delay to get a stable filter and improve the fitting results in your phase response. Can anyone explain me the reason for this and/or link me to some literature explaining this? I can't find any good literature on this. Even though an IIR filter of a given order can in principle approximate any given phase response, you will get a better fit if you choose the total delay such that it "matches" the chosen filter order. The problem is that there is no formula to help you choose such an ideal delay; you simply have to find out by trial and error. As you've already mentioned, filter stability is also determined by the choice of the total delay. You have to choose the total delay such that the given desired phase response can be reasonably approximated by a stable IIR filter of the chosen order. Also here there are no formulas for | {
"domain": "dsp.stackexchange",
"id": 3920,
"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": "filter-design, linear-systems, digital-filters",
"url": null
} |
\begin{align*} \innerproduct{\vect{u}}{\vect{v}}&=\sum_{k=1}^{m}\conjugate{\vectorentry{\vect{u}}{k}}\vectorentry{\vect{v}}{k}&& \knowl{./knowl/definition-IP.html}{\text{Definition IP}}\\ &=\sum_{k=1}^{m}\conjugate{\matrixentry{\vect{u}}{k1}}\matrixentry{\vect{v}}{k1}&& \text{Column vectors as matrices}\\ &=\sum_{k=1}^{m}\matrixentry{\conjugate{\vect{u}}}{k1}\matrixentry{\vect{v}}{k1}&& \knowl{./knowl/definition-CCM.html}{\text{Definition CCM}}\\ &=\sum_{k=1}^{m}\matrixentry{\transpose{\conjugate{\vect{u}}}}{1k}\matrixentry{\vect{v}}{k1}&& \knowl{./knowl/definition-TM.html}{\text{Definition TM}}\\ &=\matrixentry{\transpose{\conjugate{\vect{u}}}\vect{v}}{11}&& \knowl{./knowl/theorem-EMP.html}{\text{Theorem EMP}} \end{align*}
To finish we just blur the distinction between a $$1\times 1$$ matrix ($$\transpose{\conjugate{\vect{u}}}\vect{v}$$) and its lone entry.
To obtain this matrix equality, we will work entry-by-entry. For $$1\leq i\leq m\text{,}$$ $$1\leq j\leq p\text{,}$$ | {
"domain": "runestone.academy",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9886682441314384,
"lm_q1q2_score": 0.80129475275188,
"lm_q2_score": 0.8104789018037399,
"openwebmath_perplexity": 552.7782355881624,
"openwebmath_score": 0.9809508919715881,
"tags": null,
"url": "https://runestone.academy/ns/books/published/fcla/section-MM.html"
} |
ros, navigation, odometry, ros-melodic, posestamped
def rotate_quaternion(self):
# TS 2021_07_26: the heading is measured from antenna 1 (front) to antenna 2 (back) and thus mirrored over origin
quat = [self.odom.pose.orientation.x, self.odom.pose.orientation.y, self.odom.pose.orientation.z, self.odom.pose.orientation.w]
(alpha,beta,gamma) = euler_from_quaternion(quat, axes='sxyz')
self.odom.orientation.quaternion = Quaternion(*quaternion_from_euler(alpha, beta, -gamma))
def publish_heading(self):
self.odometry_pub.publish(self.odom)
def pose_callback (self, pose):
self.odom.header = pose.header
self.odom.pose = pose.pose
self.odom.child_frame_id = "base_link"
#self.rotate_quaternion()
if __name__ == '__main__':
#print('something started')
rospy.init_node('trajectory_pub')
OdomPub()
rospy.spin() here | {
"domain": "robotics.stackexchange",
"id": 36755,
"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, odometry, ros-melodic, posestamped",
"url": null
} |
homework-and-exercises, waves
\,,$$and at the same time it's also correct to do this$$
Y_{\text{S}}(t)=Y_{\text{M}}\left(t \, - \, \frac{T}{2}\right)
\,,$$leading to$$
φ_{\text{S}} \, - \, φ_{\text{M}}~=~π\left(2k \, - \, 1\right)
\,.$$My question is which one should I use? Inherently both are correct. You just get confused by the fact that you used the variable $k$ twice.
Both solutions tell you that the phase difference is an odd multiple of $\pi$. | {
"domain": "physics.stackexchange",
"id": 48654,
"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, waves",
"url": null
} |
homework-and-exercises, thermodynamics, statistical-mechanics, approximations
$$\frac{M !}{(M-N)!} \approx M^{N}$$
I understand the approximation as there are fewer molecules N than there are sites M for an ideal gas, but I fail to understand how he managed to reach the conclusion above from the previous equation above that.
I tried to solve this using the approximation:
$$x! = \left(\frac{x}{e}\right)^x$$ but this failed to reach me to the correct working in order to prove the $\approx M^{N}$ approximation.
I managed to get:
$$\frac{M^M}{(M-N)^{M-N}}\times \frac{1}{N^N}$$
but I suspect this is deviating from the main way of reaching the approximation.
How is the approximation achieved? $$
\frac{M !}{\left(M-N\right)!}
~=~
\begin{alignat}{10}
M
& \times & \left(M - 1\right)
& \times & \left(M - 2\right)
& \times & ~\cdots~
& \times & \left(M - N + 1\right)
& \times & \left(M - N\right)
& \times & \left(M - N - 1\right)
% & \times & \left(M - N - 2\right)
& \times & ~\cdots~
% & \times & 2
& \times & 1
\\[-25px] \hline
& &
& &
& &
& &
& & \left(M - N\right) | {
"domain": "physics.stackexchange",
"id": 58243,
"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, thermodynamics, statistical-mechanics, approximations",
"url": null
} |
graphs, shortest-path
Title: What happens if I replace $<$ with $\le$ in Dijkstra's algorithm? The following is Dijkstra's algorithm for finding the shortest path in a graph. I know something wrong happens if I replace d[u] + weight(u,v) < d[v] with d[u] + weight(u,v) <= d[v]. What would be an example of the algorithm working incorrectly with that replacement?
def dijkstraShortestPath(G,s,t):
d[v] = Infinity for all v in G.vertices
d[s] = 0
unsureVertices = G.vertices
while len(unsureVertices) > 0:
u = a vertex in unsureVertices so that d[u] is minimized
if d[u] == Infinity:
break
for v in u.getOutNeighbors(): //all v are in unsureVertices
if d[u] + weight(u,v) < d[v]:
d[v] = d[u] + weight(u,v)
v.parent = u
unsureVertices.remove(u)
if d[t] == Infinity:
return "Can't reach t from s!"
path = []
current = t
while current!= s:
path.append(current)
current = current.parent
path.append(current)
path.reverse() | {
"domain": "cs.stackexchange",
"id": 12718,
"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": "graphs, shortest-path",
"url": null
} |
condensed-matter, quantum-hall-effect, topological-insulators, majorana-fermions
where $\mathcal{M}(k_{x})=A\sin(k_{x})\Gamma^{1}+\left(M-4B+2B\cos(k_{x})\right)\Gamma^{5}$ and $\mathcal{T}=(iA/2)\Gamma^{2}+B\Gamma^{5}$ and we have made use of the delta function identity of the type $$\frac{1}{L}\sum_{k_{y}}e^{ik_{y}(j-\ell\pm1)}=\delta_{j-\ell\pm1}$$ several times. With the ansatz in Eq. (15), i.e. $\psi_{\alpha}(j)=\lambda^{j}\phi_{\alpha}$, an analytic solution of the edge states can be obtained (see Eq. (22)). The solution of the eigenvalue equation using this ansatz has been elegantly discussed in section 2.2 of: | {
"domain": "physics.stackexchange",
"id": 10473,
"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": "condensed-matter, quantum-hall-effect, topological-insulators, majorana-fermions",
"url": null
} |
fluid-dynamics
you have a sign error at the boundary, as mentioned by Chester in a comment
you left $y$ out of your equation for $u_1$
You should find
$$u_1 = Uy\frac{ \mu_2 }{h_1 \mu_2 + \mu_1 (h-h_1)}$$
It should be possible to detect these sorts of errors with a little care. For example, suppose $h = h_1$. Then the second fluid doesn't exist and $\mu_2$ has to disappear from your equation. Does it with your original answer? Does it with mine?
Or if $h_1 =0$, only fluid 2 exists; does your solution for $\mu_2$ do the right thing?
Also, you can detect things like forgetting the $y$ by doing a quick dimensional check. | {
"domain": "physics.stackexchange",
"id": 47856,
"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": "fluid-dynamics",
"url": null
} |
classical-mechanics, fluid-dynamics, angular-momentum, rotational-dynamics, ice
There is an urban legend that claims that the direction of spin in drains is associated with the coriolis effect and differs between the northern and southern hemispheres. While this may be true of hurricanes and cyclones, it is too small an effect to apply to bathtub drains or glasses of hot water with ice cubes. For these smaller scale systems the rotation direction is dictated by the residual rotation created when the vessel was filled. This small residual rotation may not be noticeable until the downward flow accentuates it.
Edit: @sammygerbil has found a website that discusses this phenomenon and attributes it to the same mechanism I outlined above. | {
"domain": "physics.stackexchange",
"id": 54560,
"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, fluid-dynamics, angular-momentum, rotational-dynamics, ice",
"url": null
} |
geophysics, climate-change, glaciology
A 1% more luminous sun would be in the range of 13-14 watts per square meter, so as the sun grows brighter, and if everything else stays the same, certainly within 100-200 million years, the sun would be sufficiently hot to make ice ages pretty darn unlikely. This site suggests that a 10% increase in solar luminosity could result in 47 °C, 116 °F. It will take quite a bit less than that to end ice ages. (Source)
We also have to consider orbital drift. If the Earth is slowly moving away from the sun, that's a factor too, and by this study, it is moving away, at 15 CM per year (Source), so, in 100 million years, 150,000 km, 0.1% further from the sun, about 0.2% less solar irradiance, which is only 20% of the increase in solar output,so this, at least by current estimates, will be overshadowed by the sun growing brighter. (Source)
Carbon Sequestering / atmospheric CO2 PPM | {
"domain": "earthscience.stackexchange",
"id": 540,
"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": "geophysics, climate-change, glaciology",
"url": null
} |
c#, wcf
protected TR CallServiceSafely<TU, TA, TV,TX,TY, TR>(Func<TU, TA, TV, TX, TY, TR> serviceMethod, TU firstParam, TA secondParam, TV thirdParam, TX fourthParam, TY fifthParam)
{
try
{
return serviceMethod.Invoke(firstParam, secondParam, thirdParam, fourthParam, fifthParam);
}
catch (SoapException ex)
{
throw new ServiceException(ToolKit.ErrorDescriptionFactory.CreateInstance(ex));
}
catch (WebException ex)
{
throw new ServiceException(ToolKit.ErrorDescriptionFactory.CreateInstance(ex));
}
catch (ApplicationException ex)
{
throw new ServiceException(ToolKit.ErrorDescriptionFactory.CreateInstance(ex));
}
catch (FaultException ex)
{
throw new ServiceException(CreateErrorDescriptionInstance(ex));
}
} | {
"domain": "codereview.stackexchange",
"id": 33293,
"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#, wcf",
"url": null
} |
programming, qiskit
'op' (The data type of the operation)
qargs (The qubits this gate is applied to)
cargs (The classical bits this gate is applied to)
condition
In your example where you have an $H$ Gate at node 9 and a $U_3(\theta=0.1, \phi=0.2, \lambda=-0.5)$ Gate at node 11, if you were to call print(dag_circuit.multi_graph.nodes[8]) and print(dag_circuit.multi_graph.nodes[10]), you would receive the following output:
{'type': 'op', 'op': <qiskit.extensions.standard.h.HGate object at "some_memory_address">, 'name': 'h', 'qargs': [(QuantumRegister(1, 'q'), 0)], 'cargs': [], 'condition': None}
{'type': 'op', 'op': <qiskit.extensions.standard.u3.U3Gate object at "some_memory_address">, 'name': 'u3', 'qargs': [(QuantumRegister(1, 'q'), 0)], 'cargs': [], 'condition': None} | {
"domain": "quantumcomputing.stackexchange",
"id": 687,
"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": "programming, qiskit",
"url": null
} |
php, mysql, security, pdo, authentication
}
As you can see, our Authentication class now gives us some nice methods to work with. Gives us access to our user object and is completely loosely coupled from the rest of our application. What we now need to do is write a UserRepository that handles all the PDO stuff of our users. And a SessionHandler that acts as an Adapter/Wrapper for our $_SESSION (or maybe replace $_SESSION with cookie + databaserows).
Our UserRepository will have a dependency on a PDO object. So as it in the construct. And because a UserRepository handles Users only it can have a property $table set to 'users'.
I didn't write the rest of the code because I think you are perfectly capable of doing it your self. Just remember that you are writing little pieces of code that will eventually help you in solving a problem.
Good luck! | {
"domain": "codereview.stackexchange",
"id": 9342,
"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": "php, mysql, security, pdo, authentication",
"url": null
} |
sound, music
The audio file is here. Here are some possibilities:
Transverse waves on a guitar string have two polarized components, one parallel and one perpendicular to the guitar's soundboard. User hotpaw2 mentioned energy exchange. It is imaginable that energy transfer could happen between the components. The component parallel to the soundboard is largely inaudible, so it could stealthily store energy until released later.
Or it could be that you have two strings with modes that are slightly out of tune, and they form a beat frequency.
EDIT: Having analyzed the audio sample, the things you have marked are just some low-frequency artifacts, I think from things like someone touching or shaking the mic or moving around and bumping the guitar body. Adding a 100 Hz high-pass filter mostly gets rid of those:
Figure 1. Sample after 100 Hz highpass filtering. | {
"domain": "dsp.stackexchange",
"id": 5179,
"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": "sound, music",
"url": null
} |
optics, electromagnetic-radiation, visible-light, photons, geometric-optics
Title: Can there be a single ray of light? My physics teacher told me that a beam of light is a collection of rays of light and there cannot be a single absolute ray of light. Is this true? This is how an optical ray is defined:
In optics a ray is an idealized geometrical model of light, obtained by choosing a curve that is perpendicular to the wavefronts of the actual light, and that points in the direction of energy flow
The mathematical function that describes the classical propagation of light depends on the wave equations of Maxwell.
Here is what a wavefront starting from a point source looks like.
So the ray is the line perpendicular to the front,that gives the direction of the energy from this single point.
Light is built up from many wavefronts next to each other so there are many optical rays, as many as the wavefronts.
To answer the title
Can there be a single ray of light? | {
"domain": "physics.stackexchange",
"id": 86602,
"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": "optics, electromagnetic-radiation, visible-light, photons, geometric-optics",
"url": null
} |
newtonian-mechanics, momentum, conservation-laws, rocket-science
Title: With respect to inertial observer standing at the starting point of why is the velocity of ejected mass of rocket $v + v_0$ We derived the equation of motion of a rocket this way: all the velocities are taken with respect to inertial observer standing where the rocket starts. As we take upwards direction to be positive. The initial momentum of rocket is mv. That's fine. Now at a certain time $\delta t$ later the momentum becomes $(m - \delta m) (v + \delta v) - \delta m (v + \delta v_0) $ {where $\delta m$ = amount of decrease of mass of rocket or amount of gas emitted. $\delta v$ = increase of velocity of rocket due to mass loss and conservation of momentum. Now my question is why we take the velocity of the gas to be $v + v_0$ . As we measuring with respect to inertial observer standing at the starting point of rocket. And if we are measuring with respect to the rocket then the initial momentum should be zero as well as the velocity of the rocket relative to itself is zero. So | {
"domain": "physics.stackexchange",
"id": 50969,
"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, momentum, conservation-laws, rocket-science",
"url": null
} |
dataset
Title: DBPedia as Table not having all the properties I browsed a sample for available data at http://dbpedia.org/page/Sachin_Tendulkar. I wanted these properties as columns, so I downloaded the CSV files from http://wiki.dbpedia.org/DBpediaAsTables.
Now, when I browse the data for the same entity "Sachin_Tendulkar", I find that many of the properties are not available. e.g. the property "dbpprop:bestBowling" is not present.
How can I get all the properties that I can browse through the direct resource page. The question was already answered on the DBpedia-discussion mailing list, by Daniel: | {
"domain": "datascience.stackexchange",
"id": 152,
"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": "dataset",
"url": null
} |
electrostatics, multipole-expansion, spherical-harmonics
$$Y_4^0(x,y,z) \propto \frac{35 z^4-30z^2r^2+3r^4}{r^4} $$
since you're evaluating the integral along $r=z$, that reduces to:
$$Y_4^0(0,0,z) \propto \frac{35z^4-30z^2z^2+3z^4}{z^4}=35-30+3=8 $$
All the integrals can be reduced to an integral over a constant. You just have to figure out the general formula. | {
"domain": "physics.stackexchange",
"id": 89463,
"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, multipole-expansion, spherical-harmonics",
"url": null
} |
ros, slam, navigation, ros-kinetic, rtabmap-ros
Original comments
Comment by Delbina on 2021-05-26:
Dear Mattieu,
I also installed velodyne_master that has the patch, from the source, and did catkin_make as well. but again when I launch rtbamp,I face the same error. Would you please support to fix this issue?
thanks
Comment by Delbina on 2021-05-28:
hi everyone,
my issue, has not fixed yet. I have downloaded also velodyne_master, and then did catkin_make in my workspace. then run rtabmap, but again i have this error yet:
[FATAL] (2021-05-27 16:14:50.261) MsgConversion.cpp:2198::convertScan3dMsg() Condition (scan3dMsg.data.size() == scan3dMsg.row_step*scan3dMsg.height) not met! [data=590964 row_step=0 height=1]
would you please support me to resolve this issue?.
Thanks
Comment by matlabbe on 2021-05-30:
try to debug why the velodyne topic has row_step=0, if the patch referred by the answered didn't work on your side for some reasons. | {
"domain": "robotics.stackexchange",
"id": 36454,
"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, slam, navigation, ros-kinetic, rtabmap-ros",
"url": null
} |
• This looks good, thanks. I'll try to do it again on a piece of paper and come back to comment/accept. – Eric Duminil Mar 8 '18 at 17:07
• Thanks, @EricDuminil. There was one place I had something like $\frac{1}{\sqrt{\frac{1}{2\varepsilon}}+1}$ where I had to use some algebra to simplify (hence I didn't want to type it, at least, not yet haha). – Clayton Mar 8 '18 at 17:15
• First, the integral test has hypotheses that you need to mention. And, although the estimate you give for the error is correct (under the same hypotheses!), I don't see how we can deduce that error estimate from the integral test itself. How does that go? – David C. Ullrich Mar 8 '18 at 17:20 | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9817357248544006,
"lm_q1q2_score": 0.8614503210108743,
"lm_q2_score": 0.8774767986961403,
"openwebmath_perplexity": 329.03580589035056,
"openwebmath_score": 0.8721043467521667,
"tags": null,
"url": "https://math.stackexchange.com/questions/2682525/estimating-error-when-calculating-pi2-with-8-frac832-frac852"
} |
javascript, jquery, twitter, instagram
// Sort our feed array by time
fwyFeed.sort(function(a,b) {
return parseInt(b.created,10) - parseInt(a.created,10);
});
// Loop through each tweet/photo
for (var i = 0; i < fwyFeed.length; i++) {
if(i in fwyFeed) {
var type = fwyFeed[i]["type"],
created = fwyFeed[i]["created"],
text = fwyFeed[i]["text"],
link = fwyFeed[i]["link"],
date = fwyFeed[i]["date"]; | {
"domain": "codereview.stackexchange",
"id": 1969,
"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, jquery, twitter, instagram",
"url": null
} |
homework-and-exercises, newtonian-mechanics, velocity, drag
$$v(t)=\frac{mg}{b}\left[1-e^{-bt/m}\right].$$ By defining the time constant as $\tau=\frac{m}{b}$ and using the definition of the terminal velocity, the time evolution of the velocity simplifies to $$\boxed{v(t)=v_{max}\left[1-e^{-t/\tau}\right]}.$$ The position, if desired, is found easily enough by performing another integration: $$y(t)=\int{v}dt=v_{max}\int{\left(1-e^{-t/\tau}\right)}dt.$$ Assuming that the initial position $y(0)=0$ and simplifying, the solution for vertical position is then $$\boxed{y(t)=v_{max}t+v_{max}\tau\left[e^{-t/\tau}-1\right]}.$$ So we now have analytical solutions for the acceleration, velocity, and position of the falling object as a function of time and the system parameters, all of which are known (except for $b$). Note, however, that the requested time to reach a speed of $0.63v_{max}$ is not arbitrary. After one time-constant has passed, we will have $$\frac{v(\tau)}{v_{max}}=1-e^{-1}=0.63212=\boxed{63.212\%}.$$ Thus, we simply need to calculate the | {
"domain": "physics.stackexchange",
"id": 52387,
"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, velocity, drag",
"url": null
} |
ruby, regex
def evaluate(x)
@coefficients.map.with_index { |k, index| k * (x**index) }.reduce(0, :+)
end
private
def self.sign(integer)
integer >= 0 ? '+' : '-'
end
end
There are a few things that bother me in the to_s method:
Is it bad that I wrote the short comments explaining what each gsub does? Bad in terms of "Would you do this in production code?".
Since all but one of the gsubs do the same, I could replace them with a single gsub, containing a long regexp with lots of ors (|):
.gsub(/\A\+\s|x\^0|\s(\+|-)\s0x\^\d|\s(\+|-)\s0|\^1/, '')
In that case though the regexp become quite unreadable. Which of the two is better?
Regarding the map.with_index part: | {
"domain": "codereview.stackexchange",
"id": 5638,
"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": "ruby, regex",
"url": null
} |
python, unit-testing, reinventing-the-wheel
def test_reverse_three(self):
dll = DoublyLinkedList()
dll.append('1')
dll.append('2')
dll.append('3')
assert dll.items() == ['1', '2', '3']
dll.reverse()
assert dll.items() == ['3', '2', '1']
def test_reverse_two(self):
dll = DoublyLinkedList()
dll.append('1')
dll.append('2')
assert dll.items() == ['1', '2']
dll.reverse()
assert dll.items() == ['2', '1']
def test_reverse_one(self):
dll = DoublyLinkedList()
dll.append('1')
assert dll.items() == ['1']
dll.reverse()
assert dll.items() == ['1']
def test_size(self):
dll = DoublyLinkedList()
assert dll.size() == 0
dll.append('4')
dll.append('3')
assert dll.size() == 2
dll.delete('4')
assert dll.size() == 1
dll.delete('3')
assert dll.size() == 0 | {
"domain": "codereview.stackexchange",
"id": 29144,
"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, unit-testing, reinventing-the-wheel",
"url": null
} |
general-relativity, experimental-physics, mass-energy, leptons
Title: What is the experimental evidence for creation of a gravitational field by electrons or other leptons? What experimental evidence do we have that leptons (electrons, muons, tau leptons, neutrinos) create—rather than merely respond to—a gravitational field?
General relativity (GR) predicts that all forms of mass-energy gravitate, that is, generate a curvature of spacetime proportional to their associated energy-momentum tensor. GR has yet to be empirically contradicted, so we have strong theoretical expectations here. My question is about the status of experimental evidence for this prediction.
Massless photons empirically feel gravitation, seen in gravitational lensing. I am aware of the concepts of active and passive gravitational mass. Whether experimental evidence exists for creation of a gravitational field by photons has been addressed (Do photons bend spacetime or not?); in summary, as I understand it, we do not yet know. | {
"domain": "physics.stackexchange",
"id": 75086,
"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": "general-relativity, experimental-physics, mass-energy, leptons",
"url": null
} |
thermodynamics, enthalpy
that depending on which chart you are using, many of the numbers will be slightly different. This is because there is no universal, unchanging standard describing which molecules are used to determine each bond - it depends upon what the people making the chart decided to use. | {
"domain": "chemistry.stackexchange",
"id": 17576,
"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, enthalpy",
"url": null
} |
java, performance, algorithm, programming-challenge, time-limit-exceeded
Sample implementation:
public int firstMissingPositive(int[] nums) {
for (int i = 0; i < nums.length; i++) nums[i] = Math.max(nums[i], 0);
for (int i = 0; i < nums.length; i++) {
int actualVal = Math.abs(nums[i]);
if (actualVal > 0 && actualVal <= nums.length) {
if (nums[actualVal - 1] == 0) nums[actualVal - 1] = ~nums.length;
else if (nums[actualVal - 1] > 0) nums[actualVal - 1] *= -1;
}
}
int i = 0;
while (i < nums.length && nums[i] < 0) ++i;
return i + 1;
} | {
"domain": "codereview.stackexchange",
"id": 45481,
"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, performance, algorithm, programming-challenge, time-limit-exceeded",
"url": null
} |
astrophysics, neutron-stars, supernova, stellar-evolution
Edit: I thought I'd add a brief qualitative reason why lower mass neutron stars can't exist. The root cause is that for a star supported by a polytropic equation of state $P \propto \rho^{\alpha}$, it is well known that the binding energy is only negative, $\partial M/\partial \rho>0$ and the star stable, if $\alpha>4/3$. This is modified a bit for GR - very roughly $\alpha > 4/3 + 2.25GM/Rc^2$. At densities of $\sim 10^{17}$ kg/m$^3$ the star can be supported by non-relativistic neutron degeneracy pressure with $\alpha \sim 5/3$. Lower mass neutron stars will have larger radii ($R \propto M^{-1/3}$), but if densities drop too low, then it is energetically favorable for protons and neutrons to combine into neutron-rich nuclei; removing free neutrons, reducing $\alpha$ and producing relativistic free electrons through beta-decay. Eventually the equation of state becomes dominated by the free electrons with $\alpha=4/3$, further softened by inverse beta-decay, and stability becomes | {
"domain": "physics.stackexchange",
"id": 17169,
"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, supernova, stellar-evolution",
"url": null
} |
I have used both methods several times on the site:
Since FunctionInterpolation does not work well, here is my version of it. It does the DAE method for machine precision and the ODE otherwise.
ClearAll[functionInterpolation];
SetAttributes[functionInterpolation, HoldAll];
functionInterpolation[f_, {x_, a_, b_}, opts : OptionsPattern[NDSolve]] /;
MatchQ[WorkingPrecision /. {opts}, WorkingPrecision | MachinePrecision] :=
Block[{x},
NDSolveValue[
{\[FormalY][x] == f, \[FormalT]'[x] == 1, \[FormalT][a] == a},
\[FormalY], {x, a, b}, opts]
];
functionInterpolation[f_, {x_, a_, b_}, opts : OptionsPattern[NDSolve]] :=
Block[{x},
NDSolveValue[
{\[FormalY]'[x] == D[f, x], \[FormalY][a] == f /. x -> a},
\[FormalY], {x, a, b}, opts]
];
OP's second example:
sol3nd = functionInterpolation[Exp[ln[t] /. First@sol4], {t, 0, 100}]
Plot[sol3nd[t] - n[t] /. sol3b, {t, 0, 100}, PlotRange -> All] | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9539660949832346,
"lm_q1q2_score": 0.833840037356289,
"lm_q2_score": 0.8740772253241802,
"openwebmath_perplexity": 3818.259772851654,
"openwebmath_score": 0.384339839220047,
"tags": null,
"url": "https://mathematica.stackexchange.com/questions/67494/transform-an-interpolatingfunction/67497"
} |
python, natural-language-processing
elif 'search' in response:
response = response.replace("search", "")
webbrowser.open_new_tab(response)
time.sleep(5)
elif there_exists(['sign out', 'log off']):
speak(
"Your pc will log off in 10 sec make sure you exit from all applications")
subprocess.call(["shutdown", "/l"])
elif there_exists(['shutdown the pc', 'shutdown', 'shutdown the laptop']):
speak("Shutting down your pc, make sure you exit from all applications")
subprocess.call(["shutdown", "/s"])
elif there_exists(['restart', 'restart the pc', 'restart the laptop']):
speak("Restarting your pc, make sure you exit from all applications")
subprocess.call(["shutdown", "/r"])
elif there_exists(['what is the weather like right now', 'current temperature', 'climate']):
weather = getWeather()
speak(weather)
print(weather) | {
"domain": "codereview.stackexchange",
"id": 43558,
"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, natural-language-processing",
"url": null
} |
gravity, black-holes, nuclear-physics, stars, fusion
I have done a rough calculation here that shows the interior of the cloud would reach 500 billion K by the time it had collapsed to a Schwarzschild radius, so there is simply no way that this direct collapse can happen. Nuclear fusion would occur and the star would have to go through its life cycle before any collapse can resume.
However, in the early universe, it might be possible for a gas cloud to collapse directly to a massive black hole and this may be why quasars can exist only a few hundred million years after the big bang. | {
"domain": "physics.stackexchange",
"id": 50342,
"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": "gravity, black-holes, nuclear-physics, stars, fusion",
"url": null
} |
ros, eigen, tabletop
Originally posted by GuiHome on ROS Answers with karma: 242 on 2011-06-29
Post score: 0
HI,
Because that package is for 64 bit system, so you should change some commands. Change them to this stype
pcl::PointCloud::ConstPtr table_projected_ptr (new pcl::PointCloud(table_projected));
Originally posted by Nutan with karma: 96 on 2011-07-02
This answer was ACCEPTED on the original site
Post score: 2
Original comments
Comment by GuiHome on 2011-07-04:
Indeed, I am running a 32bit Ubuntu. Thanks a lot, appears it was the reason it failed. I changed several such lines in tabletop_segmentation.cpp and I have no more issues. As soon as I get a 64bit version I will test again and come back if the changes are also required on 64bits. | {
"domain": "robotics.stackexchange",
"id": 5994,
"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, eigen, tabletop",
"url": null
} |
social, mythology-of-ai
Ex Machina the AI part (movie spoiler):
This movie will show you how an AI learn to trick someone. The AI can express her feelings, and make you trust their feeling.
Eagle Eye, the AI part (movie spoiler):
A movie about a general story "AI that want to kill". This movie can show you how The AI can compile a lot of information for its purpose.
Big Hero 6, the AI part (movie spoiler):
Baymax is a very good example of a very complex expert system, he has a "knowledge chip" and a very smart way to diagnose people | {
"domain": "ai.stackexchange",
"id": 2220,
"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": "social, mythology-of-ai",
"url": null
} |
javascript, node.js
function createResolver(keypath){
return new Function('root', `
try { return root.${keypath}; }
catch(e){ return undefined; }
`);
}
// Create a resolver for foo.bar.baz. We only have JS evaluate the string here.
resolvers['foo.bar.baz'] = createResolver('foo.bar.baz');
var obj1 = { foo: { bar: { baz: 'bam!!!' }}};
var obj2 = { foo: { bar: { baz: 'pow!!!' }}};
// We just call the function. No evaluation!
resolvers['foo.bar.baz'](obj1);
resolvers['foo.bar.baz'](obj2); | {
"domain": "codereview.stackexchange",
"id": 19564,
"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, node.js",
"url": null
} |
vba, excel, join
Public Sub CombineACTandAscentricData()
Call StoreApplicationSettings
Call DisableApplicationSettings
'/======================================================================================================================================================
'/ Author: Zak Armstrong
'/ Email: zak.armstrong@luminwealth.co.uk
'/ Date: 25/August/2015
'/
'/ Description: Given the "All Client Wrappers" Data table from Ascentric and an Excel Export of ACT Client data, assign the desired data from ACT to the Ascentric
'/ Data and print to a 3rd Workshet. Clients details are matched by matching the ascentric account number in each data set
'/ ("Account No" in Ascentric, "Ascentric Plan No" in ACT).
'/======================================================================================================================================================
Dim i As Long, j As Long, k As Long | {
"domain": "codereview.stackexchange",
"id": 15420,
"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": "vba, excel, join",
"url": null
} |
python, time-series
Lastly, would a simple normalized time_of_day and day_of_year extra new columns from date_time column suffice?
As in -1.0 for 00:00:00 through to +1.0 for 23:59:59. And -1.0 for Jan 1st through to +1.0 for Dec 31st.
The nice feature the sine waves bring is you don't get that disjoint at midnight, and at new year. You could instead do -1.0 for 00:00:00 through to +1.0 for 12:00:00, then back to -1.0 for 23:59:59 (and something similar with Jun 30th). But, at the point, sine is looking both smoother and simpler to code. | {
"domain": "datascience.stackexchange",
"id": 10494,
"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, time-series",
"url": null
} |
fft, dft, filter-bank, multi-channel
Title: Can anyone explain how dft works as a filter bank?
When we take the fft of input signal, the fft formulas say us to down convert the 2pik/N frequency content of input signal and sum one period interval. This gives us a just one complex number,not an array. When we use fft as channelizer, do we need to take inverse fft?
How can we use DFT formula as channelizer? Can anyone help me to understand concept? @Ahmet. The DFT equation you posted does not compute an array of complex numbers. For any single given integer value of frequency-domain index $k$ the equation tells us how to compute the single complex-valued number $X[k]$ based on $N$ samples of $x[n]$.
Also, please do not fall into the trap of thinking when the DFT is used as a filter that some sort of downward frequency translation occurs. It does not. When used in real-time as a filter, each real-time bin output of the DFT is the output of a bandpass filter. I explain this idea at: | {
"domain": "dsp.stackexchange",
"id": 11166,
"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": "fft, dft, filter-bank, multi-channel",
"url": null
} |
c#, queue
}
finally
{
// remove the expression from the list, because it is not needed anymore
lock (_expressionList)
{
_expressionList.Remove(expression.ToString());
}
}
value = default(T);
return false;
}
}
Update:
I am not sure but perhaps it is better to explain, why I would need such function.
Let's say you have a socket connection and send data to a server/client. You send them with a specific Sync-ID or something that is unique to identify the message. Now you are waiting for the response. So you can register, that if a message with a specific identification or criteria arrives, you should be notified. And because you don't want to poll and maybe wait only a specific time, you could use such method. Deadlocks | {
"domain": "codereview.stackexchange",
"id": 28128,
"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#, queue",
"url": null
} |
ros, rviz, jetson-tk1
[ INFO] [949364917.666700593]: DefaultWorkQueue('Root') initialising on thread b099f000.
[ INFO] [949364917.667271343]: Particle Renderer Type 'billboard' registered
[ INFO] [949364917.668126510]: SceneManagerFactory for type 'OctreeSceneManager' registered.
[ INFO] [949364917.668478426]: Stereo is NOT SUPPORTED
[ INFO] [949364917.668908926]: OpenGl version: 4.4 (GLSL 4.4).
[ INFO] [949364917.672451760]: DefaultWorkQueue('Root')::WorkerFunc - thread aa3cb3b0 starting.
[ INFO] [949364917.680719176]: DefaultWorkQueue('Root')::WorkerFunc - thread aabcb3b0 starting.
[ INFO] [949364917.702747093]: Creating resource group rviz
[ INFO] [949364917.703708843]: Added resource location '/opt/ros/indigo/share/rviz/ogre_media' of type 'FileSystem' to resource group 'rviz'
[ INFO] [949364917.709693760]: Added resource location '/opt/ros/indigo/share/rviz/ogre_media/textures' of type 'FileSystem' to resource group 'rviz' | {
"domain": "robotics.stackexchange",
"id": 22021,
"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, rviz, jetson-tk1",
"url": null
} |
ros
Title: individualMarkersNoKinect does not publish in ar_pose_marker
hello, I use ros kinetic and I downloaded the ar-track-alvar module, to read AR codes, and I want to determine how far they are.
I use a usb camera of logitech and I have written the following launch file.
<launch>
<node name="usb_cam" pkg="usb_cam" type="usb_cam_node">
<param name="video_device" value="/dev/video0"/>
</node>
<node name="ar_track_alvar" pkg="ar_track_alvar" type="individualMarkersNoKinect" respawn="false" output="screen">
<param name="marker_size" value="18"/>
<param name="max_new_marker_error" value="0.08"/>
<param name="max_track_error" value="0.2"/>
<param name="camera_image" value="usb_cam/image_raw"/>
<param name="camera_info" value="usb_cam/camera_info"/>
<param name="output_frame" value="head_camera"/>
</node>
</launch> | {
"domain": "robotics.stackexchange",
"id": 29741,
"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
} |
thermodynamics, solid-state-physics, diffusion
In cases where A and B are not mutually miscible, A will first dissolve into B at the interface, and then diffuse inward; similarly for B into A. This dissolution at the interface will typically be described by Henry's law for gas dissolution in a solid or liquid. | {
"domain": "physics.stackexchange",
"id": 79958,
"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, solid-state-physics, diffusion",
"url": null
} |
python, object-oriented, json, queue, meta-programming
return wrapper
class FileMirroredDeque(deque):
__delitem__ = updates_file(deque.__delitem__)
__iadd__ = updates_file(deque.__iadd__)
__imul__ = updates_file(deque.__imul__)
__setitem__ = updates_file(deque.__setitem__)
append = updates_file(deque.append)
appendleft = updates_file(deque.appendleft)
extend = updates_file(deque.extend)
extendleft = updates_file(deque.extendleft)
insert = updates_file(deque.insert)
pop = updates_file(deque.pop)
popleft = updates_file(deque.popleft)
remove = updates_file(deque.remove)
reverse = updates_file(deque.reverse)
rotate = updates_file(deque.rotate)
def __init__(self, cache_path, maxlen=None, clean=False, file_indent=None):
super().__init__((), maxlen) # Initializes the deque as well TODO: Check the implication of this calling __setitem__ | {
"domain": "codereview.stackexchange",
"id": 35945,
"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, object-oriented, json, queue, meta-programming",
"url": null
} |
c#, console
private static BallColor GetRandomColor()
Properties
To me, GetRandomColor looks more like a property than a method. So, I would make it a property:
public static BallColor RandomColor
{
get
{
// Convert the color enumeration to a list, as this is easier to work with
List<BallColor> ballColors = Enum.GetValues(typeof(BallColor)).Cast<BallColor>().ToList();
// Remove the first value from the color enumaration, as it is not a color
ballColors.Remove(BallColor.None);
// Pick a random value
Random random = new();
return ballColors[random.Next(ballColors.Count)];
}
}
The callsite also needs to be updated accordingly:
Color = RandomColor | {
"domain": "codereview.stackexchange",
"id": 42589,
"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#, console",
"url": null
} |
buoyancy, fluid-statics, gas
$$ V_b = \frac{n_{\text{He}}RT}{P} $$
where $n_{\text{He}}$ is the number of moles of helium. Substituting this into equation (2) we get:
$$ F = n_{\text{He}} M_{\text{air}} g $$
which is constant. So in this case we find that the bouyancy is unaffected as the pressure and temperature change.
Now consider what happens if the rubber skin is infinitely rigid, in which case the volume $V_b$ is constant. We end up with:
$$ F \propto \frac{P}{T} $$
In this case the bouyancy is affected by the pressure and temperature. Assuming the pressure is approximately constant the bouyancy is inversely proportional to temperature so the balloon will rise when it gets cold and fall when it gets hot, which matches your observation. | {
"domain": "physics.stackexchange",
"id": 26172,
"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": "buoyancy, fluid-statics, gas",
"url": null
} |
optics, reflection, refraction, geometric-optics
See this MathOverflow Thread "Symmetric Black Hole Curves" for more information. But this solution also has the catch that the incoming ray must be perfectly horizontal for trapping to happen. Since diffraction is roughly tantamount to a nonzero angular spread of rays, this means that real light will eventually escape such a structure. | {
"domain": "physics.stackexchange",
"id": 28029,
"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": "optics, reflection, refraction, geometric-optics",
"url": null
} |
python, python-3.x, multithreading, file, hashcode
def randomfail_hasher(block):
if randint(0, 100_000_000) < 2:
return sha256(block + b"Some other data").digest()
else:
return sha256(block).digest()
Note that you can write very long numbers like this: 100_000_000_000 which is extremely useful if you are not very good at counting large numbers of zeros, like me. (Before I knew that I used to do ugly things like int(1E9).)
Per your comments on the SO question, you want the whole thing to bail the moment a match doesn't happen. Although you apparently want to keep the hashes, I can't see any reason to do that as they are either the same as the correct target or not, so we are just duplicating the same values.
Here is my crypto function:
class ValidationError(Exception):
pass
def crypto(args):
block, requests, correct = args
for candidate in (randomfail_hasher(block) for _ in range(requests)):
if candidate != correct:
raise ValidationError(candidate) | {
"domain": "codereview.stackexchange",
"id": 42161,
"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, multithreading, file, hashcode",
"url": null
} |
ros
To do so, the terrorists must connect to the swarm as a fake robot, running fake nodes that pretend to be the robots covering the areas where the bombs are placed and that report "all clear" to the other nodes.
In this case, all nodes would have to be secured well enough to guard against spoofing. SSH may not be secure enough for this purpose--once a hacker gets the SSH keys and establishes the tunnel, the traffic between ROS nodes itself is too trusting. It may be necessary, as you suggest, to integrate security into ROS itself.
(I am prepared for people to tear apart this use case and point out why security is or isn't an issue. I don't claim to be a security expert, and this is just a posed use case for the purpose of discussion.) | {
"domain": "robotics.stackexchange",
"id": 23798,
"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
} |
c++, linked-list, reinventing-the-wheel, c++17
head = std::make_unique<node_type>(std::move(head), std::forward<Args>(args)...);
++length;
}
template<typename T>
typename forward_list<T>::iterator forward_list<T>::insert_after(const_iterator pos, const T& value)
{
return emplace_after(pos, value);
}
template<typename T>
typename forward_list<T>::iterator forward_list<T>::insert_after(const_iterator pos, T&& value)
{
return emplace_after(pos, std::move(value));
}
template<typename T>
typename forward_list<T>::iterator forward_list<T>::erase_after(const_iterator pos) noexcept(std::is_nothrow_destructible_v<T>)
{
if(pos.before_begin)
{
pop_front();
return begin();
}
if (pos.node && pos.node->next)
{
pos.node->next = std::move(pos.node->next->next);
--length;
return { pos.node->next.get() };
}
return end();
} | {
"domain": "codereview.stackexchange",
"id": 31600,
"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++, linked-list, reinventing-the-wheel, c++17",
"url": null
} |
algorithms, partitions
# The second partition that starts at n we now further split into
# subpartitions in a recursive manner.
subpartition_offsets, best_subpartition_size = \
findOptimalPartitions(weights[n:], num_partitions - 1)
# If the maximum size of any of the current partitions is smaller
# than the current best partitioning, we update the best partitions.
if ((first_partition_size < max_partition_size)
and (best_subpartition_size < max_partition_size)):
# The first partition always start at 0. The others start at
# ones from the subpartition relative to the current index, so
# add the current index to those.
partition_offsets[1:] = n + subpartition_offsets
# Find the maximum partition size.
max_partition_size = max(first_partition_size, best_subpartition_size)
return partition_offsets, max_partition_size | {
"domain": "cs.stackexchange",
"id": 16137,
"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": "algorithms, partitions",
"url": null
} |
climate, coastal
Title: Why do colder climates have more rugged coasts? I've been playing Worldle for a while, and noticed that colder countries seem to have more rugged coasts. See Svalbard for example:
And Patagonia:
Whereas e.g. Bali is smoother: | {
"domain": "earthscience.stackexchange",
"id": 2500,
"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": "climate, coastal",
"url": null
} |
c#, .net-datatable
At least if you have choosen a style, also this style isn't following the guidelines you should stick to the choosen style. Right now you are mixing the casing styles.
Calling Convert.ToDouble() on a double or calling ToString() on a String is redundant.
Your loops are starting at 1 and you are accessing the items by [iterator -1]. You should start at 0 as every array in NET.
The starting at 1 and the ending condition of < thegrid.RowCount will let you miss one row.
You should retrieve Cells["PUR LT"] only if partNumber == material.
Both OleDbConnection and OleDbCommand are implementing IDisposable so enclosing the usage in a using block will automatically call Dispose() on the objects and therefor also close the connection.
Instead of iterating over the rows of the datagridviews you should consider to use linq to do the job.
You should always assume that a cell of the datagridview can be DBNull.Value. So a checking for DBNull should be done. | {
"domain": "codereview.stackexchange",
"id": 12012,
"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#, .net-datatable",
"url": null
} |
ros, ros-melodic, velodyne
Originally posted by mgruhler with karma: 12390 on 2021-06-24
This answer was ACCEPTED on the original site
Post score: 2
Original comments
Comment by ManChrys on 2021-06-24:
hmmm ok i see !!! Thank you my friend for the explanation!! | {
"domain": "robotics.stackexchange",
"id": 36564,
"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-melodic, velodyne",
"url": null
} |
haskell
calculateWinner :: Game -> IO Game
calculateWinner game =
putStrLn str >> return newGame
where
newGame = endGame game
(white, black) = List.partition (== White) $ filter (/= Hole) $ Map.elems $ cells $ board newGame
(numOfWhite, numOfBlack) = (length white, length black)
winner = if numOfWhite > numOfBlack then White else Black
max' = max numOfWhite numOfBlack
min' = min numOfWhite numOfBlack
str = if numOfWhite == numOfBlack
then "Game has ended in a draw."
else Print.printf "Game over! %s has won (%d:%d)!" (show winner) max' min'
requireGameStarted :: Game -> IO Bool
requireGameStarted (Game mode _ _)
| mode /= NewMode && mode /= ActiveMode = printError "game not started" >> return True
| otherwise = return False
trim :: String -> String
trim = T.unpack . T.strip . T.pack
splitCommand :: String -> (String, String)
splitCommand str =
splitAt index str
where
index = Maybe.fromMaybe (length str) $ List.elemIndex ' ' str | {
"domain": "codereview.stackexchange",
"id": 1463,
"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": "haskell",
"url": null
} |
quantum-gate, teleportation
Depending on the quantum architecture, some gates may be difficult or impossible to execute reliably or fault-tolerantly. The operations that make up the teleportation protocol are often simpler to implement fault-tolerantly than the gate being teleported (see application 1 below). Also, gate teleportation enables us to achieve scalability by performing unreliable operations offline where failures do not restart the entire computation (see application 2 below).
Application 1: Fault-tolerant implementation of non-transversal gates
By the Eastin-Knill theorem, no quantum error correcting code admits transversal implementation of a universal set of gates. While transversality is a simple way to ensure fault-tolerance, it is not the only way. However, most other techniques are ad hoc and do not generalize to many types of gates. Gate teleportation provides fault-tolerant implementation of a large class of gates called the Clifford hierarchy. | {
"domain": "quantumcomputing.stackexchange",
"id": 2352,
"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-gate, teleportation",
"url": null
} |
ros, monocular-camera, viso2-ros
Originally posted by aldo85ita on ROS Answers with karma: 252 on 2012-10-16
Post score: 1
Yes, it is mandatory to rectify the images before feeding them to viso2_ros. And no, the library does not compute odometry using unrectified images.
To produce rectified images you can use the package image_proc. Your camera driver should publish sensor_msgs/Image together with sensor_msgs/CameraInfo containing the calibration. image_proc then creates the rectified image for you which you can feed into viso2_ros.
A sample launch file would look like this:
<!-- example launch file for mono_odometer -->
<launch>
<arg name="camera"/> <!-- camera must be set at launch -->
<node name="image_proc" pkg="image_proc" type="image_proc" ns="$(arg camera)"/>
<node name="mono_odometer" pkg="viso2_ros" type="mono_odometer" output="screen">
<remap from="image" to="$(arg camera)/image_rect" />
<param name="camera_height" value="0.5" /> <!-- cam is 0.5m above ground --> | {
"domain": "robotics.stackexchange",
"id": 11391,
"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, monocular-camera, viso2-ros",
"url": null
} |
star, planet, orbit, gravity
Title: How can a gas planet become tidally locked with a star? Supposing a planet is made entirely of gas, is it possible for the planet to become tidally locked with the star it orbits?
I know when a terrestrial planet orbits a star in a different amount of time than the length of its day, the planet warps continuously, resulting in tidal heating. This heating takes energy from the planet's rotation until it stabilizes in a tide-locked formation.
I believe a purely gaseous planet would also have some sort of internal heating for the same reason. But because the "surface" of a gas planet is fluid, it must also obey thermodynamic principles.
As a basic example, the side of the planet facing a star gets hot, and the side facing away gets cold. The hot gas expands and the cold gas contracts and you get convection, Hadley cycles, prevailing winds, and chaotic weather patterns. | {
"domain": "astronomy.stackexchange",
"id": 1981,
"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, planet, orbit, gravity",
"url": null
} |
observational-astronomy, expansion, redshift
When you look at galaxies farther away, you're looking at them farther back in time (because speed of light is constant). So, to sample the velocities of galaxies over time, you don't need to observe them for a long time, but you can work with galaxies that are at different distances, and hence at different times in the history of the universe.
Now if you notice that the recession velocities of galaxies that are farther away are slower than what you would expect from a constant expansion scenario (Hubble's law, for example), that means the universe was expanding slower, back then, than it is, now. If there is a clear trend that this is happening, then you can say that the speed of expansion of the universe has been increasing over time. This means that the universe is accelerating. | {
"domain": "astronomy.stackexchange",
"id": 429,
"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": "observational-astronomy, expansion, redshift",
"url": null
} |
java, algorithm, tree, combinatorics
if(previousResults.size() == 0){
double newKey = calculateNumbersAndOperator(0, child.getNumber(), child.getOperator());
// First expression is 0 + num, or num itself
String newExpression = "" + child.getNumber();
currentResults.put(newKey, newExpression);
} else{
// Count hashmap and don't save previous result to prevent OutOfMemoryError
int previousResultsCounter = 0;
int previousResultsHashmapSize = previousResults.entrySet().size();
for (Map.Entry<Double, String> entry : previousResults.entrySet()) {
previousResultsCounter++;
if(previousResultsCounter == previousResultsHashmapSize) {
Double previousKey = entry.getKey();
String previousExpression = entry.getValue(); | {
"domain": "codereview.stackexchange",
"id": 41302,
"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, algorithm, tree, combinatorics",
"url": null
} |
textbook-and-exercises, mathematics, linear-algebra
= \arccos\left(2\frac{|b|^2}{\|v_\pm\|^2}-1\right)
= \arccos\left(\frac{2|b|^2-\|v_\pm\|^2}{\|v_\pm\|^2}\right).\tag A$$
We are pretty much there now. Observe that
$$2|b|^2-\|v_\pm\|^2 = -2(\Delta^2 \mp \Delta S)
= 2\Delta(-\Delta\pm S),$$
and thus (A) becomes
$$\theta = \arccos\left(\frac{2\Delta(-\Delta\pm S)}{\pm2S (-\Delta\pm S)}\right)
= \arccos\left(\pm\frac{\Delta}{S}\right).$$
But also, $\lambda_+-\lambda_-=2S$, and thus you get the final expression you were looking for.
To be closer to the way the problem was stated: you can think of the above procedure as applied only to the eigenvalue $\lambda_+$, and thus obtaining your expression for $|m_1\rangle$. Once you have that, the expression for $|m_2\rangle$ follows immediately, because given any vector $(a,b)$ you can write its orthogonal as $(\bar b,-\bar a)$. You then just need to remember that you can always multiply by a global phase factor without problems. | {
"domain": "quantumcomputing.stackexchange",
"id": 3325,
"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": "textbook-and-exercises, mathematics, linear-algebra",
"url": null
} |
python, python-3.x, numpy, converting
then test all resulting arrays to make sure they are the same length. If so, I return a list containing floats and arrays. If not, return None.
I want to avoid up-conversion of booleans and small byte-length ints.
The script below appears to do what I want by brute force testing, but I wonder if there is a better way?
Desired behaviors:
fixem(some_bad_things) returns None
fixem(all_good_things) returns [42.0, 3.14, 3.141592653589793, 2.718281828459045, 3.0, 42.0, 3.0, 42.0, array([1. , 2.3, 2. ]), array([3.14, 1. , 4. ]), array([1., 2., 2.]), array([3., 1., 4.]), array([0., 1., 2.]), array([0, 1, 2])]
and sum(fixem(all_good_things)) returns array([149.13987448 149.29987448 156.99987448]) | {
"domain": "codereview.stackexchange",
"id": 36665,
"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, numpy, converting",
"url": null
} |
deep-learning, cnn, terminology, mathematics
As you can see from the drawing each feature map of the conv. layer receives all input channels as an input (and the same would apply if this was not an input layer but a conv. layer with 3 feature maps).
*Note that it does not make a difference whether the previous layer is a conv. layer too or the input layer - in the first case you call its depth "filters" and in the second you call it "channels" but that does not change how it is connected to the following conv. layer. | {
"domain": "datascience.stackexchange",
"id": 6935,
"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": "deep-learning, cnn, terminology, mathematics",
"url": null
} |
python, beginner, python-2.x, csv, template
if variable_around in doc_line:
doc_line = doc_line.replace(variable_around, '')
else:
doc_line = doc_line.replace(variable, '')
continue
if 'units' in variable:
units = variable.replace(' units', '')
if data == '1':
if units[-1] == 's':
units = units[:-1]
doc_line = doc_line.replace(variable, data + ' ' + units)
else:
doc_line = doc_line.replace(variable, data)
open_doc.write(doc_line)
open_doc.close() | {
"domain": "codereview.stackexchange",
"id": 13364,
"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, beginner, python-2.x, csv, template",
"url": null
} |
algebraically? There will be times when In simple words, the inverse function is obtained by swapping the (x, y) of the original function to (y, x). Solve for y in terms of x. Now that we understand the inverse of a set we can understand how to find the inverse of a function. =": Well, I solved for "x document.write(accessdate); In this video the instructor teaches about inverse functions. to the test. is also a function. y If you need to find the 5 | 6 | 7 Find the inverse of. Only one-to-one functions have inverses. Inverse Function First, the definition and properties of inverse function are reviewed. Just look at all those values switching places from the f ( x ) function to its inverse g ( x ) (and back again), reflected over the line y = x. As many questions, including solutions, may be generated interactively. To recall, an inverse function is a function which can reverse another function. since it violates the Horizontal Line Test: It is usually considered To avoid any | {
"domain": "engrdept.com",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9504109798251322,
"lm_q1q2_score": 0.8240403076496979,
"lm_q2_score": 0.8670357615200474,
"openwebmath_perplexity": 520.7793622770847,
"openwebmath_score": 0.6890625357627869,
"tags": null,
"url": "http://pers.engrdept.com/eyinh07/136103-how-to-find-the-inverse-of-a-function"
} |
c++, multithreading, file-system, linux, c++20
types
You use int a lot, to mean filehandle and maybe other things. You should declare named types to indicate what they are, as opposed to the implementation of the data. Even if you just use a using alias rather than any kind of strong typing mechanism, it's still easier to read and understand, and maintain when a type changes!
This is especially true for your watcher IDs. The token returned from on_modify is a special value to pass to stop_watcher, and you can't just pass any int there. Personally, I've made such tokens encapsulated classes that un-register automatically when destroyed, as opposed to manually passing it to another function.
For a file name, why not use the filesystem library instead of a string? | {
"domain": "codereview.stackexchange",
"id": 41546,
"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++, multithreading, file-system, linux, c++20",
"url": null
} |
reinforcement-learning, policy-gradients
Then the teacher says we can write the value function of another policy like the following. I get lost here.
$$ V(\tilde{\theta}) = V(\theta) + E_{\pi\tilde{\theta}}[\sum_{t=0}^{\infty} \gamma^{t} A_{\pi}(s_t,a_t)] $$
then she re-expresses that expectation as.
$$ V(\tilde{\theta}) = V(\theta) + \sum_{s}\mu(s)\sum_{a}\pi(a|s) A_{\pi}(s,a) $$
Where $V(\theta)$ is the value function of the policy parameterized by $\theta$ and $\tilde{\theta}$ is a different set of parameters than $\theta$. I don’t understand why? Im looking for an explanation of what this equation is used for? Or why it makes sense to represent the value function of a policy using the value function and advantage function of another policy. | {
"domain": "datascience.stackexchange",
"id": 10957,
"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": "reinforcement-learning, policy-gradients",
"url": null
} |
deep-learning, reinforcement-learning, cnn
Unambiguous, simple reward system (get points, don't die)
limited options (move or shoot a single weapon type)
all enemies are very similar
The player has perfect information.
Compare this to DOTA 2, which has not been mastered, but with a moderate reduction in complexity (1v1 instead of 5v5), OpenAI was able to achieve some impressive results, despite being magnitudes of order more complex than asteroids.
There are certain compromises made in the 2015 DQN paper, for example:
"Following previous approaches to playing Atari2600 games,we also use
a simple frame-skipping technique (15). More precisely, the agent sees
and selects actions on every kth frame instead of every frame, and its
last action is repeated on skipped frames. Because running the
emulator forward for one step requires much less computation than
having the agent select an action, this technique allows the agent to
play roughly k times more games without significantly increasing the
runtime.
We use k - 4 for all games" | {
"domain": "datascience.stackexchange",
"id": 2629,
"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": "deep-learning, reinforcement-learning, cnn",
"url": null
} |
c++, template-meta-programming
template<typename T>
static void print() {
TypeMapDetail<T>::map_.print();
}
};
template<typename T>
TypeMap::TypeMapDetail<T> TypeMap::TypeMapDetail<T>::map_;
I know I am currently using a simple algorithm for the binary search tree which will not auto-balance the tree. I'll take a look at fixing it once I'm sure this way will work. I'll also be splitting out the functions so that they class definition is easier to read.
I'm also aware that I should add a const getter of some sort, but I have no need for it and don't want to complicate the code any further.
Questions: | {
"domain": "codereview.stackexchange",
"id": 6225,
"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++, template-meta-programming",
"url": null
} |
Given the three sources of errors above, I'll be very happy if I get results within one percent, i.e. if it is able to give me a value of $\pi$ somewhere between, say, 3.1 and 3.2.
Now, that really great screen on the DM42 should not be allowed to go to waste while this is running, so I included instructions to plot the value $p$ computed after each iteration of the loop in the program I wrote.
First, here's the initial setup. It displays its current parameters and provides a menu for the user to specify the parameters of the experiment. $n$ gets stored in R00 and the sample size in R01. | {
"domain": "horwits.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.989181550709283,
"lm_q1q2_score": 0.8087295969752053,
"lm_q2_score": 0.8175744850834648,
"openwebmath_perplexity": 1505.0771007374226,
"openwebmath_score": 0.6629317402839661,
"tags": null,
"url": "http://techy.horwits.com/2020/09/using-random-numbers-to-compute-value-of.html"
} |
neuroscience, food
Title: What in fast food fries have that regular fries don't? Why is it that a french fry from a fast food restaurant doesn't seem to spoil the same way as one that one would cook at home?
PS: If given enough time will fast food french fries eventually decompose; if so, how long? I went through a longer winded explanation here: https://biology.stackexchange.com/a/57877/19432.
In brief, food spoils if water is bio-available to micro-organisms. In the case of a french fry from say, McDonalds. This fry has a very small volume to surface area ratio, and hence is able to dry out what little water is left after the frying process before micro-organisms can proliferate enough to visibly "spoil" the fry.
If, in your own kitchen, you were take a fresh potato, cut it into fries, and cook them in oil long enough to nearly dehydrate the fry, it would not spoil either in a dry environment. | {
"domain": "biology.stackexchange",
"id": 7155,
"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": "neuroscience, food",
"url": null
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.