text stringlengths 1 1.11k | source dict |
|---|---|
python, game, hangman, python-2.x
def take_player_guess(self):
player_input = raw_input("\nInput a letter: >> ")
if len(player_input) > 1:
self.take_player_guess()
else:
self.input_letter.insert(0, player_input)
def check_player_guess(self, guess):
if guess not in self.mk_string(self.word_to_guess):
self.count += 1
self.wrong_guesses.append(guess)
else:
for letter in range(0, len(self.mk_string(self.word_to_guess))):
if self.mk_string(self.word_to_guess)[letter] == guess:
self.mutable_hidden_word[letter] = guess
def print_hidden_word(self):
print self.mk_string(self.mutable_hidden_word, " ")
def print_wrong_guesses(self):
if not self.wrong_guesses == []:
print "Wrong guesses: " + self.mk_string(self.wrong_guesses, ", ") | {
"domain": "codereview.stackexchange",
"id": 31633,
"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, game, hangman, python-2.x",
"url": null
} |
c++, object-oriented, matrix, template
Questions:
I wouldn't worry about restricting types. The good thing about template code is that it will compile if a type supports the relevant interface, and not if it doesn't. However, if you really wanted to it could be done with std::enable_if and the various type traits, such as std::is_arithmetic.
For run-time errors, you can either #include <cassert> and use assert(condition);, or throw an exception. I would suggest using exceptions, since it's easier to test the code that throws them, and they are consistent between debug and release builds. | {
"domain": "codereview.stackexchange",
"id": 32433,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "c++, object-oriented, matrix, template",
"url": null
} |
python, python-3.x, reinventing-the-wheel, error-handling
Title: Python implementation of atoi I made an implementation of atoi (ascii to integer) in Python a while ago for fun, and I'd like to know what I could do to improve it.
class CannotConvertToInteger(Exception):
"""A non-numeric character was present in the string passed to atoi"""
pass
def atoi(string : str) -> int:
sign = multiplier = 1
val = 0
if string[0] == '-':
string = string[1:]
sign = -1
elif string[0] == '+':
string = string[1:]
for i in string[::-1]:
code = ord(i)
try:
if ((code > 57) or (code < 48)):
raise CannotConvertToInteger
else:
val += (code - 48) * multiplier
multiplier *= 10
except CannotConvertToInteger:
return print('Cannot convert string to an integer!')
return (val * sign) | {
"domain": "codereview.stackexchange",
"id": 35867,
"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, reinventing-the-wheel, error-handling",
"url": null
} |
The point where the secant line crosses the $x$-axis is
$$0 = \frac{f(b) - f(a)}{b - a}(x - a) + f(a)$$
which we solve for $x$
$$x = a - f(a)\frac{b - a}{f(b) - f(a)}$$
## Algorithm
The secant method procedure is almost identical to the bisection method. The only difference it how we divide each subinterval.
1. Choose a starting interval $[a_0,b_0]$ such that $f(a_0)f(b_0) < 0$.
2. Compute $f(x_0)$ where $x_0$ is given by the secant line $$x_0 = a_0 - f(a_0)\frac{b_0 - a_0}{f(b_0) - f(a_0)}$$
3. Determine the next subinterval $[a_1,b_1]$:
1. If $f(a_0)f(x_0) < 0$, then let $[a_1,b_1]$ be the next interval with $a_1=a_0$ and $b_1=x_0$.
2. If $f(b_0)f(x_0) < 0$, then let $[a_1,b_1]$ be the next interval with $a_1=x_0$ and $b_1=b_0$.
4. Repeat (2) and (3) until the interval $[a_N,b_N]$ reaches some predetermined length.
5. Return the value $x_N$, the $x$-intercept of the $N$th subinterval. | {
"domain": "ubc.ca",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9884918529698321,
"lm_q1q2_score": 0.8104578763294714,
"lm_q2_score": 0.8198933293122507,
"openwebmath_perplexity": 867.208416866174,
"openwebmath_score": 0.8062421083450317,
"tags": null,
"url": "https://www.math.ubc.ca/~pwalls/math-python/roots-optimization/secant/"
} |
convolution, continuous-signals, linear-systems
What is the correct way of dealing with this kind of signals, does the negative amplitude effect the results and does it change the output of LTI system, am I right or mistaken?
My question is, what is the correct way of dealing with this kind of signals, does the negative amplitude effect the results and does it change the output of LTI system, am I right or mistaken? | {
"domain": "dsp.stackexchange",
"id": 12372,
"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": "convolution, continuous-signals, linear-systems",
"url": null
} |
ros, tf2-ros, tf2, transform
Title: Again a Migration Question From TF to TF2
Hi all,
at first, I am sorry if this question might be a duplicate, however I didn't find a clear answer while searching this forum.
So I decided to migrate my code from TF to TF2. I encountered lots of confusion since I am missing now some helper functions, Datatypes are obviously changed from tf:: to tf2:: and so forth.
In a nutshell, what I am trying to do is to lookup some transforms, compute my kinematic-chain-relation and publish a new frame.
1.) lookup a transform with my tf2::buffer, which returns a geometry_msgs::TransformStamped
geometry_msgs::TransformStamped geo_msg = buffer.lookupTransform( "frame1", "frame2", ros::Time(0) ); | {
"domain": "robotics.stackexchange",
"id": 21054,
"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, tf2-ros, tf2, transform",
"url": null
} |
ros
Originally posted by SL Remy with karma: 2022 on 2013-08-14
This answer was ACCEPTED on the original site
Post score: 3 | {
"domain": "robotics.stackexchange",
"id": 15257,
"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
} |
units, unit-conversion, conventions
Title: Conversion of the units BeV (US) and GeV (UN) What is the difference in the definition of a billion electron volts in United states (US) and United Nations (UN)?
When the US people say billion, do they mean $10^{12}$ or $10^9$? In the US, 1 billion = $10^9$.
The difference is between the Long and short scales. The US uses the short scale, where a billion is $10^9$. In the long scale, a billion is $10^{12}$.
In the short scale, every term after a million (billion, trillion, etc.) is 1,000 times bigger than the previous one. So, million = $10^6$, billion = $10^9$, trillion = $10^{12}$.
In the long scale, every term after a million is 1,000,000 times bigger. So, million is again $10^6$, but billion = $10^{12}$, and trillion = $10^{18}$.
If you just use SI prefixes, though, those are the same everywhere. $10^9 eV$ is one GeV, whereas $10^{12} eV$ is one TeV. | {
"domain": "physics.stackexchange",
"id": 3915,
"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": "units, unit-conversion, conventions",
"url": null
} |
performance, c, memory-management, io
This function sets the maximum to the last element of the array and then updates it as necessary. It iterates over the array from end to beginning. If the current element is greater than the maximum, it updates maximum to be the current element. Because we know that we are starting at the end, we can save most of the checks that we are at or near the end in favor of one check whether we've reached the beginning. Further, because maximum is always maintained from the end, we only have to update when it changes. If the maximum is greater than or equal to the current element, we can simply do nothing.
This function eliminates the need to do any recursive calls. It's purely iterative. | {
"domain": "codereview.stackexchange",
"id": 10638,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "performance, c, memory-management, io",
"url": null
} |
mathematical-physics, group-theory, lie-algebra
$$
[\mathfrak h,~\mathfrak h]~\subset~ \mathfrak k,\qquad [\mathfrak h,~\mathfrak k]~\subset~ \mathfrak h, \qquad [\mathfrak k,~\mathfrak k]~\subset~ \mathfrak k.
$$
In your question, eager to follow the notation of Duff et al, you reversed the role of broken vs unbroken generators. Remember the unbroken generators
(isospin) close to a subalgebra, but the broken ones (axials) transform by the $\mathfrak k$ as isomultiplets and Lie-commutator-close to vectors $\mathfrak k$! | {
"domain": "physics.stackexchange",
"id": 30906,
"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": "mathematical-physics, group-theory, lie-algebra",
"url": null
} |
Is my solution correct and why don't rotations add to the scenario. I don't grasp this fully quite yet.
• Here is the official solution: artofproblemsolving.com/wiki/…. Is there something you don't understand there? – Isaac Browne Dec 27 '17 at 0:54
• @IsaacBrowne why are the scenarios in which the the vertical faces do not have the same color counted in the desirable outcomes – jamarcus tyrone Dec 27 '17 at 0:58
## 1 Answer
Note that the question asks for the probability that the cube can be placed. That means we don't start with 4 designated vertical faces; we have freedom to choose which faces to place vertical.
There are 3 scenarios in which four vertical faces are red and two blue: pick any pair of opposing faces of the cube to be blue, and the rest red. Then we can choose to place the cube blue-face-down, so the red faces come out vertical. There are 3 such pairs (since there are 6 faces). | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.984336353126336,
"lm_q1q2_score": 0.8137624724620572,
"lm_q2_score": 0.8267117940706734,
"openwebmath_perplexity": 351.3134273456095,
"openwebmath_score": 0.7612234354019165,
"tags": null,
"url": "https://math.stackexchange.com/questions/2581360/amc-12-question-on-probability"
} |
Any strictly monotonic function $f$, such that $\lim \limits_{x \rightarrow +\infty} f(x) \neq \infty$ could be used after a bit of linear transformations. Aside from what Ilya suggests, other natural choices could be $$1 - \frac{1}{1+|x-y|}$$ or $$\frac{2\arctan |x-y|}{\pi}$$ There is a lot of freedom here, if you know exactly what you want.
- | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9752018416062039,
"lm_q1q2_score": 0.8040167889366301,
"lm_q2_score": 0.8244619263765706,
"openwebmath_perplexity": 261.5041322813176,
"openwebmath_score": 0.6751434206962585,
"tags": null,
"url": "http://math.stackexchange.com/questions/151550/mathematical-function-for-weighting-results/151556"
} |
tensor-calculus
Title: If the contraction of some quantity is a tensor, is that quantity a tensor? Suppose I have some set of quantities $T_{ji···m···l···k}$. If the particular contraction $T_{ji···m···m···k}$ of this set of quantities is tensorial in nature, then is it true the that original quantity is tensorial in nature?
I ask this question in relation to this question from Riley, Hobson, and Bence. I believe I need to use the above lemma to solve the problem. Bonus points if you can prove the lemma as a special case of the quotient rule, although I don't think that's possible. I think that the answer is no:
Suppose that $T_{ij}=1$ for each basis and pair of indices, then $\sum_iT_{ii}$ is independent of the basis (i.e. a scalar), but $T$ is clearly not a tensor. | {
"domain": "physics.stackexchange",
"id": 92298,
"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",
"url": null
} |
quantum-mechanics, hilbert-space
Title: Confusion about Fock subspace I'm currently reading Folland's book on quantum field theory and came along some definitions.
On p.90 of his book, Folland defines the symmetric Fock space as
$$\mathcal{F}_s(\mathcal{H})=\bigoplus_{k=0}^\infty \overset{k}{\bigotimes}_s\mathcal{H} \tag{1}$$
where $\otimes_s$ is to be understood as the symmetric tensor product and $\mathcal{H}$ as Hilbert space.
On the next page he talks about finite-particle subspace (of the symmetric Fock space) of states in which the total number of particles is bounded above defined as
$$\mathcal{F}_s^0(\mathcal{H})=\text{the algebraic direct sum of the spaces}\,\overset{k}{\bigotimes}_s\mathcal{H} \tag{2}$$ | {
"domain": "physics.stackexchange",
"id": 23747,
"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, hilbert-space",
"url": null
} |
ros, rospy, messages
Title: rospy sensor_msgs.msg.BatteryState is not found
For some reason I'm not able to import the BatteryState message with rospy. This is the only message I've encountered that seems to be missing. http://docs.ros.org/indigo/api/sensor_msgs/html/msg/BatteryState.html
I'm using ros-indigo. Anyone else have this problem?
zac@nuc-2:~$ python
Python 2.7.6 (default, Jun 22 2015, 17:58:13)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from sensor_msgs.msg import Imu
>>> from sensor_msgs.msg import BatteryState
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name BatteryState
>>> | {
"domain": "robotics.stackexchange",
"id": 24363,
"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, rospy, messages",
"url": null
} |
python, object-oriented, simulation
def test_bob_loses(self):
p = FirstSwitch("Bob")
b = Board(['car', 'goat', 'goat'])
game = Game(b, p)
game.play()
self.assertFalse(game.won)
To run the unittests: python -m unittest -v
This should give you a nice way to implement the remaining strategies.
The code duplication in my main.py also presents the opportunity for the fourth class. | {
"domain": "codereview.stackexchange",
"id": 41473,
"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, simulation",
"url": null
} |
python, beginner, rock-paper-scissors
Also this
while choice != cpu_choice:
should be this
if choice != cpu_choice:
Imports
Imports should go outside of functions, and at the top of the module
import random
def main():
... code ...
Better Input Validation
Right now, you check if the input is valid. If it isn't, you print "Invalid choice!". But you don't stop the program. It keeps running with that choice. You can simplify this by using a while loop here, only breaking if the input is valid:
choice = input("Enter your choice: ")
while choice not in "RPS":
print("Invalid choice!")
choice = input("Enter your choice: ")
Unused Variables
This
game_active = True
is never used in your program. You should remove this to avoid confusion, as I initially thought this was the flag that determined if the game was to be run again. | {
"domain": "codereview.stackexchange",
"id": 36239,
"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, rock-paper-scissors",
"url": null
} |
Let $\mathcal{U}_0=\left\{U_1,U_2,U_3,\cdots \right\}$ be a countable subcollection of $\mathcal{U}$ such that $\mathcal{U}_0$ covers $\left\{b \right\} \times Y$. For each $j$, let $U_j=V_j \times W_j$ where $V_j=\prod_{\alpha \in A} V_{j,\alpha}$ is a standard basic open subset of the product space $X$ with $b \in V_j$ and $W_j$ is an open subset of $Y$. For each $j$, let $F_j$ be the support of $V_j$. Note that $\alpha \in F_j$ if and only if $V_{j,\alpha} \ne X_\alpha$. Also for each $\alpha \in F_j$, $b_\alpha \in V_{j,\alpha}$. Furthermore, for each $\alpha \in F_j$, let $V^c_{j,\alpha}=X_\alpha- V_{j,\alpha}$. With all these notations in mind, we define the following open set for each $\beta \in F_j$:
$H_{j,\beta}= \biggl( V^c_{j,\beta} \times \prod_{\alpha \in A, \alpha \ne \beta} X_\alpha \biggr) \times W_j=\biggl( V^c_{j,\beta} \times T_\beta \biggr) \times W_j$ | {
"domain": "wordpress.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9843363545048391,
"lm_q1q2_score": 0.8265806744663752,
"lm_q2_score": 0.83973396967765,
"openwebmath_perplexity": 90.51940825272462,
"openwebmath_score": 0.9695743918418884,
"tags": null,
"url": "https://dantopology.wordpress.com/tag/lindelof-space/"
} |
spectroscopy, spectra
An example is shown below. The inset image shows a broad-band image of V458 Vul - a classical nova that is surrounded by (not visible) shells of ionised material. The authors of this particular study lined up a spectrograph slit as shown in the inset and then obtained the two two-dimensional spectra shown in the main image. What you have to imagine is that each position on the slit produces a horizontal spectrum at a vertical position that corresponds to its position on the slit. Therefore we see a bright spectrum across the middle corresponding to the central source, but there are then "knots" of emission at particular wavelengths that are some distance away from the central star. | {
"domain": "astronomy.stackexchange",
"id": 1988,
"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": "spectroscopy, spectra",
"url": null
} |
ros
Comment by SL Remy on 2012-10-19:
to be clear, you're using an NVIDIA card and this isn't a virtual card correct?
Comment by Pablo Urcola on 2012-10-21:
It would be easier to help you if you post hear your world file, of course. But I can see 4 warning messages in your trace that are related to the new syntax for lasers. I recommend you to fix them just to be sure that the problem is not there.
It appears the problem is that in the stage world files the block sections are missing the z parameter. See: https: //github.com/rtv/Stage/issues/31
So I prevented the crash by adding:
z [0 .32] | {
"domain": "robotics.stackexchange",
"id": 11395,
"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
} |
Now suppose $\epsilon>0$ is such that $f(x)=-x/2$ whenever $|x|\leq\epsilon$. If $0\leq a\leq \epsilon$, the functional equation with $x=a$ and $y=-\epsilon$ then gives $$f(a+\epsilon)=-\frac{a+\epsilon}{2}.$$ That is, $f(x)=-x/2$ is also valid if $\epsilon\leq x\leq 2\epsilon$. Similarly, using $y=\epsilon$ gives that $f(x)=-x/2$ is also valid if $-2\epsilon\leq x\leq -\epsilon$.
That is, if $f(x)=-x/2$ whenever $|x|\leq\epsilon$, $f(x)=-x/2$ whenever $|x|\leq 2\epsilon$ as well. Repeating this argument over and over, we get that $f(x)=-x/2$ for all $x$.
Thus the only possibilities for $f$ are $f(x)=x$ and $f(x)=-x/2$, and you can easily check that both of these work. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9838471675459396,
"lm_q1q2_score": 0.8616405431322812,
"lm_q2_score": 0.8757869835428966,
"openwebmath_perplexity": 61.60041718928827,
"openwebmath_score": 0.9844039082527161,
"tags": null,
"url": "https://math.stackexchange.com/questions/1938052/find-the-function-fx-if-fx2fy-fxyfy/1938110"
} |
EDIT 1: If it's easier to prove, I'd specifically interested in the cases where $$E$$ is a Hilbert space or finite-dimensional (or both).
EDIT 2: Maybe I'm missing something, but shouldn't the claim trivially follow in the following way: Let $$x_1:=x$$ and $$x_2:=y$$. Since $$x_1$$ and $$x_2$$ are linearly independent, $$U:=\mathbb Rx_1+\mathbb Rx_2$$ is a $$\mathbb R$$-vector space of dimension $$2$$ and, by construction, $$(x_1,x_2)$$ is a basis of $$U$$. So, there are $$\varphi_1,\varphi_2\in U^\ast$$ with $$\varphi_i(x_j)=\delta_{ij}$$ for all $$i,j\in\{1,2\}$$. So, all we need to do is showing that $$\varphi_2$$ has a (not necessarily unique) linear extension to $$E$$. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9770226334351969,
"lm_q1q2_score": 0.8204390983581126,
"lm_q2_score": 0.8397339736884712,
"openwebmath_perplexity": 94.22431474865805,
"openwebmath_score": 0.9482513070106506,
"tags": null,
"url": "https://math.stackexchange.com/questions/3654624/if-x-and-y-are-linearly-independent-there-is-a-separating-linear-functional"
} |
c++, interview-questions, template
The first definition suggests that containing might be enough. But if you look at the example and at the other definitions, they paint a different story. To comprise of something means that all of the contents are the something. So a word like "cab" is comprised of a, b, c, d, and e. A word like "word" is not, even though it contains a d. So I believe that you failed this requirement.
Others have already said why your implementation might have been questionable. But you may have failed purely on interpretation of the requirements. Yes, my interpretation might be pedantic, but if your potential employer has legal contracts, those will be interpreted by equally pedantic lawyers.
If unsure, ask. It is not at all uncommon for interviews to be deliberately pedantic like this to weed out people who don't ask for clarification. | {
"domain": "codereview.stackexchange",
"id": 21832,
"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++, interview-questions, template",
"url": null
} |
gazebo, ros-fuerte
Msg Connected to gazebo master @ http://localhost:11345
Msg Connected to gazebo master @ http://localhost:11345
[ INFO] [1349028905.693671950]: joint trajectory plugin missing <updateRate>, defaults to 0.0 (as fast as possible)
[ INFO] [1349028912.404487554, 0.057000000]: waitForService: Service [/gazebo/set_physics_properties] is now available.
[ INFO] [1349028912.760845061, 1.894000000]: Starting to spin physics dynamic reconfigure node...
/opt/ros/fuerte/stacks/simulator_gazebo/gazebo/scripts/gui: line 2: 2834 Segmentation fault (core dumped) `rospack find gazebo`/gazebo/bin/gzclient -g `rospack find gazebo`/lib/libgazebo_ros_paths_plugin.so
[gazebo_gui-3] process has died [pid 2831, exit code 139, cmd /opt/ros/fuerte/stacks/simulator_gazebo/gazebo/scripts/gui __name:=gazebo_gui __log:=/home/salma/.ros/log/bad9db3a-0b2a-11e2-9b14-00e04c4d0e3f/gazebo_gui-3.log].
log file: /home/salma/.ros/log/bad9db3a-0b2a-11e2-9b14-00e04c4d0e3f/gazebo_gui-3*.log | {
"domain": "robotics.stackexchange",
"id": 11183,
"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": "gazebo, ros-fuerte",
"url": null
} |
deep-learning, classification, keras
y_pred = model.predict(X_test)
yhat = []
for pred in y_pred:
if pred >= 0.7:
yhat.append(1)
else:
yhat.append(0)
Data consists of 8 columns (features) and 270 000 rows (9th column is 'y' column). Out of these 270,000 rows only 9% contained labels of class 1 (rest were zero), so I downsampled the data (just removed bunch of data with label 0), trained the model and then did the prediction on full data. I modified how ones and zeros were determined by Sigmoid though, I changed threshold from 0.5 to 0.7 (which was the ROC score I got on downsampled data) Apparently the problem was that I forgot to normalize data. As I found out, sigmoid turns any input greater than 10 into 1 and inputs less than -10 into 0. Normalization solves this problem (as normalized values are between 0 and 1) | {
"domain": "datascience.stackexchange",
"id": 6374,
"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, classification, keras",
"url": null
} |
newtonian-mechanics, forces, momentum, conservation-laws, collision
Bear in mind that a force will accelerate a mass in accordance with Newton's second law if and only if the force is applied to the mass. If a huge force is delivered at low speed to a small mass, the mass will quickly accelerate to the point at which its speed equals that of the source of the force. At that point the force is no longer in full contact with the mass and so the acceleration stops.
You should also bear in mind that all kinds of transient effects come into play which are easily forgotten about. For example, if you were unfortunate enough to be hit by a truck, your body does not instantaneously accelerate as a unit- instead whichever part of your body first makes contact with the truck begins to accelerate, and it takes a finite time before a compression wave passes through your body and starts to accelerate the rest of it. | {
"domain": "physics.stackexchange",
"id": 85674,
"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, forces, momentum, conservation-laws, collision",
"url": null
} |
electromagnetism, gravity
Title: Can electromagnetism be used to generate gravity? The electromagnetic field produces a gravitational field because the EM field tensor produces a stress energy which in turn produces a gravitational field via the Einstein field equations.
This would seem to imply that a particular arrangement of current and voltage could be used to generate an electromagnetic field configuration which would in turn produce gravity on demand.
Is this actually possible? Assuming you are asking if a gravitational field can be switched on/off by flipping a switch in an electrical circuit, I think the answer is No.
The electromagnetic energy which you create must come from some other form of energy, which also gravitates. You are merely exchanging one source of gravity for another. At best you are moving the gravitational field from one place to another, in a finite time, like moving a mass. | {
"domain": "physics.stackexchange",
"id": 90512,
"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, gravity",
"url": null
} |
python, django
Title: An array of dictionaries; comparing each {key, value} pair; and combining dictionaries I'm trying to optimize a nested for loops that compares an element in the array with the rest of the element in the array.
There's two part, the first part is for example, an Array has 3 elements, and each element is a dictionary:
[{"someKey_1":"a"}, {"someKey_1":"b"}, {"somekey_1":"a"}]
1st iteration(1st element compares with 2nd element):
Test key of "someKey" for two elements, since a != b, then we do nothing
2st iteration(1st element compares with 3nd element):
Test key of "someKey" for two elements, since a == a, we do some logic
The code(Sudo):
for idx, first_dictionary in enumerate(set_of_pk_values):
for second_dictionary in (set_of_pk_values[idx+1:]):
if (first_dictionary['someKey'] == second_dictionary['someKey']):
#Some Logic | {
"domain": "codereview.stackexchange",
"id": 12602,
"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, django",
"url": null
} |
ros
/usr/include/boost/math/special_functions/round.hpp:28:44: required from ‘typename boost::math::tools::promote_args::type boost::math::detail::round(const T&, const Policy&, mpl_::false_) [with T = double; Policy = boost::math::policies::policy<boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy>; typename boost::math::tools::promote_args::type = double; mpl_::false_ = mpl_::bool_]’ | {
"domain": "robotics.stackexchange",
"id": 25864,
"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
} |
inorganic-chemistry
Title: Why did the red colour in a flame test for strontium disappear and appear again on longer heating? We did a basic flame test, and I understand that different salts produce different spectra because of atoms present in the salts.
When I was doing the test, I noticed that when I dipped the nichrome wire into the solution of $\ce{SrCl2}$ and placed it on the tip of the flame, I got the expected red color. However, what would happen is I would get the red color, and then it would disappear, going back to the typical bluish flame, the nichrome would glow orange hot, and the red colored flame would return.
Essentially, the red color appears, disappears, and then reappears. I thought that it might be "wicking" the strontium chloride from another part of the dipstick, but I was careful to only submerge a small part in the solution.
What's happening here? Good, careful observation! Here's my assumption of what happened: | {
"domain": "chemistry.stackexchange",
"id": 4568,
"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": "inorganic-chemistry",
"url": null
} |
quantum-mechanics, forces, photons
In the scenario I described above the first photon was slowed down by the Rydberg medium, but "cleared a path" for the second photon to propagate almost at full speed. This means that on the other side of the Rydberg medium the second photon will be 'closer' to the first photon than it would have been without the Rydberg medium. If you put a black box around the Rydberg medium and just look at photons going in and photons going out it would look to you like the photons have undergone a photon-photon attractive interaction inside the black box. | {
"domain": "physics.stackexchange",
"id": 69103,
"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, forces, photons",
"url": null
} |
Finally the answer comes out to be 4032-416=3616
- 2 years, 2 months ago
Answer to question 6. Let $a=m+\frac{b}{c}$ where $$m$$ is any integer and $0<b<c$ . Then $a(a-3{a})=( m+\frac{b}{c})( m-2\frac{b}{c})$ $m^{2}-\frac{bm}{c}+\frac{2b^{2}}{c^{2}}$. $m^{2}-\frac{2b^{2}-bcm}{c^{2}}$ Now, $$m$$ is an integer . Let's consider $\frac{2b^{2}-bcm}{c^{2}}=k$ where $$k$$ is an integer . After solving we get $\frac{b}{c}=\frac{m+_{-}\sqrt{m^{2}+8k}}{4}$.....(I) But $\frac{b}{c}<1$....(II) Now putting value of $$\frac{b}{c}$$ from (I) to (II). We get $m+k<2$ Therefore there are infinitely many integers $$m,k$$ such that $m+k<2$. Hence proved.
- 2 years, 2 months ago
I have a doubt in 5th question.
- 2 years, 2 months ago
Comment deleted Dec 06, 2015
There are five solutions: $$3+\sqrt{x}$$ where x={1.5,2,2.5,3,3.5}
- 2 years, 2 months ago
[@Nihar Mahajan , [@Swapnil Das , did you appear for RMO ?
- 2 years, 2 months ago
how much are you getting?
- 2 years, 2 months ago | {
"domain": "brilliant.org",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9643214450208031,
"lm_q1q2_score": 0.801489066946405,
"lm_q2_score": 0.8311430499496095,
"openwebmath_perplexity": 2242.845005371034,
"openwebmath_score": 0.9882208108901978,
"tags": null,
"url": "https://brilliant.org/discussions/thread/rmo-2015-rajasthan-region/"
} |
cosmology, structure-formation
The primordial matter density field is considered to be "almost" Gaussian. Thus, as a statistical motivation, smoothing can help us neglect the very local maxima/minima in this field.
Density contrast is a parameter mostly used for studies of Large-scale Structures (LSS). To address structures in the universe, we should specify a region. So, for studies related to structure formation, it would be necessary to define a spatial region and not just one point.
Practically, we can not measure the density contrast field with an "infinite" resolution. Thus, a smoothing is required for comparing theoretical analysis with observational results. | {
"domain": "physics.stackexchange",
"id": 70641,
"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": "cosmology, structure-formation",
"url": null
} |
# Probability of getting no vowel for each die
pNoVowels = 1 - pVowels
# Chance that we will get not a single vowel, including "y" and "Qu"
print(prod(pNoVowels))
If you run the code above, you should see that the probability of getting no vowels (including “Y” and “Qu”) is 0.000642. That works out to one in every 1557 boards. So it’s quite rare, but by no means so extraordinary that it crosses the Universal probability bound. Also, it’s not enough to just calculate how rare your event is, or how rare any similar or more extreme event is, and then be astounded. You also have to include all the other possible events that would have left you amazed. What about getting all vowels (much more rare)? What about getting 8 or 9 E’s, or a row or column of all A’s or E’s? It’s likely that if you add up all probabilities of all the rare events which might leave you amazed, you’ll end up with a good chance of amazement every time. | {
"domain": "statisticsblog.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9790357610169274,
"lm_q1q2_score": 0.8027049025417103,
"lm_q2_score": 0.8198933425148213,
"openwebmath_perplexity": 1634.2395882596413,
"openwebmath_score": 0.5785263180732727,
"tags": null,
"url": "https://statisticsblog.com/2010/07/"
} |
python, python-3.x, embedded, circuit-python
Title: OLED FeatherWing instruction page I have a Feather M0 basic paired with a OLED FeatherWing. I am making an instructions page but the code is quite repetitive. How can I make my code shorter?
import board
from busio import I2C
from adafruit_ssd1306 import SSD1306_I2C
from time import sleep
from digitalio import DigitalInOut, Direction, Pull
i2c = I2C(board.SCL, board.SDA)
oled = SSD1306_I2C(128, 32, i2c)
button_A = DigitalInOut(board.D9)
button_B = DigitalInOut(board.D6)
button_C = DigitalInOut(board.D5)
button_A.direction = Direction.INPUT
button_B.direction = Direction.INPUT
button_C.direction = Direction.INPUT
button_A.pull = Pull.UP
button_B.pull = Pull.UP
button_C.pull = Pull.UP
def check_buttons():
if button_A.value is False:
return 'A'
elif button_B.value is False:
return'B'
elif button_C.value is False:
return 'C'
else:
return None
def wait_for_A():
sleep(0.5)
while check_buttons() is not 'A':
pass | {
"domain": "codereview.stackexchange",
"id": 35525,
"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, embedded, circuit-python",
"url": null
} |
series: f 0 is referred to as ‘fundamental frequency’. Solution The simplest way is to start with the sine series for the square wave: SW(x)= 4 π sinx 1 + sin3x 3 + sin5x 5 + sin7x 7 +···. Because the Fourier spectrum would only have one peak - this would require the wave to be infinite What is a Fourier transform? A generalization of Fourier series for non-periodic functions i. My understanding is that the sinc function is the transform of a square wave. The summation can, in theory, consist of an infinite number of sine and cosine terms. Can describe object (lightfield) as superposition of “gratings” (spatial frequency components) 4. Find the Fourier series of the resulting periodic function: w w w p L L E t t L L t u t, 2, 2 sin 0 0 0. Suppose that we have a vector f of N complex numbers, f k, k ∈ {0,1,,N − 1}. Use the estimated amplitude at these frequen- cies to locate hidden periodic components. Solution: The voltage waveform is similar to the square wave in Table 15. Example: | {
"domain": "clubita.it",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.988312744413962,
"lm_q1q2_score": 0.8299197900956675,
"lm_q2_score": 0.8397339756938818,
"openwebmath_perplexity": 626.0946395695709,
"openwebmath_score": 0.8501878976821899,
"tags": null,
"url": "http://clubita.it/hzgb/fourier-transform-of-periodic-square-wave.html"
} |
beginner, vba, excel, error-handling
End With
End Sub
Private Sub cbRemoveItems_Click()
For intCount = lbItemList.ListCount - 1 To 0 Step -1
If lbItemList.Selected(intCount) Then lbItemList.RemoveItem (intCount)
Next intCount
End Sub Option Explicit
Go to Tools -> Options -> Require Variable Declaration. This will insert Option Explicit at the top of every new module you create.
Option Explicit will enforce that every variable you use is declared. This will prevent all sorts of bugs, mainly due to preventing typos.
Separation of concerns
You should never have business logic contained directly in your event triggers. It means your code is scattered around, is not easily find-able, and is very tightly coupled with your form. You should separate out your logic into Sub/Functions which your event handlers can then call.
Take this for instance:
Public Sub cmbBrand_Change()
Me.tbQuantity.Text = "1" | {
"domain": "codereview.stackexchange",
"id": 20500,
"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": "beginner, vba, excel, error-handling",
"url": null
} |
newtonian-mechanics, special-relativity, speed-of-light, rigid-body-dynamics
So one cannot construct such a rigid body, even before one can reach velocities close to c. I want also to stress, contrary to a comment, that quantum mechanics is important, because all the macroscopic properties of materials, as is the velocity of sound, emerge from the underlying quantum mechanical organization of atoms and molecules.
The forces holding solids together are electromagnetic quantum mechanical exchanges, and any impulse for the turning wheel cannot travel faster than the velocity of light. The velocity of sound is dependent on the quantum mechanical exchanges on the lattice of the solid. | {
"domain": "physics.stackexchange",
"id": 30464,
"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, special-relativity, speed-of-light, rigid-body-dynamics",
"url": null
} |
• Here's a suggestion. For each line in your figure, color it red if it is the result of the next term of the sequence going from a smaller number to a larger one, and blue if it is the result of the next term going from a larger number to a smaller one. What do you see? Feb 1, 2021 at 2:53 | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9817357184418847,
"lm_q1q2_score": 0.8769937466637607,
"lm_q2_score": 0.8933094010836642,
"openwebmath_perplexity": 735.7000469436234,
"openwebmath_score": 0.8221563100814819,
"tags": null,
"url": "https://math.stackexchange.com/questions/4005950/why-does-plotting-collatz-sequences-in-polar-coordinates-produce-a-cardioid-and"
} |
python, machine-learning
I'd like to explore training a neural network adding a few features at a time: e.g. train using the top 100 features, then add in the next 100, train again (using coefs from previous round plus random coefs for the new part of the input layer), rinse, repeat.
NOTE that this "incrementalness" is across features, not samples; it doesn't affect whether training is incremental ("online") with respect to samples.
I gather this sort of thing has been tried before with some success but I haven't been able to find implementations in the Python ML libraries I've checked, nor can I find good explanations of the details of successful algorithms. | {
"domain": "datascience.stackexchange",
"id": 1417,
"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, machine-learning",
"url": null
} |
ros, roscore, rosmaster, ros-kinetic
Originally posted by Reamees with karma: 591 on 2018-08-22
This answer was ACCEPTED on the original site
Post score: 1
Original comments
Comment by pavel92 on 2018-08-22:
I tried the rosgraph.is_master_online() and it works without a problem when there is a network connection. The problem still occurs when the network goes down as the node is in limbo state. In this case rosgraph blocks the node and fails to check for the master
Comment by Ariel_GLR on 2019-04-11:
having same issue as pavel92, every method which somehow relies on rosgraph, somehow blocks. it s as though resorption until reconnecting
Comment by aa-tom on 2021-10-20:
I'm also facing this issue. I've raised a PR with rosgraph here adding an optional timeout parameter to rosgraph.is_master_online(). In the meantime, the following solution seems to be sufficient, despite feeling a little hacky
import socket
...
socket.setdefaulttimeout(timeout)
rosgraph.is_master_online()
socket.setdefaulttimeout(None)
... | {
"domain": "robotics.stackexchange",
"id": 31594,
"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, roscore, rosmaster, ros-kinetic",
"url": null
} |
newtonian-mechanics, forces, mass, acceleration, free-fall
So, TLDR: If you assume that if the laws of physics are invariant under time translations, space translations, and Gallilean translation, AND that they don't involve derivatives higher than two, then the only possibility for the laws is that the acceleration must be constant. | {
"domain": "physics.stackexchange",
"id": 76624,
"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, forces, mass, acceleration, free-fall",
"url": null
} |
object-oriented, array, vba, excel
Private Function File_Picker(ByVal original As Boolean) As String
Dim version As String
Dim workbookName As String
If original Then
version = "original"
Else: version = "new"
End If
Dim selectFile As FileDialog
MsgBox "Please select the file with your " & version & " data."
Set selectFile = Application.FileDialog(msoFileDialogOpen)
With selectFile
.AllowMultiSelect = False
.Title = "Select the file with your " & version & " data."
.Filters.Clear
.Filters.Add "Excel Document", ("*.csv, *.xls")
.InitialView = msoFileDialogViewDetails
If .Show = -1 Then
Dim selectedItem
For Each selectedItem In selectFile.SelectedItems
File_Picker = selectedItem
Next selectedItem
End If
End With
Set selectFile = Nothing
End Function | {
"domain": "codereview.stackexchange",
"id": 24298,
"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": "object-oriented, array, vba, excel",
"url": null
} |
algorithm, c, mathematics, dynamic-programming
the program reports a max value of 1, which is correct, but you should verify that it is correct for any possible set of numbers.
Consider adding an "early bailout"
If it ever occurs that ProfitA == ProfitB == ProfitC (as with the values in the previous point) this must be the answer (do you see why?) so the program could exit early with that correct answer.
Eliminate return 0
You don't need to explicitly provide a return 0; at the end of main -- it's created implicitly by the compiler. | {
"domain": "codereview.stackexchange",
"id": 12031,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "algorithm, c, mathematics, dynamic-programming",
"url": null
} |
Lemma 1. For integers $0\lt 2b\lt a$, the polynomial $g(z)=z^a-2z^b+1$ has no multiple zeros and exactly $b$ zeroes inside the unit circle.
Proof. If $g(z)=g'(z)=0$ then $z\ne 0$ and $$0=g'(z)=az^{a-1}-2bz^{b-1}=z^{b-1}(az^{a-b}-2b),$$ so $az^{a-b}-2b=0$. Hence, $0=g(z)-g'(z)*z/a=1-2(1-b/a)z^b$ so that $|z|^b=\frac1{2(1-b/a)}=\frac a{2(a-b)}$. Also, $az^{a-b}-2b=0$ so $|z|^{a-b}=2b/a$. This implies that $$\left(\frac a{2(a-b)}\right)^{a-b}=\left(\frac{2b}a\right)^b.$$ This can be rewritten as $2(1-b/a)^{1-b/a}(b/a)^{b/a}=1$. But it is easily checked that $2(1-y)^{1-y}y^y\gt1$ for $0\lt y\lt1/2$, a contradiction.
The second part can be proved by a straight forward application of Rouché's theorem.
Lemma 2. Suppose that $\sum_{i=1}^kA_ir_i^{-j}=1$ for $1\le j\le k$. Then $\sum_{i=1}^kA_i=1-\prod_{i=1}^k(1-r_i)$. | {
"domain": "mathoverflow.net",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9852713857177956,
"lm_q1q2_score": 0.8167296945956567,
"lm_q2_score": 0.8289388146603365,
"openwebmath_perplexity": 125.62264444457085,
"openwebmath_score": 0.9337767362594604,
"tags": null,
"url": "https://mathoverflow.net/questions/63789/probability-of-a-random-walk-crossing-a-straight-line"
} |
keras, lstm, loss-function
model.compile(loss='mse', optimizer='adam', metrics=['acc'])
# fitting the model
history = model.fit(Xtrain, Ytrain, epochs=nEpochs, batch_size=50, validation_data=(Xval, Yval), shuffle=True, verbose=2)
#test model
yhat = model.predict(Xtest)
print("pediction vs truth:")
for i in range(0,10):
print(yhat[i], Ytest[i])
# summarize history for loss
plt.subplot(1,1,1)
plt.plot(history.history['loss'], '.-')
plt.plot(history.history['val_loss'], '.-')
plt.ylabel('loss')
plt.xlabel('epoch')
plt.legend(['train', 'validation'], loc='upper right')
plt.show() | {
"domain": "datascience.stackexchange",
"id": 3254,
"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": "keras, lstm, loss-function",
"url": null
} |
electromagnetism, tensor-calculus, dielectric
Title: Dielectric permittivity and Kronecker symbol I tried to express the dielectric permittivity tensor $\varepsilon_{ij}$ as:
\begin{equation}
\varepsilon_{ij} = \varepsilon_{r} \varepsilon_{0} = \left(\chi_{ij} +1\right) \varepsilon_{0}\text{,}
\end{equation}
where $\varepsilon_{0}$ is the electrical permittivity of free space, $\varepsilon_{r}$ is the relative permittivity or dielectric constant of a material and $\chi_{ij}$ is the dielectric susceptibility tensor.
However, I was told a Kronecker symbol was missing. If I understand properly, it is because the central part of the equation ($\varepsilon_{r} \varepsilon_{0}$) must be a tensor to match the left and right hand sides. Would it be correct to write the equation as:
\begin{equation}
\varepsilon_{ij} = \varepsilon_{r} \varepsilon_{0}\delta_{ij} = \left(\chi_{ij} +1\right) \varepsilon_{0}
\end{equation}
or do I misunderstand something? Your equation,
$$ | {
"domain": "physics.stackexchange",
"id": 82189,
"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, tensor-calculus, dielectric",
"url": null
} |
general-relativity, metric-tensor, differentiation
Title: Box operator in FLRW metric Definition of box operator in curved space time is $g^{\mu \nu}\partial_{\mu}\partial_{\nu}$ and in FLRW metric $g_{\mu \nu}$ is $diag(1 ,-a^2(t)$ $,-a^2(t),-a^2(t) )$ so the box operator should be $\partial^2_t- a^{-2}(t)(\partial^2_x+\partial^2_y+\partial^2_z)$ but according to the book of David Toms QFT in curved spacetime the box operator should be
$a^{-3}\partial_t(a^3\partial_t...)-a^{-2}(\partial^2_x+\partial^2_y+\partial^2_z)...$
So basically my first term is not matching, can anyone tell me where am I making the mistake? Also he is using the signature $(+- - - )$. If you take the scalar field in the curved spacetime the action is,
\begin{equation}
S=\int d^4x\sqrt{-g}\Big(g^{\mu\nu}\partial_\mu\phi\partial_\nu\phi-m^2\phi^2\Big)
\end{equation}
Now the trick is that when you integrate by parts the term with the variation $\partial_\mu\delta\phi$ the factor $\sqrt{-g}$ gets inside the derivative. So the resulting equation of motion is, | {
"domain": "physics.stackexchange",
"id": 58813,
"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, metric-tensor, differentiation",
"url": null
} |
newtonian-mechanics, gravity, reference-frames, acceleration, equivalence-principle
Title: How can a person inside from a veiled and free-falling elevator distinguish whether he is in an inertial or non-inertial frame? From wikipedia: "A non-inertial reference frame is a frame of reference that undergoes acceleration with respect to an inertial frame", according to that statement, I would say that an elevator that is in free fall under a gravitational field is a non-inertial frame, and anyone at rest on the ground can tell that, but how could the person inside the elevator tell what kind of frame the elevator is? Assume that the elevator is veiled, and there will also be no form of acceleration in the elevator, thus disregarding Einstein's Equivalence. Within the frame of the free falling elevator the reading on an accelerometer always matches the acceleration with respect to the frame. Therefore the free falling frame is inertial. | {
"domain": "physics.stackexchange",
"id": 84876,
"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, gravity, reference-frames, acceleration, equivalence-principle",
"url": null
} |
macos, homebrew, rosinstall, macos-lion, osx
Does that information happen to help anyone shed some light on what might be keeping the installation from continuing? From what I've seen on other questions people have asked, my installation is on the right track but just can't continue past detecting the other bootstrapper for some reason. I'd appreciate any ideas! Thanks!
Originally posted by lauras on ROS Answers with karma: 56 on 2012-03-23
Post score: 4
Original comments
Comment by lauras on 2012-08-08:
UPDATE: Sorry for the lack of responses--I switched to my Ubuntu VM for this project. But when the project is over, I'll try installing ROS on my Mac again. Thanks for the help (and the bug fix)!
This was a bug in rosinstall. It's fixed in 0.6.12. Ticket
Originally posted by tfoote with karma: 58457 on 2012-04-02
This answer was ACCEPTED on the original site
Post score: 1 | {
"domain": "robotics.stackexchange",
"id": 8695,
"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": "macos, homebrew, rosinstall, macos-lion, osx",
"url": null
} |
electrostatics, gauss-law
Also why and how can I prove that the outer charges will not have any effect on the inside placed charge? This is a conductor and in static equilibrium all charges are on the surfaces of the conductor, and the $\vec E$ inside the conductor is $0$.
This follows because, if there’s an $\vec E$-field inside, the (negative) charges would move, thus violating the hypothesis that we have static equilibrium. Since there’s no field inside, an arbitrary Gaussian surface anywhere inside the conductor would always have no flux and thus enclose no net charge, so there can be no net charge inside the conductor. Thus any induced charge must be on the physical surface as it cannot be inside the conductor.
If you can a Gaussian sphere inside the hollow sphere, but which excludes the charge, then it will contain no charge but field will not be zero: this is because, from the charge distribution, it is clear that the field is not constant on the surface of your Gaussian sphere so that
$$ | {
"domain": "physics.stackexchange",
"id": 87468,
"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, gauss-law",
"url": null
} |
c++, simulation
AbstractDoubleInputPinCircuitComponent* component2 =
(AbstractDoubleInputPinCircuitComponent*) component;
if (input_component == component2->getInputComponent1()) {
component1->setInputComponent1(mapped_input_component);
} else {
component1->setInputComponent2(mapped_input_component);
}
}
}
void connectOutput(AbstractCircuitComponent* component,
AbstractCircuitComponent* mapped_component,
AbstractCircuitComponent* mapped_output_component) {
if (isBranchWire(component)) {
BranchWire* branch_wire = (BranchWire*) mapped_component;
branch_wire->connectTo(mapped_output_component);
} else {
mapped_component->setOutputComponent(mapped_output_component);
}
} | {
"domain": "codereview.stackexchange",
"id": 27816,
"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++, simulation",
"url": null
} |
Now we are able to define the famous delta Dirac "distribution". It is a distribution $\delta_{x}:\mathcal{D}(\Omega)\to\mathbb{R}$ defined by the formula ($x\in\Omega$) $$\langle\delta_{x},\phi\rangle=\phi(x)$$
You can easily check by using the definition that $\delta_x\in\mathcal{D}'(\Omega)$. Also, any funcion $u\in L^1_{loc}(\Omega)$ de fined a distribution by the formula $$\langle T_u,\phi\rangle=\int_\Omega u\phi$$
On the other hand, we can define a notion of convergence in $\mathcal{D}'(\Omega)$, to wit, $T_n\to T$ in $\mathcal{D}'(\Omega)$ if $\langle T_n,\phi\rangle\to\langle T,\phi\rangle$. You can check by using this definition that if $h_\epsilon$ is a mollifier sequence, then $T_{h_\epsilon}\to \delta _x$ in the sense of distributions. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9572778012346835,
"lm_q1q2_score": 0.8136585363273243,
"lm_q2_score": 0.8499711737573763,
"openwebmath_perplexity": 211.0567484377538,
"openwebmath_score": 0.9470831155776978,
"tags": null,
"url": "http://math.stackexchange.com/questions/395850/dirac-delta-or-dirac-delta-function"
} |
Here are some other important applications of the algorithm. In numerical linear algebra, the Jacobi method is an algorithm for determining the solutions of a diagonally dominant system of linear equations. In other words, build a DSL (domain specific language) Whereever you are performing operations on A you should also be performing identical operation on I (identity matrix). If the system is consistent, then number of free variables = n rank(A): A matrix is in reduced row echelon form, if: 1. The Gauss-Jordan elimination method to solve a system of linear equations is described in the following steps. However, the method also appears in an article by Clasen published in the same year. Let us write these respective common values as Q 1 and Q 2. Find gauss-Jordan Elimination course notes, answered questions, and gauss-Jordan Elimination We use Gauss-Jordan Elimination on the matrix [A|I3] to obtain A−1. Explains the terminology and techniques of Gaussian and Gauss-Jordan elimination. | {
"domain": "globalbeddingitalia.it",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9859363717170516,
"lm_q1q2_score": 0.8060764148580296,
"lm_q2_score": 0.817574478416099,
"openwebmath_perplexity": 712.3485932488467,
"openwebmath_score": 0.63821941614151,
"tags": null,
"url": "http://puis.globalbeddingitalia.it/gauss-jordan-method.html"
} |
python, performance, file-system, iteration
def sum_file_size(folder, filepaths):
return sum([os.path.getsize(folder + '/' + filep) for filep in filepaths])
if __name__ == '__main__':
for folder in folders_in_depth(os.getcwd(),1):
foldername, files = folder
print foldername,': filecount:', len(files), ', total size:', sum_file_size(foldername,files)
which results in
/tmp/Parent/FolderB/subFolderB3 : filecount: 10 , total size: 50
/tmp/Parent/FolderB/subFolderB2 : filecount: 10 , total size: 50
/tmp/Parent/FolderB/subFolderB1 : filecount: 10 , total size: 50
/tmp/Parent/FolderA/subFolderA3 : filecount: 10 , total size: 50
/tmp/Parent/FolderA/subFolderA2 : filecount: 10 , total size: 50
/tmp/Parent/FolderA/subFolderA1 : filecount: 10 , total size: 50 | {
"domain": "codereview.stackexchange",
"id": 27940,
"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, performance, file-system, iteration",
"url": null
} |
javascript, typescript
Constructors are always synchronous and should succeed to create an object immediately. If your async call doesn't block that and you don't care about the success of your async call, then it is not a bad practice to call the function without awaiting it, and immediately .catch and handle any possible rejections.
In general, if you don't need the return value of an async call and you don't want to wait for it to complete, you should not await it. But, you should still handle rejections with a .catch; even if you do nothing: something().catch(() => {})
in the situation where you need to execute async code that does not return anything, it is necessary to execute then and catch? what are the implications of executing async code without then and catch? | {
"domain": "codereview.stackexchange",
"id": 40856,
"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, typescript",
"url": null
} |
in a triangle is a bisector lines for 3 angles in a triangle. BYJU’S online orthocenter calculator tool makes the calculation faster and it displays the orthocenter of a triangle in a fraction of seconds. Orthocenter Formula - Learn how to calculate the orthocenter of a triangle by using orthocenter formula prepared by expert teachers at Vedantu.com. Ask … Orthocenter 4. Here $$\text{OA = OB = OC}$$, these are the radii of the circle. Orthocenter It is the point where the three "altitudes" of a triangle meet and the orthocenter can be inside or outside of the triangle. Let's build the orthocenter of the ABC triangle in the next app. Origin. razoo / rɑːˈzuː / noun. Compass. Construct triangle ABC whose sides are AB = 6 cm, BC = 4 cm and AC = 5.5 cm and locate its orthocenter. The orthocenter is one of the triangle's points of concurrency formed by the intersection of the triangle's 3 altitudes.. To download free study materials like NCERT Solutions, Revision Notes, Sample Papers and | {
"domain": "daryayejonoob.ir",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9817357243200245,
"lm_q1q2_score": 0.8003428518125693,
"lm_q2_score": 0.8152324826183822,
"openwebmath_perplexity": 782.2983821656943,
"openwebmath_score": 0.438321590423584,
"tags": null,
"url": "https://daryayejonoob.ir/homemade-churn-gaqwivh/orthocenter-definition-geometry-b0c2a1"
} |
convolutional-neural-networks, tensorflow, keras, overfitting, convolution
The tricky part is finding the best combination for generalisation. Typically if you overuse regularisation to make the NN completely stable, it will lose some accuracy, so you need to run multiple experiments and measure things carefully. As you have a small dataset here and seem capable of running 1000's of epochs, I would suggest k-fold cross validation for improved measurement of cross validation loss. | {
"domain": "ai.stackexchange",
"id": 1775,
"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": "convolutional-neural-networks, tensorflow, keras, overfitting, convolution",
"url": null
} |
fourier-transform
So, summarizing, a constant in one domain corresponds to a delta impulse in the other domain. A constant in the time domain does not contain any frequencies other than 0 (delta at zero in the frequency domain). A constant in the frequency domain (i.e. a combination of all frequencies) corresponds to a delta impulse in the time domain. | {
"domain": "dsp.stackexchange",
"id": 1652,
"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": "fourier-transform",
"url": null
} |
kinematics, projectile
Discriminant is positive: There are two values of $\theta$ that will hit the target $(x,y)$.
Discriminant is zero: There is exactly one angle that will result in hitting the target. Any other angle falls short.
Disciminant is negative: There are no firing angles that will hit the target. The target is too far away or too high or both.
For an example of the last possibility, if your initial velocity is $u = 30\,\textrm{m/s}$ and your target is at $(x,y) = (1000\,\textrm{m}, 1000\,\textrm{m})$, then there is definitely no angle that will get the projectile to the target. The discriminant of equation (2) will be negative. | {
"domain": "physics.stackexchange",
"id": 55738,
"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": "kinematics, projectile",
"url": null
} |
General equation of a circle as an introduction to this topic. When you complete the square on an equation with both x‘s and y‘s, the result is a standard form of the equation for a conic section. The subscripts "1" and "2" distinguish quantities for planet 1. An ellipse obtained as the intersection of a cone with a plane. Learn vocabulary, terms, and more with flashcards, games, and other study tools. e < 1 gives an ellipse. An ellipse equation, in conics form, is always "=1". This video derives the formulas for rotation of axes and shows how to use them to eliminate the xy term from a general second degree polynomial. If has the same sign as the coefficients A and B, then the equation of an elliptic cylinder may be rewritten in Cartesian coordinates as: This equation of an elliptic cylinder is a generalization of the equation of the ordinary, circular cylinder ( a = b ). 829648*x*y - 196494 == 0 as ContourPlot then plots the standard ellipse equation when rotated, which is. 6: | {
"domain": "istitutocomprensivoascea.it",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9883127409715956,
"lm_q1q2_score": 0.8148262326780249,
"lm_q2_score": 0.824461932846258,
"openwebmath_perplexity": 356.1735119431403,
"openwebmath_score": 0.8166592717170715,
"tags": null,
"url": "http://ovzj.istitutocomprensivoascea.it/equation-of-a-rotated-ellipse.html"
} |
electric-current, dirac-equation
\begin{equation}
j^\mu = -\frac{\mathrm{i} e\hbar}{2m} \left[ \overline{\Psi} (\partial^\mu \Psi) - (\partial^\mu \overline{\Psi}) \Psi \right] - \frac{e^2}{m} A^\mu \overline{\Psi} \Psi + \frac{\mathrm{i} e \hbar}{2m} \partial_\nu (\overline{\Psi} \sigma^{\mu \nu} \Psi)
\end{equation}
First note that $j^\mu$, the charge-current density, is proportional to the kinetic momentum $p^\mu=\frac{m}{e}j^\mu$ defined by the operator $p^\mu=-i\hbar\partial^\mu-eA^\mu$, where $-i\hbar\partial^\mu$ is the operator for the canonical momentum which is proportional to the spatial/temporal frequencies and $-eA^\mu$ is the term that tells us that the momentum of a charged particle changes proportional to the electro-magnetic vector potential field. So we have.
\begin{equation}
j^\mu=-\frac{ie\hbar}{m}\partial^\mu-\frac{e^2}{m}A^\mu
\end{equation} | {
"domain": "physics.stackexchange",
"id": 27205,
"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": "electric-current, dirac-equation",
"url": null
} |
java, beginner, game
You seem interested in writing clean code. I can warmly recommend the book Clean Code: A Handbook of Agile Software Craftsmanship (Robert C. Martin). For me, it was a very thought-provoking book that helped me really understand why internal software quality matters (and how to achieve it).
Now, let's get to the Review.
Pulazzo's suggestions are spot on. (As he pointed out, you may want to revisit the concept of object instances and the this keyword).
In addition to the points already made, I'd like to explain some more abstract topics that really drive code quality. | {
"domain": "codereview.stackexchange",
"id": 2443,
"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, beginner, game",
"url": null
} |
ros, ros2, installation, build-from-source
As a reference for building ROS2 from source, you checkout the Dockerfiles located here:
https://github.com/osrf/docker_images/blob/master/ros2/source/source/Dockerfile
Originally posted by ruffsl with karma: 1094 on 2021-06-04
This answer was ACCEPTED on the original site
Post score: 3 | {
"domain": "robotics.stackexchange",
"id": 36493,
"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, ros2, installation, build-from-source",
"url": null
} |
glass
Title: Why would/do you wet glass after scoring it to break it? In this youtube video about a water cooled desktop PC build log the author uses glass tubing to route the water around the system. Around 4:08, when the first tube break/cut is shown, the author pours a small amount of water on the tube after scoring it. I've heard of "shocking" glass with hot water when cutting it, but the author does not mention that the water is hot. Further the author seems to use the same cup of water over some period of time, so it doesn't seem to be hot.
Why pour water on glass after scoring it to break it? Wheeler,(1958). Scientific Glassblowing, Interscience Publishers, New York & London. | {
"domain": "physics.stackexchange",
"id": 64813,
"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": "glass",
"url": null
} |
c++, c++11, homework, template
bag.clear();
displayBag(bag);
assert(1 == bag.isEmpty());
delete [] receipts;
}
int main()
{
ReceiptArrayBag<std::string> bag;
std::cout << "Testing the Receipt-Based Bag:" << std::endl;
bagTester(bag);
std::cout << "All done!" << std::endl;
} You've committed a cardinal C++ sin and forgotten to implement a proper destructor - your class will always leak memory.
Remember: each new needs a corresponding delete (or new[] and delete[], as in this case) (I know that this is just an oversight on your part as you've remember to do it correctly in add, but it is a big one!).
Further, this will silently do the wrong thing for operator= and its copy constructor. You should either implement these or disable them:
ReceiptArrayBag(const ReceiptArrayBag&) = delete;
ReceiptArrayBag& operator=(const ReceiptArrayBag&) = delete; | {
"domain": "codereview.stackexchange",
"id": 12188,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "c++, c++11, homework, template",
"url": null
} |
python, calculator
if self.IN_OP:
raise Exception("illegal expression")
else:
self._append_element(c)
self.IN_OP = True
elif c == '(':
self._add_new_perentheses()
self.IN_OP = True
elif c == ')':
self.EXIT_PE = True
self.IN_OP = False
else:
raise Exception("Bad input") | {
"domain": "codereview.stackexchange",
"id": 6991,
"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, calculator",
"url": null
} |
both for musicality and emotional impact. [SOLVED] spinning liquid creating a parabolic shape take a container of liquid and spin it a parcel at any given radius (r) experiences (in the rotating frame) a force outward = mass x angular speed^2 x r and a vertical force of mg. Moving 3 left from the vertex gets us to (4 - 3, -2) = (1, -2). Question 1 : Graph the following quadratic equations and state their nature of solutions. Angry Birds – Parabolas. TEKS addressed: (b) Knowledge and skills. none of the above. i need to be able to take the picture myself otherwise it doesnt count for my project. Substituting t = 1. The top of the arch measures 42 feet thick and 33 feet wide. Air drag has a much, much greater effect on the shape of a typical trajectory than does the non-uniformity of gravitational acceleration. (NASA/JPL-Caltech PR) — In the fall of 2019, the Mars 2020 rover team welcomed ten members to serve as Returned Sample Science Participating Scientists. Some rights reserved: | {
"domain": "clubita.it",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.977022625406662,
"lm_q1q2_score": 0.828483681796717,
"lm_q2_score": 0.8479677545357569,
"openwebmath_perplexity": 1010.6001698445668,
"openwebmath_score": 0.3985465466976166,
"tags": null,
"url": "http://qhgo.clubita.it/parabolas-in-nature.html"
} |
regression, linear-regression, terminology
Although polynomial regression fits a nonlinear model to the data, as
a statistical estimation problem it is linear, in the sense that the
regression function E(y | x) is linear in the unknown parameters that
are estimated from the data.
Let the model be represented by the function $f(x,w)$ with inputs $x$ and parameter vector $w$. Polynomial regression has the form $f(x,w) = w_0 + w_1*x + w_2*x^2 \ldots$ It is linear in the parameters because $f(x,a+b) = (a_0+b_0) + (a_1+b_1)*x + (a_2+b_2)*x^2 \ldots = a_0 + a_1*x + a_2*x^2 \ldots + b_0 + b_1*x + b_2*x^2 \ldots = f(x,a) + f(x,b)$. But it is not linear in the inputs because $f(x+y,w) \neq f(x,w)+f(y,w)$.
Often people think about the relationship $y=f(x)$ between $x$ and $y$, but linear in linear regression refers to linearity in $w$. | {
"domain": "datascience.stackexchange",
"id": 6281,
"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": "regression, linear-regression, terminology",
"url": null
} |
functional-programming, scala
private def isBalanced(chars: List[Char], stack: Stack[Char]): Boolean = chars match
case Nil => stack.isEmpty
case x :: xs =>
try {
val nextStack = processChar(x, stack)
isBalanced(xs, nextStack)
} catch {
case e: Exception => false
}
private def processChar(char: Char, stack: Stack[Char]): Stack[Char] = char match
case char if char == OPEN_PARENTHESIS => stack.push(char)
case char if char == CLOSED_PARENTHESIS => stack.tail
case _ => throw new IllegalArgumentException("The given char is not valid")
``` Style
Type inference
Scala supports type inference. Explicitly annotating the type of something whose type is obvious does not improve readability. You should annotate the types of your public APIs, but other than that, you should use type inference as far as possible, as long as it doesn't impact readability.
For example, this:
val OPEN_PARENTHESIS: Char = '('
val CLOSED_PARENTHESIS: Char = ')' | {
"domain": "codereview.stackexchange",
"id": 41566,
"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": "functional-programming, scala",
"url": null
} |
c, openmp
Title: OpenMP workaround for barrier in loop What I basically want to do is this:
int main()
{
const int n = 100;
#pragma omp parallel for
for (int i=0; i<n; i++)
{
int thread_ID = omp_get_thread_num();
printf("%d) work 1 %d\n", thread_ID, i);
#pragma omp barrier
printf(" %d) work 2 %d\n", thread_ID, i);
#pragma omp barrier
}
return 0;
}
except we cannot put a barrier into a parallel for in OpenMP; it just cannot be done. However, it's possible to explicitly do the separation between the threads in order to make it work:
#include <stdlib.h>
#include <stdio.h>
#include <omp.h>
int main()
{
const int n = 100;
int nthreads;
#pragma omp parallel
{
// get the number of threads
#pragma omp single
{
nthreads = omp_get_num_threads();
}
int thread_ID = omp_get_thread_num(); | {
"domain": "codereview.stackexchange",
"id": 29554,
"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, openmp",
"url": null
} |
javascript, array, hash-map
cost.sort(function(a,b) {return a-b});
for(var j=0; j<len; j++){
var left=0;
var right=len-1;
if(cost[j]<money){
var ser=money-cost[j];
while(left<=right){
var mid=Math.floor((left+right)/2);
if(ser===cost[mid]){
var val1=cost[j];
var val2=cost[mid];
break;
}
if(ser<cost[mid]){
right = mid-1;
}
else{
left = mid+1;
}
}
if(val1 !== undefined && val2 !== undefined ){
break;
}
}
}
var index1;
var index2;
if (val1===val2) {
index1 = dict1[val1][0];
index2 = dict1[val2][1];
}
else{
index1 = dict1[val1];
index2 = dict1[val2];
}
if (index2 > index1) {
console.log(index1+1, index2+1);
}
else{
console.log(index2+1, index1+1);
}
// Solution ends here
}
function main() {
const t = parseInt(readLine(), 10); | {
"domain": "codereview.stackexchange",
"id": 31401,
"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, array, hash-map",
"url": null
} |
physical-chemistry, kinetics
Title: Continuously replenished reaction Substrate ($m$) concentration in a reaction scheme is governed by the equation $$\frac{dm}{dt} = -\dfrac{r_1c_1m}{1+\dfrac{r_1}{r_2}m + \dfrac{r_1r_3}{r_2r_4}m^2}$$ where $c_1$ is the initial enzyme concentration and each $r_i$ is the reaction rate of the reactions present within this reaction scheme (which are positive). Now additionally suppose the substrate is being continuously replenished by a reaction $$\ce{A->[r_5]S,}$$ where $A$ has constant concentration $a_0$. Modify $dm/dt$ and show there are two distinct positive equilibria $0<m_1<m_2$ if $r_5<r_5^C$ where $r_5^C$ is a critical value to be determined. | {
"domain": "chemistry.stackexchange",
"id": 4467,
"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": "physical-chemistry, kinetics",
"url": null
} |
homework-and-exercises, energy, mass, nuclear-physics
This sentence speaks about $protons$ and $neutrons$ as the constituents. In your equation you have three nuclei and the sentence is valid for each of the three nuclei separately.
Your quiz question wants you, however, to compare in more detail the masses of the nuclei on the right with that on the left. And from the conservation of energy, you may have constituents flying away with some kinetic energy on expense of the binding energy of the left side. | {
"domain": "physics.stackexchange",
"id": 39839,
"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, energy, mass, nuclear-physics",
"url": null
} |
special-relativity, faster-than-light, information, non-locality
Part 2:
In Griffith's description, the bug does NOT come from B in the first place, only PB, so obviously does not carry information from B.
Imagine at t=0 the bug is at PB and at t=dt the bug is at PA, and it takes time P for the shadow to be projected. Then the shadow reaches B (from PB) at t=P and reaches A (from PA) at t=P+dt, so indeed there is a time difference of only dt between A seeing the shadow and B seeing the shadow, and dt can be quite short compared to the A-B distance over the speed of light. So there is a sense in which the shadow "travels faster than light" (two shadow events separated by a distance longer than $c * \Delta t$) which is different from your scenario, but in this scenario, no information is being carried. | {
"domain": "physics.stackexchange",
"id": 92085,
"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": "special-relativity, faster-than-light, information, non-locality",
"url": null
} |
• why the first line is true??? what if $a<b$ – MAN-MADE Aug 8 '17 at 14:17
$P(0)=0$ because if
$P(x)=a_n x^n+a_{n-1} x^{n-1}+\ldots+a_2 x^2+a_1 x+a_0$
$P(n)=a_n n^n+a_{n-1} n^{n-1}+\ldots+a_2 n^2+a_1 n+a_0$ is a multiple of $n$ for any integer $n$ only if $a_0=0$
$P(n)=n\left(a_n n^{n-1}+a_{n-1} n^{n-2}+\ldots+a_2 n+a_1 \right)$
• You just pick an example, how is this even accepted!!! – MAN-MADE Aug 8 '17 at 13:43
• This is only an example, not a proof at all! – zipirovich Aug 8 '17 at 13:44
• sorry guys accidentally accepted the answer, please don't dislike his answer he was guessing – Dhruva Aug 8 '17 at 13:45
• @MANMAID Could you please cancel the downvote. I have corrected my proof – Raffaele Aug 8 '17 at 14:00
• @zipirovich Could you please cancel the downvote. I have corrected my proof – Raffaele Aug 8 '17 at 14:00
$P(x)=xQ(x)+P(0)$.
Note that for any prime number $p$, $pQ(p)\equiv 0(\mod p)$. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9770226247376173,
"lm_q1q2_score": 0.8055179510906485,
"lm_q2_score": 0.8244619220634456,
"openwebmath_perplexity": 321.9259804665318,
"openwebmath_score": 0.8335342407226562,
"tags": null,
"url": "https://math.stackexchange.com/questions/2386691/yet-another-question-on-number-theory"
} |
graph-algorithms, shortest-path, proof-complexity, worst-case
This holds for all shortest paths $P$ from $s$, so, for any shortest-path tree $T$ rooted at $s$, by the start of run $\text{depth}(T)$, the distance labels of all vertices will be correct, so the algorithm will have at most $\text{depth}(T)$ runs.
In each run, each vertex $u$ is popped from the queue at most once, just because all vertices popped from the queue in a given run were in the queue at the start of the run (and the queue never holds two copies of the same vertex). By this and the previous paragraph, each vertex $u$ is popped from the queue at most $\text{depth}(T)$ times.
It follows that each edge $(u, v)\in E$ is considered in Line 7 at most $\text{depth}(T)$ times. It follows that the total number of iterations of the inner loop is at most $|E|\cdot \text{depth}(T)$. This implies the theorem. $~~~\Box$. | {
"domain": "cstheory.stackexchange",
"id": 5369,
"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": "graph-algorithms, shortest-path, proof-complexity, worst-case",
"url": null
} |
time-complexity, runtime-analysis, computer-architecture, cpu-cache, cpu-pipelines
I would like to enrich this list both in breadth and length. So any addition to the list of such events or the details of how any particular event causes a delay is most welcomed.
P.S. If my question if not well formulated, please do help me to improve. You forgot the most obvious factor: the input of the program. The time taken by a program heavily depends on the input unless it does not have any input or the input comes from a small fixed set.
Other factors can be classified into two classes: 1) Internal factors and 2) External factors.
Internal factors:
1) Input
2) Waiting for I/O
3) Waiting for System resources like memory/semaphores etc.
4) How effectively memory is cached in CPU (may be different for different runs, what you have termed as cache misses.)
5) Disruptions in instruction pipeline
6) Interactive events
7) If the process needs to swap in/out some pages to swap area
8) If the process uses other hardware such as graphics card/audio/network | {
"domain": "cs.stackexchange",
"id": 6019,
"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": "time-complexity, runtime-analysis, computer-architecture, cpu-cache, cpu-pipelines",
"url": null
} |
ruby, console
My complete Code:
require "rmagick"
require "readline"
def convert_images(prefix, max_dim, path = Dir.pwd)
#Use a glob instead of checking the pathes later,
#Use each_with_index (Attention, i will start with 0!)
Dir.glob(File.join(path, '*.jpg')).each_with_index do |file, i|
img = Magick::Image.read(file).first
resized = img.resize_to_fit(max_dim)
#Don't use string operations for pathes
newpath = File.join(path,prefix % [i+1] + ".jpg") #i starts with 0, so add 1.
resized.write(newpath) do
self.quality = 80
end
puts "%s -> %s" % [ file, newpath ]
#~ File.delete file
img.destroy!
resized.destroy!
end
end
#Define parameters with defaults.
max_dim = ARGV[0] || 100
prefix = ARGV[1] || 'my_pic_version_%i'
prefix.sub!(/\$/, '%02i') #use string format options.
puts "max dimension: #{max_dim}"
puts "prefix: #{prefix}" | {
"domain": "codereview.stackexchange",
"id": 22305,
"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, console",
"url": null
} |
c++, multithreading
template <class T>
class Launcher
{
public:
Launcher(T * obj, void * (T::*mfpt) (void *), void * arg) : myobj(obj), fpt(mfpt), myarg(arg) {}
~Launcher() {}
void launch() { (*myobj.*fpt)(myarg);}
private:
T* myobj;
void* myarg;
void * (T::*fpt) (void *); //Member function pointer
};
template <class T>
void * LaunchMemberFunction(void * obj)
{
Launcher<T> * l = reinterpret_cast<Launcher<T>*>(obj);
l->launch();
}
int main()
{
pthread_t threads[3];
Launcher<Test> * larray[3];
Test t;
for (int i = 0; i < 3; ++i)
{
std::cout << "In main: creating thread " << i << std::endl; | {
"domain": "codereview.stackexchange",
"id": 654,
"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",
"url": null
} |
javascript, beginner, complexity, palindrome
Title: Next palindromic number I wrote a function that takes a number and finds the next palindromic number. Time complexity is currently O(n2), which is really bad. How could one make this function more efficient?
function nextPalindrome(n) {
// first we create a function to check if a single number is a palindrome
function isPalindrome(num) {
const forward = num.toString();
let backward = [];
for (let i = forward.length - 1; i >= 0; i--) {
backward.push(forward[i]);
}
backward = backward.join('');
return forward === backward;
}
// now let's create a counter variable to increment our number (n)
// we'll initialize it as n + 1 since we know we're not going to check the first number
let countUp = n + 1;
// we also need a nextPalindrome variable
let nextP;
// now we need to begin some sort of loop
// perhaps a while loop will do
while (true) {
if (isPalindrome(countUp)) {
return countUp;
} else {
countUp += 1;
} | {
"domain": "codereview.stackexchange",
"id": 30817,
"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, beginner, complexity, palindrome",
"url": null
} |
php, security, authentication, hashcode
The naming of your variables seems somewhat sloppy. In the beginning you call an encoded password $newPass. Is it a new password? I don't think so. Then in the authorise() function you rename it correctly to $passEncode, by which you probably mean $passEncoded.
So the big question is, why do you define your own hashing routine? Is it any better than the existing routines? PHP offers many of them!
See this link to tutsplus which addresses some issues that are encountered in hashing passwords. Is your routine resistent to all these issues? I don't think so.
It is far better to use a good existing password hashing library that is present in PHP. Have a look here: http://php.net/manual/en/faq.passwords.php
There's a lot of information about hashing and PHP out there. Find it and use it. I do really support new and inventive ways to solve problems but in this case it is definately not a good idea to reinvent the wheel. | {
"domain": "codereview.stackexchange",
"id": 13090,
"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, security, authentication, hashcode",
"url": null
} |
c#, object-oriented, design-patterns, factory-method
Factory class:
public interface IShapeFactory
{
IShape GetShape(ShapeType shapeType);
}
public class ShapeFactory : IShapeFactory
{
public IShape GetShape(ShapeType shapeType)
{
switch(shapeType)
{
case ShapeType.SquareShape:
return new Square();
case ShapeType.CircleShape:
return new Circle();
case ShapeType.TriangleShape:
return new Triangle();
default :
throw new ArgumentException();
}
}
} | {
"domain": "codereview.stackexchange",
"id": 30883,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "c#, object-oriented, design-patterns, factory-method",
"url": null
} |
evolution, selection
I could ask numerous question regarding the biology (including what happens to the rest of the genome, and positive selection) and formal logic of this statement, but maybe I could impose, and just leave it to whomever kindly replies.
This remark comes from the abstract of Grauer & al. "On the immortality of television sets: "function" in the human genome according to the evolution-free gospel of ENCODE"
And the Abstract itself: | {
"domain": "biology.stackexchange",
"id": 10734,
"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, selection",
"url": null
} |
special-relativity
For example, chose as your reference frame, instead of the one above, the frame of the travelling twin on the outbound leg (we've switched which twin is "moving away").
In this frame, it is the stay-at-home twin that ages slowly, during the outbound phase, compared to the travelling twin. However, and crucially, the travelling twin must change direction in order to return to the other twin.
So, at the halfway point, the travelling twin changes direction and is now travelling faster than the stay-at-home twin.
Now, it is the travelling twin that is ageing more slowly than the stay-at-home twin. Moreover, due to the non-linear time dilation factor, the travelling twin is ageing slowly enough on the inbound leg such that the total ageing along the outbound and inbound paths is less than the total ageing along the straight path of the stay-at-home twin.
The bottom line is that the situation isn't symmetric. The stay at home twin never changes direction while the travelling twin does. | {
"domain": "physics.stackexchange",
"id": 8097,
"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": "special-relativity",
"url": null
} |
${\displaystyle P_{\pi }={\begin{bmatrix}\mathbf {e} _{\pi (1)}\\\mathbf {e} _{\pi (2)}\\\vdots \\\mathbf {e} _{\pi (m)}\end{bmatrix}},}$
where ${\displaystyle \mathbf {e} _{j}}$, a standard basis vector, denotes a row vector of length m with 1 in the jth position and 0 in every other position.[2]
For example, the permutation matrix Pπ corresponding to the permutation ${\displaystyle \pi ={\begin{pmatrix}1&2&3&4&5\\1&4&2&5&3\end{pmatrix}}}$ is
${\displaystyle P_{\pi }={\begin{bmatrix}\mathbf {e} _{\pi (1)}\\\mathbf {e} _{\pi (2)}\\\mathbf {e} _{\pi (3)}\\\mathbf {e} _{\pi (4)}\\\mathbf {e} _{\pi (5)}\end{bmatrix}}={\begin{bmatrix}\mathbf {e} _{1}\\\mathbf {e} _{4}\\\mathbf {e} _{2}\\\mathbf {e} _{5}\\\mathbf {e} _{3}\end{bmatrix}}={\begin{bmatrix}1&0&0&0&0\\0&0&0&1&0\\0&1&0&0&0\\0&0&0&0&1\\0&0&1&0&0\end{bmatrix}}.}$
Observe that the jth column of the I5 identity matrix now appears as the π(j)th column of Pπ. | {
"domain": "wikipedia.org",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9955316159986551,
"lm_q1q2_score": 0.8020323103511809,
"lm_q2_score": 0.8056321843145405,
"openwebmath_perplexity": 329.03738189263527,
"openwebmath_score": 0.9800283312797546,
"tags": null,
"url": "https://en.wikipedia.org/wiki/Permutation_matrix"
} |
thermal-radiation, history, physical-constants
The h is a proportionality constant between energy of the mode ( we now call photon) and frequency. I.e., since continuous frequencies did not fit the data, he tried discrete, and fitted them with just a constant measured from data and in the end given Plack's name.
The success of solving the ultraviolet catastrophy for black body radiation is one of the basic reasons that quantum mechanics was discovered to be necessary to explain the data in the microcosm of atoms.. | {
"domain": "physics.stackexchange",
"id": 42349,
"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": "thermal-radiation, history, physical-constants",
"url": null
} |
solid-state-physics, crystals
The problem is, I don't really see how that changes anything. The positions of the atoms/points didn't change relative to each other.
1) Do I have to imagine the two atoms "combined" into one? If I do that, where is the new "2-in-1" atom located?
2) How can I construct a primitive vector that will go to this point?
3) Is there an infinite amount of points/atoms I can combine? Are there an infinite amount of basis I can choose?
4) Would the Wigner-Seitz cell have to be over two points if I choose a two atom basis?
Edit: The answer to nearly everything is: yes :) your intuition about it is quite right, and your picture is good, too.
You have two different kinds of points, and any pair with one point from each kind would be a suitable basis. You will of course take adjacent ones in practice. | {
"domain": "physics.stackexchange",
"id": 89745,
"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": "solid-state-physics, crystals",
"url": null
} |
python, time-series, xgboost, conformalprediction
I made the data stationary using diff, dropped the NaN and then I created additional features this way:
def create_features(df):
df['date'] = df.index
df['hour'] = df['date'].dt.hour
df['dayofweek'] = df['date'].dt.dayofweek
df['quarter'] = df['date'].dt.quarter
df['month'] = df['date'].dt.month
df['year'] = df['date'].dt.year
df['dayofyear'] = df['date'].dt.dayofyear
df['dayofmonth'] = df['date'].dt.day
df['weekofyear'] = df['date'].dt.isocalendar().week
X = df[['hour','dayofweek','quarter','month','year',
'dayofyear','dayofmonth','weekofyear']]
y = df["TRANSACTIONAMOUNT"]
return X,y
I used this to separate test and train datasets' y component:
X_train, y_train = create_features(train)
X_test, y_test = create_features(test) | {
"domain": "datascience.stackexchange",
"id": 11954,
"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, xgboost, conformalprediction",
"url": null
} |
4. Jun 4, 2017
One question/comment for @Buffu is how do you know that the homogeneous solution $y=A \, e^{-x}$ doesn't play a role in the solution? That is apparently an underlying assumption in the problem (that you ignore any homogeneous solution), but it is always good practice to consider the possibility of a homogeneous solution. $\\$ Editing: In the solution for $x>1$, the solution is in fact the homogeneous solution. Also, for $0<x<1$, the integrating factor method you used actually generated a homogeneous solution. $\\$ Let me offer an alternative solution to the differential equation above: For $0<x<1$, $y_p=2$ and the homogeneous solution is $y_h=A \, e^{-x}$, so that for $0<x<1$ , $y=2+A \, e^{-x}$ for some $A$ . $\\$ For $x>1$, $y_p=0$, and $y_h=B \, e^{-x}$, so that $y=B \, e^{-x}$ for some $B$. $\\$ The constants $A$ and $B$ are easily found.
Last edited: Jun 5, 2017
5. Jun 5, 2017 | {
"domain": "physicsforums.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.970239907775086,
"lm_q1q2_score": 0.8021087665508992,
"lm_q2_score": 0.8267117855317474,
"openwebmath_perplexity": 455.03882058206364,
"openwebmath_score": 0.9545342326164246,
"tags": null,
"url": "https://www.physicsforums.com/threads/linear-ordinary-differential-equation.916648/"
} |
Bernat Espigulé Pons 9 Votes Last week Vi Hart submitted a new class titled “Doodling in Math Class: DRAGONS”. There, she introduced a family of fractals known as dragon curves, see here below the most famous one, the Heighway dragon:The Heighway dragon (also known as the Harter–Heighway dragon or the Jurassic Park dragon) was first investigated by NASA physicists John Heighway, Bruce Banks, and William Harter. It was described by Martin Gardner in his Scientific American column Mathematical Games in 1967. Many of its properties were first published by Chandler Davis and Donald Knuth. It appeared on the section title pages of the Michael Crichton novel Jurassic Park. ⟜ WikipediaWouldn’t it be great to doodle fractals as fast as she does? What about doodling dragons in Mathematica?Two years ago, when I was playing with the mind-blowing “Tree Bender” demonstration by Theodore Gray, I spotted a striking property. When the two branch-locators were placed in a symmetrical arrangement along | {
"domain": "wolfram.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9799765598801371,
"lm_q1q2_score": 0.8208479341266143,
"lm_q2_score": 0.8376199673867851,
"openwebmath_perplexity": 14498.064466761258,
"openwebmath_score": 0.5283409953117371,
"tags": null,
"url": "http://community.wolfram.com/groups/-/m/t/108323?source=frontpage"
} |
newtonian-mechanics, mass, statics, weight
Moving out of unison will cause variations in the load each person carries, but this is difficult to quantify.
The initial lift, and the final descent, of the object do involve some small amount of change in total force applied. How much change depends on how quickly they try to pick it up or set it down. Of course, to keep an object moving at constant velocity requires zero net force. But the object is initially at rest on the ground, so it takes some acceleration to start it moving upward, so they have to exert more total force than just the object weight alone. In the extreme case, imagine that they just drop the object all at once. Clearly, they stop applying any force to it immediately, and gravity does its thing. But if they pick it up and set it down slowly enough, the accelerations will be small enough that the total force applied will still be pretty close to just the weight of the object. | {
"domain": "physics.stackexchange",
"id": 57592,
"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, mass, statics, weight",
"url": null
} |
coordinate-systems, singularities
If let's say we solve this issue by taking the limits on both the sides (as suggested by one of the answers there). then what is the guarantee that the limits will match and give a unique answer?
What if I don't wish to change the coordinate system (in the question there's an answer suggesting that we can transition from Cartesian to polar and vice-versa to solve the problem of singularity) and what if choose to remain only in 1 coordinate system? | {
"domain": "physics.stackexchange",
"id": 82354,
"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": "coordinate-systems, singularities",
"url": null
} |
machine-learning, deep-learning, weights-initialization
Title: When do you know that your neural network is learning something when metrics are garbage? When training a neural network for binary classification on a highly imbalanced set its training loss decreases, however validation loss increase even though accuracy is very high (due to highly imbalanced dataset) and its other metrics (auc, recall, precision) are bad.
I want to figure out whether there is something wrong with the model architecture, therefore building a new model would be the right choice or is the model learning something; however you just need to tweak some hyperparameters.
By plotting activation outputs and weights at each layer we can see if there is a vanishing/exploding gradient or saturation at a certain layer (activation output being on extremes when using saturating activation functions like tanh, sigmoid).
My question is, is that only thing we can interpret from weights and activation output values?
What can weights distribution of layers at each layer tell us? | {
"domain": "ai.stackexchange",
"id": 3456,
"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, deep-learning, weights-initialization",
"url": null
} |
speed-of-light, definition, conventions, si-units, metrology
Title: Why is the speed of light defined as 299792458 m/s? Why is the speed of light defined as $299792458$ $m/s$? Why did they choose that number and no other number?
Or phrased differently:
Why is a metre $1/299792458$ of the distance light travels in a sec in a vacuum? The speed of light is 299 792 458 m/s because people used to define one meter as 1/40,000,000 of the Earth's meridian - so that the circumference of the Earth was 40,000 kilometers.
Also, they used to define one second as 1/86,400 of a solar day so that the day may be divided to 24 hours each containing 60 minutes per 60 seconds.
In our Universe, it happens to be the case that light is moving by speed so that in 1 second defined above, it moves approximately by 299,792,458 meters defined above. In other words, during one solar day, light changes its position by
$$ \delta x = 86,400 \times 299,792,458 / 40,000,000\,\,{\rm circumferences\,\,of\,\,the\,\,Earth}.$$ | {
"domain": "physics.stackexchange",
"id": 83817,
"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": "speed-of-light, definition, conventions, si-units, metrology",
"url": null
} |
c#, performance, array, .net, enum
arrayParam is not a descriptive name, what is it? List of roles? Make it clear changing name to - for example - roles.
2.
arrayParam.Select(myField => Enum.Parse(typeof(MyEnum), myField.ToString()))
You're converting each arrayParam item to a string however you're not doing any check, if one of them is null then code will fail with NullReferenceException for a long line packed with a lot of code. Not so helpful. You may check in advance with:
if (arrayParam.Any(x => x == null))
throw new ArgumentException("...");
Otherwise just let Enum.Parse() fail and use Convert.ToString(myField) won't throw for null input. Note that if type is restricted to be string or MyEnum then you may change your function definition accordingly:
public AuthorizeRoles(params string[] arrayParam)
public AuthorizeRoles(params MyEnum[] arrayParam)
Note that a weird user may have this:
object[] pars = null; // It may be a function argument...
AuthorizeRoles(pars); | {
"domain": "codereview.stackexchange",
"id": 20464,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "c#, performance, array, .net, enum",
"url": null
} |
python, python-2.x
You'd use this with calling code like this:
try:
ValidateGoto(goto)
except ValidationError, err
print err # then possibly return
else: # passed-validation case (can omit else if there's a return in the except)
...
If you are looking to make it easier to add named validations, you could take an approach similar to that used by unit tests. Choose a naming convention and write code that looks for the methods that follow that name. Here's a very simple skeleton to illustrate the idea:
class ValidateGoto:
def __init__(self, placeGoto):
for validation in dir(self):
if validation.startswith("validate_"):
getattr(self)(placeGoto)
def validate_provided(self, placeGoto):
if not placeGoto:
raise ValidationError("Enter a positive integer in the text box")
def validate_positive(self, placeGoto):
if placeGoto <= 0:
raise ValidationError("I need a positive integer in the text box please") | {
"domain": "codereview.stackexchange",
"id": 5596,
"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-2.x",
"url": null
} |
meteorology, geophysics, wind
The above effects can be rolled into the non-linear and friction terms in the momentum equation, which are the reasons that your observations of the wind periodically change directions. | {
"domain": "earthscience.stackexchange",
"id": 136,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "meteorology, geophysics, wind",
"url": null
} |
quantum-gate, pauli-gates
Title: Rotation operator on Pauli parity gates $XX$, $YY$ and $ZZ$ If we suppose that $XX$ is the tensor product of $X$ with $X$ such as $XX = X \otimes X$
How would we calculate the rotation operator of this $XX$ gate.
Does this work? If so why?
$$
R(XX)_\theta = e^{-i\frac{\theta}{2}XX} = \cos\left(\frac{\theta}{2}\right)I - i\sin\left(\frac{\theta}{2}\right)XX $$ This does indeed work because this construction works for any matrix $H$ where $H^2=\mathbb{I}$.
$$
R_\theta(H)=e^{-i\theta H/2}=\cos\frac{\theta}{2}\mathbb{I}-i\sin\frac{\theta}{2}H
$$
There are several ways that you could prove this. I think the easiest way is to realise that because $H^2=\mathbb{I}$, then the eigenvalues of $H^2$ are 1, and hence the eigenvalues of $H$ must be $\pm 1$. Let $P_{\pm}$ be projectors onto the eigenspaces of eigenvalue $\pm 1$ respectively. So,
$$
\mathbb{I}=P_++P_-\qquad H=P_+-P_-
$$ | {
"domain": "quantumcomputing.stackexchange",
"id": 651,
"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, pauli-gates",
"url": null
} |
seurat
Title: Seurat CCA, AlignSubspace, Argument dist.method is only useful with multivariate timeseries I am trying to combine two datasets to be able to compare the cells in them and using Seurat CCA for it:
https://satijalab.org/seurat/Seurat_AlignmentTutorial.html
When I am running AlignSubspace function I am getting a warning for each single dimension that I selected it to be run on:
seurat_union <- AlignSubspace(object = seurat_union, reduction.type =
"cca", grouping.var = "protocol", dims.align = 1:13) | {
"domain": "bioinformatics.stackexchange",
"id": 602,
"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": "seurat",
"url": null
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.