text stringlengths 49 10.4k | source dict |
|---|---|
If $\displaystyle H(x)=\frac{2x\sin\alpha}{[x^2-2x\sin\alpha+1][x^2+2x\sin\alpha+1]},$
$$H(-x)=\frac{2(-x)\sin\alpha}{[(-x)^2-2(-x)\sin\alpha+1][(-x)^2+2(-x)\sin\alpha+1]}$$
$$=\frac{-2x\sin\alpha}{[x^2+2x\sin\alpha+1][x^2-2x\sin\alpha+1]}=-H(x)$$ | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9752018455701406,
"lm_q1q2_score": 0.816848534129017,
"lm_q2_score": 0.8376199633332891,
"openwebmath_perplexity": 131.8843109534249,
"openwebmath_score": 0.9609994888305664,
"tags": null,
"url": "https://math.stackexchange.com/questions/1047676/does-adding-an-odd-function-to-the-numerator-of-an-even-function-integrand-keep"
} |
You can apply the following rule (Leibniz rule): [edited in response to Didier Piau's comment]:
If $$I(x)=J(u(x),v(x),x),\quad\text{with}\ J(\alpha,\beta,z)=\int_\alpha^\beta f(t,z)dt,\tag{1}$$
then, under suitable conditions, we have
$$I^{\prime }(x)=\displaystyle\int_{u(x)}^{v(x)}\dfrac{\partial f(t,x)}{\partial x}dt+f(v(x),x)v^{\prime }(x)-f(u(x),x)u^{\prime }(x).\tag{2}$$
For further detais see this answer of mine.
Added 3. Pierre-Yves Gaillard's comment proves $(2)$. I derive $(2)$ as follows, by using this old blog post of mine (hereafter $t$ is the independant variable): | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9891815532606978,
"lm_q1q2_score": 0.8155425332039468,
"lm_q2_score": 0.8244619306896955,
"openwebmath_perplexity": 600.395962371277,
"openwebmath_score": 0.9197989106178284,
"tags": null,
"url": "http://math.stackexchange.com/questions/58594/how-do-i-differentiate-this-integral"
} |
java, mergesort
/**
* Scans the runs over the range
* <code>array[fromIndex .. toIndex - 1]</code> and returns a
* {@link UnsafeIntQueue} containing the sizes of scanned runs in the same
* order as they appear in the input range.
*
* @param <E> the component type.
* @param array the array containing the desired range.
* @param fromIndex the least index of the range to process.
* @param toIndex the index one past the greatest index contained by the
* range.
*
* @return a {@link UnsafeIntQueue} describing the lengths of the runs in
* the input range.
*/
static <T>
UnsafeIntQueue buildRunSizeQueue(T[] array,
int fromIndex,
int toIndex,
Comparator<? super T> comparator) {
UnsafeIntQueue queue =
new UnsafeIntQueue(((toIndex - fromIndex) >>> 1) + 1);
int head;
int left = fromIndex;
int right = left + 1;
int last = toIndex - 1;
boolean previousRunWasDescending = false;
while (left < last) {
head = left;
// Decide the direction of the next run.
if (comparator.compare(array[left++], array[right++]) <= 0) {
// Scan an ascending run.
while (left < last
&& comparator.compare(array[left], array[right]) <= 0) {
++left;
++right;
}
int runLength = left - head + 1;
if (previousRunWasDescending) {
if (comparator.compare(array[head - 1], array[head]) <= 0) {
// "Merge" the current run to the previous one in
// constant time.
queue.addToLast(runLength);
} else {
queue.enqueue(runLength);
}
} else {
queue.enqueue(runLength);
} | {
"domain": "codereview.stackexchange",
"id": 17338,
"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, mergesort",
"url": null
} |
python, algorithm, numpy, bioinformatics
The line return probs has the wrong indentation. Copy/paste error?
There are no docstrings. What do these functions do and how do I call them? (The text from your question would be a good starting-point for docstrings.)
There are no test cases. This is the kind of code that would benefit from some unit tests and/or doctests.
You write, "cond_probs() produces a dictionary {'AT': n1, 'AG': n2, 'AA': n3, 'AC': n4, ... , 'TC': n16}" but when I run it the dictionary has tuples for keys, not strings:
>>> cond_probs(['AAC'])
{('A', 'C'): 0.5, ('A', 'A'): 0.5}
I don't understand the behaviour when reverse=True. You write, "In reverse, the transitional probabilities are calculated with the sequences in reverse" but this doesn't seem to be the case:
>>> cond_probs(['CAA'], reverse=True)
{('A', 'A'): 1.0}
What has happened to C? This looks wrong to me.
If I were writing this, I'd implement cond_probs to run only in the forward direction; to do the reverse direction I would pass in reversed sequences.
Prefer using True and False for Booleans, not 1 and 0. So the second parameter to cond_probs should be reverse=False.
Instead of:
counts = {}
# ...
counts[X] = counts.get(X, 0) + 1
use collections.Counter and write:
counts = Counter()
# ...
counts[X] += 1
(But see below for how to use collections.Counter.update.)
Instead of:
range(len(seq))[::-1][:-1]
write:
range(len(seq) - 1, 0, -1) | {
"domain": "codereview.stackexchange",
"id": 6694,
"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, algorithm, numpy, bioinformatics",
"url": null
} |
Here is a straightforward application of Theorem BS.
Begin with a set of five vectors from $$\complex{4}\text{,}$$
\begin{equation*} S=\set{ \colvector{ 1 \\ 1 \\ 2 \\ 1},\, \colvector{ 2 \\ 2 \\ 4 \\ 2},\, \colvector{ 2 \\ 0 \\ -1 \\ 1},\, \colvector{ 7 \\ 1 \\ -1 \\ 4},\, \colvector{ 0 \\ 2 \\ 5 \\ 1} } \end{equation*}
and let $$W=\spn{S}\text{.}$$ To arrive at a (smaller) linearly independent set, follow the procedure described in Theorem BS. Place the vectors from $$S$$ into a matrix as columns, and row-reduce,
\begin{equation*} \begin{bmatrix} 1 & 2 & 2 & 7 & 0 \\ 1 & 2 & 0 & 1 & 2 \\ 2 & 4 & -1 & -1 & 5 \\ 1 & 2 & 1 & 4 & 1 \end{bmatrix} \rref \begin{bmatrix} \leading{1} & 2 & 0 & 1 & 2 \\ 0 & 0 & \leading{1} & 3 & -1 \\ 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 \end{bmatrix}\text{.} \end{equation*}
Columns 1 and 3 are the pivot columns ($$D=\set{1,\,3}$$) so the set
\begin{equation*} T=\set{ \colvector{ 1 \\ 1 \\ 2 \\ 1},\, \colvector{ 2 \\ 0 \\ -1 \\ 1} } \end{equation*}
is linearly independent and $$\spn{T}=\spn{S}=W\text{.}$$ Boom! | {
"domain": "runestone.academy",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9678992942089575,
"lm_q1q2_score": 0.8127779126922124,
"lm_q2_score": 0.8397339656668287,
"openwebmath_perplexity": 334.65660186840586,
"openwebmath_score": 0.9999849796295166,
"tags": null,
"url": "https://runestone.academy/ns/books/published/fcla/section-LDS.html"
} |
java, multithreading, datetime, swing, timer
Better to handle any manipulation of graphical components through the EDT.
(2) Earlier versions of Java held JTextField.setText(String) to be thread-safe, but this guarantee was dropped in 7 and later.
Overall Design
Think about what you need. Drill it down to the barest essence. At the very minimum, you will need two concepts: one to represent your stopwatch, and one to represent your GUI. These are the two major entities in your design. Everything else is basically frills.
A more subtle consideration, but very defining for your design, is who is responsible for relaying the passage of time. Does the stopwatch send out signals when its state changes? Do interested parties query once every while? Either approach has its pros and cons, so it's a matter of insight and preference.
Let's stay with your original choice: the stopwatch is a passive construct and does not send out signals; this means that interested parties must poll for changes. Helpful here will be javax.swing.Timer, a timer that's designed to be Swing-safe.
Regardless of what approach you take, the stopwatch design will be pivotal to both entities:
// Alternatively, instead of start()/stop(), consider setRunning(boolean)
interface IStopwatch {
/** Total time the stopwatch has been running since the last call to reset(). */
long getElapsedTime();
/** Starts adding to elapsed time. */
void start();
/** Stops adding to elapsed time. */
void stop();
/** Resets elapsed time to zero. */
void reset();
/** Whether the stopwatch is currently running / accumulating time. */
boolean isRunning();
}
Sample implementation
Here's a quick-and-dirty sample implementation that uses polling to get the stopwatch's state. Note that the example implementation of the stopwatch is not inherently thread-safe, but is created and manipulated solely from the EDT.
public class StopwatchFrame extends JFrame {
// Do not confuse with java.util.Timer !
javax.swing.Timer timer;
IStopwatch stopwatch;
JLabel time;
JToggleButton stopStart;
JButton reset; | {
"domain": "codereview.stackexchange",
"id": 8967,
"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, multithreading, datetime, swing, timer",
"url": null
} |
experimental-chemistry
Title: How to produce Fe(OH)2? I'm interested in producing Ferrum hydroxide (II), I did some research on the internet and made a plan for myself:
Conduct electrolysis:
Conduct electrolysis producing $\ce{NaOH}$ and chlorine solution.
Produce $\ce{HCl}$:
Produce $\ce{HCl}$ from chlorine solution by exposing it to UV light.
Make iron and hydrochloric acid react:
Adding iron in hydrochloric acid makes this reaction: $\ce{2HCl + Fe -> FeCl2 + H2}$ producing a solution with $\ce{HCl}$ and $\ce{FeCl2}$, then evaporate it and be left with solid $\ce{FeCl2}$ crystals.
Produce $\ce{Fe(OH)2}$:
As we have $\ce{FeCl2}$ and $\ce{NaOH}$, we can make this reaction: $\ce{2NaOH + FeCl2 -> Fe(OH)2 + 2NaCl}$ producing a participate ($\ce{Fe(OH)2}$). | {
"domain": "chemistry.stackexchange",
"id": 17712,
"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": "experimental-chemistry",
"url": null
} |
= 1; end %% Solve the Puzzle % The Sudoku problem is complete: the rules are represented in the |Aeq| % and |beq| matrices, and the clues are ones in the |lb| array. Solve the % problem by calling |intlinprog|. Ensure that the integer program has all % binary variables by setting the intcon argument to |1:N|, with lower and % upper bounds of 0 and 1. intcon = 1:N; [x,~,eflag] = intlinprog(f,intcon,[],[],Aeq,beq,lb,ub); %% Convert the Solution to a Usable Form % To go from the solution x to a Sudoku grid, simply add up the numbers at % each \$(i,j)\$ entry, multiplied by the depth at which the numbers appear: if eflag > 0 % good solution x = reshape(x,9,9,9); % change back to a 9-by-9-by-9 array x = round(x); % clean up non-integer solutions y = ones(size(x)); for k = 2:9 y(:,:,k) = k; % multiplier for each depth k end S = x.*y; % multiply each entry by its depth S = sum(S,3); % S is 9-by-9 and holds the solved puzzle else S = []; end ``` | {
"domain": "mathworks.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9845754483707558,
"lm_q1q2_score": 0.8139601395241336,
"lm_q2_score": 0.8267117983401363,
"openwebmath_perplexity": 605.3819028007081,
"openwebmath_score": 0.831002950668335,
"tags": null,
"url": "https://it.mathworks.com/help/optim/ug/solve-sudoku-puzzles-via-integer-programming-solver-based.html"
} |
naive-bayes-classifier, bayesian-networks
Title: Reversing Naive Bayes to find extreme points of data sets I'd like to know if this is a sensible idea and if there exist any already formed methods to do this (I'm new to the data science area).
Essentially, I have used Naive Bayes to accurately classify three types of food, based on their nutritious value (fat, salt, sugar, protein, and carbohydrates as my features).
Now that I can accurately classify these foods, Is there a method which uses the Naive Bayes to reverse this approach, and find the extreme values these features can be to be still classified as a type of food?
E.g: The max fat food1 can be, to still be considered food1.
I realize that these values will change, as other nutrient variables are changed, but I wondered if an optimized set of equations could be obtained in 5 dimensions? What you are looking for is called "decision boundary", which is the set of (extreme) points laying on the boundary between classes.
Decision boundary of NB is a set of points $\boldsymbol{x}$ that satisfy at least one of these $K(K-1)/2$ conditions $$i\neq j \in [1, K]:{\Bbb P}(\boldsymbol{x}, C_i)={\Bbb P}(\boldsymbol{x}, C_j) \overset{\forall k}{\geq} {\Bbb P}(\boldsymbol{x}, C_k)$$
Generally, Naive Bayes does not learn an explicit decision boundary (specially when categorical features are involved), however, for example here is the derivation of NB boundary for continuous variables when ${\Bbb P}(\boldsymbol{x}|C_i)$ is chosen from exponential family (e.g. a Gaussian). Nonetheless, you could still select a set of random points, then assign a class to each, and finally plot them using something like t-SNE to get a sense of decision boundaries. For example, a tool like this interactive t-SNE plot would be helpful:
Or a library like mlxtend.plotting that carries out a similar procedure: | {
"domain": "datascience.stackexchange",
"id": 5123,
"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": "naive-bayes-classifier, bayesian-networks",
"url": null
} |
expanding the products in the numerator, you can verify that: $$a^2(a^2-b^2-c^2)^2+b^2(b^2-a^2-c^2)^2+c^2(c^2-a^2-b^2)^2-(a^2-b^2-c^2)(b^2-a^2-c^2)(c^2-a^2-b^2)=4a^2b^2c^2$$
so the fraction simplifies to
$$\frac{4a^2b^2c^2}{4a^2b^2c^2}=1$$
• Right, but not a geometric way to prove the claim. – Michael Hoppe Sep 10 at 18:39
• The critical first step, "Since the angles $A + B + C = \pi$, these are the internal angles of a general triangle. [Therefore] using the law of cosines..." is certainly itself a geometric argument, even if the rest of the solution is algebraic manipulation. – Travis Willse Sep 10 at 18:49
• Though it consists of some geometry, but it is almost using algebra. – Isaac YIU Math Studio Sep 11 at 8:53
A purely geometric way doesn't look likely, because the degrees of the cosine terms (two and three respectively) don't match. For what it's worth, here is an alternative trigonometric derivation. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9875683469514965,
"lm_q1q2_score": 0.8097006999054582,
"lm_q2_score": 0.8198933293122506,
"openwebmath_perplexity": 389.38589059823414,
"openwebmath_score": 0.9726846814155579,
"tags": null,
"url": "https://math.stackexchange.com/questions/3350887/prove-a-trigonometric-identity-cos2a-cos2b-cos2c2-cos-a-cos-b-cos-c-1"
} |
From $|x+y|+|1-x|=6$:
$x+y-(1-x)=6$
$2x+y=7$
From $|x+y+1|+|1-y|=4$:
$x+y+1+1-y=4$
$x=2$ and $y=7-2x=7-2(2)=3$
But $y<1$, thus, this isn't a valid case either.
Case A (ii)+$y\geq1$:
$x+y\geq0$, $1-x<0$ and $y\geq1$
From $|x+y|+|1-x|=6$, we get $2x+y=7$, and
From $|x+y+1|+|1-y|=4$:
$x+y+1-(1-y)=4$
$x+2y=4$
$2x+y=7$
Solving these for y, we obtain $y=\frac{1}{3}$.
Since $y\geq1$, we need to eliminate this case too.
So, there are no solutions if $x+y\geq0$.
#### anemone
##### MHB POTW Director
Staff member
Case B (i) +$y<1$ :
$x+y<0$, $1-x\geq0$ and $y<1$
From $|x+y|+|1-x|=6$:
$-(x+y)+1-x=6$
$2x+y=-5$
From $|x+y+1|+|1-y|=4$:
$|x-5-2x+1|+1-y=4$
$|-x-4|=y+3$ or $|x+4|=y+3$
$x+4=-(y+3)$ or $x+4=y+3$
$x+y=-7$ or $x-y=-1$ | {
"domain": "mathhelpboards.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9715639669551475,
"lm_q1q2_score": 0.8117256916741952,
"lm_q2_score": 0.8354835289107307,
"openwebmath_perplexity": 831.1287678038831,
"openwebmath_score": 0.8556641340255737,
"tags": null,
"url": "https://mathhelpboards.com/threads/solving-absolute-value-equations.3630/"
} |
Math Help - Probability
1. Probability
I'm having a lot of trouble with permutations and combinations, so I was hoping someone here could help me out with a few questions. Please make sure that you explain your working; I really want to understand this topic... The first question asks;
A queue has 4 boys and 4 girls standing in line. Find how mant different arrangements are possible if;
a) The boys and girls alternate.
b) 2 particular girls wish to stand together.
c) All the boys stand together.
d) Also find the probability that 3 particular people will be in the queue together if the queue forms randomly.
EDIT: If it's any help, here are the answers...
a) 1152
b) 10080
c) 2880
d) 3/28
EDIT: I've got a new problem now;
A table has 4 boys and 4 girls sitting around it.
a) Find the number of ways of sitting possible if the boys and girls can sit anywhere around the table.
b) If the seating is arranged at random, find the probability that;
i) 2 particular girls will sit together.
ii) All the boys will sit together.
2. Hello, Flay!
We have to "talk" our way through these problems . . .
A queue has 4 boys and 4 girls standing in line.
Find how mant different arrangements are possible if;
a) The boys and girls alternate.
There are 2 possible arrangements: . $BGBGBGBG\,\text{ and }\,GBGBGBGB.$
The four boys can be placed in 4! ways.
The four girls can be placed in 4! ways.
Therefore, there are: . $2 \times 4! \times 4! \;=\;\boxed{1152}$ ways.
b) 2 particular girls wish to stand together.
Suppose the two girls are $X$ and $Y.$
Duct-tape them together.
Note that there are 2 possible orders: . $XY\,\text{ or }\,YX.$
Now we have seven "people" to arrange: . $\boxed{XY}\,,G,G,B,B,B,B$
. . and they can be arranged in ${\color{blue}7!}$ ways. | {
"domain": "mathhelpforum.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9902915215128428,
"lm_q1q2_score": 0.8801302934887906,
"lm_q2_score": 0.8887587890727755,
"openwebmath_perplexity": 770.5921127119627,
"openwebmath_score": 0.806406557559967,
"tags": null,
"url": "http://mathhelpforum.com/statistics/45708-probability.html"
} |
algorithms, search-algorithms, artificial-intelligence
Depth-first iterative-deepening is asymptotically optimal among
brute-force tree searches in terms of time, space, and length of
solution.
Of course, it delivers optimal solutions so that it is admissible and hence, asymptotically optimal. It only practices depth-first traversals and therefore, it is asymptotically optimal in terms of space (requiring with a good implementation only $O(d)$).
As for the time, I already outlined the main theoretical reason but let me know highlight three main reasons why it is so fast in practice: | {
"domain": "cs.stackexchange",
"id": 15124,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "algorithms, search-algorithms, artificial-intelligence",
"url": null
} |
ros, permissions
Originally posted by mcamp on ROS Answers with karma: 3 on 2016-01-14
Post score: 0
Original comments
Comment by ahendrix on 2016-01-14:
What do you have your CMAKE_PREFIX_PATH and your ROS_PACKAGE_PATH environment variables set to? You might be able to adjust those to control the package search crawing behavior.
Comment by mcamp on 2016-01-15:
I edited the question to show the content of both variables, can you see how to solve this with that information?
The tab-completion for roscd eventually calls rospack; and that startup for rospack tries to query if the current directory is within a ROS package or not, by walking up from the current directory to /, looking for a package.xml.
It looks like this is a bug in rospack, and I don't see a good way to suppress it without modifying rospack. You should file an issue on the rospack issue tracker.
Originally posted by ahendrix with karma: 47576 on 2016-01-15
This answer was ACCEPTED on the original site
Post score: 1
Original comments
Comment by mcamp on 2016-01-15:
I see, thanks for that
I will file this issue then | {
"domain": "robotics.stackexchange",
"id": 23441,
"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, permissions",
"url": null
} |
problem. The spring with k=500N/m is exerting zero force when the mass is centered at x=0. The 'mass damper' adopted by Renault for its 2005 R25 Formula 1 car was a stability aid that improved front-end downforce before it was outlawed by the FIA. 3) where k is the spring constant for the spring and m is the oscillating mass. Free, undamped vibrations. Practice Problems. Frequencies of a mass‐spring system • When the system vibrates in its second mode, the equations blbelow show that the displacements of the two masses have the same magnitude with opposite signs. Mass on a Spring System. The intelligent solution to any vibration problem involves the following steps: 1) Characterize the system parameters (mass, stiffness, damping) by experimental methods,. If the mass is pulled down 3 in and then released, determine the position of the mass at any time. The springs coupling mass 1 and 3 and mass 1 and 2 have spring constant k, and the spring coupling mass 2 and mass 3 has spring constant 2k. The model is equipped with a parallel spring, stiffness K(N/m) and the system is responsible for giving rectilinear motion to a mass, M along the x-axis. Solving Problems in Dynamics and Vibrations Using MATLAB Parasuram Harihara And Dara W. 5 kg, determine (a) the mechanical energy of the system, (b) the maximum speed of the mass, and (c) the maximum acceleration. How much mass should be attached to the spring so that its frequency of vibration is f = 3. Damping is the presence of a drag force or friction force which is non-. For each case the behaviour of the system will be different. The physics of bungee jumping is an interesting subject of analysis. Find the magnitude of the acceleration with which the bucket and the block are moving and the magnitude of the tension force T by which the rope is stressed. Physics and Chemistry by a Clear Learning in High School, Middle School, Upper School, Secondary School and Academy. A mass-spring system with such type displacement function is called overdamped. Copyright © 2020 by author(s) and Open Access Library Inc. Recall that the net force in this case is the restoring. Or some simply say: Force equals mass times acceleration. JP Variable Mass Operating System. Weight w is mass times gravity, so | {
"domain": "mexproject.it",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.986777179803135,
"lm_q1q2_score": 0.8157803347695534,
"lm_q2_score": 0.8267117962054048,
"openwebmath_perplexity": 576.3393247798474,
"openwebmath_score": 0.5349347591400146,
"tags": null,
"url": "http://mexproject.it/jtjy/spring-mass-system-problems.html"
} |
electromagnetism
For an ideal capacitor the electric field lines and the rate of change of electric field are parallel and run between the plates, so for surface 1 as shown above, the E-field would always be tangential to that part of the cylinder's curved surface between the plates and since there is also no electric field outside the plates there would be no displacement current term at all. However, there is obviously still the $I_c$ conduction current through the flat face of the cylinder contributing to the RHS of Ampere's law case, so how can we square that with the smaller value of the toroidal B-field for the Amperian loop between the plates?
Well, what you cannot assume is that there is zero conduction current in the plates themselves. For example if the capacitor plates are circular with radius $R$ and your circular path is of radius $r$, then a fraction $(R^2 -r^2)/R^2$ of the charge on the plates lies outside the cylindrical surface I defined above. But if the charge on the plates is changing with time there must be a net current flowing from the outer part of the plates to the inner part and then into the wire (shown as a blue current density in the picture). This will be a negative term on the RHS of Ampere's law because it flows into the cylindrical surface, and will be of size $I(r^2 -R^2)/R^2$. The sum of the conduction current terms is therefore smaller and indeed will match the reduced B-field between the plates at radius $r$ compared with the field you would expect for a similar loop outside the plates.
For surface 2 the solution is different. The surface does not cut through the plates at all so there is no additional conduction current term. However here there is a negative displacement current contribution due to the integral of the rate of change of E-field over that part of surface 2 which is between the plates. It is a negative contribution because the E-field lines are going into surface 2 between the plates. Again, a careful calculation would show that this negative displacement current plus the conduction current that exits surface 2 outside the plates is exactly what is required to balance the smaller LHS of Ampere's law for the small loop of radius $r$ between the plates. | {
"domain": "physics.stackexchange",
"id": 74171,
"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",
"url": null
} |
javascript, performance, algorithm, tic-tac-toe
//third column
else if((grid[2].innerText==computerSym&&grid[5].innerText==computerSym)&&(document.getElementById(grid[8].id).innerText==="")){
return Number(grid[8].id);}
else if((grid[8].innerText==computerSym&&grid[2].innerText==computerSym)&&(document.getElementById(grid[5].id).innerText==="")){
return Number(grid[5].id);}
else if((grid[5].innerText==computerSym&&grid[8].innerText==computerSym)&&(document.getElementById(grid[2].id).innerText==="")){
return Number(grid[2].id);}
return -1;
}
function blockOppWin(){
//diagonal left to right
if((grid[0].innerText==playerSym&&grid[4].innerText==playerSym)&&(document.getElementById(grid[8].id).innerText==="")){
return Number(grid[8].id);}
else if((grid[0].innerText==playerSym&&grid[8].innerText==playerSym)&&(document.getElementById(grid[4].id).innerText==="")){
return Number(grid[4].id);}
else if((grid[4].innerText==playerSym&&grid[8].innerText==playerSym)&&(document.getElementById(grid[0].id).innerText==="")){
return Number(grid[0].id);} | {
"domain": "codereview.stackexchange",
"id": 20141,
"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, performance, algorithm, tic-tac-toe",
"url": null
} |
SubsectionExercises
C20
For each matrix below, find a set of linearly independent vectors $X$ so that $\spn{X}$ equals the column space of the matrix, and a set of linearly independent vectors $Y$ so that $\spn{Y}$ equals the row space of the matrix. \begin{align*} A&= \begin{bmatrix} 1 & 2 & 3 & 1 \\ 0 & 1 & 1 & 2\\ 1 & -1 & 2 & 3 \\ 1 & 1 & 2 & -1 \end{bmatrix} & B&= \begin{bmatrix} 1 & 2 & 1 & 1 & 1 \\ 3 & 2 & -1 & 4 & 5\\ 0 & 1 & 1 & 1 & 2 \end{bmatrix} & C& =\begin{bmatrix} 2 & 1 & 0 \\ 3 & 0 & 3\\ 1 & 2 & -3 \\ 1 & 1 & -1 \\ 1 & 1 & -1\end{bmatrix} \end{align*} From your results for these three matrices, can you formulate a conjecture about the sets $X$ and $Y\text{?}$
C30
Example CSOCD expresses the column space of the coefficient matrix from Archetype D (call the matrix $A$ here) as the span of the first two columns of $A\text{.}$ In Example CSMCS we determined that the vector \begin{equation*} \vect{c}=\colvector{2\\3\\2} \end{equation*} was not in the column space of $A$ and that the vector \begin{equation*} \vect{b}=\colvector{8\\-12\\4} \end{equation*} was in the column space of $A\text{.}$ Attempt to write $\vect{c}$ and $\vect{b}$ as linear combinations of the two vectors in the span construction for the column space in Example CSOCD and record your observations.
Solution
C31 | {
"domain": "ups.edu",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9883127402831221,
"lm_q1q2_score": 0.805704657737613,
"lm_q2_score": 0.8152324915965392,
"openwebmath_perplexity": 144.48185733870667,
"openwebmath_score": 0.9492066502571106,
"tags": null,
"url": "http://linear.ups.edu/fcla/section-CRS.html"
} |
scrnaseq, seurat
Title: Cells with zero expression of a given gene I have scRNA-seq from PBMC analyzed by Seurat. I am seeing for most of genes a lot of cells have a zero expression like this gene
So 268 single cells have the expression level == 0
And I am more wondering when seeing zero expression for a housekeeping gene like | {
"domain": "bioinformatics.stackexchange",
"id": 2405,
"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": "scrnaseq, seurat",
"url": null
} |
c#, asp.net, validation, captcha
Title: Simple Google ReCaptcha validation Linked:
Google reCAPTCHA Validator: Iteration II
I have also created a simple Google Recaptcha Validation class to handle verification.
I used some code from CodingFusion's post Google New reCaptcha I am not a robot using asp .net, but I have altered it so that it fit my use case, and to make it extendable and reusable.
Can I clean it up further?
public class ReCaptchaValidator
{
private readonly string _ReCaptchaSecret;
private readonly string _ReCaptchaSiteKey;
public List<string> ErrorCodes { get; set; }
public ReCaptchaValidator(string reCaptchaSecret)
{
_ReCaptchaSecret = reCaptchaSecret;
this.ErrorCodes = new List<string>();
}
public ReCaptchaValidator(string reCaptchaSecret, string reCaptchaSiteKey)
{
_ReCaptchaSecret = reCaptchaSecret;
_ReCaptchaSiteKey = reCaptchaSiteKey;
this.ErrorCodes = new List<string>();
}
public bool ValidateCaptcha(HttpRequest request)
{
var sb = new StringBuilder();
sb.Append("https://www.google.com/recaptcha/api/siteverify?secret=");
sb.Append(_ReCaptchaSecret);
sb.Append("&response=");
sb.Append(request.Form["g-recaptcha-response"]);
//client ip address
sb.Append("&remoteip=");
sb.Append(GetUserIp(request)); | {
"domain": "codereview.stackexchange",
"id": 15163,
"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#, asp.net, validation, captcha",
"url": null
} |
3. 0725. This calculator shows the steps and work to convert a fraction to a decimal number. Write the repeating part as the numerator of the fraction. Okay, so you can use division to see if a fraction has a repeating decimal, but how do you convert a repeating decimal into a fraction? Changing a repeating decimal in which all numbers after the decimal repeat, such as zero point one repeating, zero point two repeating, etc. Ask students to describe each piece as a fraction (1/8), a decimal (0. $$\frac{decimal}{1}$$ Step 2: For Every number after the decimal point multiply by 10 for both top and bottom (i. 125 Arranging decimal numbers by size When comparing decimal numbers and arranging them in order it is usually easiest to line up the numbers vertically with the decimal points in a vertical line. Convert fractions to repeating decimals Grade 5 Decimals Worksheet Convert to decimals, round to 3 digits if necessary. 5 ), this percentage is simpler to convert than was the previous one. Here is a simple online Recurring Decimal to Fraction Calculator to convert from Repeating Decimal to Fraction. to Fractions Focus 4 - Learning Goal #1: Students will know that there are numbers that are not rational, and approximate them with rational numbers. Writing Terminating Decimals as Fractions. 3 2 1 0. Example: Convert 0. 7025 = 3 + . 444444…. Name: _____ Converting Fractions, Decimals, and Percents fraction decimal percent a. 5555555555 Step 2: After examination, the repeating digit is 5 Step 3: To place the repeating digit ( 5 ) to the left of the decimal point, you need to move the decimal point 1 repeating part of the number is immediately next to the decimal. Converting decimals to fractions To convert a decimal to a fraction we rst split it into the whole number part added to the decimal part Example: 3. Convert decimal to fraction changing 1. Fractions as decimals. Decide how many numbers are repeating. org and *. Math Worksheets Fractions as Decimals Fractions as Decimals. org This file derived from G7-M2-TE-1. Use repeating DECIMALS INTO. To convert fractions to decimals, look at the fraction as a division problem. Students should be able to convert fractions to decimals, decimals | {
"domain": "clean-igm.com",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9835969703688159,
"lm_q1q2_score": 0.8175097776455764,
"lm_q2_score": 0.8311430415844384,
"openwebmath_perplexity": 1116.3885719091054,
"openwebmath_score": 0.6260017156600952,
"tags": null,
"url": "http://clean-igm.com/xdfd2mqaj/convert-repeating-decimal-to-fraction-pdf.html"
} |
quantum-mechanics, statistical-mechanics, condensed-matter, solid-state-physics, partition-function
Title: Does Bohr van Leeuwen theorem not exclude the possibility of explaining paramagnetism classically? We have the Bohr-van Leeuwen theorem which tells that magnetism cannot be explained classically. The proof is simple; it turns out that classically the partition function is independent of the magnetic vector potential and therefore, the free energy is independent of the magnetic field which proves that there cannot be magnetization.
But we have a classical Langevin theory of paramagnetism where the partition function is not independent of $B$, and thus we get a magnetization. So how can we say that magnetism cannot be explained classically? Doesn't the Bohr van Leeuwen theorem fail here? One way to answer your question is that, citing J. H. Van Vleck,
when Langevin assumed that the magnetic moment of the atom or molecule had a fixed value $\mu$, he was quantizing the system without realizing it.
If you do not assume the existence of a permanent magnetic moment, but try to derive it from the motion of electrons inside the atoms, then this is doomed to fail (classically), precisely because of the Bohr-van Leeuwen theorem. In other words, Langevin theory is not a classical theory, but a kind of semi-classical theory.
This is discussed, for instance, in this recent review paper. | {
"domain": "physics.stackexchange",
"id": 75414,
"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, statistical-mechanics, condensed-matter, solid-state-physics, partition-function",
"url": null
} |
organic-chemistry, alcohols, esters
Title: which starting material on heating with concentrated sulfuric acid generate cyclic ester
I have just learned esterification of normal reactions with aliphatic compounds, but this one is a cyclic compound. Is it different? There are both a hydroxyl group and a carboxyl group in choice B and D, but why the correct answer is B, not D? The correct answer is glycolic acid, B.
It forms the cyclic di-ester glycolide (1,4-dioxane-2,5-dione). | {
"domain": "chemistry.stackexchange",
"id": 5142,
"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": "organic-chemistry, alcohols, esters",
"url": null
} |
javascript, html, error-handling, ecmascript-6, null
<form id="thingSelection2">
...
</form>
<script src="./thingSelection.js"></script>
where thingSelection.js adds the event listener. But that'll require a separate request to the server, which may be a problem on a large page on HTTP 1.1 - if you have lots of different scripts like this, the sheer number of parallel requests could slow things down, especially for users with high latency. (The HTTP/2 protocol doesn't have issues with additional connections to the same server IIRC)
(You could also inline the script, eg </form><script>// etc</script>but I prefer putting scripts in separate files to permit caching)
But if it were me, I'd strongly prefer to fully integrate the creation of the HTML with the event listeners for that HTML, to make it completely inconceivable of one existing without the other, using a framework. For example, with React, you could do something along the lines of:
const Things = () => {
const [item, setItem] = useState('');
const [selectedOption, setSelectedOption] = useState('foo');
const clickHandler = (e) => {
const fn = options[selectedOption];
if (fn) {
setItem(fn());
}
};
return (
<div>
<select value={selectedOption} onChange={e => setSelectedOption(e.currentTarget.value)}>
<option value="foo">foo</option>
<option value="bar">bar</option>
</select>
<button onClick={clickHandler}>click</button>
<output>{item}</output>
</div>
);
};
const options = {
foo: () => 'foo',
bar: () => 'bar',
}; | {
"domain": "codereview.stackexchange",
"id": 39669,
"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, html, error-handling, ecmascript-6, null",
"url": null
} |
Evaluate the line integral over the vector field given this semi-circle
So here is the problem on the practice test verbatim
Evaluate $$\int_{C}^{ } \textbf{F} \cdot d\textbf{r} \text{ where } C = \{ (x,y) \in \mathbb{R} \mid (x-1)^2 + y^2 = 1 \text{ and } y \ge 0 \}$$ oriented counter clockwise and $$\textbf{F}(x,y) = <-y,x>$$
I've considered doing it a few ways but keep getting stuck. At first I thought I'd parameterize it but then I realized I didn't know what to do with $$\textbf{F}(x,y) = <-y,x>$$ so then I thought converting it to curl would make sense but then I get confused because if I dot with the gradient vector then both x and y go to zero since the x component isn't in terms of x and the y component isn't in terms of y.
Brute force way
Parameterise the curve by some suitable $$r(t)=(x(t), y(t))$$ where $$t$$ goes from $$t_0$$ to $$t_1$$. The line integral is then given by $$\int_{t_0}^{t_1} F(x(t),y(t))\cdot r'(t) dt$$ For instance, setting $$r(t) = (\cos(t) + 1, \sin(t))$$ with $$t\in [0, \pi]$$, we get $$\int_0^\pi(-\sin(t), \cos(t) + 1)\cdot (-\sin(t), \cos(t)) dt = \int_0^\pi(1 + \cos(t))dt$$ which isn't too hard to calculate.
Using theorems | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9766692298333416,
"lm_q1q2_score": 0.8281840193745913,
"lm_q2_score": 0.8479677602988601,
"openwebmath_perplexity": 232.19629862924623,
"openwebmath_score": 0.8621958494186401,
"tags": null,
"url": "https://math.stackexchange.com/questions/3322682/evaluate-the-line-integral-over-the-vector-field-given-this-semi-circle"
} |
black-hole, speed, time-dilation, visualization
So the real answer to your question is that nobody knows what it would happen, but if we imagine two point singularities when two black holes merge, the laws of special relativity suggest that they would fly into each other very very fast, perhaps a tiny fraction of a second. Gravitational energy would be emitted as they spiral into each other, as defined by special relativity, but I don't imagine that energy would escape, it would remain inside the event horizon, but on that, I'm just speculating. There's many reasons why this question probably can't be neatly answered.
There's also a kerr black hole possibility where the point singularity is more of a rotating hoop or ring in order to retain it's angular momentum, but I've always had a hard time seeing how that meshes with losing energy via gravitational waves . . . but I'm not going to try to explain that one, cause it's above my pay grade.
Apologies if I waxed poetic a little too much, but I think this question almost works as a thought experiment, though it's probably impossible to answer. | {
"domain": "astronomy.stackexchange",
"id": 3358,
"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": "black-hole, speed, time-dilation, visualization",
"url": null
} |
Here is one way forward. We will write the series in terms of the even and odd parts of its summand. Proceeding, we find that
\begin{align} \sum_{n=1}^\infty \frac{(-1)^{n-1}x^n}{n}&=\sum_{n=1}^\infty \left(\frac{x^{2n-1}}{2n-1}-\frac{x^{2n}}{2n}\right)\\\\ &=\sum_{n=1}^\infty x^{2n-1}\left(\frac{2n(1-x)+1}{2n(2n-1)}\right)\\\\ &=\sum_{n=1}^\infty \frac{(1-x)x^{2n-1}}{2n-1}+\sum_{n=1}^\infty \frac{x^{2n-1}}{2n(2n-1)}\tag1 \end{align}
Now, the second series on the right-hand side of $$(1)$$ is easily seen to be uniformly convergent for $$0\le x\le 1$$.
To show that the first series on the right-hand side of $$(1)$$ converges uniformly on $$[0,1]$$ we have for any $$\varepsilon>0$$ (and $$N\ge1$$) | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9683812345563902,
"lm_q1q2_score": 0.8090665791117658,
"lm_q2_score": 0.8354835371034368,
"openwebmath_perplexity": 312.339209519376,
"openwebmath_score": 0.9795765280723572,
"tags": null,
"url": "https://math.stackexchange.com/questions/3939490/finding-the-limit-as-x-approaches-1-of-sum-frac-1n1n-xn"
} |
navigation, turtlebot, gmapping
Title: modifying a known map gmapping
I was wondering if it's possible to create a partial map using the navigation stack and then reloading the map later to complete it. Correct me if I am wrong but it seems you can load previously known maps to the amcl demo but that program does not build on the map, trying the same command to the gmapping demo doesnt seem to work:
$ roslaunch turtlebot_navigation gmapping_demo.launch map_file:=/tmp/my_map.yaml
How does one complete a partial map? Also is it possible to edit the map.pgm file in something like gpaint to correct small errors?
Originally posted by Rydel on ROS Answers with karma: 600 on 2012-06-28
Post score: 6 | {
"domain": "robotics.stackexchange",
"id": 9980,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "navigation, turtlebot, gmapping",
"url": null
} |
navigation, turtlebot, transform
By inserting a lot of INFOs into move_base.cpp it seems that when the problem occurs move_base gets stuck at this line:
planner_costmap_ros_ = new costmap_2d::Costmap2DROS("global_costmap", tf_);
Originally posted by JediHamster on ROS Answers with karma: 995 on 2011-11-19
Post score: 1
Original comments
Comment by eitan on 2011-11-28:
It seems like AMCL is not publishing the transform from map to odom in the case where you see the warning. Are you sure that its getting odometry and laser data and running correctly?
I had the same error and found that minimal.launch (turtlebot) wasn't running. Double check roscore?
Originally posted by brianpen with karma: 183 on 2012-02-22
This answer was ACCEPTED on the original site
Post score: 0 | {
"domain": "robotics.stackexchange",
"id": 7347,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "navigation, turtlebot, transform",
"url": null
} |
classical-mechanics, mathematical-physics, aerodynamics, drag, rocket-science
Title: How should I throttle my rocket to reach highest altitude? "Real world" problem.
Suppose we want to launch a rocket equipped with an engine which can be throttled as we prefer. Suppose also that the amount of fuel burnt per time is directly proportional to the upward force the engine exerts. How should we throttle the engine to reach the highest altitude, taking into account atmospheric drag? | {
"domain": "physics.stackexchange",
"id": 14754,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "classical-mechanics, mathematical-physics, aerodynamics, drag, rocket-science",
"url": null
} |
javascript, optimization, jquery, parallax
Title: jQuery parallax plugin I'm working in my project with the following script:
;(function($, doc, win) {
"use strict";
// cache the window object
var jQuerywindow = $(window);
$('section[data-type="background"]').each(function(){
// declare the variable to affect the defined data-type
var jQueryscroll = $(this);
$(window).scroll(function() {
// HTML5 proves useful for helping with creating JS functions!
// also, negative value because we're scrolling upwards
var yPos = -(jQuerywindow.scrollTop() / jQueryscroll.data('speed'));
// background position
var coords = '50% '+ yPos + 'px';
// move the background
jQueryscroll.css({ backgroundPosition: coords });
}); // end window scroll
}); // end section function
})(jQuery, document, window);
The script allows me to have several sections with parallax background effect. So, I can have one or ten in a page. I'm a bit concern about performance. Can the script be improved? First of all, your code looks quite good. You've encapsulated the plugin well, and cached all your jQuery instances, which are, in my experience, the most common pitfalls.
One thing I noticed is that you create a scroll event handler for every section[data-type="background"] element. Performance wise, this might not be optimal since the scroll event fires quite often. Instead of creating multiple scroll events, something like the following could be done:
var backgrounds = [];
$('section[data-type="background"]').each(function(){
backgrounds.push($(this));
} | {
"domain": "codereview.stackexchange",
"id": 4495,
"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, optimization, jquery, parallax",
"url": null
} |
javascript, jquery
//Door type 2
else if( id2 == "#Door2" && id3 == "#Grey")
{
var door = "#Door2Grey"
$("g" + door).show().siblings("g:not(#BG," + id + ")").hide();
//console.log(door);
}
else if( id2 == "#Door2" && id3 == "#Blue")
{
var door = "#Door2Blue"
$("g" + door).show().siblings("g:not(#BG," + id + ")").hide();
//console.log(door);
}
else if( id2 == "#Door2" && id3 == "#Red")
{
var door = "#Door2Red"
$("g" + door).show().siblings("g:not(#BG," + id + ")").hide();
//console.log(door);
}
//Door type 3
else if( id2 == "#Door3" && id3 == "#Grey")
{
var door = "#Door3Grey"
$("g" + door).show().siblings("g:not(#BG," + id + ")").hide();
//console.log(door);
}
else if( id2 == "#Door3" && id3 == "#Blue")
{
var door = "#Door3Blue"
$("g" + door).show().siblings("g:not(#BG," + id + ")").hide();
//console.log(door);
}
else if( id2 == "#Door3" && id3 == "#Red")
{
var door = "#Door3Red"
$("g" + door).show().siblings("g:not(#BG," + id + ")").hide();
//console.log(door);
} | {
"domain": "codereview.stackexchange",
"id": 18421,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "javascript, jquery",
"url": null
} |
javascript, reinventing-the-wheel, raphael.js, animation
sectors = [],
opacity = [],
beta = 2 * Math.PI / sectorsCount,
pathParams = {stroke: color, "stroke-width": width, "stroke-linecap": "round"};
Raphael.getColor.reset();
for (var i = 0; i < sectorsCount; i++) {
var alpha = beta * i - Math.PI / 2,
cos = Math.cos(alpha),
sin = Math.sin(alpha);
opacity[i] = 1 / sectorsCount * i;
sectors[i] = r.path([["M", cx + r1 * cos, cy + r1 * sin], ["L", cx + r2 * cos, cy + r2 * sin]]).attr(pathParams);
if (color == "rainbow") {
sectors[i].attr("stroke", Raphael.getColor());
}
}
var tick;
(function ticker() {
opacity.unshift(opacity.pop());
for (var i = 0; i < sectorsCount; i++) {
sectors[i].attr("opacity", opacity[i]);
}
r.safari();
tick = setTimeout(ticker, 1000 / sectorsCount);
})();
return function () {
clearTimeout(tick);
r.remove();
};
} I really like what you wrote there, though I am afraid at this point you ought to expand the code, not reduce it. | {
"domain": "codereview.stackexchange",
"id": 6554,
"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, reinventing-the-wheel, raphael.js, animation",
"url": null
} |
reference-request, ethics, explainable-ai
Interpretability and Explainability in Machine Learning, Harvard COMPSCI 282BR
Other resources
explained.ai blog
A Twitter thread, linking to several interpretation tools available for R
A whole bunch of resources in the Awesome Machine Learning Interpetability repo
The online comic book (!) The Hitchhiker's Guide to Responsible Machine Learning, by the team behind the textbook Explanatory Model Analysis and the DALEX package mentioned above (blog post and backstage) | {
"domain": "ai.stackexchange",
"id": 2426,
"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": "reference-request, ethics, explainable-ai",
"url": null
} |
python, html, css, flask, bootstrap-4
# If reached by get, present login form.
if request.method == "GET":
return render_template("login.html")
# If reached by post, check input and then log the user in.
if request.method == "POST":
# Ensure username was entered.
if not request.form.get("username"):
flash("Username was not entered, please enter a username.")
return render_template("/login.html")
else:
username = request.form.get("username")
# Ensure password was entered.
if not request.form.get("password"):
flash("Password was not entered, please enter password.")
return render_template("/login.html")
# Check database for username and password.
SQL = "SELECT * FROM users WHERE username = (:username)"
data = {"username": username}
rows = db.execute(SQL, data).fetchall()
# Commit & close database connection.
db_close()
# Check if password matches or if no password found in database.
if len(rows) != 1 or not check_password_hash(rows[0]["hashed_password"], request.form.get("password")):
flash("Username and/or password does not match.")
return render_template("/login.html")
# Remember user has logged in and set current cube to blank.
session["user_id"] = rows[0]["id"]
session["current_cube_id"] = 0
session["username"] = username
# Redirect to homepage.
return redirect("/")
# Logout the current user.
@app.route("/logout")
def logout():
# Forget any user_id
session.clear()
# Redirect user to login form
return redirect("/") | {
"domain": "codereview.stackexchange",
"id": 41307,
"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, html, css, flask, bootstrap-4",
"url": null
} |
Scalar script:
frac 0.5
frac -1.3
frac 1.3
3-2/13
frac 2.8461538461538463
frac pi
The decimal to fraction conversion algorithm is carried out in a few steps. The first step is to try to find an accurate representation through an optimized search method. You can control the search range using the parameter available in the application options.
To Fraction Init Search Size – Maximum number for initial search of denominator – default value 10000
## Thank you 🙂
Thank you for reading and thank you for using Scalar. If you like my app please make me a gift posting a review on Google Play store – links below.
All the best!
## 5 Replies to “✉️ Fractions support in Scalar Calculator”
1. Allan says:
Muy buena ayuda
2. This is a very helpful tutorial on how to use scalar calculator in dealing with fractions. Fraction computation is easier using this scalar calculator.
Thank you!
3. mr.N says:
please make it possible to set Epsilon in frac | {
"domain": "scalarmath.org",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.976310529389902,
"lm_q1q2_score": 0.800470505422203,
"lm_q2_score": 0.8198933447152498,
"openwebmath_perplexity": 5548.861957292421,
"openwebmath_score": 0.5089510083198547,
"tags": null,
"url": "https://scalarmath.org/mathematics/fractions-support-in-scalar-calculator/"
} |
5/11/2018,21:30:00,19.58,0.74,7.21,7.74,84.61,1.73,2.75,0.68,12.89, 5/11/2018,21:45:00,19.54,0.74,7.2,7.67,83.79,1.75,2.61,0.71,12.77. The design of the vegetable garden is based on four (Light, Height, size, companion planting) factors ., assuming that you have a small area of 12 feet X 10 feet. In this case Prob(Omnibus) is 0.062, which implies that the OLS assumption is not satisfied. R-squared: It signifies the “percentage variation in dependent that is explained by independent variables”. In OLS regression it is assumed that all the variables are directly depended on the ‘y’ variables and they do not have any co-relationship with each other. There are eight variables (X1,x2,x3 ...X8 ) independent variables and y is the dependent variables. It is useful in accessing the strength of the relationship between variables. A value between 1 to 2 is preferred. The null hypothesis under this is “all the regression coefficients are equal to zero”. Regression analysis is a statistical method used for the elimination of a relationship between a dependent variable and an independent variable. The equation for an OLS regression line is: $\hat{y}_i=b_0+b_1x_i$ On the right-hand side, we have a linear equation (or function) into which we feed a particular value of $$x$$ ($$x_i$$). Three variables have a negative relationship with the dependent variable ‘y’ and other variables have a positive relationship. A regression analysis generates an equation to describe the statistical relationship between one or more predictors and the response variable and to predict new observations. But, clearly here it seems to be a useless exercise to build this model. … This also means that the stability of the coefficients estimates will not be affected when minor changes are made to model specifications. Ordinary least-squares (OLS) regression is a generalized linear modelling technique that may be used to ... change in the deviance that results from the ... measure that indicates the percentage of variation | {
"domain": "newsreportnakhonpathominside.com",
"id": null,
"lm_label": "1. Yes\n2. Yes",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9706877726405083,
"lm_q1q2_score": 0.8046407573006413,
"lm_q2_score": 0.8289387998695209,
"openwebmath_perplexity": 898.321942536921,
"openwebmath_score": 0.4437622129917145,
"tags": null,
"url": "http://newsreportnakhonpathominside.com/overtraining-syndrome-ctkpbll/archive.php?id=ols-regression-results-explained-f40cd2"
} |
python, playing-cards
Title: Assigning card values Is there a better way to do this?
This function takes, as an argument, a natural number, n, which is between 1 and 52 inclusive and returns a list containing the point value associated with that number as an integer. The aces are the numbers 1,14,27,40 in the respective suits and they worth either 1 or 11 points. The regular cards with the numbers 2-10,15-23,28-36,41-49 in their respective suits are worth their face values. The face cards
are represented by the numbers 11-13,24-26,37-39,50-52 in their respective suits and they are each worth 10 points.
def getPoints(n):
#the ace values
if n == 1 or n == 14 or n == 27 or n == 40:
return [1,11]
#the regular card values
if 2<=n<=10:
return [n]
if n == 15 or n == 28 or n == 41:
return [2]
if n == 16 or n == 29 or n == 42:
return [3]
if n == 17 or n == 30 or n == 43:
return [4]
if n == 18 or n == 31 or n == 44:
return [5]
if n == 19 or n == 32 or n == 45:
return [6]
if n == 20 or n == 33 or n == 46:
return [7]
if n == 21 or n == 34 or n == 47:
return [8]
if n == 22 or n == 35 or n == 48:
return [9]
if n == 23 or n == 36 or n == 49:
return [10]
if 11<=n<=13 or 24<=n<=26 or 37<=n<=39 or 50<=n<=52:
return [10] Instead of making a function that maps a number from 1 to 52 you can reduce your domain to 1 to 13, and use modulo 13 to every number. That will reduce 75% of your conditions. It is done with a bit of modulo math.
Then this function becomes quite short:
def getPoints(n):
n = (n-1) % 13 + 1
#the ace values | {
"domain": "codereview.stackexchange",
"id": 22421,
"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, playing-cards",
"url": null
} |
python, optimization, performance, mathematics
Title: Python -- polynomial operations class This Python class takes a GF2 (finite field mod 2, basically binary) polynomial in string form, converts it to a binary value, then does arithmetic operations, then converts the result back into a polynomial in string form.
There are 2 parts I'd like to direct your attention to. I'll call them exhibits a and b.
For exhibit a, the regex has to be done on the string upon intake, so there were some issues with how class instances were used in terms of still allowing the string format. So that's the reason why the class is being called at the bottom. That should be invisible to the user (unless they actually go looking in the file), and when they call the class in whatever file is being used, then it should just be another class and they go on about their business. Not saying it's good coding, just saying why it looks like that. I'm sure it looks duck-taped from the professional Python coder's perspective, but for me I was pretty glad to solve it any way possible.
Also somewhat duck-taped was the modular inverse function, which I'll give as exhibit b.
I'm teaching myself Python and trying to drop all my beginner bad habits quickly. Just trying to get some good advice on the code.
import re
class gf2pim:
def id(self,lst): #returns modulus 2 (1,0,0,1,1,....) for input lists
return [int(lst[i])%2 for i in range(len(lst))]
def listToInt(self,lst): #converts list to integer for later use
result = obj.id(lst)
return int(''.join(map(str,result)))
def parsePolyToListInput(self,poly):
c = [int(i.group(0)) for i in re.finditer(r'\d+', poly)] #re.finditer returns an iterator
return [1 if x in c else 0 for x in xrange(max(c), -1, -1)] | {
"domain": "codereview.stackexchange",
"id": 4053,
"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, optimization, performance, mathematics",
"url": null
} |
special-relativity, resource-recommendations, computational-physics, simulations, software
GeoGebra: Relativity-LightClock-MichelsonMorley-2018
GeoGebra: RRGP-CoordinateSystems which uses my Relativity on Rotated Graph Paper visualizations of "light-clock diamonds".
In situations with nice numbers (e.g. $(v/c)=3/5$ or $(v/c)=4/5$ where the Doppler factor is rational, leading to triangles with Pythagrorean triples), you could graphically construct the coordinate grids on graph paper. Thus, you could learn to read off values and relationships from the diagram without having to redraw it manually or with software. (I may update this post later to give more details.) | {
"domain": "physics.stackexchange",
"id": 93263,
"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, resource-recommendations, computational-physics, simulations, software",
"url": null
} |
c#, performance, excel
Title: Extract Excel data using Interop.Excel from C# Code Objective
I need to create a System.Data.DataSet object from an Excel workbook. Each DataTable within the DataSet must correspond to a nonempty worksheet in the workbook. The top row of each sheet will be used as column names for each DataTable and the columns will be populated as the string representation of the worksheet data. The string part here is very important--everything in the final DataSet must be visually identical to what is in the Excel file with no assumptions about data types.
The Issue
My code is horrendously slow. The workbook I'm using to test my code has one worksheet which uses the Excel columns A through CO and uses rows 1 through 11361, so I don't expect it to be too blazing fast, but I finally stopped it after 20 minutes of letting it run. That's really slow, even for a big workbook.
My Goal Here
I would love your help in determining the cause of the slowness, or perhaps if there's an altogether more efficient way of going about this. My instinct was to post this to Stack Overflow, but I figured this would be a better place because the code actually works and does what I want it to do, it just does it very slowly.
The Code
I used Dylan Morley's code here for creating an Excel "wrapper" which aids with orphaned Excel processes and the release of COM objects.
namespace Excel.Helpers
{
internal class ExcelWrapper : IDisposable
{
private class Window
{
[DllImport("user32.dll", SetLastError = true)]
static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll")]
private static extern IntPtr GetWindowThreadProcessId(IntPtr hWnd,
out IntPtr ProcessID);
public static IntPtr GetWindowThreadProcessId(IntPtr hWnd)
{
IntPtr processID;
IntPtr returnResult = GetWindowThreadProcessId(hWnd, out processID);
return processID;
} | {
"domain": "codereview.stackexchange",
"id": 7440,
"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, excel",
"url": null
} |
react.js, jsx, to-do-list
"eslint-config-airbnb": "^18.2.1",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-react": "^7.21.5",
"eslint-plugin-react-hooks": "^4.0.0"
},
"keywords": [],
"description": ""
} | {
"domain": "codereview.stackexchange",
"id": 40215,
"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": "react.js, jsx, to-do-list",
"url": null
} |
c++, entity-component-system
How can the sparse set implementation be improved?
It doesn't look very sparse to begin with: you always resize mSparses[id] to maxEntityAmount()[id]. It even says so in the comment: the first member variable of SegSparseSet is an array of "Dense Sets".
Using a hash table you can also get \$O(1)\$ insertion and deletion, and \$O(N)\$ time to iterate over the \$N\$ entries it holds. Of course, it has a higher cost than your SegSparseSet.
You could also consider storing the set as a std::vector<bool>, where each bit indicates whether a given entity is in the set or not. If you keep track of the highest entity number in the set, then iterating over the set can be done quite efficiently; especially if it's not sparser than 1 in every 32 numbers being in the set, you will use the same or less memory bandwidth to scan through the items in the set.
Does it make more sense to move all of TypeSortedSS into EntityManager, and replace mSparses with a tuple of mCDS instead?
If there is a signifcant reduction in the complexity of EntityManager by moving part of that complexity into TypeSortedSS, then I would keep it like it is. Otherwise, if EntityManager is the only user of TypeSortedSS, it might indeed be better to move it into EntityManager.
Naming things
You are using various ways to abbreviate names in your code, and not all of them are clear. So of them are: | {
"domain": "codereview.stackexchange",
"id": 44389,
"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++, entity-component-system",
"url": null
} |
c++, c++11, reflection, enum, macros
Example usage:
SSVU_REFLECTED_ENUM_DEFINE_MANAGER(ReflectedEnum);
SSVU_REFLECTED_ENUM(ReflectedEnum, Colors, int, Red, Yellow, Green);
void tests()
{
assert(int(Colors::Red) == 0);
assert(int(Colors::Yellow) == 1);
assert(int(Colors::Green) == 2);
assert(ReflectedEnum<Colors>::getElementAsString(Colors::Red) == "Red");
assert(ReflectedEnum<Colors>::getElementAsString(Colors::Yellow) == "Yellow");
assert(ReflectedEnum<Colors>::getElementAsString(Colors::Green) == "Green");
}
What do you think?
Thoughts/questions:
Consider the case where the user defines custom values for the enum elements:
SSVU_REFLECTED_ENUM(ReflectedEnum, Test, int, A = -2, B = 15, C = 0);
Getting element count would still be possible, as it's easy to count variadic macro elements. However, getting an element's name as a string would require using a std::map instead of an array. Should I figure out a way to detect if the enum has custom values? Or should I ditch the array for an std::map altogheter?
Or would an alternative syntax be better? Example:
SSVU_REFLECTED_CUSTOM_ENUM(ReflectedEnum, Test, int, A, -2, B, 15, C, 0);
Maybe this would be more flexible and easier to work with.
I have macro variadic args iteration facilities in my ssvu library. Do you think it's worthwhile figuring out a way to generate the enum string elements array at compile-time with macro metaprogramming? Or is the current solution good enough? Just a few things to point out: | {
"domain": "codereview.stackexchange",
"id": 6898,
"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, reflection, enum, macros",
"url": null
} |
Your solution is almost correct (and neither $$g_1^{(k)}(x)$$ or $$g_1^{(n)}(x)$$ are wrong). The only problem is that $$(x^{n-1})^{(k)} = \frac{(n-1) !x^{n-1-k}}{(n-1-k) ! }$$ is only true for $$0 \le k \le n-1$$. For $$k \ge n$$, the $$k$$th derivative will be $$0$$. For example, the $$2$$nd derivative of $$x^1$$ is $$0$$.
The step $$f^{(n)} =\sum_{k=0}^{n}\binom{n}{k}\left(x^{n-1}\right)^{(k)}(\ln x)^{(n-k)} \tag 1$$
is right. But then at the next step, the sum should only go from $$k = 0$$ to $$k = n-1$$ since $$\left(x^{n-1}\right)^{(n)} = 0$$.
Then after that, the same logic applies, so you would end up with $$= (-1)x^{-1} (n-1) ! \sum_{k=0}^{n-1}\binom{n}{k}(-1)^{n-k} = \frac{(n-1)!}{x}$$ | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9790357549000774,
"lm_q1q2_score": 0.8321521734635825,
"lm_q2_score": 0.8499711775577735,
"openwebmath_perplexity": 256.97215566746326,
"openwebmath_score": 0.9958974719047546,
"tags": null,
"url": "https://math.stackexchange.com/questions/3950515/leibniz-formula-for-the-nth-derivative-of-fx-xn-1-ln-x"
} |
navigation, odometry, turtlebot, amcl
Title: amcl not publishing map -> odom
After trying to simulate turtlebot navigation on STDR instead of Stage, I always run into missing transforms problems and navigation cant start. I ran view_frames and put a link to the resulting pdf.
pdf file of TF tree
The particularity of STDR is that it is publishing its own map and doesnt need map_server (from what I could understand). I also had to manually add some transforms to avoid a lot of remapping,
odom -> base_footprint which is just a
copy of map_static -> robot0
and
base_link -> base_laser_link which is
a copy of robot0 -> robot0_laser_0
When I run everything, I get the following error:
Waiting on transform from
base_footprint to map to become
available before running costmap, tf
error: Could not find a connection
between 'map' and 'base_footprint'
because they are not part of the same
tree.Tf has two or more unconnected
trees.
As you can see in the pdf map is also supposed to be connected to odom, which is actually the task of AMCL. But in my case it is not. And i couldnt find out the source of the problem.
I would be very thankful for your help.
Originally posted by Mehdi. on ROS Answers with karma: 3339 on 2014-09-24
Post score: 0
Original comments
Comment by Mehdi. on 2014-09-24:
I could temporarily bypass this problem by publishing my own map -> odom as a identity transform but this would simulate a perfect odometry?
amcl generally needs 4 things at a minimum: a published map (default topic map), a laserscan source (default topic scan), valid odometry tf (default base_link->odom, and the freedom to create the transform odom->map. The last part is important because a frame can only have one parent.
This is outside all the internal algorithm parameters. It looks like you have all the essentials setup tf wise. | {
"domain": "robotics.stackexchange",
"id": 19518,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "navigation, odometry, turtlebot, amcl",
"url": null
} |
performance, image, matlab, signal-processing
subplot(2,2,4), imshow(imgD_HH, [min(min(imgD_HH)) max(max(imgD_HH))]); title('Img Deconstruction - HH filter'); | {
"domain": "codereview.stackexchange",
"id": 22080,
"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, image, matlab, signal-processing",
"url": null
} |
gazebo, exploration, turtlebot, explore, package
/move_base_simple/goal
/odom
/robot_pose_ekf/odom
/rosout
/rosout_agg
/scan
/set_hfov
/set_update_rate
/slam_gmapping/entropy
/tf
/turtlebot_node/sensor_state
/visualization_marker
/visualization_marker_array | {
"domain": "robotics.stackexchange",
"id": 14319,
"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, exploration, turtlebot, explore, package",
"url": null
} |
c#, beginner, file-system
private int ScoreTitle(string[] titleParts, string[] filenameParts, string[] directoryParts)
{
var score = filenameParts.Intersect(titleParts).Count();
if (score > 0)
{
score += directoryParts.Intersect.(titleParts).Count();
}
// if the percentage of word matches and total words in the title is > 80% (arbitrary)
// To avoid false matches with longer titles boost the score
if ((100 * score / (2 * titleParts.Length)) > 80)
{
score += 2;
}
return score;
}
private List<Category> SortFiles(List<FileInfo> allFiles, BackgroundWorker backgroundWorker)
{
List<Category> categories = new List<Category>();
int fileCount = 0;
var splitTitles = titles.Select(t => new { Title = t, Parts = SplitByRemovables(t) }).ToList();
foreach (FileInfo file in allFiles)
{
fileCount++;
var filenameParts = SplitByRemovables(Path.GetFileNameWithoutExtension(file.Name));
var directoryParts = SplitByRemovables(file.Directory.Name);
var topTitle = splitTitles.Select(t => new { Title = t.Title, Score = ScoreTitle(t.Parts, filenameParts, directoryParts) })
.OrderByDescending(x => x.Score)
.First();
var childFile = new Children(file);
if (topTitle.Score > 0)
{
var category = categories.FirstOrDefault(c => c.Name == topTitle.Title);
if (category == null)
{
category = new Category(childFile, topTitle.Title);
categories.Add(category);
}
else
{
category.AddChildren(childFile, topTitle.Title);
}
}
else
{
// Files without a score were not matched with any existing category
notSortedFiles.Add(childFile);
} | {
"domain": "codereview.stackexchange",
"id": 17960,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "c#, beginner, file-system",
"url": null
} |
c#, wpf, tic-tac-toe, xaml
<Button x:Name="BottomRight" Content="" HorizontalAlignment="Left" Margin="647,416,0,0" VerticalAlignment="Top" Width="135" Height="143" Background="#FF32BEFF" BorderBrush="#FF32BEFF" FontSize="100" FontFamily="Ubuntu" Click="BottomRightClick"/> | {
"domain": "codereview.stackexchange",
"id": 9685,
"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#, wpf, tic-tac-toe, xaml",
"url": null
} |
python
It should be noted while I could just say based on this csv it indicates these samples all have ~6 or 9 fits, I do not want any assumptions to be made. I'd like this to be flexible if the number of fits or parameters change.
At the end the of the day, I am trying to show via these plots the results for these 3 different methods of fitting. The code does work, and the output is the desired output (short of somehow connecting the pints with lines). Any assisstance in simplifying the code/cleaning it up would greatly be appreciated!
Here is the csv, it should be noted I'm not posting the whole thing cause it's quite big, but the code works just fine if you have the whole thing or only portions:
Sample,RedChi2,DoF,Variables,Solutions±Uncertanties
WT_2017
Closed_Single_Scale,11.651219458497874,1361,scaling_factor,5.289818805209734e-09±2.5333027184960425e-12
Open_Single_Scale,129.7644067034128,1361,scaling_factor,5.78352277180727e-09±9.267293505002799e-12
Monomer_Single_Scale,2800.8454801421376,1361,scaling_factor,1.237352353911092e-08±9.567271509437632e-11
Closed_Individual_Scales,3.141241032954263,1359,scaling_factor10_0,scaling_factor5_0,scaling_factor2_5,5.278888659532299e-09±2.0916648214625956e-12,2.6134330255445093e-09±1.0297600525607774e-12,1.361607049332747e-09±7.479465652276344e-13 | {
"domain": "codereview.stackexchange",
"id": 44935,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "python",
"url": null
} |
python, optimization, array, numpy, cython
Here's my rewrite of the countlower function. Note the docstring, the doctest, and the simple implementation, which loops over the sequence elements rather than their indices:
def countlower1(v, w):
"""Return the number of pairs i, j such that v[i] < w[j].
>>> countlower1(list(range(0, 200, 2)), list(range(40, 140)))
4500
"""
return sum(x < y for x in v for y in w)
And here's a 1000-element test case, which I'll use in the rest of this answer to compare the performance of various implementations of this function:
>>> v = np.array(list(range(0, 2000, 2)))
>>> w = np.array(list(range(400, 1400)))
>>> from timeit import timeit
>>> timeit(lambda:countlower1(v, w), number=1)
8.449613849865273
2. Vectorize
The whole reason for using NumPy is that it enables you to vectorize operations on arrays of fixed-size numeric data types. If you can successfully vectorize an operation, then it executes mostly in C, avoiding the substantial overhead of the Python interpreter.
Whenever you find yourself iterating over the elements of an array, then you're not getting any benefit from NumPy, and this is a sign that it's time to rethink your approach.
So let's vectorize the countlower function. This is easy using a sparse numpy.meshgrid:
import numpy as np
def countlower2(v, w):
"""Return the number of pairs i, j such that v[i] < w[j].
>>> countlower2(np.arange(0, 2000, 2), np.arange(400, 1400))
450000
"""
grid = np.meshgrid(v, w, sparse=True)
return np.sum(grid[0] < grid[1]) | {
"domain": "codereview.stackexchange",
"id": 5843,
"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, optimization, array, numpy, cython",
"url": null
} |
javascript, beginner, object-oriented
Person.prototype.defaultFirst = function(){
var first = "";
for(var i=0;i<this.fullName.length; i++){
if(this.fullName[i] !== " "){
first += this.fullName[i];
}else{
break;
}
}
return first;
};
Person.prototype.defaultLast = function(){
var last = "";
for(var i=this.fullName.length-1; i>0; i--){
if(this.fullName[i] !== " "){
last += this.fullName[i];
}else{
break;
}
}
return last.split("").reverse().join("");
};
Just so you know, undefined in JS is mutable. It's value can be changed. You could resort to using void 0 instead of undefined.
In JS, assignment operations are as good as values, equivalent to the value assigned. Also, the || acts like a "default" operation, where if the left-side value is falsy (ie, blank string, undefined, null, false, 0), the right-side value is used. And so, getFirstName (and similarly, getLastName) can be simplified into:
return this.firstName = this.firstName || this.defaultFirst();
For defaultFirst and defaultLast, essentially you're splitting by space and getting the first and last contiguous word, respectively. And so, it can be simplified using split and shift or pop:
// For first name:
return this.fullName.split(' ').shift();
// For last name:
return this.fullName.split(' ').pop(); | {
"domain": "codereview.stackexchange",
"id": 14728,
"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, object-oriented",
"url": null
} |
java, game, design-patterns, game-of-life, coordinate-system
GameMain
package nl.owlstead.gameoflife;
import java.util.regex.Pattern;
public class GameMain {
private static final Pattern POSITION_FINDER_PATTERN = Pattern.compile("[(](\\d+),(\\d+)[)]");
public static void main(String[] args) {
var builder = new Board.Builder(8, 8);
String gliderStartState = "(1,0)(2,1)(0,2)(1,2)(2,2)";
var m = POSITION_FINDER_PATTERN.matcher(gliderStartState);
while (m.lookingAt()) {
int x = Integer.parseInt(m.group(1));
int y = Integer.parseInt(m.group(2));
Position pos = new Position(x, y);
builder.makeAlive(pos);
m.region(m.end(), m.regionEnd());
}
if (!m.hitEnd()) {
throw new RuntimeException();
}
var start = builder.build();
var game = new Game(start);
do {
System.out.println(game.getCurrent());
} while (game.next());
}
} Not bad at all, therefore here's only a few things that rub me the wrong way: | {
"domain": "codereview.stackexchange",
"id": 41869,
"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, game, design-patterns, game-of-life, coordinate-system",
"url": null
} |
complexity-theory, turing-machines, computability, programming-languages, turing-completeness
Title: Explain the difference between Turing Complete and Turing Equivalence I'm not sure if I understand the difference between Turing Complete and Turing Equivalent programming languages.
A computational system that can compute every Turing-computable
function is called Turing-complete (or Turing-powerful).
A Turing-complete system is called Turing-equivalent if every function
it can compute is also Turing-computable; i.e., it computes precisely
the same class of functions as do Turing machines.
I'm not sure if I understand the difference between these two terminologies properly and what "Turing-computable" means. So for example if I have a programming language $X$, it is Turing complete if it can do any and everything that a Turing Machine can do? And it $X$ ends up being Turing complete and it can be shown that all of the functions that it computes are Turing computable, then $X$ is also Turing equivalent? A system is Turing-complete if it is at least as powerful as Turing machines.
A system is Turing-equivalent if it is exactly as powerful as Turing machines.
An example of a Turing-complete system which is not Turing equivalent is Turing machines with oracle access to an oracle for the halting problem.
One can come up with one additional definition to complete the picture: a system is effective if it is at most as powerful as Turing machines, that is, if every function computed by the system is computable by a Turing machine. | {
"domain": "cs.stackexchange",
"id": 17511,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "complexity-theory, turing-machines, computability, programming-languages, turing-completeness",
"url": null
} |
homework-and-exercises, newtonian-mechanics, rotational-dynamics
Title: What's the motion of this yoyo under external force will be? A yoyo on a horizontal table is being pulled by a string to the right, the table is not frictionless. If we only know that the object doesn't slip, how do we know if the string is winding up or unwinding? My reasoning is initially the friction is not ever effect so the force pulling the yoyo to the right will act a torque to the object such that the string is unwinding. But someone else said it should be winding up. I don't know why. I think that a sketch says more than equations and words
The yoyo will, in an infinitesimal sense, have to move around the red dot (but is kept from doing so by the table). The direction in which the yoyo will move, depends on the angle of the string, and thus the direction of torque around this touching point. | {
"domain": "physics.stackexchange",
"id": 7246,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "homework-and-exercises, newtonian-mechanics, rotational-dynamics",
"url": null
} |
human-biology, circadian-rhythms, digestive-system
Title: What influences the timing of human bowel movements in the morning? I'm trying to understand if the timing of human bowel movements in the morning is associated with the circadian rhythm, and can thus be used to make predictions about the circadian rhythm.
What influences the timing of bowel movements? Is it the timing of meals, caffeine intake or is it a biologically programmed time?
Thank you! The bowel movements are influenced by a lot of factors. For example, when you eat a meal it induces a movement in your large intestines, to defecate and clear up space for new food.
Also, there is MMC, migrating motor complex, which is responsible for the bowel movements when you are fasting. It causes a flushing effect, which prevents bacteria to overproduce in intestines.
So, the daily bowel movements are mainly influenced by the timing and content of the food that you eat. But as I said there are many other factors. The gastrointestinal system has a very complex nervous system. Even psychological factors can effect the bowel movements greatly, for example extreme physical pain may induce the symphatetic system and cause constipation.
Also caffeine may affect it, like many drugs do. | {
"domain": "biology.stackexchange",
"id": 207,
"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": "human-biology, circadian-rhythms, digestive-system",
"url": null
} |
quantum-mechanics, heisenberg-uncertainty-principle, wave-particle-duality
Also, I have a second idea that I want to present as an aside, something that I don't believe can be proven as of now, but I wonder if, according to current understanding, it is possible.
What if, instead of analyzing the situation at hand through the distance traveled, it was analyzed by analyzing the passage of time. Specifically, if time is quantized, would it resolve the dichotomy paradox in a physical sense? I realize that whether or not time is quantized is up for debate (there is even this question here at stack exchange that explores the idea), so I am not going to ask if time is quantized. Based off of my understanding, however, there is nothing known as of now that says time cannot be quantized (please correct me if I am wrong). Therefore, if time were quantized then could we not say that for a given constant velocity there is a minimum distance that can be traveled? A distance that corresponds to $\Delta t_{min} * v$? Would this not imply that as our moving box reached a certain distance, $d$ away from point B, and if $d < \Delta t_{min} * v$, the box would physically not be able to travel such a small distance, and in the next moment that the box moved, it would effectively be across the destination point B? | {
"domain": "physics.stackexchange",
"id": 11664,
"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, heisenberg-uncertainty-principle, wave-particle-duality",
"url": null
} |
quantum-chemistry, computational-chemistry, intermolecular-forces, software
Title: How to calculate Lennard-Jones potential with quantum mechanical methods I want to know the procedure to calculate the Lennard-Jones potential for a metal-halogen pair (specifically vanadium-chlorine). Is it possible to calculate using any QM packages like Mopac, NWChem, or Gaussian?
I am specifically looking for values of A and B in the 12-6 potential. Yes, this is technically possible. A basic tutorial for this is in the excellent Psi4Numpy project, which I'll reproduce here with minor modifications. Their example fits the counterpoise-corrected MP2/aug-cc-pVDZ total interaction energy of the helium dimer.
from __future__ import print_function
import psi4
import numpy as np
import matplotlib as mpl
mpl.use('Agg')
import matplotlib.pyplot as plt
he_dimer = """
He
--
He 1 **R**
"""
distances = [2.875, 3.0, 3.125, 3.25, 3.375, 3.5, 3.75, 4.0, 4.5, 5.0, 6.0, 7.0]
energies = []
for d in distances:
# Build a new molecule at each separation
mol = psi4.geometry(he_dimer.replace('**R**', str(d)))
# Compute the Counterpoise-Corrected interaction energy
en = psi4.energy('MP2/aug-cc-pVDZ', molecule=mol, bsse_type='cp')
# Place in a reasonable unit, Wavenumbers in this case
en *= 219474.6
# Append the value to our list
energies.append(en)
print("Finished computing the potential!")
# Fit data in least-squares way to a -12, -6 polynomial
powers = [-12, -6]
x = np.power(np.array(distances).reshape(-1, 1), powers)
coeffs = np.linalg.lstsq(x, energies)[0] | {
"domain": "chemistry.stackexchange",
"id": 8432,
"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-chemistry, computational-chemistry, intermolecular-forces, software",
"url": null
} |
javascript, jquery, ajax
Title: Return fake jqXHR from custom Ajax method I have several methods that wrap the $.ajax() method and return its jqXHR, but I need to force fail before even calling the original $.ajax() and still allow to use success/error methods of the result.
//just a very simple example, actuall code is more complicated
$.rpc = function(method, args) {
if (!method || 'string' === typeof method ||) {
return false; //PROBLEM - cannot use success/error handlers!
}
return $.ajax({
type: 'POST',
url: '/rpc',
data: { method: method, params: args },
}); //AJAX()
};
//usage:
$.rpc(loginMethod, credentials).success(gotoProfile).fail(gotoLogin);
//if loginMethod is for any reason undefined it crash instead of calling fail handler
So I use this helper method, since the jqXHR is created directly inside the Ajax method:
$.ajax.getFailed = function(message) {
var
jqDef = new $.Deferred(),
jqXHR = jqDef.promise();
jqXHR.success = jqXHR.done; //deprecated $.ajax methods
jqXHR.error = jqXHR.fail;
jqDef.reject.defer(1, jqXHR, [jqXHR, message]);
//defer is from extJS, alternative to setTimeout
return jqXHR;
};
$.rpc = function(method, args) {
if (!method || 'string' === typeof method ||) {
return $.ajax.getFailed('Missing method');
}
return $.ajax({
type: 'POST',
url: '/rpc',
data: { method: method, params: args },
}); //AJAX()
}; | {
"domain": "codereview.stackexchange",
"id": 12552,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "javascript, jquery, ajax",
"url": null
} |
pcl, pcl-1.7, ros-indigo
-- looking for PCL_VISUALIZATION
-- Found PCL_VISUALIZATION: /usr/local/lib/libpcl_visualization.so
-- looking for PCL_REGISTRATION
-- Found PCL_REGISTRATION: /usr/local/lib/libpcl_registration.so
-- looking for PCL_KEYPOINTS
-- Found PCL_KEYPOINTS: /usr/local/lib/libpcl_keypoints.so
-- looking for PCL_RECOGNITION
-- Found PCL_RECOGNITION: /usr/local/lib/libpcl_recognition.so
-- looking for PCL_PEOPLE
-- Found PCL_PEOPLE: /usr/local/lib/libpcl_people.so
-- looking for PCL_OUTOFCORE
-- Found PCL_OUTOFCORE: /usr/local/lib/libpcl_outofcore.so | {
"domain": "robotics.stackexchange",
"id": 23739,
"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": "pcl, pcl-1.7, ros-indigo",
"url": null
} |
ros, ros-kinetic
in order, define:
The location of the image
The resolution meters/pixels (This is based on how you choose to draw the image)
0,0,0 (origin) of your map (set this number to where ever your robot will consistently start in your drawn map) (or you could initialize your robots pose at a point other than map origin)
The % that occupied is defined as (leave this default if your map is black and white)
The % that free is defined as (leave this default if your map is black and white)
Leave this default as if true inverts occupied and free
The restriction of not having environmental sensory data will affect navigation in that you won't have dynamic avoidance. You are restricted to what ever map you draw. Ensure you represent your environment accurately or you might collide with obstacles and ensure you have not added obstacles.
Using a global planner your path will be generated to navigate the environment you have specified in your OGM. The local control is where sensory data is usually important. If you use a blank costmap then a local planner will control a local path to achieve the global plan without dynamic avoidance. Without dynamic information of obstacles, the navigation will assume there are no obstacles and will control the robot to achieve the global plan which has already accounted for the static obstacles you have defined in your OGM.
I can understand that a LIDAR might be expensive however I have personally chosen to use an Xbox Kinect as it is rather cheap and can sense a 3D environment. You do not have to use 3D environments if you choose this path and can squash everything to 2D.
Please consider choosing an answer :)
Originally posted by PapaG with karma: 161 on 2019-08-15
This answer was ACCEPTED on the original site
Post score: 1 | {
"domain": "robotics.stackexchange",
"id": 33608,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "ros, ros-kinetic",
"url": null
} |
database, snp, public-databases, human-genome
Title: Question about public availability of human SNP dataset with country of origin Is there a publicly available data set for humans SNPs, preferably together with the country of origin? If so, could someone please point me towards it.
I've looked through other questions on the site and have been unable to find a similar one. I don't know how sensitive human SNP data is, so I'm not sure if this would be public. 1000 genomes, HGDP and SGDP all contain SNP data from individuals where the country of origin is known.
They all have slightly different numbers of people from different populations (1000 genomes and HGDP have more individuals in each pop, but fewer pops, and SGDP is the opposite). | {
"domain": "bioinformatics.stackexchange",
"id": 1747,
"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": "database, snp, public-databases, human-genome",
"url": null
} |
homework-and-exercises, newtonian-mechanics, forces, friction, acceleration
Title: Finding minimal velocity for which block can travel to the end of the plank
A plank of length $L$ and mass $M$ is placed on the ground such that there is no friction between the plank and the ground. A small block with mass $m$ is placed on one side of the plank. Friction between block and plank is $\mu$. At point $t=0$ block has some velocity $v_0$. What is the minimal $v_0$ such that block can travel to the end of the plank?
There is an image for easier understanding. | {
"domain": "physics.stackexchange",
"id": 34455,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "homework-and-exercises, newtonian-mechanics, forces, friction, acceleration",
"url": null
} |
vacuum
Title: Why is space a vacuum? Why is space a vacuum ? Why is space free from air molecules ?
I heard that even space has a small but finite number of molecules. If so, won't there be a drag in space?
Why is space a vacuum ?
Because, given enough time, gravity tends to make matter clump together. Events like supernovae that spread it out again are relatively rare. Also space is big. Maybe someone could calculate the density if visible matter were evenly distributed in visible space. I imagine it would be pretty thin.
(Later)
Space is big. Really big. You just won't believe how vastly, hugely, mind-bogglingly big it is. I mean, you may think it's a long way down the road to the chemist's, but that's just peanuts to space.
Douglas Adams, Hitchiker's guide to the galaxy.
According to Wikipedia, the observable universe has a radius of 46.6 billion light years and contains about $10^{53}$ kg of matter.
One light year is about $9.5 \times 10^{15} m$ - so that is a radius of roughly $4.4 \times 10^{24} m$ and a volume of roughly $2.73 \times 10^{80} m^3$ So that means a density of $0.366 \times 10^{-27} kg/m^3$
If that matter were all Hydrogen, which has $6 \times 10^{26}$ atoms per kg, that would give us around $0.2$ atoms per $m^3$.
So if my horrible calculations are any guide (and I'm very likely to have made an error), space is a vacuum mostly because the amount of matter in the observable universe is negligible.
Why is space free from air molecules ?
Well, air is what we call the mix of gases in Earth's atmosphere, so this is a question about space near Earth specifically.
Air is mostly molecular Nitrogen and Oxygen - $N_2$ and $O_2$. These are heavy enough that not many of them escape Earth's gravity. Also, space is big.
I heard that even space has a small but finite number of molecules. If so, Wont there be a drag in space?
According to WIkipedia: | {
"domain": "physics.stackexchange",
"id": 18029,
"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": "vacuum",
"url": null
} |
c#, async-await, rubberduck
State.SetModuleState(vbComponent, ParserState.Parsed);
}
private IParseTree ParseInternal(string code, IEnumerable<IParseTreeListener> listeners, out ITokenStream outStream)
{
var input = new AntlrInputStream(code);
var lexer = new VBALexer(input);
var tokens = new CommonTokenStream(lexer);
var parser = new VBAParser(tokens);
parser.AddErrorListener(new ExceptionErrorListener());
foreach (var listener in listeners)
{
parser.AddParseListener(listener);
}
outStream = tokens;
return parser.startRule();
}
private void declarationsListener_NewDeclaration(object sender, DeclarationEventArgs e)
{
_state.AddDeclaration(e.Declaration);
}
private void ResolveReferences(VBComponent component, IParseTree tree, CancellationToken token)
{
if (_state.GetModuleState(component) != ParserState.Parsed)
{
return;
}
_state.SetModuleState(component, ParserState.Resolving);
var declarations = _state.AllDeclarations;
var resolver = new IdentifierReferenceResolver(new QualifiedModuleName(component), declarations);
var listener = new IdentifierReferenceListener(resolver, token);
var walker = new ParseTreeWalker();
walker.Walk(listener, tree);
_state.SetModuleState(component, ParserState.Ready);
}
private class ObsoleteCallStatementListener : VBABaseListener
{
private readonly IList<VBAParser.ExplicitCallStmtContext> _contexts = new List<VBAParser.ExplicitCallStmtContext>();
public IEnumerable<VBAParser.ExplicitCallStmtContext> Contexts { get { return _contexts; } } | {
"domain": "codereview.stackexchange",
"id": 17389,
"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#, async-await, rubberduck",
"url": null
} |
signal-analysis, continuous-signals, signal-detection, cross-correlation
Title: "Perfect waveform" for cross-correlations? I am well versed in cross-correlations, as my masters thesis heavily relied on them for music classification and beat detection. So this question focuses more on the signals that I am running an xcorr on as opposed to the actual cross correlation process.
Here is a simplified version of my setup:
Suppose I have the original signal, which I time shift the signal (add a delay), and add noise/distort the signal. Then I run a cross-correlation on the two signals to find this time delay and get some value of R.
Is there some formulation to come up with a signal that will reduce ambiguity errors and optimize my value of R?
I know it will be some non-repeating, pseudo-random signal, but is there a formal formulation for this? Or should I be looking at other techniques?
Perhaps something like this would be perfect: http://tedxtalks.ted.com/video/TEDxMIAMI-Scott-Rickard-The-Wor. You see any issues with this?
I'm not talking about cross correlation processing techniques to improve the performance. I'm strictly talking about the shape of the waveform Finally, I found the answer I was looking for! A whole host of sequences have been analyzed and discussed in terms of their auto- and cross-correlation properties in the following thesis.
De Bruijn Sequences in Spread Spectrum Systems: Problems and Performance in Vehicular Applications by Stefano Andrenacci
(http://www.openarchive.univpm.it/jspui/bitstream/123456789/472/1/Tesi.Andrenacci.pdf)
Here are the possible candidates. I will have to research them further, but I will surely go with one of these:
M-Sequences
Gold Sequences
Chaos-Based Sequences
Kasami Sequences
OVSF Sequences
De Bruijn Sequences
The author advocates De Bruijn Sequences, but I believe my case is mmost suited towards an M-Sequence. | {
"domain": "dsp.stackexchange",
"id": 2224,
"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": "signal-analysis, continuous-signals, signal-detection, cross-correlation",
"url": null
} |
homework-and-exercises, electricity
Title: Derive that $P = I^2R$ As our homework, we were asked to derive $P = I^2R$.
Now, I started off with the basic relation $P = \frac{W}{T}$. I was not able to think of anything from here, so I started plugging in random formulas from a purely algebraic point of view.
I tried the one for voltage $V = \frac{W}{q} \implies Vq = W$ and got $P = \frac{Vq}{T}$. And since $I = \frac{q}{T}$, $IT = q$, plugging this in we get $P = IV$. A simple application of Ohm's Law gives us the required equation. But, when I tried to get an intuitive grasp of what I'd just done, I found a few discrepancies:
In the definition of voltage, $W$ refers to the energy an electron loses when it goes from the negative to the positive terminal. In the definition of power, $W$, refers to the total energy consumed by the appliances. How can you relate the two?
In the definition of current $T$, refers to the time taken by the electron to go from one terminal to the other, whereas, in power $T$ refers to the time for which the appliances run or the energy is supplied. How can these two be the same? | {
"domain": "physics.stackexchange",
"id": 46099,
"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, electricity",
"url": null
} |
16. Aug 26, 2013
### cdux
That makes perfect sense.
Per the first reply, doesn't continuity play a role?
17. Aug 26, 2013
### LCKurtz
Yes, it plays a role in the particular argument that was given. But they could have used other arguments. Any logical argument at all that shows that $\rho=0$ would do. Just like in my simpler example, you could have used other values of x and y.
Your original problem could probably be worked by choosing particular x and y also. It's just that you would need a calculator to work it out, where the limit argument they gave is "simpler" that way.
18. Aug 26, 2013
### LCKurtz
Actually, why don't you try $x=1,~y=1$ in your problem. See that you can get $\rho=0$ out of that. It's easy.
19. Aug 26, 2013
### D H
Staff Emeritus
That's not quite right. One has to show that ρ=0 is a solution under all circumstances *and* that this is the only solution under all circumstances. The first condition is trivial to prove; just substitute ρ=0 and you get 1=1. The second condition is where the given proof comes into to play. If there is some circumstance where the only solution is the trivial solution ρ=0, then that's all one needs.
20. Aug 26, 2013
### D H
Staff Emeritus
How about ρ ≈ -1.47767 and ρ ≈ 2.51286? Both of are also solutions to eρxy=(1+ρx)(1+ρy) at x=y=1. The problem is that these non-trivial solutions for this specific x,y pair are not valid for all x,y>0. Use some other values of x and y and the equality no longer holds. | {
"domain": "physicsforums.com",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.952574122783325,
"lm_q1q2_score": 0.8019013255771008,
"lm_q2_score": 0.8418256452674008,
"openwebmath_perplexity": 644.5358633187326,
"openwebmath_score": 0.7939848899841309,
"tags": null,
"url": "https://www.physicsforums.com/threads/how-is-that-always-proven.707188/"
} |
javascript, strings, regex
Title: JavaScript function to convert underscore-case to camel-case (and vice-versa) Actually I needed a function which converts underscore to camel-case.
But then I've had the idea: Why not extend the function so, that is works the other way around?
Finally I recalled that there is a third case which programmers use: Pascal-Case. So I included that too.
The function doesn't work perfect but as long as the different cases are used as expected it works alright.
Any hints and suggestions concerning improvements are welcomed.
/**
* Converts a string to either underscore-case or camel-case or
* to pascal-case.
* @param {string} toChange
* @param {string} [toCase='toUnderscoreCase'] - Options:
* 'toUnderscoreCase' | 'toCamelCase' | 'toPascalCase'
* @returns {string} according toCase-param.
* Returns an empty string in case of error.
*/
function changeCase(toChange, toCase) {
var needle = null;
var funct = null;
var needleChangingUpperLower = /[a-z0-9]_[a-z0-9]/g;
var needleToUnderscore = /(([a-zA-Z0-9]*?)(([a-z0-9][A-Z]))|([a-zA-Z0-9]*)$)/g;
toCase = toCase || 'toUnderscoreCase'
if ( !toChange ||
typeof toChange !== 'string' ||
toChange.length < 2 ) {
return '';
}
if (toChange.search(/[^\w]/g) > -1) {
return '';
}
function toChangingUpperLower(match) {
var chars = match.split('_');
return chars[0] + chars[1].toUpperCase();
}
function toUnderscore(match, wordComplete, wordTruncated, wordChange) {
var ret = '';
if (wordChange) { | {
"domain": "codereview.stackexchange",
"id": 19608,
"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, strings, regex",
"url": null
} |
numerical-methods, verilog, fpga
reg[7:0] yregone;
reg[7:0] yregtwo;
reg[7:0] innerSumOutput;
reg[7:0] innerSum;
function [7:0] multiply;
input [7:0] a;
input [7:0] b;
reg [15:0] a1, a2, a3, a4, a5, a6, a7, a8;
begin
a1 = (b[0]==1'b1) ? {8'b00000000, a} : 16'b0000000000000000;
a2 = (b[1]==1'b1) ? {7'b0000000, a, 1'b0} : 16'b0000000000000000;
a3 = (b[2]==1'b1) ? {6'b000000, a, 2'b00} : 16'b0000000000000000;
a4 = (b[3]==1'b1) ? {5'b00000, a, 3'b000} : 16'b0000000000000000;
a5 = (b[4]==1'b1) ? {4'b0000, a, 4'b0000} : 16'b0000000000000000;
a6 = (b[5]==1'b1) ? {3'b000, a, 5'b00000} : 16'b0000000000000000;
a7 = (b[6]==1'b1) ? {2'b00, a, 6'b000000} : 16'b0000000000000000;
a8 = (b[7]==1'b1) ? {1'b0, a, 7'b0000000} : 16'b0000000000000000;
multiply = a1 + a2 + a3 + a4 + a5 + a6 + a7 + a8;
end
endfunction
always @(posedge CLK)
begin
yregtwo <= yregone;
yregone <= SIGNAL; | {
"domain": "codereview.stackexchange",
"id": 35342,
"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": "numerical-methods, verilog, fpga",
"url": null
} |
newtonian-mechanics, newtonian-gravity, estimation, tidal-effect
Title: Given that the Moon affects tides and most of the human body is water, do tides affect people? It is known that the Moon causes tides. Given that the human body is 60%-70% water, is there any research that shows that the tides affect humans in any tangible way?
If this is not the appropriate place to ask, then please let me know a more appropriate place to ask? The gravitational attraction between two masses $m_1$, $m_2$ with distance $r$ can be calculated by
$$F_G = G \frac{m_1 m_2}{r^2},$$
where $G$ is the gravitational constant. The average distance of the moon to earth is around $r^\prime=384402 km$ but because we are at the surface of the earth, we will gladly substract $6400km$ from it. Assuming you have a mass of $m_1=80kg$ and the moon's mass is $m_2=7.342 \cdot 10^{22}kg$ we arrive at
$$F_G = 2.744 mN.$$
This is about the same attraction you'd experience if you'd stand 2m in front of a space shuttle (thanks to Wolfram Alpha).
So the answer is: No, you are not affected in any tangible way. | {
"domain": "physics.stackexchange",
"id": 94962,
"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, newtonian-gravity, estimation, tidal-effect",
"url": null
} |
quantum-mechanics, decoherence, density-operator
where $B=\ln(1/I)$.
To make the off-diagonal entries of the density matrix vanish or almost vanish after some time, the entanglement with the environmental degrees of freedom is essential. If the two subsystems were not entangled, in other words, if the total pure state were a tensor product $|a\rangle\otimes |R\rangle$, the tracing over the $R$ degrees of freedom would give you the pure density matrix $|a\rangle\langle a|$ back: the system $R$ would have no effect on the system $a$ because of the lack of entanglement (lack of correlation).
You may read about decoherence e.g. at pages 9-16 here: | {
"domain": "physics.stackexchange",
"id": 6658,
"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, decoherence, density-operator",
"url": null
} |
machine-learning, deep-learning, self-study, books
To sum it up: how can I 'escape' this beginner area and become a next-level data scientist/ml engineer? A one that can bring something unique to the table, other than doing the basic and obvious stuff for each problem.
I would really appreciate any advice on this. Thanks in advance. There's a good chance that your question will be closed I'm afraid, but here are a few thoughts: | {
"domain": "datascience.stackexchange",
"id": 9616,
"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, self-study, books",
"url": null
} |
quantum-field-theory, path-integral, correlation-functions, propagator, klein-gordon-equation
consider a correlation function
$$
\langle{P(\Phi)}\rangle= \frac 1 Z \int d[\Phi] P(\Phi)e^{-S[\Phi]}.
$$
The functional integral over $\Phi$ should be unaffected by a linear shift in the integration variables $\phi_i(x) \to \phi_i(x) +\delta \phi_i(x)$. We therefore have
$$
0= \frac 1 Z \int d[\Phi] \left\{\int \delta \phi_i(x) \left(\frac{\delta P}{\delta \phi_i(x)} - P(\Phi) \frac{\delta S}{\delta \phi_i(x)}\right)d^d x\right\} e^{-S[\Phi]},
$$
and hence
$$
0=\left\langle \int \delta \phi_i(x) \left(\frac{\delta P}{\delta \phi_i(x)} - P(\Phi) \frac{\delta S}{\delta \phi_i(x)}\right)d^d x\right\rangle
$$
for any $\delta\phi_i(x)$. So, for each point $x$ and field $\phi_i$, we have
$$
\left\langle \frac{\delta P}{\delta \phi_i(x)}\right\rangle= \left\langle P(\Phi) \frac{\delta S}{\delta \phi_i(x)}\right\rangle,
$$
which is the quantum counterpart of the classical equation of motion$$
\frac{\delta S}{\delta \phi_i(x)}=0.
$$
When the fields in $P= \phi(x_1)\phi(x_2) \cdots \phi(x_n)$ are bosonic
$$ | {
"domain": "physics.stackexchange",
"id": 100025,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "quantum-field-theory, path-integral, correlation-functions, propagator, klein-gordon-equation",
"url": null
} |
r, regression, machine-learning-model, logistic-regression
Title: Trying to perform elastic-net regression in R I am new to R and Elastic-Net Regression Model. I am running Elastic-Net Regression Model on the default dataset, titanic. I am trying to obtain the Alpha and Lambda values after running the train function. However when I run the train function, the output keeps on lagging and I had to wait for the output but there is no output at all. it is empty.... I am trying Tuning Parameters.
data(Titanic)
example<- as.data.frame(Titanic)
example['Country'] <- NA
countryunique <- array(c("Africa","USA","Japan","Australia","Sweden","UK","France"))
new_country <- c()
#Perform looping through the column, TLD
for(loopitem in example$Country)
{
#Perform random selection of an array, countryunique
loopitem <- sample(countryunique, 1)
#Load the new value to the vector
new_country<- c(new_country,loopitem)
}
#Override the Country column with new data
example$Country<- new_country
example$Class<- as.factor(example$Class)
example$Sex<- as.factor(example$Sex)
example$Age<- as.factor(example$Age)
example$Survived<- as.factor(example$Survived)
example$Country<- as.factor(example$Country)
example$Freq<- as.numeric(example$Freq)
set.seed(12345678)
trainRowNum <- createDataPartition(example$Survived, #The outcome variable
#proportion of example to form the training set
p=0.3,
#Don't store the result in a list
list=FALSE);
# Step 2: Create the training mydataset
trainData <- example[trainRowNum,]
# Step 3: Create the test mydataset
testData <- example[-trainRowNum,] | {
"domain": "datascience.stackexchange",
"id": 10609,
"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": "r, regression, machine-learning-model, logistic-regression",
"url": null
} |
quantum-mechanics, quantum-field-theory, mathematical-physics, path-integral, research-level
For P1, imposing positivity order by order, e.g., truncating the series at some $n$ is very bad. For $n$ odd, one has a polynomial of odd degree which will take negative values. I think P1 and P2 require a summation procedure, i.e., going from $\mathbb{R}[[g]]$ to $\mathbb{R}$. One could define P3 as just the positivity of the zero-th order term but this seems too coarse.
Finally, note that there has been recent work on violation of unitarity in QFTs in non integer dimension (see this article). I didn't look at it, but I suspect they must have addressed this positivity issue somehow. | {
"domain": "physics.stackexchange",
"id": 46614,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "quantum-mechanics, quantum-field-theory, mathematical-physics, path-integral, research-level",
"url": null
} |
c#, beginner
Console.Read();
}
} You are very much correct that switch statements cannot take boolean operators like that: switch statements are used to build jump tables, and can only use constants to do so. However, you can easily come up with a fairly robust solution to your problem using a Dictionary and some LINQ.
Since you tagged your question beginner I'll be gentle with the explanation.
The first thing we'll do is make a Dictionary<int, string> which represents the lowest value associated with each grade.
var gradeMap = new Dictionary<int, string>
{
[0] = "X",
[201] = "A",
[401] = "B",
[801] = "Z",
};
So, this means if the value is >= 801, then it's Z, and so on.
Next, we'll simply one-line this entire operation in LINQ:
gradeMap.OrderByDescending(x => x.Key).FirstOrDefault(x => x.Key <= testWeight).Value
What's happening here? LINQ is Language Integrated Query, if you've ever worked with SQL you might recognize the Query bit, essentially, LINQ allows you to build code which looks and act's like a query against an IEnumerable object (which Dictionary is).
So if we take this step-by-step, we can start with our dictionary as follows:
0: X
201: A
401: B
801: Z
The gradeMap.OrderByDescending(x => x.Key) bit will first take the entire gradeMap dictionary, and order it by the key value in highest-to-lowest order:
801: Z
401: B
201: A
0: X
Next, we do a FirstOrDefault(x => x.Key <= testWeight), which will loop through all the elements (in the backwards order we have them) that are in the dictionary, and find the first one that matches our expression (x.Key <= testWeight). The x.Key is the reference to the key of the dictionary (our int values):
801: Z (Skipped)
401: B (Skipped)
201: A (Matched) | {
"domain": "codereview.stackexchange",
"id": 22775,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "c#, beginner",
"url": null
} |
y= 2x+ 5 in polar coordinates. Equations of Motion In two dimensional polar rθ coordinates, the force and acceleration vectors are F = F re r + F θe θ and a = a re r + a θe θ. Here we derive equations for velocity and acceleration in polar coordinates and then we solve a few problems. The Lagrangian [mat. Each point P in the plane can be assigned polar coordinates r,! ( ) as follows: r is the directed distance from O to P and ! is the directed angled, counterclockwise from polar axis to segment ! OP. To apply equations of motion (Newton’s 2nd law) to solve particle kinetic problems using cylindrical coordinates. Convert the Cartesian coordinates defined by corresponding entries in matrices x and y to polar coordinates theta and rho. where ( h, k) is the center of the circle and r is its radius. Equation (2. When I integrate in polar coordinates I just get circles. Polar coordinates describe a point P as the intersection of a circle and a ray from the center of that circle. Ask Question Asked 26 days ago. Polar Coordinates Polar coordinates are an alternative to Cartesian coordinates for describing position in R2. Arc length and surface area of parametric equations. Exercises 1-18 give parametric equations and parameter intervals for the motion of a particle in the xy-plane. Polar coordinates describe a point P as the intersection of a circle and a ray from the center of that circle. Find intersections of polar equations, and illustrate that not every intersection can be obtained algebraically (you may have to graph the curves). Conic Sections and Polar Coordinates. Processing • ) - - - - - - - - - - - -. And so this is what the velocity and acceleration look like. Polar Derivatives. E) Toss up between B and C. 7 Two-Dimensional Polar Coordinates • Although Newton’s 2nd law takes a simple form in Cartesian coordinates, there are many circumstances where the symmetry of the problem lends itself to other coordinates. the equation of motion for inviscid flow. Identify the particle's path by finding a Cartesian equation for it. In its basic form, Newton's Second Law states that the sum of the forces on a body will be equal to mass of that body times the rate of. To apply equations of motion (Newton’s 2nd law) to solve particle kinetic problems using cylindrical coordinates. POLAR COORDINATES AND CELESTIAL MECHANICS | {
"domain": "metrokaralis.it",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.990140142659816,
"lm_q1q2_score": 0.8251081316348945,
"lm_q2_score": 0.8333245932423308,
"openwebmath_perplexity": 406.21296170265595,
"openwebmath_score": 0.9168432354927063,
"tags": null,
"url": "http://dyyx.metrokaralis.it/equation-of-motion-in-polar-coordinates.html"
} |
php, object-oriented
<tr class='row2'>
<td style='width: 50%'><strong>From E-mail:</strong><br />Enter the sender's e-mail address in this field.</td>
<td><input type="text" class="input_text" name="senderEmail" id="senderEmail" value="<?php if (isset($_POST['senderEmail'])) { echo $_POST['senderEmail']; } ?>" size="50" maxlength="125" /></td>
</tr>
<tr class='row1'>
<td style='width: 50%'><strong>Recipient:</strong><br />Enter the recipient's e-mail address in this field.</td>
<td><input type="text" class="input_text" name="recipient" id="recipient" value="<?php if (isset($_POST['recipient'])) { echo $_POST['recipient']; } ?>" size="50" maxlength="125" /></td>
</tr>
<tr class='row2'>
<td style='width: 50%'><strong>Carbon Copy:</strong><br />Send a copy to someone else? Enter another e-mail address here. Leave blank for no copy.</td>
<td><input type="text" class="input_text" name="copy" id="copy" value="<?php if (isset($_POST['copy'])) { echo $_POST['copy']; } ?>" size="50" maxlength="125" /></td>
</tr> | {
"domain": "codereview.stackexchange",
"id": 6612,
"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, object-oriented",
"url": null
} |
organic-chemistry, reaction-mechanism, radicals
30 % / 6 = 5 % → 1-chloro-2-methylbutane
15 % / 3 = 5 % → 1-chloro-3-methylbutane
Thus, 2-chloro-2-methylbutane is indeed slightly preferred – as you have expected. | {
"domain": "chemistry.stackexchange",
"id": 2918,
"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": "organic-chemistry, reaction-mechanism, radicals",
"url": null
} |
here is my solution, is it correct aswell?
$\displaystyle G \equiv |Z(G)| (mod p)$ since Z(G) is a fixed point set.
Now $\displaystyle |Z(G)| \equiv p^n(mod p)$, |Z(G)|=0.
So Z(G) has atleast p elements.
Let $\displaystyle G$ act on itself by conjugation (i.e. $\displaystyle X=G$ and $\displaystyle g*x = gxg^{-1}$). Also $\displaystyle G$ is a finite $\displaystyle p$-group which fits the above result thus $\displaystyle |G| \equiv |G^G| (\bmod p)$ but $\displaystyle G^G = \text{Z}(G)$ because that is the subset left fixed under conjugation. Thus, $\displaystyle |G| \equiv |\text{Z}(G)|(\bmod p)$ which means the center needs to be divisible by $\displaystyle p$, i.e. it cannot be trivial.
8. Originally Posted by joanne_q
for part (iii) i believe you have proved the opposite of the question? i.e. G/Z(G) is cyclic and thus abelian...
to prove that it is non cyclic, do all the points you stated have to be contradicted..?
No, there is no contradiction argument. I proved the contrapositive statement. | {
"domain": "mathhelpforum.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9755769071055403,
"lm_q1q2_score": 0.8576752812496851,
"lm_q2_score": 0.8791467643431002,
"openwebmath_perplexity": 236.2139222347338,
"openwebmath_score": 0.9514423608779907,
"tags": null,
"url": "http://mathhelpforum.com/advanced-algebra/29103-centre-group-z-g.html"
} |
php, laravel
protected function addToPreOrdersTable(string $hash)
{
$this->cartCollection();
OrderService::createPreOrder($this->contents, $hash, 'buy');
}
}
Services/PaymentServiceInterface.php
interface PaymentServiceInterface {
run(Request $request);
}
ExternalService/ExternalPaymentService.php
class ExternalPaymentService {
public function send(Request $request, $tkey)
{
$this->cartCollection();
$availableMethods = ['mb', 'mbw', 'cc', 'dd']; | {
"domain": "codereview.stackexchange",
"id": 45040,
"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, laravel",
"url": null
} |
cc.complexity-theory, complexity-classes, counting-complexity, reductions, probabilistic-complexity
Title: #P- vs PP-Completeness Suppose $A$ is any #P-complete problem. Now, $A$ is modified to obtain a decision problem $A'$ not by asking whether there is a solution but whether at least half of the potential solutions are actually true solutions. Question: Is $A'$ PP-complete?
This works if $A$ is #Sat, since MajSat is PP-complete. My approach so far: If $A$ is #P-complete, then there is a reduction from #Sat. So it should be possible to adapt this reduction to obtain a reduction from MajSat to $A'$. However, I ran into the problem that the reduction from #Sat to $A$ often requires a Turing (or Cook) reduction and it seemed far from clear how to obtain a many-one reduction from it. Not necessary. Imagine the following Fake-#SAT problem: possible solutions are extended by one bit, and all vectors with this bit set are solutions. That is, the number of satisfying assignments for the new problem is $2^n+f$, where $f$ is the number of satisfying assignments for the original #SAT problem ($0\le f\le 2^n$).
The problem remains #P-complete; however, the corresponding "majority" problem (formulates as $\ge$ vs $<$) has always the answer "yes". | {
"domain": "cstheory.stackexchange",
"id": 3175,
"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": "cc.complexity-theory, complexity-classes, counting-complexity, reductions, probabilistic-complexity",
"url": null
} |
general-relativity, black-holes, observers
Title: Is the observation of an observer local in general relativity? Taking Schwarzschild spacetime as an example, an observer at infinity can observe events happened in his neighbourhood at infinity and measure the corresponding physical quantities. I want to know whether the observer at infinity can observe events happened at finite $r$. No, the Schwarzschild observer is not a local observer. The observer at infinity is an idealised observer. An observer actually at an infinite distance would be useless because it would take infinite time for them to receive information from any finite $r$. To explain this observer, we need to invoke the concept of limits from calculus. We put the observer at a finite $r$ which is sufficiently far from $r=0$ that spacetime is almost flat, and then in the limit as $r\to\infty$ spacetime curvature approaches zero, and our finite observer approaches the observer at infinity.
However, the Schwarzschild observer does not directly observe events. Instead, they correlate events observed by local observers. A good description of this procedure is given in the Wikipedia article on Gullstrand–Painlevé coordinates. This article first explains Schwarzschild coordinates so that it can then describe how Gullstrand–Painlevé coordinates differ from them.
Schwarzschild coordinates
A Schwarzschild observer is a far observer or a bookkeeper. He does not directly make measurements of events that occur in different places. Instead, he is far away from the black hole and the events. Observers local to the events are enlisted to make measurements and send the results to him. The bookkeeper gathers and combines the reports from various places. The numbers in the reports are translated into data in Schwarzschild coordinates, which provide a systematic means of evaluating and describing the events globally. Thus, the physicist can compare and interpret the data intelligently. | {
"domain": "physics.stackexchange",
"id": 67587,
"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, black-holes, observers",
"url": null
} |
Boundary conditions (How do I correctly obtain the second and third conditions, viz., $c_3, c_4$)
Subscript[Γ, d1] = DirichletCondition[0, r == a]
Subscript[Γ, n1] = NeumannValue[0, r == a]
Subscript[c, 3] = -(Derivative[1][w][b]/b^2) + (w^′′)[
b]/b +
\!$$\*SuperscriptBox[\(w$$,
TagBox[
RowBox[{"(", "3", ")"}],
Derivative],
MultilineFunction->None]\)[b]
Subscript[c, 4] = (ν Derivative[1][w][b])/
b + (w^′′)[b]
Application of Boundary conditions in NDSolve for my domain $\Omega$ (UNABLE TO ACCOMPLISH THIS)
sol = NDSolve[
{
w''''[r] + (2/r) w'''[r] - (1/(r^2)) w''[r] + (1/(r^3)) w'[
r] == -p0/De,
Subscript[Γ, d1] == 0,
Subscript[Γ, n1] == 0,
-(Derivative[1][w][b]/b^2) + Derivative[2][w][b]/b +
Derivative[3][w][b] == 0,
(ν Derivative[1][w][b])/b + Derivative[2][w][b] == 0
},
w, r ∈ Ω,
Method -> {"FiniteElement", "InterpolationOrder" -> 2,
"MeshOptions" -> {"MaxCellMeasure" -> 0.5,
"MaxBoundaryCellMeasure" -> 0.02}}
]
The FEM parameters chosen in NDSolve are not very well thought of currently and I am open to suggestions. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.965899575269305,
"lm_q1q2_score": 0.8285178482894977,
"lm_q2_score": 0.8577681049901036,
"openwebmath_perplexity": 4060.6279178762175,
"openwebmath_score": 0.32957637310028076,
"tags": null,
"url": "https://mathematica.stackexchange.com/questions/91142/fem-solution-desired-for-plate-with-orifice-deflection-application-of-boundar"
} |
general-relativity, gravity, electrons, antimatter, protons
Edit: I am a bit unsure about my original (speculative) conclusion, that electrons would still attract each other, in case of their mass being negative; from the point of view of newtonian mechanics we could probably argue that a mass sign would enter quadratically into the gravitational force of like charges, resulting in an overall attractive gravitation between electrons (inertial mass must always remain positive if Lorentz' force law shall not be compromised) and a repulsive gravitation between electrons and protons; but from the point of view of GRT, the weak equivalence principle would dictate that gravitation is just geodesic motion in the external field (in this case of an electron), regardless of what kind of other charged particle falls into this field; so if electrons had negative gravitational mass, their metric and the corresponding Levi-Civita connection would be somehow inverted, but it would act the same on other electrons and protons; meaning if this metric causes repulsion, it would repel protons as well as other electrons; but then again, the question remains whether the weak equivalence principle (which has been experimentally confirmed only for makroscopic matter) could also be confirmed for elementary particles... Yes, we can be sure that leptons and baryons attract each other. Eotvos experiments and other tests of the equivalence principle give null results to about one part in $10^{11}$ these days. Under your hypothesis, different chemical substances would have different gravitational accelerations, and therefore we would get violations on the order of one part in $10^4$. | {
"domain": "physics.stackexchange",
"id": 75645,
"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, gravity, electrons, antimatter, protons",
"url": null
} |
variant-calling, illumina, gatk
This is telling me that at position 28607916 of chr13, I have 1 read supporting a deletion (*, see https://www.htslib.org/doc/samtools-mpileup.html for an explanation of the symbols), 93 reads supporting the reference residue (T, in this case) and 915 supporting an A, so a T=> A variant.
However, a better approach is to use a variant caller and force it to call the variant you want. You can then investigate the support for it. With mutect2, you can use the --alleles option to force the calling and then use the -L option to limit calling to only the specific region. If you give the same vcf file for both options, that will return results for the variants you want and only those. For example, given this file foo.vcf.gz (which needs to be compressed using bgzip and indexed using tabix):
$ zcat 1.vcf.gz
##fileformat=VCFv4.3
##reference=/genomes/hg19/hg19.fa
##FORMAT=<ID=AB,Number=A,Type=Float,Description="Allelic Balance">
##FORMAT=<ID=DP,Number=1,Type=Integer,Description="Read depth">
##FORMAT=<ID=GQ,Number=1,Type=Integer,Description="Net Genotype quality across all datasets, calculated from GQ scores of callsets supporting the consensus GT, using only one callset from each dataset">
##FORMAT=<ID=GT,Number=1,Type=String,Description="Genotype">
##contig=<ID=chr13,assembly=hg19,length=115169878>
#CHROM POS ID REF ALT QUAL FILTER INFO FORMAT HG003
chr13 28607917 . G C . . . GT:AB:DP:GQ 1/1:0.6:395:318 | {
"domain": "bioinformatics.stackexchange",
"id": 2667,
"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": "variant-calling, illumina, gatk",
"url": null
} |
# rewrite
Rewrite expression in terms of another function
## Syntax
``R = rewrite(expr,target)``
## Description
example
````R = rewrite(expr,target)` rewrites the symbolic expression `expr` in terms of another function as specified by `target`. The rewritten expression is mathematically equivalent to the original expression. If `expr` is a vector or matrix, `rewrite` acts element-wise on `expr`.```
## Examples
collapse all
Rewrite any trigonometric function in terms of the exponential function by specifying the target `"exp"`.
```syms x sin2exp = rewrite(sin(x),"exp")```
```sin2exp = $\frac{{\mathrm{e}}^{-x \mathrm{i}} \mathrm{i}}{2}-\frac{{\mathrm{e}}^{x \mathrm{i}} \mathrm{i}}{2}$```
`tan2exp = rewrite(tan(x),"exp")`
```tan2exp = $-\frac{{\mathrm{e}}^{2 x \mathrm{i}} \mathrm{i}-\mathrm{i}}{{\mathrm{e}}^{2 x \mathrm{i}}+1}$```
Rewrite the exponential function in terms of any trigonometric function by specifying the trigonometric function as the target. For a full list of target options, see target. | {
"domain": "mathworks.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9802808701643912,
"lm_q1q2_score": 0.8370743419745725,
"lm_q2_score": 0.8539127585282744,
"openwebmath_perplexity": 909.7096262948294,
"openwebmath_score": 0.9389408230781555,
"tags": null,
"url": "https://de.mathworks.com/help/symbolic/rewrite.html"
} |
python, numpy, statistics, pandas, numerical-methods
Title: Monte Carlo Simulation of P-Value I'm testing Python 3 code to perform a Monte Carlo simulation based on the result of an statistical test.
I currently have the result of the statistical test in a pandas dataframe, like this.
Dataframe A
+-----+-------+
| id | f_res |
+-----+-------+
| 1 | 4.22 |
| 2 | 5.25 |
| 3 | 3.3 |
| 4 | 2.5 |
| 5 | 1.9 |
| 6 | 9.3 |
+-----+-------+
So my idea is; for each row in f_res, pass that value to a function and extract multiple values from a Noncentral chi-squared distribution, ask how many of this extracted values are greater than the original and divide this by the total of values analyzed.
I'm working with numpy to generate the array of values, and I have this working code.
import numpy as np
import pandas as pd
total_sample = 100
def monte_carlo(x, tot_sample):
gen_dist = np.random.noncentral_chisquare(df=1, nonc=x, size=tot_sample)
compare = gen_dist > x
return np.divide(np.sum(compare), tot_sample)
df = pd.DataFrame(np.random.randint(0,10, 625527), columns=[['A']])
b = np.array(df.values)
g = np.vectorize(monte_carlo)
x = g(b, total_sample) | {
"domain": "codereview.stackexchange",
"id": 27262,
"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, numpy, statistics, pandas, numerical-methods",
"url": null
} |
optics, attenuation
We can describe the path taken simply by changing the radius $r$ from the coordinate system origin, the intensity of radiation $I$ will reduce due to attenuation by the material coefficient $\alpha$ and due to the expansion of the surface area element $dA=r^2 d\Omega$ associated with the solid angle.
We want to solve,
$$
\frac{dI}{dr} = - \alpha I dA = - r^2 \alpha I d\Omega
$$
Performing the angular integration gives a constant factor,
$$
\int_0 ^{\Omega_c} d\Omega = \Omega_c
$$
Giving,
$$
\frac{dI}{dr} = - r^2 \alpha I \Omega_c
$$
This is a first-order linear ODE which you can solve yourself, but the solution is proportional to
$$
I(r) \propto \exp \left( -\Omega_c \alpha r^3 / 3 \right)
$$
If this was simply the Beer-Lambert law we would expect the exponential term to simply have an $r$ dependence. The solution has the $r^3$. Implying an additional $r^2$ due to the expanding surface area reducing the intensity faster. | {
"domain": "physics.stackexchange",
"id": 60435,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "optics, attenuation",
"url": null
} |
electromagnetism, magnetic-fields, potential-energy, magnetic-moment, conservative-field
We actually realize that inside the magnet the divergence of the magnetization is zero, because it is constant. So we conclude that
$$\mathbf{\nabla}\cdot \mathbf{H}|_{\partial B} = \mathbf{\nabla}\mathbf{M}\quad\text{otherwise}\quad \mathbf{\nabla}\cdot \mathbf{H}=0 \tag{1} $$
Furthermore there is no electron current around neither an electric diplacement field, so we have also
$$ \mathbf{\nabla}\times \mathbf{H}=0$$
everywhere in our set-up. This a constellation very well-known from electrostatics (Remember $\mathbf{\nabla}\cdot \mathbf{E} =4\pi \rho$).
We can introduce the magnetic potential $\varphi_m$ via the gradient
$$ \mathbf{\nabla}\varphi_m = \mathbf{H}\quad\text{that solves}\quad \mathbf{\nabla}\times \mathbf{\nabla}\varphi_m=0$$.
If the distribution of (change of) magnetization is known, i.e. if $\mathbf{\nabla}\cdot \mathbf{M}$ is known (and of course for a permanent magnet it is known) we now solve for the magnetic potential via the Poisson respectively the Laplace equation:
$$ \Delta\varphi_m= \mathbf{\nabla \cdot \nabla} \varphi_m = \mathbf{\nabla}\cdot \mathbf{M}|_{\partial B}$$
This is just an example, but one can imagine many different constellations where this technique can be applied. In particular this is done in the design of larger magnets for instance for accelerators.
Of course if a current-carrying wire is around and one wants to know the magnetic potential around a loop which contains the wire a magnetic potential makes no sense anymore, respectively sophisticated techniques like those mentioned in hyportnex's post have to be applied. | {
"domain": "physics.stackexchange",
"id": 96410,
"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, magnetic-fields, potential-energy, magnetic-moment, conservative-field",
"url": null
} |
quantum-mechanics, schroedinger-equation
$$
\sqrt{\hbar} \,a(p) = \phi(k)
$$
then the first integral will become
$$
\frac{1}{\sqrt{2\pi}}\int_{-\infty}^\infty \sqrt{\hbar}\, a(p) e^{i\left(\frac{p}{\hbar} x - \frac{\hbar}{2m}\frac{p^2}{\hbar^2}t\right)} \frac{dp}{\hbar}
$$
which is exactly the second integral. It's just a change of notation! | {
"domain": "physics.stackexchange",
"id": 6343,
"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, schroedinger-equation",
"url": null
} |
# Prove: If $p$ is an odd prime and $a,b$ are any two integers with $0 \leq a < b \leq (p-1)/2$, then $a^2 \not\equiv b^2 \pmod{p}$.
The Problem
I am currently working on the following question:
If $p$ is an odd prime (i.e., $p \neq 2$) and $a,b$ are any two integers with $0 \leq a < b \leq (p-1)/2$, then $a^2 \not\equiv b^2 > \pmod{p}$.
I should note that this question is the second step in a multi-part problem. The first step asks to prove the following:
If $p$ is prime and $a^2 \equiv b^2 \pmod{p}$, then either $a \equiv b > \pmod{p}$ or $a \equiv -b \pmod{p}$.
To this, I offered the following proof:
Proof. Suppose that $p$ is prime and $a^2\equiv b^2 \pmod p$. We then have for some integer, say $k$, $$\frac{a^2-b^2}{k}=\frac{(a-b)(a+b)}{k}=p.$$ Setting $x=(a-b)$ and $y=(a+b)$, we see that $p|xy$. By the theorem provided in the hint, we have $p|x$ or $p|y$. If $p|x=a-b$ then we have $a\equiv b \pmod p$. Similarly, if $p|y=a+b$, we have $a\equiv -b \pmod p$. Thus, either $a\equiv b \pmod p$ or $a \equiv -b \pmod p$.
My Questions | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.986777175525674,
"lm_q1q2_score": 0.8201529974779896,
"lm_q2_score": 0.8311430562234877,
"openwebmath_perplexity": 81.508468399548,
"openwebmath_score": 0.8782829642295837,
"tags": null,
"url": "https://math.stackexchange.com/questions/2339430/prove-if-p-is-an-odd-prime-and-a-b-are-any-two-integers-with-0-leq-a-b"
} |
electricity, potential
Title: Basics of Current Electricity I have certain questions which confuse me a great deal. I want to have a very basic and clear idea about some concepts. Here it goes:
1) I am really confused on how a battery actually works. The very basic question that I have is whether positive ions flow in a battery? I ask this because my textbook uses phrases like 'positive ion flow'. While explaining the working of a battery, it highlights the journey of a positive ion across the circuit. I get confused because positive ions don't move in a wire.
2) I know potential difference between two points is the amount of work that needs to be done to move a positive charge from one point to the other. But when we talk about a battery, my textbook uses the phrase 'Potential difference between the electrodes'. I don't quite understand what this means. Does this mean that one electrode of the battery has an excess of electrons and the other has deficiency? What is the path of a charge through a cell?
3) Also, what does 'Potential Drop' means? Why does the potential drop across a resistor? I tried reading some resources but I don't get it.
4) What is EMF? I know the basic definition, but can you please explain with simplicity?
I don't know if I'm unnecessarily confusing myself? Perhaps I should accept some things as facts. The main problem is that I really get confused while solving a problem. Clearing the questions I asked above would make me understand what I actually am doing while solving a question. Thank you! I'll briefly address several of your questions but do consider breaking up these questions into separate posts if you want greater detail.
The very basic question that I have is whether positive ions flow in a
battery?
Inside a battery (cell) is an electrolyte that reacts with the electrodes, removing electrons from one and adding electrons to the other. An electrolyte is a solution containing electrically charged atoms.
When an external circuit is connected to the battery, electrons will flow from the terminal with excess electrons, through the external circuit, to the terminal with a deficit of electrons.
Within the electrolyte, there is an electric current due to the flow of ions. Within the terminals and external circuit, the electric current is due to the flow of electrons.
Does this mean that one electrode of the battery has an excess of
electrons and the other has deficiency | {
"domain": "physics.stackexchange",
"id": 15049,
"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": "electricity, potential",
"url": null
} |
quantum-mechanics, quantum-information, quantum-optics, interferometry
Title: How fast a quantum state updates in a quantum experiment when the experimental setup itself changes. Are there known experiments on this? Consider the following Sagnac interferometer setup: | {
"domain": "physics.stackexchange",
"id": 51896,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "quantum-mechanics, quantum-information, quantum-optics, interferometry",
"url": null
} |
Divided by the total number of outcomes two cases for the union must true... And other related probabilities of two independent events, or the events are either mutually,! Among other things types of standard normal Z-tables replaced before the next is... The mean, it is not replaced Calculator, is a 54.53 % chance Snickers. Most 7 … related probability Calculator | sample Size Calculator for Proportions for a permutation replacement sample r... B occurs but not both that standard deviation is typically denoted as σ within the union,,... Or the events are independent rolling a 4 and 6 on a single roll of a normal. Ownership of the likelihood of an event occurring dependent probability without replacement calculator ( distinguishable ) of $n$ objects which! A set Size of n, each element r can be simultaneously.... Not replaced diagram of a die ; it is an indicator of the estimate permutation replacement sample of elements! At least one of the estimate conditions within the union of events ; the events are either mutually exclusive or. Picked out and then replaced before the next object is selected, this is further affected by whether events., so feel free to write to describe and approximate any variable tends. Sample Size Calculator the mean take the example of a bag of 10 marbles 7. Various confidence levels 6 cards in our randomly-selected sample of 12 cards the next object is picked and. Events are either mutually exclusive events, P ( a ∩ B ) = 0 the certain... Which are black, and 3 of which probability without replacement calculator black, and related! 20 marbles elements from a set Size of n, each element r can be simultaneously.! The hypergeometric probability is 0.210 the measure of the estimate space for the second event is then 19 instead! Various confidence levels the union must hold true, all conditions can be chosen n.! Calculator, is a probability of having drawn the number of outcomes exclusive events, (... Branch of mathematics called combinatorics, which involves studying finite, discrete structures be true..., and 3 of which are black, and 3 of which are blue to calculate the rest probabilities event. Standard normal Z-tables note that even though the actual value of interest is on! Single roll of a typical normal distribution curve is sampling with replacement cards in our randomly-selected sample | {
"domain": "chegg.net",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9697854120593483,
"lm_q1q2_score": 0.8163902283535563,
"lm_q2_score": 0.8418256432832333,
"openwebmath_perplexity": 627.2916332568178,
"openwebmath_score": 0.7373608350753784,
"tags": null,
"url": "https://chegg.net/page/probability-without-replacement-calculator-3b244a"
} |
visible-light, biophysics, vision, technology
Title: Why was RGB chosen as the basis / primary color set for pixels? Human eyes have retinal cells that are sensitive to red, green, and blue light. Pixels on electronic screens use the same three colors to produce many apparent colors.
But a little thought (and knowledge of vector spaces) reveals that neither of these facts necessitates the other. There are infinitely many bases for a single vector space, and there are infinitely many sets of primary colors that could reproduce a large color gamut.
So why was RGB chosen as the basis / primary color set for pixels? Was it technologically easiest to produce pixels that create those colors? Is there a practical advantage to having the colors align closely with those that our retinal cells can detect? Or is there an external factor that singles out RGB as a "preferable" color basis for both vision and pixels (e.g., perhaps RGB allows for the largest color gamut).
Similar question here, but with unsatisfying answers. Very related to question #3 here, but it isn't addressed directly in the answers from what I can tell. That question is about why the frequencies of pixels are slightly different from those that our retinal cells are most receptive to, which adds yet another wrinkle to this topic. The CIE Chromaticity diagram from that other answer is somewhat informative.
With 3 display colors, you can perform a linear interpolation of them, and you can reach any space within the convex hull of their locations. In other words, if you pick 3 points, you can draw a triangle between them and reach any color in the interior.
There are certainly material reasons that make one specific color easier or more difficult to produce, but in general you can see that the largest triangle you could create within the CIE color space is one with one corner at red, one corner at blue, and one corner in green.
You can cover more space with more points, but that becomes more complex with less marginal benefit. 3 points seems to be a good tradeoff between utility and technical complexity.
See also this SO question enter link description here which shows a representation of a few different color gamuts. | {
"domain": "physics.stackexchange",
"id": 79704,
"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": "visible-light, biophysics, vision, technology",
"url": null
} |
ros
odom_broadcaster.sendTransform(odom_trans);
//**************************************************************
nav_msgs::Odometry odometry;
odometry.header.frame_id = "odom";
odometry.child_frame_id = "base_link";
odometry.header.stamp = msg1->header.stamp;
odometry.pose.pose.position.x = x;
odometry.pose.pose.position.y = 0;
odometry.pose.pose.position.z = 0;
odometry.pose.pose.orientation = quaternion;
odometry.twist.twist.linear.x = dx/dt; // convet back to velocity
odometry.twist.twist.linear.y = 0;
odometry.twist.twist.angular.z = dtheta/dt; // convet back to velocity
pubOdometry.publish(odometry);
}
private:
double x;
float theta;
ros::Time timeold;
ros::NodeHandle n;
ros::Publisher pubOdometry;
tf2_ros::TransformBroadcaster odom_broadcaster;
ros::Subscriber subInitialPose;
boost::shared_ptr<Subscriber<control_msgs::JointControllerState> > j1_sub;
boost::shared_ptr<Subscriber<control_msgs::JointControllerState> > j2_sub;
boost::shared_ptr<TimeSynchronizer<control_msgs::JointControllerState, control_msgs::JointControllerState> > sync;
}; // Enodof Class
int main(int argc, char **argv)
{
ros::init(argc, argv, "robot_odometry");
// publish static latch transformations | {
"domain": "robotics.stackexchange",
"id": 15782,
"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
} |
wpf, xaml, gui
I guess I could refine it more:
<LabeledContent Grid.Column="1" Grid.Row="2" Grid.ColumnSpan="2" Label="Start" Content="12:00pm"/>
Simplicity at the cost of flexibility. Perhaps instead I should be doing it as a style? My opinion is that for simple tasks like in your situation, you should not complicate your XAML. Wrapping a StackPanel around two TextBlock-elements is still pretty clean.
Extracting the code and wrapping it in your own control where you would set the Label and Content surely is an option. But if this only to be done once, I think you're overdoing it. Only when you have to place the same code there a lot of times, your XAML will be cleaner using your own control. | {
"domain": "codereview.stackexchange",
"id": 3174,
"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": "wpf, xaml, gui",
"url": null
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.