text stringlengths 1 1.11k | source dict |
|---|---|
object-oriented, design-patterns, mvc, actionscript-3
InputRadioButtonView
protected function updateClip():Boolean {
// Stash the value for convenience
_value = _model.getLiveFieldValue(_modelProperty);
if (clip){
if (_value) {
movieClip.gotoAndStop(LABEL_ON);
} else {
movieClip.gotoAndStop(LABEL_OFF);
}
return true;
}
return false;
}
If I see a construct like this, the little guy in my head screems USE A GUARD CLAUSE to safe vertical spacing.
Another voice will ask me "Why is this _value variable filled if clip != true?"
The next one just states, "I can't read the code that easy because there aren't always spaces before a brace {.
So fixing these three points to silence the voices in my head is pretty straightforward like so
protected function updateClip():Boolean {
if (!clip) {
return false;
}
// Stash the value for convenience
_value = _model.getLiveFieldValue(_modelProperty); | {
"domain": "codereview.stackexchange",
"id": 15193,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "object-oriented, design-patterns, mvc, actionscript-3",
"url": null
} |
javascript, jquery, html, css
Next, there's the click actions. You're adding those inside the mouseenter event. This is a big no-no. It means that every time you mouse over a button, a new click event handler gets added! You just don't notice it because you're inserting and re-inserting the same element. But if you mouse over the red button 3 times before clicking it, the effect is that you're clicking it 3 times because now you've got 3 separate but identical event handlers attached.
Yet another reason to keep the actions separate from the hover effects.
You can either attach the event handlers to an element by its ID (as below), or you can use some other means of linking an element to an action. | {
"domain": "codereview.stackexchange",
"id": 12585,
"lm_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, html, css",
"url": null
} |
water, atmospheric-science, gas, geophysics, evaporation
Measurements from satellites such as the Tropical Rainfall Measuring Mission (TRMM) show that convective precipitation dominates over the tropics and subtropics where the Earth's heaviest precipitation occurs, while stratiform is more common at higher latitudes. (See, for example, Figures 3 & 4 in this paper.) I can't immediately find a consensus number for the convective-to-total precipitation ratio (PC/PR). According to Table 1 of this paper, global climate models typically have PC/PR around 0.7, but the value for different models can range from 0.4 to 1.0. | {
"domain": "physics.stackexchange",
"id": 92327,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "water, atmospheric-science, gas, geophysics, evaporation",
"url": null
} |
homework-and-exercises, differential-geometry, metric-tensor, coordinate-systems, differentiation
\end{equation}
We are again missing the factor $r\sin^2(\theta)$ and again have an unwanted term $\Gamma^r_{\theta\theta}$.
I notice the unwanted connection terms all contain the two equal indices downstairs. Can someone explain to me both where the factor $r^2\sin(\theta)$ I am missing should come from, and tell me where my mistake is in the connection terms. I doubt that you are still worrying about this, but I ran into the same issues when attempting this problem, so I wanted to post my answer for any future readers. | {
"domain": "physics.stackexchange",
"id": 86800,
"lm_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, differential-geometry, metric-tensor, coordinate-systems, differentiation",
"url": null
} |
ros-melodic
from ros_robodk_post_processors.srv import *
ImportError: No module named ros_robodk_post_processors.srv
Traceback (most recent call last):
File "/builds/InstitutMaupertuis/ros_robodk_post_processors/catkin_workspace/src/ros_robodk_post_processors/test/services_tests.py", line 5, in <module>
from ros_robodk_post_processors.srv import *
ImportError: No module named ros_robodk_post_processors.srv
... logging to /root/.ros/log/rostest-runner-ed2dce3a-project-7702522-concurrent-0-1987.log
[ROSUNIT] Outputting test results to /builds/InstitutMaupertuis/ros_robodk_post_processors/catkin_workspace/build/test_results/ros_robodk_post_processors/rostest-test_services.xml
[Testcase: testservices_tests] ... FAILURE!
FAILURE: test [services_tests] did not generate test results
File "/usr/lib/python2.7/unittest/case.py", line 329, in run
testMethod()
File "/opt/ros/melodic/lib/python2.7/dist-packages/rostest/runner.py", line 164, in fn | {
"domain": "robotics.stackexchange",
"id": 32334,
"lm_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-melodic",
"url": null
} |
quantum-state, fidelity, information-theory
Part 2
First note that it is the same channel that is being applied to the two states $\rho$ and $\sigma$. So if for example $\rho = \sigma$ and they have perfect fidelity then $\mathcal{N}(\rho) = \mathcal{N}(\sigma)$ and the `noisy' outputs also have perfect fidelity. On the opposite end of the spectrum if we take a channel which produces white noise i.e., $\mathcal{N}(\rho) = \mathrm{Tr}[\rho] I/d$ then $\mathcal{N}(\rho) = \mathcal{N}(\sigma)$ for any two states $\rho$ and $\sigma$. Thus even those that previously had fidelity $0$ will have, after sending them through this maximally noisy channel, perfect fidelity. | {
"domain": "quantumcomputing.stackexchange",
"id": 1988,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "quantum-state, fidelity, information-theory",
"url": null
} |
c, linked-list, queue
Suggestions
You are trying to optimize the storage size, at the cost of allocations, i am assuming you have looked at the amounts that you have/need and decided that this is a necessary step. By itself the this looks fine, you'll have to be the judge of whether it actually does what you think it should accomplish.
You could introduce a buffer structure just to carry the data and size pairs, this might make peek and pop more clear, but there probably would always be a difference between the allocated amount from the pointer passed in and the actual written amount. Unless the amount of reserved memory is fixed.
You could implement this as a circular buffer on a fixed amount of memory. This might have some advantages depending on your needs. If you are low on memory you might want to save on allocations as well. | {
"domain": "codereview.stackexchange",
"id": 29381,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "c, linked-list, queue",
"url": null
} |
newtonian-mechanics, newtonian-gravity, orbital-motion, centripetal-force
Title: Was Feynman right about the chalk in the spaceship? I have heard this problem many times before from various sources, but I am quoting Feynman's words from his Lectures On Physics (Vol : 1) , just in case you want it to be authentic.
Therefore, Gagarin or Titov would find things weightless inside spaceship; if they happened to let go of a piece of chalk, for example, it would go around the earth in exactly the same way as the whole spaceship, and so it would appear to remain suspended before them in space. | {
"domain": "physics.stackexchange",
"id": 50403,
"lm_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, orbital-motion, centripetal-force",
"url": null
} |
c++
So for a class that implements the < operator it would just take inheriting from relational to have the rest of the operators defaulted.
struct foo : relational<foo>
{
// implement < operator here
};
Are there any alternative, better designs?
Is there a time bomb in this code?
While trying to use this code with classes that already defined one of { >, ==, !=, <=, >= } I had ambiguity problems. The implementation I opted for (also the one existing in the linked Github repository) is tweaked like so
// inside the relational struct
friend bool operator>(relational const &lhs, relational const &rhs)
{ // functions that involve implicit conversion are less favourable in overload resolution
return (T const&)rhs < (T const&)lhs;
} | {
"domain": "codereview.stackexchange",
"id": 7356,
"lm_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++",
"url": null
} |
stability, proteins, structural-biology
Previous studies and theoretical models[2] have shown that ion pairing is expected to have a marked effect on stability. At room temperature, the formation of a salt bridge leads to an unfavourable reduction of solvation which overcompensates any enthalpy gained. At higher temperatures however, this desolvation penalty is strongly reduced and the stability gain from salt bridges thus increased.
The authors do point out one major caveat concerning hyperthermophilic proteins they studied:[1] | {
"domain": "chemistry.stackexchange",
"id": 7817,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "stability, proteins, structural-biology",
"url": null
} |
thermodynamics, temperature, everyday-life
If I add milk to my coffee and wait 5 minutes before drinking it and another person waits 5 minutes and then adds the milk to his/her coffee, who is drinking the hottest coffee?
A theoretical derivation of the end temperatures can be carried out based on the following assumptions/simplifications.
amounts of milk and coffee are identical in both cases
mixing of milk and coffee is adiabatic
the cooling of the liquid (coffee or coffee plus milk) follows Newton's Law of Cooling
radiative losses during cooling are negligible compared to convective losses
evaporative losses are negligible
material constants like density, specific heat capacity and convective heat transfer coefficients are independent of temperature
the above list of assumptions may not be fully exhaustive | {
"domain": "physics.stackexchange",
"id": 68217,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "thermodynamics, temperature, everyday-life",
"url": null
} |
electromagnetism, magnetic-fields, electric-current
Title: How to determine the direction of force from a current carrying wire I'm having trouble determining the directions for magnetic force and field from a current carrying wire. | {
"domain": "physics.stackexchange",
"id": 65707,
"lm_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, electric-current",
"url": null
} |
biochemistry, proteins
Pictures are from here, that is a great site that explains basic protein strucutre in a quite understandable way.
These secondary structures are important because they can from motifs with specific functions like DNA binding, interaction surface with other proteins. The aforementioned wiki sites have detailed info. These secondary structures and motifs serve as building block for higher order functions. Between motifs "loose" non-structured parts can be found to allow for flexibility.
Tertiary structure:
This is the level where complex 3D geometric structure is defined. The aforementioned 2D structures are packed into domains - a single functional element of a protein. A single protein can have multiple domains and the relative position of these domains result in the tertiary structure. The domains themselves are connected with loose regions that do not show any high order structure and provide flexibility between the domains. Flexibility is necessary for conformational changes. | {
"domain": "biology.stackexchange",
"id": 3937,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "biochemistry, proteins",
"url": null
} |
object-oriented, design-patterns, typescript, classes
Title: Random generation of points for the graphs of 3 stock share parameters I currently studying OOP and related design patterns, and tried to implement random data generation for some stock charts using OOP as an exercise.
This code randomly generates data points for 3 parameters (share price, spread and yield), so it later can be used as an input for the graphs.
I want to receive some feedback on how to make this code more SOLID and in accordance with OOP best practices in general. Have I used the proper design patterns?
import { faker } from "@faker-js/faker";
import {
addDays,
eachDayOfInterval,
subMonths,
isAfter,
subWeeks,
subYears,
startOfWeek,
startOfMonth,
startOfQuarter,
startOfYear,
} from "date-fns"; | {
"domain": "codereview.stackexchange",
"id": 45269,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "object-oriented, design-patterns, typescript, classes",
"url": null
} |
ros, navigation, odometry, encoders, phidgets
if (subscribed_to_encoders) {
std::string base_link = "base_link";
nh.getParam("base_link", base_link);
std::string frame_id = "odom";
nh.getParam("frame_id", frame_id);
left_encoder_counts_per_mm = 0;
right_encoder_counts_per_mm = 0;
nh.getParam("countspermmleft",
left_encoder_counts_per_mm);
if (left_encoder_counts_per_mm < 1) {
left_encoder_counts_per_mm = 1000;
}
nh.getParam("countspermmright",
right_encoder_counts_per_mm);
if (right_encoder_counts_per_mm < 1) {
right_encoder_counts_per_mm = 1000;
}
wheelbase_mm = 0;
nh.getParam("wheelbase", wheelbase_mm);
if (wheelbase_mm < 1) wheelbase_mm = 400;
nh.getParam("verbose", verbose);
nh.setParam("verbose", false); | {
"domain": "robotics.stackexchange",
"id": 28892,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "ros, navigation, odometry, encoders, phidgets",
"url": null
} |
keras, regression, lstm, anomaly-detection
Title: How to fit a model on validation_data? can you help me understand this better? I need to detect anomalies so I am trying to fit an lstm model using validation_data but the losses does not converge. Do they really need to converge? Does the validation data should resemble train or test data or inbetween?
Also, which value should be lower, loss or val_loss ? Thankyou! When validating machine learning models, you have to use a validation procedure that is consistent with your problem. For an anomaly detection use-case, it means correctly split your data, evaluate your model and with the right metrics.
Split of the data
You have to correctly choose the way you are splitting your data. By default, you have to define three different sets : training, validation and the test sets. | {
"domain": "datascience.stackexchange",
"id": 10863,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "keras, regression, lstm, anomaly-detection",
"url": null
} |
# Techniques for proving a series is uniformly convergent
I am trying to determine whether the series$$\sum_{n=1}^\infty{\frac{x}{n(1+nx^2)}}$$is uniformly convergent on the real numbers, and am really stuck. I have tried using the Weierstrass $M$ test but cannot seem to find any series greater than this which is convergent. I have looked at comparing it to series which have $1/n^k$ in particular. Are there any other methods I can use? Or am I just using the Weierstrass M test incorrectly?
• uniformly convergent where? – zhw. Mar 15 '18 at 22:52
• @zhw Sorry, should have clarified. On the reals. – Flose Mar 15 '18 at 22:56
• You are not using it incorrectly. In this case a different method is preferable. – DanielWainfleet Mar 16 '18 at 0:45 | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9838471656514752,
"lm_q1q2_score": 0.8198640350566132,
"lm_q2_score": 0.8333245891029456,
"openwebmath_perplexity": 430.4317751172605,
"openwebmath_score": 0.8618423342704773,
"tags": null,
"url": "https://math.stackexchange.com/questions/2693004/techniques-for-proving-a-series-is-uniformly-convergent/2693018"
} |
are the secants. Improving upon bisection (12/15) A disadvantage of bisection is that it is not particularly efficient. MathJax reference. Let ε step = 0. Not recommended for general BVPs! But OK for relatively easy problems that may need to be solved many times. Making statements based on opinion; back them up with references or personal experience. Question 2. 2(a) shows passengers climbing to the roof of a train, while Fig. pdf; Here are some Bisection method examples 0 Comments. 8jui9iijr4yy, 6434wt3ppq, gybgb08ev5t6w, 1ucs1ed1xvdm, t09zgkjqst3li4, hhjnajne54, 1r9gvxf1mhta, mgxh2zxhh30ve9, ivw5kjjhw79, qon4mhqy7vvwxfl, fcaukrb0nlv109, xvlx21qozg669, 4wy3gqgd9n, dq8ktfgxkk8w54w, 07ydyiane2, cjlkv1yv9e, l0ee2iun2ja, domdr8djb9hl3, hkzwkcm03ew1df, kcw3eu216zs7, 8z4dvk1zx9twib, d9f1ftml9wofo91, rmolfjwd4hs0yn4, 48gunpmkn7g3q, lrz1tv77qamh5cw, rbkh5lolf9q, 9ghvbkl5xhgc, ir4b48gsvq698r7, n4paq5ihbdgc, 2ylt67xq4bgxt, moshj23uch | {
"domain": "tuningfly.it",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9719924826392581,
"lm_q1q2_score": 0.8013707925641456,
"lm_q2_score": 0.8244619242200081,
"openwebmath_perplexity": 778.5248216033502,
"openwebmath_score": 0.5310834646224976,
"tags": null,
"url": "http://tuningfly.it/mwdx/bisection-method-questions-and-answers-pdf.html"
} |
kinematics, forward-kinematics, jacobian
(By looking at the schematic you attached, and not doing the math, I am not convinced that the robot you described has a diagonal jacobi matrix) | {
"domain": "robotics.stackexchange",
"id": 1244,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "kinematics, forward-kinematics, jacobian",
"url": null
} |
$A\cdot (B\times C)=0$
$A=(2,-1,1),~B=(1,2,-3),~C=(3,a,5)$
$B\times C = (10 + 3 a, -14, -6 + a)$
$A \cdot (B \times C) = 28+7a = 0 \Rightarrow a = -4$
Another way of looking at this is you can form a 3x3 matrix using the vectors.
If those vectors are coplanar then the determinant of this matrix will be zero indicating that the system isn't full rank.
The operations of finding this determinant are identical to those of taking the triple product.
Chemist116
if the three vectors are coplanar the triple product will be zero.
$A\cdot (B\times C)=0$
$A=(2,-1,1),~B=(1,2,-3),~C=(3,a,5)$
$B\times C = (10 + 3 a, -14, -6 + a)$
$A \cdot (B \times C) = 28+7a = 0 \Rightarrow a = -4$
Another way of looking at this is you can form a 3x3 matrix using the vectors.
If those vectors are coplanar then the determinant of this matrix will be zero indicating that the system isn't full rank. | {
"domain": "mathforums.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9736446479186301,
"lm_q1q2_score": 0.819639032063378,
"lm_q2_score": 0.8418256432832333,
"openwebmath_perplexity": 271.97913336077676,
"openwebmath_score": 0.7633339762687683,
"tags": null,
"url": "https://mathforums.com/threads/how-can-i-prove-that-a-set-of-vectors-belong-to-the-same-plane-given-three-of-them.347804/"
} |
# Median from two unmergable datasets
I am trying to calculate the "overall" median of a variable that is spread across two datasets. I have access to the raw data in each dataset but can't bring their raw data together. What would be the best way to calculate the median (or any quantile for that matter)? What I was thinking to do was to get the quantiles from the "remote" dataset, say with N_1 samples and bring them to the other dataset; then sample N_1 values from these quantiles (essentially discrete empirical CDF) and use these values as "raw" scores to calculate the overall median or any other quantile. I wonder if there is a more sophisticated way of doing this?
I can't combine the two datasets because of data governance issues, where I have to analyse them separately on different computers. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9715639677785087,
"lm_q1q2_score": 0.8032033846345082,
"lm_q2_score": 0.8267117876664789,
"openwebmath_perplexity": 1277.0964510576914,
"openwebmath_score": 0.651271402835846,
"tags": null,
"url": "https://stats.stackexchange.com/questions/496028/median-from-two-unmergable-datasets"
} |
genetics, dna, sexual-reproduction
Title: How does DNA still work after recombination? If you take two computer programs and randomly swapped pieces from each of them. The result is not going to work. It will just be garbage. If you take two novels and randomly swapped chapters the result will be garbage too.
How is it than DNA (which is infinitely more complicated) can be combined, some from the father and some from the mother and yet it still somehow works?
Can you give a simple example? Homologous DNA recombination does not swap parts randomly in the sense that any two bits of DNA can swap places. DNA recombination is random in the sense that it may or may not occur. In fact DNA homologous recombination is highly specific and its specificity is what it makes a great tool to study genetics in organisms like yeast by swapping a gene of interest with something else. | {
"domain": "biology.stackexchange",
"id": 8405,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "genetics, dna, sexual-reproduction",
"url": null
} |
javascript, ajax
var request = new XMLHttpRequest();
var data = null;
if(settings.data){
if(typeof settings.data == 'object'){
data = new FormData();
for(prop in settings.data){
if(settings.data.hasOwnProperty(prop)){
data.append(prop, settings.data[prop]);
}
}
}else{
data = settings.data;
}
}
request.addEventListener('readystatechange', readystatechangeHandler);
request.addEventListener('progress', progressHandler);
request.open(method, settings.url, settings.async);
request.send(data);
function readystatechangeHandler(){
if(request.status >= 400){
if(typeof fail == 'function') fail(request);
if(typeof always == 'function') always(request); | {
"domain": "codereview.stackexchange",
"id": 12911,
"lm_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, ajax",
"url": null
} |
information-theory, randomness
Title: Shared randomness does not increase capacity of a noisy channel - Why? Why is it the case that when Alice and Bob use a noisy channel for communication, the capacity of the channel does not increase even if they are allowed to share pre-distributed randomness?
This is mentioned in some notes (see paragraph before Section 4 of https://cds.cern.ch/record/613098/files/0304102.pdf) but I have not seen a proof or an intuitive argument for it yet. Any reference to where this is covered would also be appreciated! Each value of the shared randomness corresponds to a communication protocol. So overall, we have a mixture of communication protocols, whose expected quality is good. There must therefore be one of these communication protocols – a setting of the shared randomness – which is as good.
As an example, we know that a random code achieves capacity. This means that some particular code achieves capacity. It might be hard to find that code, but we know that it exists. | {
"domain": "cs.stackexchange",
"id": 17612,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "information-theory, randomness",
"url": null
} |
java, game, timer
if (endTime - startTime == 60)
System.out.println("1 Minute left");
if (endTime - startTime == 30)
System.out.println("30 Seconds left");
if (endTime - startTime == 15)
System.out.println("15 Seconds left");
if (endTime - startTime == 5)
System.out.println("5 Seconds left");
else if (endTime - startTime == 1) {
System.out.println("Baron is up!");
}
}
}
}
} (relatively critical review ... apologies in advance)
The two issues I feel are most incorrect about your code is the buggy switch statement, and the poor choice of timing mechanism. The decision to use these mechanisms has lead to a poor OOP design.
Switch
First, though, the switch bug: | {
"domain": "codereview.stackexchange",
"id": 7289,
"lm_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, timer",
"url": null
} |
https://leetcode.com/problems/unique-paths
https://www.algoexpert.io/questions/Number%20Of%20Ways%20To%20Traverse%20Graph
Unique Paths II can help in understanding this
"""
"""
Since robot can move either down or right,
there is only one path to reach the cells in the first row: right->right->...->right.
The same is valid for the first column, though the path here is down->down-> ...->down.
"""
# starting from end to beginning
# note that the start is 1,1. 0,0 is out of bounds
class SolutionMEMO:
def uniquePaths(self, m, n):
cache = [[False for _ in range(n+1)] for _ in range(m+1)]
return self.uniquePathsHelper(m, n, cache)
def uniquePathsHelper(self, m, n, cache):
if m == 1 and n == 1:
return 1
if m < 1 or n < 1:
return float('-inf')
if cache[m][n]:
return cache[m][n]
left = self.uniquePathsHelper(m, n-1, cache)
up = self.uniquePathsHelper(m-1, n, cache)
total = 0
if left != float('-inf'):
total += left
if up != float('-inf'):
total += up | {
"domain": "paulonteri.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9559813501370535,
"lm_q1q2_score": 0.8218225111577803,
"lm_q2_score": 0.8596637487122111,
"openwebmath_perplexity": 6090.381773024074,
"openwebmath_score": 0.30743175745010376,
"tags": null,
"url": "https://dsa.paulonteri.com/Data%20Structures%20and%20Algorithms%2016913c6fbd244de481b6b1705cbfa6be/Recursion%2C%20DP%20%26%20Backtracking%20525dddcdd0874ed98372518724fc8753.html"
} |
java, object-oriented, design-patterns
public abstract String getName();
}
public class Sugar extends Sweet {
public Sugar(Beverage beverage) {
super("Sugar", beverage);
}
@Override
public String getName() {
return "Strong-" + name + "ed " + beverage.getName();
}
@Override
public Double getCost() {
return 0.2 + beverage.getCost();
}
}
UML: I would remove the name field entirely, and instead inline it into the getName() method.
That way you can implement the getName() similar to how you implemented getCost().
Concretely this means your getName() method from Beverage becomes abstract just like the other abstract classes.
public abstract String getName();
The base beverage (HouseBlend) then implements the method as:
public String getName() {
return "HouseBlend";
}
And similarly the decorator classes implement it as such:
public String getName() {
return "Milk-flavored " + beverage.getName();
} | {
"domain": "codereview.stackexchange",
"id": 24838,
"lm_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, object-oriented, design-patterns",
"url": null
} |
control, motor
Title: Motor-controller with path output I'm entirely new to robotics and have the following design requirement for a project I'm working on:
Given a robot capable of positioning an object in three dimensional space ( vis. a plastic extruder or syringe, etc ), allow the robot's end user to manually move that object through a path so that the robot's motor/controller will output the path taken. | {
"domain": "robotics.stackexchange",
"id": 1211,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "control, motor",
"url": null
} |
c, linux, http, socket, server
}
}
else if(response_type==RESPONSE_MIAN_QUERY)
{
//
send(*(con_obj->new_socket) , data_saved_message , strlen(data_saved_message) , 0 );
//send(*(con_obj->new_socket) , data_saved_message , 200 , 0 );
//send(*(con_obj->new_socket) , data_saved_message , 200 , 0 );
//data_saved_message
printf("data saved\n");
return HTTP_OK_200;
}
return 0;
}
This is sendfile.c
#include <stdio.h>
#include "headers/accept.h"
ssize_t sendfile(int out_fd, int in_fd, off_t *offset, size_t count)
{
off_t orig;
if (offset != NULL) {
/* Save current file offset and set offset to value in '*offset' */
orig = lseek(in_fd, 0, SEEK_CUR);
if (orig == -1)
return -1;
if (lseek(in_fd, *offset, SEEK_SET) == -1)
return -1;
}
size_t totSent = 0; | {
"domain": "codereview.stackexchange",
"id": 42215,
"lm_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, linux, http, socket, server",
"url": null
} |
fasta, snp, genomics
>speciesB_control_region_partial_sequence_mitochondrial
TTAAAGTAATGTAACCCTACATTAATGAAAAATCAAAA-TTATAGGAACTTAAATACATTACACCATCAAATAAATATGAAGGTAGACATAAACCATTGAATTTTAAATTTCATTAAACATGTTAAAAAAATGACGATATTGAATTGCCCTATCACAACTCTCATCAGTCTAGATATACCAGGACTCACCACCTCTGCAAGTAAGAGTCAAATGCAGTAAGAGACCACCATCAGTTGATTTCTTAATGTACACGTTTATTGATGGTCACGGACAAAAATCGTGGGGGTCGCACACAGTGAACTATTCCTGGCATTTGGTTCCTATTTCAGGTTCATCAATTGAATACATTCCCCTAACATTTCTTGACGCTTGCATAAGTTAATGGTGGAGTACATACTCCTCGTTACCCACCATGCCGAGCCTTCACTCTATAGGGCTACTGGTATCTTTTTTCTATTTCCTTTCACTTGACATTTCAGAGTGCATACAGAAATGTTATATCAAGGTTGAACATTTCCTTGCCCGGCGGAAAATGTATGAATGTAATTAAACTTTTATTTATGAATTGCATAACTGATATCAAGAGCATAAAGTATCATTTTTTCCCCTGACTTTCCTATCAAGCACCCCTCTCGGCTTTTGCGGGCCAAAACCCCCCCTCCCCCCTAAACTCGTGAGATTCCATTGTGTCTGCAAACCCCCCGGAAACAGAGCAAATCTTACTAGTTTTATCCCTTCTCAAATTTTTGTTCACTTGTATTTTTA | {
"domain": "bioinformatics.stackexchange",
"id": 1748,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "fasta, snp, genomics",
"url": null
} |
proteins, enzymes, enzyme-kinetics
Title: How does one derive a KD from an equilibrium titration experiment? I am definitely making a mistake somewhere Any help would be greatly appreciated. Thank you in advance.
If I have an antibody A and a target B, and experimentally titrate the antibody against a single concentration of B, and then measure the % of B that is bound after the solutions reach equilibrium, I should be able to determine the KD of the interaction.
Source below (and others) shows that determining KD is as simple as determining the EC50 of such a curve. from:https://www.sciencedirect.com/topics/nursing-and-health-professions/maximum-binding-capacity 50% occupancy | {
"domain": "chemistry.stackexchange",
"id": 16690,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "proteins, enzymes, enzyme-kinetics",
"url": null
} |
genetics, evolution, population-genetics, hardy-weinberg
It's important to consider sampling effects in your measurement, too. Your estimates will rarely match the Hardy-Weinberg frequencies perfectly just from noise in your sampling. You'll want some estimate of how likely it is that, assuming the population actually does follow Hardy-Weinberg, you'd get a deviation as large as the one you observe. That is achieved by performing a chi-squared test. | {
"domain": "biology.stackexchange",
"id": 12485,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "genetics, evolution, population-genetics, hardy-weinberg",
"url": null
} |
algorithms
Title: Algorithm exercise making exercises to prepare a test I'm having problems to understand 2 questions, the questions are:
how many are the leafs of a decisional tree associated to any algorithm for
the search problem in a ordered set?
for this question I have 2 set of answer where, for every set, 1 is right, looking at the solution I found this, but I'm not able to understand why the right answers are all C.
1. a) Θ(n log n) b) Θ(log n) *c) Ω(n!) d) O(n!)
2. a) Θ(n log n) b) Θ(log n) *c) Ω(n) d) Θ(n!)
The other question, referred to the first one is:
and in a non-ordered one? | {
"domain": "cs.stackexchange",
"id": 718,
"lm_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",
"url": null
} |
relative-motion
$$\gamma'(t) = \begin{cases} x'(t) =x_0 \color{red}{{}+ v_0t}-A\frac{t^2}{2} \\ y'(t) = h-g\frac{t^2}{2}\end{cases}.$$
Remember that the particle was initially at rest in the train's reference frame, before the train began decelerating. So your first constant of integration of $\ddot\gamma'$ shouldn't be equal to $v_0$ – it should be zero. Then, after we include our choice of origin $x_0=0$, we get
$$x'(t)=-At^2/2.$$
And from this you'll get a sensible result of
$$x(t)=v_0t.$$ | {
"domain": "physics.stackexchange",
"id": 49111,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "relative-motion",
"url": null
} |
c++, performance, base64
Base64Decoder::Base64Decoder() {
BuildDecodingTable(DecodingTable);
}
Base64Decoder::~Base64Decoder() {
}
void Base64Decoder::BuildDecodingTable(DecodingMap& table) {
table.clear();
char cur_char = 'A';
for(int i = 0; i < 26; ++i) {
table.insert(std::make_pair(cur_char++, i));
}
cur_char = 'a';
for(int i = 26; i < 52; ++i) {
table.insert(std::make_pair(cur_char++, i));
}
cur_char = '0';
for(int i = 52; i < 62; ++i) {
table.insert(std::make_pair(cur_char++, i));
}
table.insert(std::make_pair('+', 62));
table.insert(std::make_pair('/', 63));
}
//First Byte is all 6 of first symbol and 2 most significant bits of second symbol.
char Base64Decoder::GetFirstByte(char* decoding_buffer) {
DecodingMap::iterator first_iter = DecodingTable.find(decoding_buffer[0]);
DecodingMap::iterator second_iter = DecodingTable.find(decoding_buffer[1]); | {
"domain": "codereview.stackexchange",
"id": 26259,
"lm_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, base64",
"url": null
} |
cc.complexity-theory, quantum-computing, big-picture, qma
Title: Understanding QMA This question comes out of an answer Joe Fitzsimons gave to a different question. Most natural complexity classes have a one-line "intuitive description" that helps characterize core problems in that class. NP is "efficient verification", #P is about "enumerating solutions", PSPACE is about "game playing", and so on.
I've generally understood MA as BP(NP), where the M step gives you the NP guesser, and the A step is the BP part, and so questions about the relation between MA and NP are really derandomization questions. So my question is: | {
"domain": "cstheory.stackexchange",
"id": 153,
"lm_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, quantum-computing, big-picture, qma",
"url": null
} |
regex
Because the 11 can't be substituted by \3, as the capture is empty at that point in time. So you'll have to duplicate the syntax:
^((00)*|(11)*|((10|01)(00|11)*(10|01))*)+$
Then there is some additional optimization you can do. Instead of repeating each internal group 0..* times and the out group 1..* times, you can remove the inner repetition and change the outer one to 0..*:
^(00|11|((10|01)(00|11)*(10|01))*$
Further simplification doesn't seem possible without resorting to tricks such as zero-width assertions, basically ensuring that you end up with an even number of 1's and and even number of 0's and ensuring that both are true:
^(?=0*((10*){2})*$)1*((01*){2})*$
Cheating a bit further, we already know by the capturing expression that we have an even number of 0's, so we can replace the look-ahead to just ensure we're on an even number of characters, there are no other characters to worry about:
^(?=(.{2})*$)1*((01*){2})*$ | {
"domain": "codereview.stackexchange",
"id": 15464,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "regex",
"url": null
} |
c, strings, parsing, floating-point, embedded
Title: Parsing comma-separated floats and semicolon-delimited commands I wrote a cstring parser. It has to work with a relatively wide amount of arguments (usually 3 or 4, but maybe in future with a different amount), which are separated by an , or ;. My wish is to make at least Function 1 less static and save some code. However, I don't really want to use dynamic memory allocation (just if it not to avoid and would bring a benefit). The whole code should run on ATMega2560. This is why I cannot use higher library functions.
Function 1:
float *Receiver::parse_pid_substr(char* buffer) {
static float pids[8];
memset(pids, 0, 8*sizeof(float) ); | {
"domain": "codereview.stackexchange",
"id": 6664,
"lm_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, strings, parsing, floating-point, embedded",
"url": null
} |
quantum-chemistry, computational-chemistry, theoretical-chemistry
If we want to recover the linear form of the original expression for $\Phi$ we would need to use a basis of Slater determinants for our trial basis $\chi_i$,
$$
\Phi\left(r_1,r_2,...,r_n\right) = \sum^k_{i=1} c_i \Psi_i\left(r_1,r_2,...,r_n\right)
$$
The question this begs, is how to choose a suitable many electron basis $\Psi_i$.
The Configuration Interaction method uses this approach - a Rayleigh-Ritz approximation using a basis of Slater determinants. It selects the Slater determinants by first solving the system with the HF approximation. This gives a set of one electron MOs, some of which are occupied and some unoccupied. By building Slater determinants with the occupied MO, then all but one occupied MO and one unoccupied MO (single excited Slater determinants), then all but two (double excited Slater determinants) etc, you can build an arbitrarily large basis of Slater determinants. | {
"domain": "chemistry.stackexchange",
"id": 16535,
"lm_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, theoretical-chemistry",
"url": null
} |
terminology, logic, first-order-logic, propositional-logic
If you clean up your room I will make pancakes.
And let us say that you did not clean up your room, but when you walked into the kitchen your mom was making pancakes. Ask yourself, whether this makes your mom a liar. It does not! She would be a liar only if you cleaned the room but she refused to make pancakes. There might be other reasons that she decided to make pancakes (perhaps your sister cleaned up her room). Your mom did not tell you "If you do not clean up the room I will not make pancakes," did she?
So, if I say
"If the sun is green then the grass is green."
that does not make me a liar. The sun is not green (you did not clean up the room), but the grass turned out to be green anyhow (but your mom made pancakes anyhow). | {
"domain": "cs.stackexchange",
"id": 7764,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "terminology, logic, first-order-logic, propositional-logic",
"url": null
} |
• Thanks @JochenWengenroth. So what I wrote two steps above, the sentence ending by (I think) and the sentence after, should have regarded the unit ball in a Banach space, not the whole space, right? – Uri Bader Oct 10 '16 at 14:40 | {
"domain": "mathoverflow.net",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9780517437261226,
"lm_q1q2_score": 0.8018981111639272,
"lm_q2_score": 0.8198933403143929,
"openwebmath_perplexity": 458.17289654377214,
"openwebmath_score": 0.855269193649292,
"tags": null,
"url": "https://mathoverflow.net/questions/251779/closed-convex-bounded-sets-are-weakly-compact-for-which-spaces/251789"
} |
quantum-mechanics, newtonian-mechanics, particle-physics, atomic-physics, molecular-dynamics
In your concern about whether the material would have a normal force you are forgetting a very important aspect of the interaction between material objects on the microscopic scale: the electrostatic interactions of the particles. While you are correct to a first approximation that interatomic forces (what chemists call bonds) can be modeled somewhat like springs that will "snap back" if you do not apply so much force as to irrevocably separate them, I want to focus in on your "0 K" scenario, as it raises an important point. Even if the atoms in your hypothetical substance were utterly frozen in a perfect crystal lattice at absolute zero, and the substance has no heat capacity with which to obtain vibrational energy as heat from other sources, the particles that make up your foot (or your shoe or...) would still be strongly repelled by the hypothetical substance due to the Coulomb force at short ranges. Thus, you would still experience a normal force and could still step on this | {
"domain": "physics.stackexchange",
"id": 95579,
"lm_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, newtonian-mechanics, particle-physics, atomic-physics, molecular-dynamics",
"url": null
} |
php, html
$regex = '#<title>(.*?)<\/title>#';
preg_match($regex, $data, $match);
$title = $match[1];
array_push($titles, $title);
$regex2 = '#( |-|,)#';
$id = preg_split($regex2, $title)[0];
array_push($ids, $id);
}
}
// the first loop sets the nav bar
echo "<div id='navigation'>";
echo "<ul>";
for ($x = 0; $x < sizeof($contents); $x++) {
echo "<li><a href='#" . $ids[$x] . "'>" . $titles[$x] . "</a></li>";
}
echo "</ul>";
echo "</div>";
// this second loop sets the contents
echo "<div id='content'>";
for ($x = 0; $x < sizeof($contents); $x++) {
echo "<div id='" . $ids[$x] . "'>" . $contents[$x] . "</div>";
}
echo "</div>";
I like the idea of having all the content on one big page and the nav bar helps a lot when I'm viewing it on my phone.
Questions | {
"domain": "codereview.stackexchange",
"id": 33311,
"lm_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, html",
"url": null
} |
neural-networks, backpropagation, bias
I was in doubt: In multilayer perceptron, to update the Bias value, do we use the neuron's delta, or do we use the sum of all deltas? I really like the way Michael Nielsen describes backpropagation in his book. I will not explain all the details of these formulas because for that it's way better to read his chapter on backpropagation.
The formulas are the following:
\begin{align*}
(1) \quad & \delta^L = \Delta_a C \odot \sigma'(z^L) \\
(2) \quad & \delta^l = ((w_k^{l+1})^T\delta^{l+1}) \odot \sigma'(z^l)\\
(3) \quad & \frac{\partial C}{\partial b^l_j}= \delta^l_j \\
(4) \quad & \frac{\partial C}{\partial w^l_{j \space k}}= a_k^{l-1} \delta^l_j \\
\end{align*} | {
"domain": "ai.stackexchange",
"id": 4089,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "neural-networks, backpropagation, bias",
"url": null
} |
klein-gordon-equation
You can use the Pauli matrices to form the classical version of the Dirac operator such that when you square it you obtain the usual, classical Laplace operator of $\mathbb{R}^3$.
When Dirac manufactured his operator, he worked backwards, searching for what kind of matrices would fit the squaring procedure. The ones that worked were not the Pauli matrices, otherwise he would have used them immediately and positrons would not exist :)... | {
"domain": "physics.stackexchange",
"id": 55175,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "klein-gordon-equation",
"url": null
} |
c#, event-handling, delegates
// release any unmanaged objects
// set the object references to null
_disposed = true;
}
public void AddListener<T>(ApplicationEventHandlerDelegate<T> handler) where T : IApplicationEvent
{
if (_applicationEventHandlers.ContainsKey(typeof(T)))
{
Delegate handlersForType = _applicationEventHandlers[typeof(T)];
_applicationEventHandlers[typeof(T)] = Delegate.Combine(handlersForType, handler);
}
else
{
_applicationEventHandlers[typeof(T)] = handler;
}
} | {
"domain": "codereview.stackexchange",
"id": 18175,
"lm_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#, event-handling, delegates",
"url": null
} |
• From the factorization you can get a factor that's $\equiv 1 \mod 3$, but not necessarily a prime one – MCT Apr 1 '16 at 15:38
• Ran a code for the for all such numbers less than $10^7$. Seems ok. I am addin a list of the first few numbers and their prime factors. (7, 7) (26, 13) (63, 7) (124, 31) (215, 43) (342, 19) (511, 7) (728, 7) (999, 37) (1330, 7) (1727, 157) (2196, 61) (2743, 13) (3374, 7) (4095, 7) (4912, 307) (5831, 7) (6858, 127) (7999, 19) (9260, 463) (10647, 7) (12166, 7) (13823, 601) (15624, 7) (17575, 19) (19682, 13) (21951, 271) (24388, 7) (26999, 7) (29790, 331) (32767, 7) (35936, 1123) (39303, 397) (42874, 13) (46655, 7) (50652, 7) (54871, 37) (59318, 7) (63999, 13) (68920, 1723) (74087, 13) (79506, 7) – Banach Tarski Apr 1 '16 at 15:49
• Ran the code again. This statement seems to be true for all such numbers smaller than $2 * 10^8$ – Banach Tarski Apr 1 '16 at 15:56 | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9857180664944447,
"lm_q1q2_score": 0.8528669977724771,
"lm_q2_score": 0.865224070413529,
"openwebmath_perplexity": 154.6055233985329,
"openwebmath_score": 0.8251487016677856,
"tags": null,
"url": "https://math.stackexchange.com/questions/1723465/if-n-is-a-positive-integer-does-n3-1-always-have-a-prime-factor-thats-1-m"
} |
ubuntu, ros-fuerte, ubuntu-precise, openni-launch, openni-camera
roswtf in openni_camera says:
/opt/ros/fuerte/stacks/openni_camera$ roswtf
Loaded plugin tf.tfwtf
Package: openni_camera
================================================================================
Static checks summary: | {
"domain": "robotics.stackexchange",
"id": 9316,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "ubuntu, ros-fuerte, ubuntu-precise, openni-launch, openni-camera",
"url": null
} |
hours), but only when all of the rates are the same. How can I set up an equation to find the weights of each and use these weights to find the average rate of pay? I've got this setup in excel, so if I need to paste in the relevant parts of the document I can. • The simplest approach is that the average rate is total money earned divided by total hours worked. Why make it more complicated? – Ross Millikan Jan 31 '16 at 1:59 • I really like math, so sometimes I will try and find alternate routes to an answer. I got stuck before I figured the total money/total hours method, and I'm very interested how I would solve it with my original method – OSG Jan 31 '16 at 2:13 ## 1 Answer Let's say there are$n$days, for which$h_i$is the number of hours worked and$r_i$is the number of dollars per hour for that day for$i \in \Bbb{N}$.$h_i$is the weight on each day because days with more hours affect the average rate of pay more. Therefore, to find the weighted sum, we simply need to sum up all of | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.974434786819155,
"lm_q1q2_score": 0.814124222368301,
"lm_q2_score": 0.8354835371034368,
"openwebmath_perplexity": 608.160158010435,
"openwebmath_score": 0.8001357913017273,
"tags": null,
"url": "https://math.stackexchange.com/questions/1633935/calculating-a-weighted-average-for-different-pay-rates-and-different-hours"
} |
ros
Originally posted by Ryan with karma: 3248 on 2012-07-25
This answer was ACCEPTED on the original site
Post score: 3 | {
"domain": "robotics.stackexchange",
"id": 10349,
"lm_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
} |
organic-chemistry, elimination
Title: Can dehalogenation reaction occur through E2 mechanism? I have seen examples of dehydrohalogenation reaction that occur through E2 mechanism but never came across dehalogenation reaction that occur through E2 mechanism (for example, dehalogenation of 1,2-chloropropane).
Why is that all dehalogenation reaction occur through E1 reaction, if not can someone give a counterexample for it? Dehalogenation of vicinal dihalides can occur through the E2 mechanism. After some digging, I found this article from 1955. The full text is behind a paywall for me, so I cannot cite the specific rate constants, but the general findings are that trans-1,2-dihalocylohexanes undergo iodide-mediated dehalogenation more rapidly than the cis-stereoisomer.
These findings suggest the anti conformation is necessary, which supports the E2 mechanism.
This answer suggests that the final step of the reductive dehalogenation of vicinal dihalides by zinc dust is E2-like. | {
"domain": "chemistry.stackexchange",
"id": 15675,
"lm_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, elimination",
"url": null
} |
python, python-3.x
Return amt to be added to the bid pool
"""
# set opts as a dictionary for easy membership-testing
# of user-selected options
opts = {
'c': 'check',
'r': 'raise',
'b': 'call',
'a': 'all-in',
'f': 'fold'
}
curr, state, last_bet = status
if state == "All-In":
print(f"Player {name} is already All-In")
return 0
while True:
action = input(f"Which action would you choose? "
f"({', '.join(map(': '.join, opts.items()))})").strip().lower()
# This is a fast check to make sure inputs are valid
# Loop again if not in options dictionary
if action not in opts:
print("Invalid option, please try again")
continue | {
"domain": "codereview.stackexchange",
"id": 37213,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "python, python-3.x",
"url": null
} |
Series that converge which you should memorize:
$$\sum_{n=1}^\infty \frac{1}{n^2} \qquad \text{(converges)}$$
$$\sum_{n=1}^\infty \frac{1}{n^p} \qquad \text{(converges if p>1)}$$
$$\sum_{n=0}^\infty ar^n \qquad \text{(converges if |r|<1)}$$
Series which diverge that you should memorize:
$$\sum_{n=1}^\infty \frac{1}{n} \qquad \text{(diverges)}$$
$$\sum_{n=2}^\infty \frac{1}{\ln(n)} \qquad \text{(diverges)}$$
Something else to keep in mind is the rate of growth of different funcitons. In the long run we have: $$\ln(n) \lt n \lt n^2 \lt 5^n \lt n!$$ which means that $$\frac{1}{\ln(n)} \gt \frac{1}{n} \gt \frac{1}{n^2} \gt \frac{1}{5^n} \gt \frac{1}{n!}.$$
If you don't already know it you should learn the limit comparison test. This is a free licence to your intuition. For instance when determining the convergence of the following series:
$$\sum_{n=1}^\infty \frac{5n^3-3n^2+177}{6n^4-n^2+1}$$ | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9648551576415562,
"lm_q1q2_score": 0.8061205998988614,
"lm_q2_score": 0.8354835371034368,
"openwebmath_perplexity": 355.8915032608615,
"openwebmath_score": 0.8965409994125366,
"tags": null,
"url": "http://math.stackexchange.com/questions/433980/integral-and-series-convergence-intuition"
} |
quantum-mechanics, homework-and-exercises, wavefunction, harmonic-oscillator
But the answer given in book is
$c_n = i\sqrt{(n+1)\hbar\omega} $
A similar result I got for $a_-\psi_n$ and $\psi_{n-1}$ is
$c_n = \sqrt{n\hbar\omega}$
But the answer given in book is
$c_n = -i\sqrt{n\hbar\omega}$
And the reason given for these answers is "$i$'s are there to make the wavefunction real"
Please help me understand this statement or point out where I've gone wrong in proving the given equation Your answer is perfectly fine. As you can see one can choose an abritrary phase $\exp(i\phi)$ for $c_n$ in the equation
$$E_n + \frac{\hbar \omega}{2} = |c_n|^2$$
and it will still hold. This relates to the fact that you can always choose an arbitrary phase for the eigenfunctions $\psi_n$. All physical observables (e.g. $A_{nn} =\langle \psi_n|\hat{A}|\psi_n\rangle $) are invariant under the choice of the phase. In your book they just chose it to their convenience. | {
"domain": "physics.stackexchange",
"id": 25182,
"lm_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, homework-and-exercises, wavefunction, harmonic-oscillator",
"url": null
} |
scheme, racket
(trimmer size (rest lst-of-lsts)))
(else (cons (take (car lst-of-lsts) size)
(trimmer size (rest lst-of-lsts))))))
(joiner (get-values lst key)
(trimmer 4 (map
(lambda (lst) (remq* key2 lst))
(splitter lst (first key2)))))) | {
"domain": "codereview.stackexchange",
"id": 11046,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "scheme, racket",
"url": null
} |
special-relativity, photons, faster-than-light, tachyon
Title: What if photons are not the fastest particles? Einstein originally thought that special relativity was about light and how it always travelled at the same speed. Nowadays, we think that special relativity is about the idea that there is some universal speed limit on the transfer of information (and experiments tell us that photons, the quanta of light, move with the largest speed, $c$).
But what if tomorrow we happen to observe a particle $X$ that travels with a speed $v>c$? What changes would have to be made to special relativity? If (and that's a big if) tomorrow we had a $70\sigma$ detection in a repeatable experiment of a particle that travelled faster than $c$, then one of several things would be true. | {
"domain": "physics.stackexchange",
"id": 23380,
"lm_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, photons, faster-than-light, tachyon",
"url": null
} |
natural-language-processing, pig-latin, apl
A more holistic array approach is to append to every word, and instead modify what is appended. That is, collapse the appendix to shape 0 for words of length different from 1. Rephrased, this becomes keep the appendix as-is for words of length equal to 1, or 'w'/⍨1=≢. It becomes a "conditionally" append function in the form of ⊢,'w'/⍨1=≢, which you could then apply to each with (⊢,'w'/⍨1=≢)¨. However, you might want to…
Reduce ¨pepper¨
Some APLers call code with too many ¨s "too peppered" referring to the many tiny dots in foods that contain lots of black pepper. You may want to consider fusing the loops by defining the constituent transformation functions and applying them together in a single loop. Appropriate naming of the functions allows shortening the comments to become clarifications of the names, which can even make a comment obsolete.
Revised code
PigLatin←{
⍝ Monadic function expecting character scalar or character vector and returning character vector. | {
"domain": "codereview.stackexchange",
"id": 37914,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "natural-language-processing, pig-latin, apl",
"url": null
} |
ros, pr2-controllers
My CMakeLists.txt
cmake_minimum_required(VERSION 2.4.6)
include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)
# Set the build type. Options are:
# Coverage : w/ debug symbols, w/o optimization, w/ code-coverage
# Debug : w/ debug symbols, w/o optimization
# Release : w/o debug symbols, w/ optimization
# RelWithDebInfo : w/ debug symbols, w/ optimization
# MinSizeRel : w/o debug symbols, w/ optimization, stripped binaries
#set(ROS_BUILD_TYPE RelWithDebInfo)
rosbuild_init()
#set the default path for built executables to the "bin" directory
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
#set the default path for built libraries to the "lib" directory
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
#uncomment if you have defined messages
#rosbuild_genmsg()
#uncomment if you have defined services
#rosbuild_gensrv()
#common commands for building c++ executables and libraries | {
"domain": "robotics.stackexchange",
"id": 4973,
"lm_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, pr2-controllers",
"url": null
} |
cell-biology, dna, dna-sequencing, human-genome
Title: why dna polymerase 3 requires a primer for replication Why DNA polymerase 3 needs a primer to star replication.And whats happens when there is no AUG sequence on entire DNA. You are confused among DNA replication, DNA transcrption, and RNA translation.
First, DNA replication happens during cell division, it create two exactly same daughter DNA.
Second, DNA transcription transcribes DNA sequence into RNA sequence, this RNA sequence may be used to synthesize protein, or RNA itself as signal, etc.
Third, RNA translation is the RNA sequence (codon) recognized by tRNA, and then synthesize protein sequence.
AUG is a codon in the RNA, the is recognized by tRNA, and then start translation. And please remember, DNA use A, G, C, T, but RNA use A, G, C, U, there is no U in DNA.
For DNA synthesis, why does it need primer? I have another answer for solving your question: https://biology.stackexchange.com/a/40954/17473 | {
"domain": "biology.stackexchange",
"id": 4790,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "cell-biology, dna, dna-sequencing, human-genome",
"url": null
} |
c++, reinventing-the-wheel, memory-management, c++20
std::ranges::swap(*this, temp); // swap - normally this will be no-fail
return *this;
}
If the copy fails, then the original object is untouched.
This is why you should write the copy constructor properly, and then do copy assignment in terms of copy construction… not the other way around.
message_combiner& operator=(message_combiner&& other)
{
std::swap(size, other.size);
std::swap(payload, other.payload);
return *this;
}
This is fine, but it could be noexcept.
Also, you should really consider writing a swap function, and then writing move assignment (and copy assignment, and move construction) in terms of that. If you do it the way you are doing now, then swapping becomes ridiculously over-complicated. On the other hand, if you write a proper swap, then that will be efficient… and everything that uses swapping will also be.
~message_combiner() { if (payload != nullptr) delete [] payload; } | {
"domain": "codereview.stackexchange",
"id": 41951,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "c++, reinventing-the-wheel, memory-management, c++20",
"url": null
} |
I tried with Mathematica and there is no palindromic power of $2$ with exponent $n<10000$:
palindromeQ[n_] := IntegerDigits[n] === Reverse@IntegerDigits[n];
For[i = 1, i < 10000, i++, If[PalindromeQ[2^i], Print[i]] ]
Finally, I think that the answer will be the same if we replace $2$ by any integer $n>1$ which is not a multiple of $11$. I don't know how I could prove (even for the case of even length…) that $11^n$ is not a palindromic number for $n≥5$.
Any hint will be helpful. Thank you!
• The general claim is false...$2201^3=10662526601$. No idea about powers of $2$.
– lulu
Feb 13 '16 at 11:40
• Maybe you could use $11^{n} = (10+1)^{n} = \sum_{k=0}^{n} {n \choose k} 10^{k}$ for your last problem. Feb 13 '16 at 11:41
• @lulu, the question was about exponent at least 4. This also rules out $26^2=676$. Feb 13 '16 at 12:17
• @Downvoter : could you justify the downvote? Sep 12 '16 at 18:59 | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9865717428891156,
"lm_q1q2_score": 0.8263721851049078,
"lm_q2_score": 0.837619961306541,
"openwebmath_perplexity": 269.6853133438883,
"openwebmath_score": 0.7258709669113159,
"tags": null,
"url": "https://math.stackexchange.com/questions/1653079/is-there-any-palindromic-power-of-2"
} |
python, python-2.x
C = Constants()
def find_missing_argument(field_list, **fields):
"""Find the missing argument from fields, and return this or None.
Loop through all expected fields from <field_list>, and check if they
are present in passed field arguments, <fields>. If more than one is
missing, raise an error with all missing arguments. If noone is missing
then return None to indicate that all are present, and if just one is
missing, then return the name of the missing argument
"""
missing_arguments = [field for field in field_list if field not in fields]
count_of_missing_arguments = len(missing_arguments)
if count_of_missing_arguments > 1:
raise AttributeError('Too many missing arguments - {}'.format(', '.join(missing_arguments)))
elif count_of_missing_arguments == 1:
return missing_arguments[0]
else:
return None | {
"domain": "codereview.stackexchange",
"id": 16066,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "python, python-2.x",
"url": null
} |
fft, fourier-transform, dft, phase, cosine
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
If I make time range a multiple of 0.5, the results of imaginary parts has very little value that is e-14~15.
Let me know why this problem happened... Those $10^{-15}$ error terms after the FFT are typical roundoff errors... Apart from that, you should properly frame the cosine into a fully periodic length, as it seems you did, then you can expect the imaginary part to be as close to zero as the numerical format allows. Note that the accumulated FFT roundoff error grows with the square root of the length N of the FFT block; so the longer the FFT block, the larger will be the accumulated FFT error.
The following line of OCTAVE / MATLAB code shows the effect of frame length (aka aperture size) on the FFT computation:
L = 16 ; period of cosine
N = 128 ; frame length of sample block (integer multiple of L)
figure,stem(imag(fft(cos(2*pi*[0:N-1]./L),N))); title('imaginary part of the FFT'); | {
"domain": "dsp.stackexchange",
"id": 6472,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "fft, fourier-transform, dft, phase, cosine",
"url": null
} |
ros, velodyne-pointcloud, ros-kinetic, velodyne
min_intensity: 0, rot_correction: -0.08578884940168556, vert_correction: -0.2819583420854119,
vert_offset_correction: 0.11615006}
- {dist_correction: 1.233083807, dist_correction_x: 0, dist_correction_y: 0, focal_distance: 0,
focal_slope: 0, horiz_offset_correction: 0.025999999, laser_id: 46, max_intensity: 255,
min_intensity: 0, rot_correction: -0.16894748762061568, vert_correction: -0.3431963604842866,
vert_offset_correction: 0.11194568}
- {dist_correction: 0.845306021, dist_correction_x: 0, dist_correction_y: 0, focal_distance: 0,
focal_slope: 0, horiz_offset_correction: -0.025999999, laser_id: 47, max_intensity: 255,
min_intensity: 0, rot_correction: -0.10868622004833936, vert_correction: -0.335197900494832,
vert_offset_correction: 0.11250457000000001}
- {dist_correction: 1.107458999, dist_correction_x: 0, dist_correction_y: 0, focal_distance: 0,
focal_slope: 0, horiz_offset_correction: 0.025999999, laser_id: 48, max_intensity: 255, | {
"domain": "robotics.stackexchange",
"id": 31508,
"lm_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, velodyne-pointcloud, ros-kinetic, velodyne",
"url": null
} |
javascript, performance, strings
Title: Encoding strings using periodic table abbreviations I took a JavaScript challenge to finish a task related to logo of "Breaking Bad" where letters in your first name and last name are spotted with elements of periodic table and its respective atomic number. I wrote the below code, any suggestions to improve performance or any best coding practices
function Process() {
var ellist = {
"h": "1",
"he": "2",
"li": "3",
"be": "4",
"b": "5",
"c": "6",
.
.
.
"Lv":"116",
"Uus":"117",
"Uuo":"118"
};
var fname = document.getElementById("firstname");
var lname = document.getElementById("lastname");
var splits = fname.split("");
var value; | {
"domain": "codereview.stackexchange",
"id": 4797,
"lm_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, strings",
"url": null
} |
c++
Results
Using all of these suggestions, we get a simpler, smaller, safer interface in a single function. Here is the alternative version:
std::ostream& hex_dump(std::ostream& os, const void *buffer,
std::size_t bufsize, bool showPrintableChars = true)
{
if (buffer == nullptr) {
return os;
}
auto oldFormat = os.flags();
auto oldFillChar = os.fill();
constexpr std::size_t maxline{8};
// create a place to store text version of string
char renderString[maxline+1];
char *rsptr{renderString};
// convenience cast
const unsigned char *buf{reinterpret_cast<const unsigned char *>(buffer)}; | {
"domain": "codereview.stackexchange",
"id": 37324,
"lm_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++",
"url": null
} |
Sum of $\sum_{n=1}^{\infty}(-1)^{n+1}\frac{x^{2n-1}}{2n-1}$
I've been working with the series:
$$\sum_{n=1}^{\infty}(-1)^{n+1}\frac{x^{2n-1}}{2n-1}$$
From the ratio test it is clear that the series converges for $|x| < 1$, but I'm unable to obtain the sum of the series.
I'm looking for any hint of how to obtain the sum.
• Differentiate by x, use the geometric sum, integrate, and use that f(0)=0. Result is arctan(x) – Ákos Somogyi Aug 25 '15 at 17:11
Let $f(x)=\sum_{n=1}^{\infty}\frac{(-1)^{n+1}x^{2n-1}}{2n-1}$. Then we have
\begin{align} f'(x)=\sum_{n=1}^{\infty} (-1)^{n+1}x^{2n-2}&=\frac{-1}{x^2}\sum_{n=1}^{\infty} (-x^2)^{n}\\\\ &=\frac{1}{1+x^2} \tag 1 \end{align}
Integrating $(1)$ and using $f(0)=0$ reveals that
$$\bbox[5px,border:2px solid #C0A000]{f(x)=\arctan(x)}$$ | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9814534376578004,
"lm_q1q2_score": 0.8544506835424719,
"lm_q2_score": 0.870597270087091,
"openwebmath_perplexity": 384.5111916355857,
"openwebmath_score": 0.8960800170898438,
"tags": null,
"url": "https://math.stackexchange.com/questions/1409368/sum-of-sum-n-1-infty-1n1-fracx2n-12n-1"
} |
beginner, c
Alternatively, use:
fputs(lines[i][0], stdout);
(Do not use puts() because it adds newlines to the end of your data - unless you remove the newlines from the input.)
When I compile your code using my default options, I get two warnings about the printf() - confirmation of what I'd already observed - plus a warning that findTail() does not return a value even though it is declared to return an int. That's best fixed by making it into a void function.
/usr/bin/gcc -g -std=c99 -Wall -Wextra -Wmissing-prototypes \
-Wstrict-prototypes cr.c -o cr
That's a pretty stringent set of warning options, and your code is good to generate just those three. I wish all the code I dealt with was as clean.
When I run the program on its own source code, it works fine. When I run it with:
$ perl -e 'for $i (1..12) { print "A" x 2047, "\n"; }' | ./cr
error: not enough room in buffer.
$ | {
"domain": "codereview.stackexchange",
"id": 4037,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "beginner, c",
"url": null
} |
ros, broadcaster, transform
Originally posted by dreamcase on ROS Answers with karma: 91 on 2014-05-29
Post score: 0
There are three standard ways of broadcasting TF data for your robot. If your robot has a URDF file that specifies where the joints and links are and how they are sized, and your drivers output a sensor_msgs/JointState topic with the joint positions, then you can use the robot_state_publisher node to turn joint positions and kinematic model into TF frames. You don't mention what type of robot you have, it might already have this implemented as part of the standard ROS drivers for the platform.
However, if you have a very simple robot, or just some static frames you need to publish (I presume here that the laser is actually fixed to the base, not moving, has no joints in between base_frame and laser frame), then you can use the static_transform publisher, which is part of tf and is documented here: http://wiki.ros.org/tf#static_transform_publisher | {
"domain": "robotics.stackexchange",
"id": 18105,
"lm_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, broadcaster, transform",
"url": null
} |
python, beginner, game, python-3.x, number-guessing-game
Using spaces around operators, removing unnecessary parentheses, and using messages that seem more understandable to me. (Your homework will make this messages fully customizable, so if you do not like my choices do not worry)
elif numPlayer == randomNum:
return tries
If the player guessed correctly our function halts and returns (gives back) how many tries it took for the user to guess the number.
print ("Well done you guessed my number in {} guesses".format(
number_guessing(0, 50)))
We just call the function we wrote and print its result, that is how many tries it took.
Final code
Just to play around and implement the change I suggested:
from random import randint
from itertools import count | {
"domain": "codereview.stackexchange",
"id": 15771,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "python, beginner, game, python-3.x, number-guessing-game",
"url": null
} |
What prevents dragons from destroying or ruling Middle-earth? So for mod 3, you need base 4 digits (pairs of bits). This answer is elaborated based on the question asked in GATE CSE Facebook Community for GATE aspirants. initial state (upper part of the figure) to the acceptance state, Adjective agreement-seems not to follow normal rules. Does "a point you choose" include any movable surface? So how do you compute if a binary number is divisible by 3? Why can't California Proposition 17 be passed via the legislative process and thus needs a ballot measure? Can a small family retire early with 1.2M + a part time job? I keep sharing my coding knowledge and my own experience on. site design / logo © 2020 Stack Exchange Inc; user contributions licensed under cc by-sa. By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy. Language L: {a^n| n is even or divisible by 3} 1 2 3 4. I am complete Python Nut, love Linux and vim as an editor. Asking | {
"domain": "eslo-info.org",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9489172659321807,
"lm_q1q2_score": 0.8388801353120098,
"lm_q2_score": 0.884039278690883,
"openwebmath_perplexity": 645.9422291902057,
"openwebmath_score": 0.2016274482011795,
"tags": null,
"url": "https://eslo-info.org/blog/fw20c.php?tag=69846c-nfa-divisible-by-3"
} |
java, strings
for(int i = 0; i < words.length; i++) {
words[i] = reverseInOn2Time(words[i]);
}
for(i = 0; i < words.length; i++) {
blank.append(words[i] + " ");
}
return blank.toString();
I personally would choose the first solution.
These snippets assume that reverseInOn2Time reverses a string, as stated by the comments near the function call. | {
"domain": "codereview.stackexchange",
"id": 14428,
"lm_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, strings",
"url": null
} |
php, object-oriented, dependency-injection
class Router
{
function get()
{
$url = $this->getExplodedUrl();
// get view object
$viewsDir = __DIR__ . '/../path/to/views/dir'; //@TODO: Read this from a config file
$view = new ViewCreator($viewsDir)
// get orm object
$db = new Orm(new \Pdo('...'))
// get form builder object
$formBuilder = new FormBuilder('...');
// IF URL matches, and controller + method exists.
return (new $controller)->$method($url, $db, $view, $formBuilder);
}
}
class UserController
{
public function showUserProfile($args, $db, $view)
{
// extract username & id from current url. i.e. dev.foo.com/john/11
list($userName, $id) = $args;
$select = UserRecord::fetchUserFromDb($db, [$userName, $id]);
UserProfile::showUserProfile($view, ["select"=>$select]);
}
} | {
"domain": "codereview.stackexchange",
"id": 9770,
"lm_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, dependency-injection",
"url": null
} |
python, comparative-review
Return DRAW, HOME or AWAY depending on the outcome
"""
if home_goals > away_goals:
return HOME
elif away_goals > home_goals:
return AWAY
else:
return DRAW
I personally find the verbose if-else logic in the latter solution, and the assumed equality in the 3rd branch, less appealing. The documentation to cmp says nothing about the return value except it being negative, zero or positive, so you rely on implementation-dependent behaviour. This exact function will also not work in Python 3, as there is no cmp function anymore.
I'd say use the second option or shorten it a bit:
def winning_side(home_goals, away_goals):
if home_goals == away_goals:
return DRAW
return HOME if home_goals > away_goals else AWAY | {
"domain": "codereview.stackexchange",
"id": 12107,
"lm_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, comparative-review",
"url": null
} |
data
Title: Docker for data science I recently started to read articles about Docker.
To me, in data science, Docker is useful because:
1) You have a totally different environment, which protect you against libraries and dependencies problems.
2) If your application modify, for example, the database of your company, you want first to make sure that the code works fine, and won't have bad consequences on the database. Thus, you use Docker to test your code first.
my questions: | {
"domain": "datascience.stackexchange",
"id": 10104,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "data",
"url": null
} |
When the prime is a reasonably small one I'd rather find directly the inverse: $$9^{-1}=\frac{1}{9}=3\pmod {13}\Longrightarrow 9x=7\Longrightarrow x=7\cdot 9^{-1}=7\cdot 3= 21=8\pmod {13}$$ But...I try Gauss's method when the prime is big and/or evaluating inverses is messy.
-
9x = 7 mod 13
9x = 7 + 13n
9x = 20 for n = 1
9x = 33 for n = 2
9x = 46 for n = 3
9x = 59 for n = 4
9x = 72 for n = 5
Then x = 8 mod 13
You arrive at the correct answer before n = 13.
- | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9740426412951847,
"lm_q1q2_score": 0.8336355135381395,
"lm_q2_score": 0.8558511488056151,
"openwebmath_perplexity": 484.1728047110517,
"openwebmath_score": 0.8980107307434082,
"tags": null,
"url": "http://math.stackexchange.com/questions/174676/solving-simple-congruences-by-hand"
} |
algorithms, mathematical-programming, pseudocode
The encoding of the problem as integer programming is tedious but fairly straightforward. You introduce zero-or-one integer variables $x_{i,j}$, with the intended meaning that $x_{i,j}=1$ means that the $i$th item is assigned to the $j$th group. (When you have multiple elements of the same color, treat them all as a single item with the same value of $i$; they just add more than one to the number of elements in that group.) Then the number of elements in the group is a linear function of the $x$'s, and the group average of each group is a linear function of the $x$'s, so you can write down constraints for these to be a valid solution as linear inequalities. | {
"domain": "cs.stackexchange",
"id": 11537,
"lm_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, mathematical-programming, pseudocode",
"url": null
} |
python, number-guessing-game
attempts = [0]
isPlaying = True
# Setting the global variable dif to 1-3 to determine difficulty later on
def difficultysetting(input):
global dif
if input.lower() == "e":
dif = 1
elif input.lower() == "m":
dif = 2
elif input.lower() == "h":
dif = 3
# Returns the high score of whatever difficulty the user is playing on
def highscore():
if dif == 1:
return easyScore
elif dif == 2:
return mediumScore
elif dif == 3:
return hardScore
while isPlaying:
print("Difficulties (E)asy, (M)edium, (H)ard")
difficulty = difficultysetting(input("Choose a difficulty: "))
guess = -1
# Checking which difficulty user is playing on and generating a random number based on that
if dif == 1:
number = int(random.randint(1, 100))
elif dif == 2:
number = int(random.randint(1, 1000))
elif dif == 3:
number = int(random.randint(1, 10000)) | {
"domain": "codereview.stackexchange",
"id": 43843,
"lm_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, number-guessing-game",
"url": null
} |
c++, performance, api, symbolic-math
double SField::valueAtLastPosition() const
{
return start_Node->value;
}
SField& SField::operator+=(const SField& g) {return *this = *this+g;}
SField& SField::operator*=(const SField& g) {return *this = *this*g;}
SField& SField::operator-=(const SField& g) {return *this = *this-g;}
SField& SField::operator/=(const SField& g) {return *this = *this/g;}
///////////////////////////////////////////////////////////////////////////////////////////////
//VAR//////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////
Var::Var() : vn(new IMPLEMENTATION::VarNode()) {} | {
"domain": "codereview.stackexchange",
"id": 45345,
"lm_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, api, symbolic-math",
"url": null
} |
# Simulating order statistics
I am having a problem with the density of the first order statistic of a series of n random variables iid with common distribution (standard normal).
I am using Arnold's book as a reference for such a density function for the k'th order stat: $$f_{X_{k:n}}(x) = \frac{n!}{k-1! (n-k)!} F(x)^{k-1} (1-F(x))^{n-k} f(x).$$
The I simulate data in R store the min and compare the obtained empirical distribution against the theoretical function. These curves diverge substantially.
What am I doing wrong? or missing?
# Distribution
Fx <- function(x) pnorm(x)
fx <- function(x) dnorm(x)
n <- 10
# ATTENTION: 6M simulation may take some time
z <- replicate(1e6, min(rnorm(n)))
# Probabiltiy z > y
prob <- function(x) {
sapply(x, function(u) mean(z>u))
}
# Density
fos_k <- function(x, n, k) {
fact <- factorial(n) / (factorial(k-1) * factorial(n-k))
fact * fx(x) * Fx(x)^(k-1) *(1-Fx(x))^(n-k)
} | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9626731105140615,
"lm_q1q2_score": 0.8669158000329825,
"lm_q2_score": 0.9005297754396141,
"openwebmath_perplexity": 2384.3748603649874,
"openwebmath_score": 0.5744186639785767,
"tags": null,
"url": "https://stats.stackexchange.com/questions/241652/simulating-order-statistics"
} |
ros, gazebo, clock
Originally posted by gvdhoorn with karma: 86574 on 2017-02-27
This answer was ACCEPTED on the original site
Post score: 1
Original comments
Comment by WLemkens on 2017-02-27:
Yes thank you! It was pointing to 127.0.0.1 instead of my real ip-address.
Comment by gvdhoorn on 2017-02-27:
What was pointing to 127.0.0.1? In any case, that should probably also work.
Comment by WLemkens on 2017-02-27:
ROS_IP and ROS_MASTER_URI were pointing to 127.0.0.1. After changing it to use the ip of my network card the messages were working again.
Comment by gvdhoorn on 2017-02-27:
If you are not trying to distribute your ROS application across multiple networked hosts, the setting all of those is probably not necessary. Not setting them will allow ROS to detect proper values for them automatically. | {
"domain": "robotics.stackexchange",
"id": 27143,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "ros, gazebo, clock",
"url": null
} |
python, beginner, tic-tac-toe
print_board(board)
print("You are playing as 'X'")
while True:
player_turn(board)
cpu_turn(board) Answers to the explicit questions
Better to pass board between functions or set as a global variable?
I'd recommend against global variables, since accessing those will lead to side-effects within your functions. Either pass the object to pure functions or create an instance of the board as a property of some superordinate Game class.
OK to use same variable name within different functions?
This is perfectly fine.
Would you recommend using Object Orientated Programming for this?
Programming paradigms should be selected based on the problem to solve. Python is a multi-paradigm language. You can use functional or OO programming and mix those. You should use the paradigm that most fittingly solves your problem at hand. That being said, your functional approach is absolutely reasonable.
General review
PEP 8
Read and apply PEP8. | {
"domain": "codereview.stackexchange",
"id": 42748,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "python, beginner, tic-tac-toe",
"url": null
} |
quantum-mechanics, photons, atomic-physics, quantum-electrodynamics
Title: Can an electron jump to a higher energy level if the energy is insufficient or exceeds the $\Delta E$? Let's say we have an atom of hydrogen. It has one electron on $E_1 = -13.6~\mathrm{ eV} ~~(E_2 = -3.4~\mathrm{eV})$ energy level. I know that if we fire a photon with 10.2 eV energy the hydrogen atom will absorb it and the electron will jump on the next energy level E2.
And below are my questions. | {
"domain": "physics.stackexchange",
"id": 35667,
"lm_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, photons, atomic-physics, quantum-electrodynamics",
"url": null
} |
ds.algorithms, graph-theory, optimization
Title: Finding good induced subgraph You are given a graph $G = (V,E)$ with $n$ vertices. It might be bipartite if you want. There are $m$ sets of edges $E_1,\ldots, E_m \subseteq E$ (say disjoint). I am interested in the problem of finding a subset $S \subseteq V$, as small as possible (or even smaller), such that the induced graph $G_S$ has at least one edge from each class $E_i$, for $i=1,\ldots, m$.
Currently, I know that this problem is set cover hard. I also have a not completely obvious (roughly) $O(\sqrt{n})$ approximation.
This seems like a natural problem - is anyone aware of any relevant references, or any better algorithms? Look for Minimum Rainbow Subgraph. | {
"domain": "cstheory.stackexchange",
"id": 1369,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "ds.algorithms, graph-theory, optimization",
"url": null
} |
optimization, knapsack-problems
Title: Spandex knapsack? I'm going camping. While I'm away, I plan to eat only s'mores, which consist of 20% chocolate, 50% marshmallow, and 30% graham cracker. I did a thorough clean-out of my pantry, which revealed multiple packages of each of these ingredients in various sizes.
I'll need at least 5kg of food to get me through the weekend, but I'm willing to carry up to 10kg of weight if it means I can achieve a more perfect balance of chocolate, marshmallow, and graham cracker. (My camping companions like s'mores, too.)
I really don't care about the weight, as long as it's in the range of 5-10kg. But the farther away from a 20/50/30 split, the sadder I'll be. :-( | {
"domain": "cs.stackexchange",
"id": 3942,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "optimization, knapsack-problems",
"url": null
} |
gravity, weight
Motionlessness occurs for just a single instant1 for an object thrown into the air. Because there is no air resistance if there is no motion, this is also a moment of weightlessness.
To feel (near-) weightlessness for an extended period of time while moving, I recommend going sky diving, or even riding a roller coaster with a vertical drop. | {
"domain": "physics.stackexchange",
"id": 13458,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "gravity, weight",
"url": null
} |
scikit-learn, pandas, linear-regression
Title: Apply multivariable linear regression to a dataset in pandas with sklearn I'm trying to predict the population for states and the country in 2050. My current dataset has values for each state from 1951,1961...2011 in the same table. Here is a sample view:
Row States/Union Territories 1951 1961 1971 1981 1991 2001 2011
0 Andaman and Nicobar Islands 31 64 115 189 281 356 381
1 Andhra Pradesh 31115 35983 43503 53551 66508 76210 84581
2 Arunachal Pradesh 307 337 468 632 865 1098 1384
.
.
. | {
"domain": "datascience.stackexchange",
"id": 7355,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "scikit-learn, pandas, linear-regression",
"url": null
} |
orbital-motion, earth, collision, moon
Bonus points for justifying (or providing references that justify) the impact speed. One could ask how much energy is needed to separate all that mass, and how much of the pre-collision kinetic energy goes into this versus melting the surface and heating the mantle. This is mostly to put an upper bound on how much the impact could have perturbed Earth's orbit - it should be easy enough to argue that the collision wasn't any faster than, say, $30\ \mathrm{km}/\mathrm{s}$.
When it comes to angular momentum (and energy), the situation is somewhat complicated by the fact that our orbiting object is not a classical point mass. The Earth can rotate, and the Earth+Moon system will clearly also have angular momentum. Can these extra degrees of freedom relieve the burden of the impact, leaving Earth in a still rather circular orbit? | {
"domain": "physics.stackexchange",
"id": 8272,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "orbital-motion, earth, collision, moon",
"url": null
} |
Fetching Coordinates¶
So first we need to find all the supercharger locations. One possible way to do that is to get a list of addresses for them and then geocode the addresses into coordinates. However it turns out that some of the superchargers are in remote places that aren't easily specified by a street address. They are more conveniently specified by latitudes and longitudes.
Luckily the Tesla website contains references to coordinates of all the supercharger locations. We can use simple regular expressions and BeautifulSoup to parse the pages.
In [3]:
%matplotlib inline
import matplotlib.pyplot as plt
from IPython.core.pylabtools import figsize
figsize(15, 5)
In [4]:
from bs4 import BeautifulSoup
import re
import requests
import numpy as np
import pandas as pd
In [5]:
# get the list of superchargers in the US
url = 'http://www.teslamotors.com/findus/list/superchargers/United+States'
rv = requests.get(url)
content = rv.text | {
"domain": "mortada.net",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9898303413461357,
"lm_q1q2_score": 0.806941859876889,
"lm_q2_score": 0.8152324960856175,
"openwebmath_perplexity": 2819.326138800254,
"openwebmath_score": 0.5810510516166687,
"tags": null,
"url": "http://mortada.net/the-traveling-tesla-salesman.html"
} |
ecology, mathematical-models, population-dynamics, theoretical-biology
And to be clear, nothing of this has anything to do with period/cycle length per se (in the sense of species interactions or lagging feedback loops), but is a property of the model and the population growth rate. The statement about period 3 implying chaos probably refers to a brief window around r ~3.83 ($1+\sqrt{8})$ where you get cycling between three values, and at higher values then this you only find chaotic behaviour (which you get at lower values as well though).
Addition:
I now realize that the statement "Period three implies chaos" comes from the theoretical paper with the same name (Li & Yorke, 1975). This paper proves that all one-dimensional models (not only the equation above) that has a period 3 cycle will also show chaotic behaviour. This proof is a special case of the Sharkovsky's theorem, which is older but was unknown to Li & Yorke at the time.
There is also a question at MathSE that deals with the same problem, and some of the answers there link to useful resourses: | {
"domain": "biology.stackexchange",
"id": 1798,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "ecology, mathematical-models, population-dynamics, theoretical-biology",
"url": null
} |
qiskit, programming, quantum-state, ibm-q-experience, textbook-and-exercises
Title: Given this code fragment, what is the probability that a measurement would result in $|0\rangle$? Trying to understand below probability how it occured?
qc = QuantumCircuit(1)
qc.ry(3 * math.pi/4, 0)
A. 0.8536
B. 0.5
C. 0.1464
D. 1.0
And the answer is C. But I can't understand the calculation behind it. Can someone please explain? We have,
$$\begin{align}\begin{aligned}\newcommand{\th}{\frac{\theta}{2}}\\\begin{split}Ry(\theta) = \exp\Big(-i \th Y\Big) =
\begin{pmatrix}
\cos{\th} & -\sin{\th} \\
\sin{\th} & \cos{\th}
\end{pmatrix}\end{split}\end{aligned}\end{align}$$
If the input state is $|0\rangle$, then the probability of getting $|0\rangle$ as a measurement result is the square of the absolute value of the entry in the first row and first column. That is, $\cos^2\big({\th}\big)$.
Now, $\theta = 3 \pi/4$, so the probability equals $\cos^2(3 \pi/8) = 0.1464$. | {
"domain": "quantumcomputing.stackexchange",
"id": 3422,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "qiskit, programming, quantum-state, ibm-q-experience, textbook-and-exercises",
"url": null
} |
ros, rosws
Original comments
Comment by sam on 2012-08-17:
I have already install ROS electric. Why I still need to rosinstall /opt/ros/electric/.rosinstall ? Thank you~
Comment by Lorenz on 2012-08-17:
Please have a look at the ros overlay installation page for more information on how to properly set up a ros overlay. You need to merge /opt/ros/electric/.rosinstall to your current workspace if you want to use stacks installed as debian pkgs.
Comment by sam on 2012-08-17:
I understand I always use a cumbersome way of ROS. But I still don't understand what's the effect of rosinstall /opt/ros/electric/.rosinstall? Thank you~
Comment by Lorenz on 2012-08-17:
A ros workspace is a directory that contains a .rosinstall file that points to all repositories you installed from source, to local directories that should be part of your ROS_PACKAGE_PATH. rosws merge merges the content of another rosinstall file with your workspace.
Comment by sam on 2012-08-17: | {
"domain": "robotics.stackexchange",
"id": 10654,
"lm_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, rosws",
"url": null
} |
python, numpy, statistics, matplotlib
For my data, I have ~800 arrays of size 256x256. I don't think I'm able to upload that for anyone to use.
EDIT 2
I just realised that we don't need to keep the data in the R list, so we can remove it as well as the lines
Solution = []
for k in range(len(R)):
Solution.append(np.mean(R[k]))
and edit the while loop to
### Autocorrelation for varying lags.
Count = 1
Solution = []
while Count < len(New_Data)//2: # Arbitrary choice for max lag time.
Matrix_Multiply = []
for j in range(len(New_Data)-Count):
Matrix_Multiply.append(np.multiply(New_Data[j],New_Data[j+Count]))
R = sum(Matrix_Multiply)
Solution.append(np.mean(R))
Count = Count+1 | {
"domain": "codereview.stackexchange",
"id": 31105,
"lm_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, matplotlib",
"url": null
} |
PDF. Methods of Real Analysis. We cannot guarantee that Real Analysis book is in the library, But if You are still not sure with the service, you can choose FREE Trial service. 1 Notations ∈ - belongs to. Read PDF Introduction To Real Analysis Solution Manual instead the printed documents. com [TBB-Dripped] Elementary Real Analysis - Dripped Version Thomson*Bruckner*Bruckner. Real Analysis August 29, 2020 Chapter 2. Online course materials supplement the required textbook. Account 40. , and Honours in Mathematics and Physics students of several universities and institutions across India. 5, Chapter X, etc. Although the prerequisites are few, I have written the text assuming the reader has the level of mathematical maturity of one who has completed the standard sequence of calculus courses, has had some exposure to the ideas of mathematical proof (including induction), and has an acquaintance with such basic ideas as equivalence. Once one has the Lebesgue integral, one can start | {
"domain": "icscaponnetto.it",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9843363485313247,
"lm_q1q2_score": 0.8202716852162337,
"lm_q2_score": 0.8333245911726382,
"openwebmath_perplexity": 1089.603905556381,
"openwebmath_score": 0.4706494212150574,
"tags": null,
"url": "http://rvic.icscaponnetto.it/real-analysis-pdf.html"
} |
molecular-design
E(RB97D3) = -849.855064121
C 0.00000 -0.71210 0.00000
C -0.00000 0.71210 0.00000
C -1.25688 -1.35508 -0.01308
C 1.25688 -1.35508 0.01309
C -1.25688 1.35508 0.01309
C 1.25688 1.35508 -0.01308
C -2.46545 -1.49799 -0.06310
C -2.46545 1.49799 0.06310
C 2.46545 1.49799 -0.06310
C 2.46545 -1.49799 0.06310
C 3.90819 -1.43687 0.24464
C 4.25416 -0.48923 1.44910
C 4.64897 -0.93627 -1.02206
C 4.64897 0.93627 1.02206
H 5.08644 -0.93074 2.00793
H 3.39579 -0.45561 2.12315
C 4.25416 0.48923 -1.44910
H 5.72105 -0.97274 -0.79444
H 4.47838 -1.63040 -1.84994 | {
"domain": "chemistry.stackexchange",
"id": 9575,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "molecular-design",
"url": null
} |
general-relativity, special-relativity, differential-geometry, tensor-calculus, differentiation
Title: Why, when going from special to general relativity, do we just replace partial derivatives with covariant derivatives? I've come across several references to the idea that to upgrade a law of physics to general relativity all you have to do is replace any partial derivatives with covariant derivatives.
I understand that covariant derivatives become partial derivatives in Minkowski space however is the reverse unique? Is there no other tensor operation which becomes a partial derivative / if so why do we not mention them? Transforming partial derivatives to covariant derivatives when going from Minkowski to a general spacetime is just a rule of thumb, and should not be applied carelessly.
For example, when studying electromagnetism in the Lorenz gauge $(\nabla_\mu A^\mu =0)$, working from first principles, one can show that the inhomogeneous wave equation reads:
$$\nabla_\nu \nabla^\nu A^\mu - R^\mu_{\,\,\nu} A^\nu = -j^\mu$$
whereas in Minkowski the same equation reads: | {
"domain": "physics.stackexchange",
"id": 56911,
"lm_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, special-relativity, differential-geometry, tensor-calculus, differentiation",
"url": null
} |
java, socket, chat
System.out.println(msg);
broadcast(msg);
}
private void broadcast(String msg) throws IOException {
ByteBuffer messageBuffer = ByteBuffer.wrap(msg.getBytes());
for (SelectionKey key : mSelector.keys()) {
if (key.isValid() && key.channel() instanceof SocketChannel) {
SocketChannel channel = (SocketChannel) key.channel();
channel.write(messageBuffer);
messageBuffer.rewind();
}
}
}
} Bad support for fragmented tcp packets
StringBuilder sb = new StringBuilder();
mBuffer.clear();
int read = 0;
while ((read = ch.read(mBuffer)) > 0) {
mBuffer.flip();
byte[] bytes = new byte[mBuffer.limit()];
mBuffer.get(bytes);
sb.append(new String(bytes));
mBuffer.clear();
} | {
"domain": "codereview.stackexchange",
"id": 19483,
"lm_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, socket, chat",
"url": null
} |
Technical Article
# The Effect of Symmetry on the Fourier Coefficients
3 hours ago by Dr. Steve Arar
## Learn about how symmetry in signals can simplify the calculation of the Fourier coefficients when used to find the steady-state response of a circuit.
Finding the Fourier series coefficients of a waveform often involves some relatively tedious calculations. Only by visual inspection of the waveform and without performing a single calculation, it is sometimes possible to determine which coefficients are going to work out to zero. This can be done when the waveform possesses certain types of symmetries. Read on to learn about these symmetries and how they can be used to simplify the calculation of the Fourier coefficients.
### Understanding Fourier Series Coefficients
The following equation can be used to express a periodic signal, f(t), with period T in terms of its Fourier series coefficients: | {
"domain": "allaboutcircuits.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9886682488058381,
"lm_q1q2_score": 0.8238815683339719,
"lm_q2_score": 0.8333245953120233,
"openwebmath_perplexity": 616.3378161159237,
"openwebmath_score": 0.8675824999809265,
"tags": null,
"url": "https://www.allaboutcircuits.com/technical-articles/the-effect-of-symmetry-on-the-fourier-coefficients/"
} |
javascript, performance, algorithm, array, sorting
In the output, 4 is before 1 because A < Z. 5 and 6 are sorted alphabetically under 4 and before 1. Similar case for 8 and 7 under 2 and before 3.
and if desc, the output should be:
[
{ _id: 1, parent: 0, name: 'Z' },
{ _id: 3, parent: 1, name: 'Z' },
{ _id: 2, parent: 1, name: 'H' },
{ _id: 7, parent: 2, name: 'L' },
{ _id: 8, parent: 2, name: 'G' },
{ _id: 4, parent: 0, name: 'A' },
{ _id: 6, parent: 4, name: 'N' },
{ _id: 5, parent: 4, name: 'M' }
]
I tried to implement a function as below.
function sortByHierarchyAndName(arr, sort) {
var i = 0;
j = 0;
t = 0;
parentFound = false;
x = arr.length;
arr2 = [];
//Sort by parent asc first
arr = arr.sort(function(a, b) {
if(a.parent < b.parent) return -1;
if(a.parent > b.parent) return 1;
return 0;
}); | {
"domain": "codereview.stackexchange",
"id": 18414,
"lm_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, array, sorting",
"url": null
} |
ros, transform, tf2
After this got the expected result:
$ ros2 run tf2_ros tf2_echo odom base_link
**
[INFO] [1681154384.590858888] [tf2_echo]: Waiting for transform odom -> base_link: Invalid frame ID "odom" passed to canTransform argument target_frame - frame does not exist
At time 2.1000000
- Translation: [-0.000, -0.022, 0.900]
- Rotation: in Quaternion [0.000, 0.000, 0.001, 1.000]
At time 3.1000000
- Translation: [-0.001, -0.023, 0.900]
- Rotation: in Quaternion [0.000, 0.000, 0.001, 1.000]
At time 4.1000000
- Translation: [-0.001, -0.023, 0.900]
- Rotation: in Quaternion [0.000, 0.000, 0.001, 1.000]
^C[INFO] [1681154388.348508517] [rclcpp]: signal_handler(signal_value=2)
**
Originally posted by Vini71 with karma: 266 on 2023-04-10
This answer was ACCEPTED on the original site
Post score: 0 | {
"domain": "robotics.stackexchange",
"id": 38334,
"lm_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, transform, tf2",
"url": null
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.