text stringlengths 1 1.11k | source dict |
|---|---|
graphs
Title: What are graph embedding? I recently came across graph embedding such as DeepWalk and LINE. However, I still do not have a clear idea as what is meant by graph embeddings and when to use it (applications)? Any suggestions are welcome! Graph embedding learns a mapping from a network to a vector space, while preserving relevant network properties.
Vector spaces are more amenable to data science than graphs. Graphs contain edges and nodes, those network relationships can only use a specific subset of mathematics, statistics, and machine learning. Vector spaces have a richer toolset from those domains. Additionally, vector operations are often simpler and faster than the equivalent graph operations. | {
"domain": "datascience.stackexchange",
"id": 11888,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "graphs",
"url": null
} |
water, materials
I have no background in chemistry, unfortunately, so I am not even sure if I am searching for this formula using the right terms. I tried to do something similar when I had a humid car.
In chemistry, we often use $\ce{CaSO4}$ or anhydrite to serve as a desiccant. You could probably get cost-effective plaster for similar purposes. You could also get gypsum and heat it to generate plaster of Paris yourself.
As you're probably aware, people also use silica gel in products (and food) to minimize water content.
Either material should be much better as a desiccant than regular salt.
One key criteria is to increase the surface area - make sure the material is a fine powder and enclose it in something porous. I've seen people use various cloth materials, paper towels, etc. | {
"domain": "chemistry.stackexchange",
"id": 7046,
"lm_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, materials",
"url": null
} |
separation of variables. Learn more about 3d, diffusion, discrete, gaussian, convolution, rate, coefficient, blur, blurring, kernel, sigma MATLAB. For the latter, probabilistic tractography maps were generated using the FSL/FMRIB’s Diffusion Toolbox (FDT v. m: Simulating a stochastic system with the Gillespie algorithm. It integrates computation, visualization, and programming in an easy-to-use environment where problems and solutions are expressed in common mathematical notation. The space discretization is performed by means of the standard Galerkin approach. Perona and J. written by Tutorial45. The "STEADY_NAVIER_STOKES" script solves the 2D steady Navier-Stokes equations. At each time. Channel A gives voltage. They include EULER. Hi, I've been having some difficulty with Matlab. This code plots deformed configuration with stress field as contours on it for each increment so that you can have animated deformation. Lecture 06. In this tutorial, I am decribing the classification of | {
"domain": "aresdeck.it",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9755769071055402,
"lm_q1q2_score": 0.8440926429097708,
"lm_q2_score": 0.865224091265267,
"openwebmath_perplexity": 1675.8624038387193,
"openwebmath_score": 0.5665031671524048,
"tags": null,
"url": "http://aresdeck.it/ifmt/2d-diffusion-matlab.html"
} |
javascript, beginner, calculator
checkCashRegister(3.26, 100, [["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.1], ["QUARTER", 4.25], ["ONE", 90], ["FIVE", 55], ["TEN", 20], ["TWENTY", 60], ["ONE HUNDRED", 100]]);
Thanks for trying to understand it xD First thing that stands out is that your function is 140 line long, which is just too much. You have put the comments in, which is good, but it would be simpler if you extracted that piece of code into a function.
This for loop does three things:
Filters the cash for return, calculates the total in register and copies the register. You can split it in three different functions.
for (let i = 0; i < cid.length; i++) {
// Filter for cash that can be used as return
if (cid[i][1] < cash) {
newArr.push(cid[i])
}
totalCash += cid[i][1]
newArr0.push(cid[i])
} | {
"domain": "codereview.stackexchange",
"id": 42073,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "javascript, beginner, calculator",
"url": null
} |
home-experiment, ph, experimental-chemistry
Title: Is there a means to measure pH without indicators? I have created a solution that should contain hydroxide ions. Therefore, the pH > 7, but is there any way to roughly estimate the pH in absence of any indicator? Maybe using current, or checking whether it dissolves certain chemicals?
Please mind that I am limited in equipment and so complex science is not feasible for me. Have you tried with red or black tea? It turns lighter in acidic media and turns dark in basic media. I tried once adding the pulp juice of one lemon to a cup of tea and it lighted up (mainly for acetic acid), then I added NaOH-based salt and turned very black and opaque.
Maybe that suits for your solution. | {
"domain": "chemistry.stackexchange",
"id": 1534,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "home-experiment, ph, experimental-chemistry",
"url": null
} |
vectors, coordinate-systems
This is an example of a coordinate system. In general, a coordinate system is a method of assigning to each point a tuple of numbers. Taking coefficients of a linear combination is a special case of a coordinate system. In general, coordinate systems need not be built off of vector spaces.
The spherical coordinate system is not based on linear combination. The spherical coordinates of u+v will not be sum of the individual coordinates. Spherical coordinates are not based on combining vectors like rectilinear coordinates are. Each point's coordinates are calculated separately.
Also, your reference to "the three unit vectors" suggests a misunderstanding. Given a particular basis, the vectors in the basis are called elementary vectors. In three dimensions, there are three elementary vectors, which are unit vectors. There are an infinite number of unit vectors. | {
"domain": "physics.stackexchange",
"id": 91642,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "vectors, coordinate-systems",
"url": null
} |
ruby, ruby-on-rails
def_delegators :first, :increment_value, :max_work_hours_per_day #...
end
I think spelling out the methods you want to forward like this is preferable to simply forwarding everything as it won't accidentally forward something you don't want to forward. It also does not affect the error message when calling a method that does not exist. | {
"domain": "codereview.stackexchange",
"id": 617,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "ruby, ruby-on-rails",
"url": null
} |
waves, acoustics, frequency, resonance
Title: Can't understand Resonance in an Air Column
In this image about resonating air column in my book, they say that resonance occurs at those specific lengths marked in the diagram. However,
its also said that natural frequency of air column decreases with increase in length.
resonance occurs when the natural frequency of tuning fork is equal to the natural frequency of the air column. | {
"domain": "physics.stackexchange",
"id": 86215,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "waves, acoustics, frequency, resonance",
"url": null
} |
c++, graph, library
UDiGraph<V,E>& addEdgeBetween(VertexID vertex_1, VertexID vertex_2)
{
if ( !GraphABC<V,E>::vertexExists(vertex_1) || !GraphABC<V,E>::vertexExists(vertex_2) )
{
throw std::out_of_range("vertex does not exist");
}
this->mEdges[vertex_1].insert(std::pair<VertexID, EdgeObjectID>(vertex_2, GraphABC<V,E>::NO_EDGE_OBJECT));
this->mEdges[vertex_2].insert(std::pair<VertexID, EdgeObjectID>(vertex_1, GraphABC<V,E>::NO_EDGE_OBJECT));
return *this;
} | {
"domain": "codereview.stackexchange",
"id": 43522,
"lm_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++, graph, library",
"url": null
} |
botany
Title: Why do the sick and unhealthy trees leaf out first in spring? It's spring. The time of year that trees start to leaf out. I have been watching them, and noticed an interesting pattern. The unhealthy trees of a species leafs out first. I've noticed this especially with the wild black cherries. The hollow and damaged trees and the ones in poor conditions leaf out a week ahead of the good ones. The last ones to leaf out are the strongest in the area. This is not just a casual observation, and I have kept careful track of it. What causes this? Trees that have been dormant over the winter exist on nutrients stored in their roots during fall. When a tree has been damaged or diseased, it may not have been able to store enough nutrients before winter, or may not have enough stored to heal the damage/disease. If the damaged/diseased tree has depleted its winter root stores, it must leaf out (earlier than others of its species) and resume photosynthesis in order to have enough energy to | {
"domain": "biology.stackexchange",
"id": 653,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "botany",
"url": null
} |
python, python-2.x
Title: Simulating a game of signals The following code simulates a game of signals in which four participants (playing in pairs) show (muestra) and see (observan) signals. Signals are randomly assigned in the first round. Signals in the second round are assigned depending on a probability equation that takes into account memory dictionaries.
The final output is (sorted by participant):
Signals shown in the first round
Signals shown in the second round
Memory dictionary of shown signals
Memory dictionary of observed signals
I would like to simplify and optimise my code.
import random
emparejamientos= ([[1,2],[3,4], #round 1 (participant 1 plays with 2, and 3 with 4)
[1,3],[2,4]]) #round 2 (1 with 3 and 2 with 4)
s1=1
s2=0
s3=0
s4=0
b=0.5
x=0.5
m=0.02 | {
"domain": "codereview.stackexchange",
"id": 23644,
"lm_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
} |
php, powershell, active-directory
Feel free to test this script beyond breaking point and comment, as I would like to see how well I have done in scripting something for Active Directory.
Can anyone confirm that I don't need to escape if possible? Post results if you do break it, please.
Here is the PHP script:
<?php setlocale(LC_CTYPE, "en_US.UTF-8"); ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Pw Changer</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<?php
/*
* Note: Errorstate var is changeable client side and should not be trusted
*/ | {
"domain": "codereview.stackexchange",
"id": 10751,
"lm_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, powershell, active-directory",
"url": null
} |
telescope, photography, space-telescope
Live Streaming Jupiter (from Earth):
https://www.youtube.com/watch?v=ILh4lWHi_ag
Shoemaker-Levy image:
https://en.wikipedia.org/wiki/Comet_Shoemaker%E2%80%93Levy_9
ISS Live Stream [for comparison]:
https://www.youtube.com/watch?v=EEIk7gwjgIM As several people have said, the capabilities of the sensor are probably less important than the problem of getting enough light to have anything to record in a short exposure. We find that a magnitude zero star (one of the brightest) corresponds to a visible light flux of about $3.6\times 10^{−20} erg/(s·cm^2·Hz)$. | {
"domain": "astronomy.stackexchange",
"id": 4438,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "telescope, photography, space-telescope",
"url": null
} |
newtonian-mechanics, classical-mechanics, lagrangian-formalism, kinematics
The equation(s) of motion for the two stages of the Woodpecker toy are (using this model):
Eq. I : ($\theta$ is the only degree of freedom (DOF))
$$(I_2+m_2b^2)\ddot{\theta}=-c\theta+m_2bg_{gr}\tag{1}$$
Eq. II : (two DOF, vertical motion $z$ included)
$$(I_2+m_2b^2(1-\frac{m_2}{m_1+m_2}))\ddot{\theta}=-c\theta\tag{2}$$
$$(m_1+m_2)\ddot{z}+m_2b\ddot{\theta}=(m_1+m_2)g_{gr}\tag{3}$$
Now, the first equation corresponds to the Woodpecker being jammed (not moving vertically), thus only DOF is $\theta$. The equation is easily derived from the law of angular momentum:
$$\frac{dL}{dt}=I\boldsymbol\alpha+2rp_{||}\boldsymbol\omega.$$
Since it is planar motion it reduces to one equation (the equation above). | {
"domain": "physics.stackexchange",
"id": 55585,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "newtonian-mechanics, classical-mechanics, lagrangian-formalism, kinematics",
"url": null
} |
newtonian-mechanics, classical-mechanics
Title: What stops the middle point of a power line from falling? Say you have a system that is a uniformly weighted string with slack suspended from two points; i.e. a power line.
There are three forces acting on any given point on this string: string tension going left, string tension going right, and gravity.
Consider the point exactly in the middle of the string. The tension forces act tangent to the string, which (in this case) is directly left and right. So these forces have no upwards component, so no matter how large they are, they won't be able to counteract gravity.
But the string is not moving, and the middle point is not actually accelerating downwards. So what am I missing? What's counteracting gravity? The part at the exact middle of the string has zero mass. | {
"domain": "physics.stackexchange",
"id": 21879,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "newtonian-mechanics, classical-mechanics",
"url": null
} |
quantum-mechanics, wavefunction, measurement-problem, wavefunction-collapse, decoherence
So in quantum decoherence theory, system (example: a particle) becomes "measurable" when system interacts with another system or environment with certain conditions and consequences.
But this seems to raise issues of how systems can ever be interacting "objectively". After all, every system described by wavefunctions that only give probability for possible measurements in general (of course there are cases that when met with proper basis and knowledge of wavefunction, definitive measurement can be guaranteed). This for me seems to suggest even before quantum decoherence, two systems that will interact have been connected by some wavefunction that describes the chance of quantum decoherence. Or we need some kinds of observers to either bring effects of quantum decoherence. | {
"domain": "physics.stackexchange",
"id": 34660,
"lm_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, wavefunction, measurement-problem, wavefunction-collapse, decoherence",
"url": null
} |
classification, feature-selection, multiclass-classification, multilabel-classification
And here are the classification results (I took the numbers off the labels):
.
Therefore how to improve classifcation when some are less represented ?
I thought of duplicating a few rows of the classes it doesn't predict well in the train sample. But maybe this assumption is entirely false, maybe it is not because they are less represented that are badly classified. Maybe I should have a look on the feature selection I did by hand and rather do a PCA ?
Update
class weight with inverted frequency
I passed the class_weight parameter in model.fit() which is a list of the inverted frequency of the classes on the dataset:
>>> lossWeights = df['grade'].value_counts(normalize=True)
>>> lossWeights = lossWeights.sort_index().tolist()
>>> print(lossWeights)
[0.204064039408867, 0.2954361054766734, 0.29536185163720663, 0.13638619240799768, 0.04878839466821211, 0.014684149521877717, 0.0052792668791654595]
weights = {0: 1 / 0.204064,
1: 1 / 0.295436,
2: 1 / 0.295362, | {
"domain": "datascience.stackexchange",
"id": 6015,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "classification, feature-selection, multiclass-classification, multilabel-classification",
"url": null
} |
ros, time, transform
Title: tf2::ExtrapolationException, transforming point clouds from the past using a new transform
I want to put two pointclouds in a single frame that are taken from two different locations. The pointclouds are taken in the /base_link frame (which moves between scans), the position of the marker is determined, and a transform from /base_link to /marker is published. I then want to transform the pointcloud from /base_link to /marker, but the call:
listener->waitForTransform("/marker", (*cloud_msg).header.frame_id, (*cloud_msg).header.stamp , ros::Duration(5.0));
listener->transformPointCloud ("/marker", saved_cloud1, localized_cloud1); | {
"domain": "robotics.stackexchange",
"id": 24596,
"lm_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, time, transform",
"url": null
} |
fft, python, dft, scipy
A different way to look at it: the DFT assumes that the time signal is periodic with the FFT length. Since your exponential does NOT have an integer number of periods inside one FFT frame, the periodic repetition creates a discontinuity at the frame boundary | {
"domain": "dsp.stackexchange",
"id": 9667,
"lm_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, python, dft, scipy",
"url": null
} |
java, programming-challenge
Let's take a look at the prime factorization for those numbers
Number Divisors Prime Factorization
6 4 2*3
28 6 2*2*7
36 9 2*2*3*3
66 8 2*3*11
120 16 2*2*2*3*5 | {
"domain": "codereview.stackexchange",
"id": 16944,
"lm_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, programming-challenge",
"url": null
} |
weather-forecasting
Then there are local anomalies. Are there gully winds? Do cloud banks form in the mornings, or high cumulus towers build up in the afternoons (quite common in the Western Ghats of India)? Is there a local temperature inversion, and does it disperse daily? What kind of local wind patterns are there? Is there a lake nearby that could create local cooling if the winds are in the right direction? Conversely, is there a source of local heat anomalies - factories, power stations?
On the larger scale, what is the area topography, and what local air circulation does it create? Is there some interaction between monsoonal air flow and continental air masses? What turbulence does this create?
Some bizarre anomalies are also possible, like birds roosting on the instrumentation!
Really, there is no short-cut answer. The only solution is to go there with an unbiased and inquiring mind, and check out what's going on. I'm guessing that for such a consistent fluctuation it will be something obvious. | {
"domain": "earthscience.stackexchange",
"id": 799,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "weather-forecasting",
"url": null
} |
heat, combustion
Title: What is a kg.cal per gram, as a heat of combustion? I see heats of combustion given in kg [dot] calories per gram molecular weight (Handbook of Chemistry and Physics, 1969-1970). I don't know how that makes sense, as I don't know what a kg cal might be. I would have expected units of energy per mass (calories per gram) or energy per mole. What is a kg cal, and what is wrong in my thinking? $\mathrm{kg~cal}$ probably represents the kilogram calorie (especially given that it is an old book). Nowadays it is usually just known as the Calorie, usually abbreviated $\mathrm{kcal}$. It is roughly the amount of energy required to raise the temperature of $1~\mathrm{kg}$ of water by $1~\mathrm{^\circ C}$. Since this is temperature and pressure dependent, there are slight variations in the actual definition depending on the context in which it is used. | {
"domain": "chemistry.stackexchange",
"id": 3702,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "heat, combustion",
"url": null
} |
slam, navigation, rosmake, ros-electric
/home/zhutou/ros/g2o/include/g2o/solvers/cholmod/linear_solver_cholmod.h:162: undefined reference to `cholmod_factorize'
/home/zhutou/ros/g2o/include/g2o/solvers/cholmod/linear_solver_cholmod.h:167: undefined reference to `cholmod_change_factor'
CMakeFiles/rgbdslam.dir/src/glviewer.o: In function `GLViewer::drawToPS(QString)':
/home/zhutou/ros/rgbdslam/src/glviewer.cpp:676: undefined reference to `gl2psBeginPage'
/home/zhutou/ros/rgbdslam/src/glviewer.cpp:678: undefined reference to `gl2psEndPage' | {
"domain": "robotics.stackexchange",
"id": 10393,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "slam, navigation, rosmake, ros-electric",
"url": null
} |
signal-analysis, linear-systems, laplace-transform, non-linear, differential-equation
Added later:
This doubt rises from the book I am studying signals, there, it is said that a LIT causal system must have a ROC that is a right-side plane in $s$ with $s$ the complex plane defined when taking the Laplace transform... but the book also states on a previous subsection that every finite-duration signals must have a ROC that contains the whole $s$-plane, so I feel its kind of contradicts the requirement to be an LIT causal system, but surely I am missing something (maybe there is a mixed with properties of one-side and bilateral Laplace Transforms, but I don´t really know)... but at these extent, it looks like there is a problem for signals for being being causal LIT and of finite-duration at the same time. | {
"domain": "dsp.stackexchange",
"id": 10823,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "signal-analysis, linear-systems, laplace-transform, non-linear, differential-equation",
"url": null
} |
quantum-mechanics, classical-mechanics, commutator, time-evolution, poisson-brackets
So let us rephrase our question as "how does (1) motivate (2)"? (1) describes the time evolution of the value of some smooth function $f = f(\psi)$ on a manifold $M$ we call "configuraton space" when a system's state $\psi \in M$ evolves along a path in $M$, which path is defined by the classical Hamilton's equations of motion. Everything is deterministic, the co-ordinates represented by generalized positions $\mathbf{p}$ and momentums $\mathbf{q}$ are in principle definable to infinite precision and one can meaningfully talk about system "positions" and "momentums" all at once to any precision. We can think of a general smooth function $f(\psi)$ as an infinite precision measurement on the system when the latter's state is $\psi$. | {
"domain": "physics.stackexchange",
"id": 9051,
"lm_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, classical-mechanics, commutator, time-evolution, poisson-brackets",
"url": null
} |
java, object-oriented, role-playing-game
break;
}
} while (status == false);
currDungeon = Dungeon.newRandomDungeon(currPlayer);
dungeon.dungeonLogic(currPlayer, currDungeon);
}
public static void loadGame() {
}
public static void settings() {
}
}
Dungeon class:
package projectmoria;
public final class Dungeon {
private static boolean northDirection = false;
private static boolean southDirection = false;
private static boolean westDirection = false;
private static boolean eastDirection = false;
public static Room[][] newRandomDungeon(Player player) {
Room[][] dungeon = new Room[30][30];
for (int i = 0; i < dungeon.length; i++) {
for (int j = 0; j < dungeon.length; j++) {
dungeon[i][j] = Room.newRoomInstance();
}
}
player.setCurrRoom(dungeon[14][14]);
return dungeon;
} | {
"domain": "codereview.stackexchange",
"id": 37720,
"lm_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, role-playing-game",
"url": null
} |
backpropagation, activation-functions, objective-functions
The plus sign in $\prod^+\!$ designates that the factors multiplied must be downstream in the forward signal flow from the parameter matrix being updated.
In sentence form, $\Delta P$ at any layer shall be the quotient of cost function $c$ (given label vector $\vec{\ell}$ and network output signal $\vec{o}$), attenuated by learning rate $\alpha$, over the product of all the derivatives leading up to the cost evaluation. The multiplication of these derivatives arise through the recursive application of the chain rule.
It is because the chain rule is a core method for feedback signal evaluation that partial derivatives must be used. All variables must be bound except for one dependent and one independent variable for the chain rule to apply.
The derivatives include three types. | {
"domain": "ai.stackexchange",
"id": 869,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "backpropagation, activation-functions, objective-functions",
"url": null
} |
operators, momentum, observables
\nonumber\\
&\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\! x_{\boldsymbol{r}}\!\!\!\int\limits_{\boldsymbol{-\infty}}^{\boldsymbol{+\infty}}\!\!\!\!\mathrm p \left( x_{\boldsymbol{r}}, x_{\boldsymbol{c}}\right)f\left(x_{\boldsymbol{c}}\right)\mathrm dx_{\boldsymbol{c}}\boldsymbol{-}\!\!\!\!\int\limits_{\boldsymbol{-\infty}}^{\boldsymbol{+\infty}}\!\!\!\!\mathrm p \left( x_{\boldsymbol{r}}, x_{\boldsymbol{c}}\right)x_{\boldsymbol{c}}f\left(x_{\boldsymbol{c}}\right)\mathrm dx_{\boldsymbol{c}}\boldsymbol{=}i\hbar\!\!\!\int\limits_{\boldsymbol{-\infty}}^{\boldsymbol{+\infty}}\!\!\!\!\delta\left( x_{\boldsymbol{r}}\!\boldsymbol{-}\!x_{\boldsymbol{c}}\right)f\left(x_{\boldsymbol{c}}\right)\mathrm dx_{\boldsymbol{c}} \quad \Longrightarrow
\nonumber\\ | {
"domain": "physics.stackexchange",
"id": 51057,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "operators, momentum, observables",
"url": null
} |
java, algorithm, graph
public int getWeight (int source, int target)
{
return edges[source][target];
}
public int [] neighbors (int vertex)
{
int count = 0;
for (int i=0; i<edges[vertex].length; i++)
{
if (edges[vertex][i]>0) count++;
}
final int[]answer= new int[count];
count = 0;
for (int i=0; i<edges[vertex].length; i++)
{
if (edges[vertex][i]>0)
answer[count++]=i;
}
return answer;
}
public void print ()
{
for (int j=0; j<edges.length; j++)
{
System.out.print (labels[j]+": ");
for (int i=0; i<edges[j].length; i++)
{
if (edges[j][i]>0) System.out.print (labels[i]+": Cost : "+edges[j][i]+" ");
}
System.out.println ();
}
}
}
and Dijkstra's algorithm
package sdfghj;
import java.util.ArrayList;
import static sdfghj.smallNetworkSimulation.routingTable; | {
"domain": "codereview.stackexchange",
"id": 19822,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "java, algorithm, graph",
"url": null
} |
ruby
stdout = run "find #{path} -type f -exec #{shred_cmd} '{}' ';'"
FileUtils.rm_rf path
stdout
end
find is used to execute shred, since it lacks a recursive option. I initially tried execdir instead of exec for security, but travis and other build environments hate it. Potential problem?
validate_path tries to keep the user from screwing themselves by expanding the path, better ways of doing this? Some notes: | {
"domain": "codereview.stackexchange",
"id": 4109,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "ruby",
"url": null
} |
c++, c++11
Use C++ file I/O
Don't use the ancient FILE* I/O but instead use modern C++ std::fstream. The interface is neater and you can write a nice class extractor instead of having all of the details for extracting data placed within main.
Don't use std::endl if '\n' will do
Using std::endl emits a \n and flushes the stream. Unless you really need the stream flushed, you can improve the performance of the code by simply emitting '\n' instead of using the potentially more computationally costly std::endl.
Don't return nonzero from main unless there's an error | {
"domain": "codereview.stackexchange",
"id": 26134,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "c++, c++11",
"url": null
} |
strings, dynamic-programming, substrings
Edit: This calculates the maximal $L$ such that $M(i,i,L) \leq K$ for some $i$. The actual problem wanted to find the maximal $L$ such that $M(i,j,L) \leq K$ for some $i,j$. By considering all possible shifts, we can solve this in $O(N^2)$ time and $O(K)$ space. | {
"domain": "cs.stackexchange",
"id": 556,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "strings, dynamic-programming, substrings",
"url": null
} |
python, beginner, rock-paper-scissors
and this is my version of game_start()
def game_start():
begin = input("Would you like to play Rock, Paper, Scissors? ").capitalize()
while begin != "Yes":
if begin == "No":
print("Game Over")
return sys.exit()
else:
print("Please try again")
begin = input("Would you like to play Rock, Paper, Scissors? ").capitalize()
play()
while True:
begin = input('Play again?').capitalize()
while begin != "Yes":
if begin == "No":
print("Game Over")
sys.exit()
else:
print("Please try again")
begin = input("Play again? ").capitalize()
play()
the whole code looks now like this:
import random
import sys | {
"domain": "codereview.stackexchange",
"id": 26843,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "python, beginner, rock-paper-scissors",
"url": null
} |
ruby, casting
Even if you have a Square class already, you can still have a method of the same name:
class Square
# ...
end
def Square(side) # no naming conflict
Square.new(side)
end | {
"domain": "codereview.stackexchange",
"id": 2495,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "ruby, casting",
"url": null
} |
special-relativity, differential-geometry, metric-tensor, group-theory
Title: Poincare Group (Wald, Chapter 4 Page 59) In Wald's text on general relativity, he mentions that in special relativity, many different global inertial coordinate systems are possible and can be put into one-to-one correspondence with elements of the 10-parameter Poincare group.
I am unfamiliar with Poincare group so I would like to see an explanation of what this sentence exactly means.
First of all, in special relativity we realize the spacetime as a four-dimensional manifold $M$. Furthermore, the statement that there exists a global inertial frames in special relativity is, as I understand it, the statement that $M$ can be covered by a single coordinate chart $(U,\psi)$, with $\psi:M\to\mathbb{R}^4$. In this local (which happens to also be global) chart, one can then associate every point in $M$ to a point in $\mathbb{R}^4$, which we call an event, denoted by say $(t,x,y,z)$. | {
"domain": "physics.stackexchange",
"id": 31174,
"lm_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, differential-geometry, metric-tensor, group-theory",
"url": null
} |
tides, moon, earth-moon
With that, one effect would be that the tidal pull would be stronger, but also the tides would not move across the face of the Earth as we are used to seeing.
First, consider the strength of the tidal pull. The tidal pull across Earth imparted by any other massive body is proportional not to the overall gravitation acceleration imparted by the other body onto Earth, but to the difference in gravitational acceleration between one part of Earth and another. That difference is inversely proportional to the cube of the distance to the other body, not the square of the distance as the bulk gravitational acceleration would be.
So the geosynchronous Moon, scaled down in mass by 115 times to match the squared distance and overall gravitational acceleration, ends up generating a difference across the Earth more than ten times as large as the actual Moon because that difference contains an extra power of the distance. Hence a larger tidal height. | {
"domain": "earthscience.stackexchange",
"id": 2532,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "tides, moon, earth-moon",
"url": null
} |
ros, ros2, ardent
We've discussed in the past that we could separate the logic where users declare an intention have certain parameters, either to a standalone free-function or static method (so it could be called without creating the node) or to a DSL file outside of the C++/Python code (similar to the .cfg files for dynamic reconfigure in ROS 1). That would let you describe the parameters that would be used in a way that it could be used in the code of the node and to generate documentation automatically. | {
"domain": "robotics.stackexchange",
"id": 30901,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "ros, ros2, ardent",
"url": null
} |
sorting, linked-lists
Title: Time complexity of insertion in linked list Apologies if this question feels like a solution verification, but this question was asked in my graduate admission test and there's a lot riding on this:
What is the worst case time complexity of inserting $n$ elements into an empty linked list, if the linked list needs to be maintained in sorted order? | {
"domain": "cs.stackexchange",
"id": 15519,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "sorting, linked-lists",
"url": null
} |
If your response variable (or rather, what will become the residuals of your response variable) on the original scale has a Normal distribution as you imply, then transforming it to create a linear relationship with the other variables will mean that it no longer is Normal and it will also change the relationship between its variance and mean values. So from that part of your description I think you are better off using non-linear regression than transforming the response. Otherwise, after linear transformation of the response, you will need a more complex error structure (although this can be a matter of judgement and you would need to check, using graphical methods).
Alternatively, investigate transformation of the explanatory variables. As well as straight transformations, you also have the option of adding in quadratic terms.
More generally, transformation is more an art than a science, if there is no existing theory to suggest what you should use as the basis of transformation. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9621075766298656,
"lm_q1q2_score": 0.8038250333144714,
"lm_q2_score": 0.8354835289107307,
"openwebmath_perplexity": 435.0975181959227,
"openwebmath_score": 0.6578108668327332,
"tags": null,
"url": "https://stats.stackexchange.com/questions/24227/how-to-choose-the-best-transformation-to-achieve-linearity/24236"
} |
java, performance, game-of-life
By reusing the parts of the environment pattern that are shared between adjacent cells, the code only needs to do three reads from the oldBuffer array per cell, as opposed to nine in your version. Uncached array access is expensive, so this is likely to provide a significant speedup. (Also, like your code, mine also makes sure to access the buffers as close to sequentially as possible, iterating first by rows and then by columns. This is also important for CPU cache locality.)
The code above doesn't update the cells at the edges of the array, which means it doesn't have to worry about (literal) edge cases such as array indices being out of bounds. (Hopefully, the compiler / JVM may notice this too, and may omit some of its internal array bounds checks.) | {
"domain": "codereview.stackexchange",
"id": 9440,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "java, performance, game-of-life",
"url": null
} |
javascript, jquery, game, html5, snake-game
It is also best to put this object inside a namespace. For example, instead of calling new Snake('snakePlatform'), you would call new Dominic.Games.Snake('snakePlatform'). This makes it easier to track and maintain code in large projects. While this project is fairly simple and may not need namespaces, it's good to get in the habit of using them unless there is a very good reason not to do so.
3. Enums
Although JavaScript doesn't really have the concept of enum like many other languages, it is often useful to define helper objects that act as enums. Here are the two enums that I would define for this game:
var directions = {
LEFT: 37,
UP: 38,
RIGHT: 39,
DOWN: 40,
};
var states = {
READY: 0,
RUNNING: 1,
OVER: 2,
}; | {
"domain": "codereview.stackexchange",
"id": 20604,
"lm_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, game, html5, snake-game",
"url": null
} |
finite-automata, compilers
My question is this: Do I need to understand more than this to write a Compiler? Is there something unique about FSA that I'm just completely missing? Or is this just an over complication of a simple concept in regards to creating a compiler? What you have asked: "Do I need to understand more than this to write a compiler?" then answer is basically, No - but it does depend on the compiler! | {
"domain": "cs.stackexchange",
"id": 9411,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "finite-automata, compilers",
"url": null
} |
java, homework
Write a method called populate that takes two parameters, m and n. The method creates and returns an m x n matrix filled with the counting numbers in row-major order starting with one.
public int[][] populate(int m, int n) {
int[][] arr = new int[m][n];
int count = 1;
for(int i = 0; i < arr.length; i++) {
for(int j = 0; j < arr[i].length; j++) {
arr[i][j] = count;
count++;
}
}
return arr;
}
My tester class (test.java)
import java.util.Arrays;
public class test {
public static void main(String[] args) { | {
"domain": "codereview.stackexchange",
"id": 33827,
"lm_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, homework",
"url": null
} |
logic, propositional-logic
Title: Propositional Logic: Entailment Given the sentences, S1, S2, if S1 |= S2 then all models that satisfy S1 also satisfy S2, how is the following statement correct?
A ∧ ¬A |= B
How can something and not something equate to true?
I am stuck trying to work out how true and false can still entail true, actually how can A and ¬A occur at the same time?
Thanks. It's not easy to give a full explanation without knowing your axioms and rules, however, $A \land \neg A$ is a contradiction, and it is by exploiting that, that you can prove whatever you like.
First, let $\top = A \lor \neg A$.
We know that "true or whatever else" must be true. Since $\top$ is a tautology, then $\top \lor B$ must be true.
But since $A \land \neg A = \neg (A \lor \neg A) = \neg \top$ is assumed to be true we conclude the following:
from $\top \lor B$ and $\neg \top$
$B$ | {
"domain": "cs.stackexchange",
"id": 17645,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "logic, propositional-logic",
"url": null
} |
thermodynamics, entropy, heat-engine
Title: Clausius Principle vs Kelvin-Planck Principle how to prove that the Clausius and Kelvin-Planck principle era equivalent?
In other words: How do a 100% efficiency machine would violate the second law of thermodynamics? First, the Kelvin-Planck statement is:
No heat engine can operate in a cycle while transferring heat with a single heat reservoir.
This is the same thing as saying no heat engine operating in a cycle can convert heat entirely into work.
The Clausius' statement of the second law says:
No refrigeration or heat pump cycle can operate without a net work input.
This is the same thing as saying heat cannot flow naturally (without any net work being done) from a cold body to a hot body, something that has never been observed in nature. | {
"domain": "physics.stackexchange",
"id": 66547,
"lm_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, entropy, heat-engine",
"url": null
} |
ecology, theoretical-biology, population-dynamics, parasitism
Ito, M., and N. Hijii. “Factors Affecting Refuge from Parasitoid Attack in a Cynipid Wasp, Aphelonyx Glanduliferae.” Population Ecology 44, no. 1 (2002): 23–32. https://doi.org/10.1007/s101440200003.
Price, Peter W. “Inversely Density-Dependent Parasitism: The Role of Plant Refuges for Hosts.” Journal of Animal Ecology 57, no. 1 (1988): 89–96. https://doi.org/10.2307/4765.
Walde, Sandra J., Robert F. Luck, Dicky Sicki You, and William W. Murdoch. “A Refuge for Red Scale: The Role of Size-Selectivity by a Parasitoid Wasp.” Ecology 70, no. 6 (December 1989): 1700–1706. https://doi.org/10.2307/1938104. | {
"domain": "biology.stackexchange",
"id": 11959,
"lm_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, theoretical-biology, population-dynamics, parasitism",
"url": null
} |
ros, ros-industrial, abb
Please ask this as a separate question. Apart from the fact that you want to use an ABB, I don't see any connecting to the Q&A that you posted your comment on.
Comment by thompson104 on 2018-08-04:
Thank you for your quick response as always. I have posted my question in the following link and I wonder if you may give me some suggestions? Thank you.
#q299622. | {
"domain": "robotics.stackexchange",
"id": 29522,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "ros, ros-industrial, abb",
"url": null
} |
computability, turing-machines, undecidability
Given some TM M, we enumerate all its states as $s_1$ ... $s_n$. We can search through potential inputs $w_0,w_1,\ldots$ and mark each state that one of the computation visits. If we ever mark all states, we halt. This gives a procedure that recognizes exactly the complement of USELESS. | {
"domain": "cs.stackexchange",
"id": 10189,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "computability, turing-machines, undecidability",
"url": null
} |
homework-and-exercises, pressure, density, fluid-statics
My attempt: $P = \rho gh \therefore (1030)(10)(h) - 101kPa = 60kPa$
However the markscheme gives the equation $(1030)(10)(h) = 60kPa$
I feel that this equation does not account for the information the question gives, that the pressure is $60 kPa$ more than atmospheric pressure. Is there some concept that I am missing in my attempt? Since we are talking about the difference in pressure between two levels in a single liquid, to avoid confusion, it is more appropriate to use the formula $\Delta P=\rho \times g \times h,$ where it means exactly what it is meant to. The question is concerned with this change in pressure rather than the absolute pressure you are concerned with. This fact is indeed signalled in the statement, "The pressure at point M is 60kPa more than atmospheric pressure;" the word more than is the key to understand that we are dealing with relative change rather than absolute value. | {
"domain": "physics.stackexchange",
"id": 29605,
"lm_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, pressure, density, fluid-statics",
"url": null
} |
# Solving an exponential equation involving e: $e^x-e^{-x}=\frac{3}{2}$
In a previous exam, my professor had the question
\begin{equation*} e^x-e^{-x}=\frac{3}{2}. \end{equation*}
I attempted to take the natural log of both side to solve it, but evidently that was incorrect... how does one start to go about solving this type of problem? Any help or advice would be greatly appreciated. Thanks!
• Both sides times e^x. Could you take it from here? – Vim May 11 '15 at 4:06
• suppose $y=e^x$. – John Joy May 11 '15 at 13:19
## 4 Answers
$$e^x-e^{-x}=\frac{3}{2}$$ Multiply by $e^x$. $${\left(e^{x}\right)^2}-1=\frac{3e^x}{2}$$ Let $u=e^x$ $$u^2-\frac{3u}{2}-1=0$$ $$2u^2-3u-2=0$$ Now solve for $u$, and back substitute into $u=e^x$. Consider only positive solutions for $u$.
• 2nd line, I assume you mean $e^{2x}$ not $e^{x^2}$ – uqtredd1 May 11 '15 at 4:14
• In the last line you forgot to multiply the -1 by two. – Roman Reiner May 11 '15 at 6:37 | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9822877002595527,
"lm_q1q2_score": 0.8053711329082787,
"lm_q2_score": 0.8198933293122506,
"openwebmath_perplexity": 507.5997372374239,
"openwebmath_score": 0.9213041663169861,
"tags": null,
"url": "https://math.stackexchange.com/questions/1276599/solving-an-exponential-equation-involving-e-ex-e-x-frac32"
} |
c++, logging
//inner logging level classes for ostream overloading
ologger::ologger::Debug::Debug(ologger& parent)
: parent_(parent), start_of_line_(true)
{}
ologger::Debug& ologger::Debug::operator<<(endl_type endl)
{
if (parent_.level_ >= log_level::LOG_INFO) {
parent_.log_stream_ << endl;
}
parent_.changeover_if_required();
start_of_line_ = true;
return *this;
}
ologger::ologger::Info::Info(ologger& parent)
: parent_(parent), start_of_line_(true)
{}
ologger::Info& ologger::Info::operator<<(endl_type endl)
{
if (parent_.level_ >= log_level::LOG_INFO) {
parent_.log_stream_ << endl;
}
parent_.changeover_if_required();
start_of_line_ = true;
return *this;
}
ologger::ologger::Error::Error(ologger& parent)
: parent_(parent), start_of_line_(true)
{}
ologger::Error& ologger::Error::operator<<(endl_type endl)
{
if (parent_.level_ >= log_level::LOG_ERROR) {
parent_.log_stream_ << endl;
} | {
"domain": "codereview.stackexchange",
"id": 40305,
"lm_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++, logging",
"url": null
} |
javascript, php, validation, ajax
$error['message'] = validate_input('termsandconditions', 'off');
$error['name'] = $name;
return $error;
}
Finally, since you reuse the same validate_input() line for your error message, if it has one, I would set it as a variable before the if statement and then check the variable before setting the error with the new getError() function.
$isValid = validate_input($key, $value);
if($isValid !== true) { array_push($errors, getError($key, $isValid)); }
Variable Variables
$$key = $value; // Set the title of the field to its name
$$key is a variable variable. And most people agree that these are bad. Not only are they almost impossible to spot (I almost missed it) but they are impossible to document. No IDE that I know of will even recognize them. Not only that, but you don't even use it as far as I can tell. My advice, stay away from variable variables. They only cause headaches. | {
"domain": "codereview.stackexchange",
"id": 1776,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "javascript, php, validation, ajax",
"url": null
} |
electromagnetism, forces, magnetic-fields, conventions, magnetic-moment
He goes on to hypotheses that if this orbit were in the presence of a magnetic field in the z-direction, this magnetic force would be added to the above expression
$\frac{1}{4 \pi \epsilon_{0}}\frac{e^{2}}{R^{2}}=m_{e}\frac{v^{2}}{R}$.
Recall that the magnetic force is given by $-e\left ( \vec{v} \times \vec{B}\right )$ for a negative charge -e.
The magnetic field is perpendicular to the orbit of -e and $\vec{v}$ the velocity vector of -e.
Then we have -evB.
But adding this force to the expression
$\frac{1}{4 \pi \epsilon_{0}}\frac{e^{2}}{R^{2}}$
would result in
$\frac{1}{4 \pi \epsilon_{0}}\frac{e^{2}}{R^{2}}
-evB$.
Griffiths, however, has$\frac{1}{4 \pi \epsilon_{0}}\frac{e^{2}}{R^{2}}
+e\bar{v}B$
which I cannot understand. | {
"domain": "physics.stackexchange",
"id": 33300,
"lm_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, forces, magnetic-fields, conventions, magnetic-moment",
"url": null
} |
frequency-spectrum, preprocessing
From looking at the variance graph it seems fairly obvious where the anomalies are (ca. at wave numbers 480, 800, 1500, 1650-1700 and 2150).
I ultimately want to use the data for machine learning. So far I've implemented an algorithm that looks where the variance exceeds a certain threshold and then removes outlier spectra at that point (it removes the entire spectrum) until the variance doesn't exceed the threshold at any point. The problem with this algorithm is that it removes around 60% of the spectra which is acceptable but not ideal.
I'm thinking about a different method where I delete the information at all the wave numbers where the variance exceeds a certain threshold (like cutting out a vertical strip from the first graph where the variance is too high). Since most of the anomalies are relatively "narrow" I think I would't lose much information. | {
"domain": "dsp.stackexchange",
"id": 7692,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "frequency-spectrum, preprocessing",
"url": null
} |
quantum-mechanics, schroedinger-equation, hydrogen, spherical-harmonics
$$\{Y_a \otimes R_b\}_{(a,b) \in A\times B} \subset L^2(X, dx) \otimes L^2(Y, dy)\equiv L^2(X\times Y, dx\otimes dy)$$
is a Hilbert basis as well for $ L^2(X\times Y, dx\otimes dy)$.
Specializing the result to (1), we see that a Hilbert basis of $L^2(\mathbb{R}^3, d^3x)$ is made of the products $$Y^\ell_m(\theta, \phi) f_n(r)$$ where $\{f_n\}_{n \in N}$ is any given Hilbert basis of $L^2([0,+\infty). r^2dr)$.
Notice that, in view of (3),
$$L^2 (Y^\ell_m f_n) = ({\cal L}^2 \otimes I) Y^\ell_m \otimes f_n = \hbar^2 \ell(\ell+1) (Y^\ell_m f_n)$$
and
$$L_z (Y^\ell_m f_n) = ({\cal L}_z \otimes I) Y^\ell_m \otimes f_n = \hbar m (Y^\ell_m f_n)$$
More generally, with the same argument,
$$L^2 (Y^\ell_m f) = \hbar^2 \ell(\ell+1) (Y^\ell_m f)$$
and
$$L_z (Y^\ell_m f) = \hbar m (Y^\ell_m f)$$
for every $f\in L^2([0,+\infty), r^2dr)$. | {
"domain": "physics.stackexchange",
"id": 85395,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "quantum-mechanics, schroedinger-equation, hydrogen, spherical-harmonics",
"url": null
} |
We ask whether it is (1) homomorphism, (2) isomorphism, (3) endomorphism, and (4) automorphism
We will give "O" if it is true. We will give "X" if it is false.
1. The domain $$k \in \mathbb{Z}$$ maps to the image $$f(k)=0$$. It is not injective nor surjective over codomain.
$$\text{(1) O, (2) X, (3) O, (4) X.}$$
1. The domain $$k \in \mathbb{Z}$$ maps to the image $$f(k)=k \mod N \in \mathbb{Z}/N\mathbb{Z}$$, where $$N$$ can be some integer. In fact, the image $$\mathbb{Z}/N\mathbb{Z}$$ is not a subgroup of codomain. So we cannot consider endomorphism. It is not injective but it is surjective over image.
$$\text{(1) O, (2) X, (3) X, (4) X.}$$
1. The domain $$k \in \mathbb{Z}$$ maps to the image $$f(k)= N k\in N\mathbb{Z}$$, where $$N$$ can be some integer but $$N \neq \pm 1$$. In fact, the image $$N\mathbb{Z}$$ is a subgroup of codomain. So it is an endomorphism. It is injective and also surjective over image. It is injective but not surjective over the codomain. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.975946441508702,
"lm_q1q2_score": 0.847928397242355,
"lm_q2_score": 0.8688267728417087,
"openwebmath_perplexity": 342.24993123690984,
"openwebmath_score": 0.9679341316223145,
"tags": null,
"url": "https://math.stackexchange.com/questions/4129897/automorphism-endomorphism-isomorphism-homomorphism-within-mathbbz"
} |
If we scale up by $n$ and replace the centroid by the sum, then the point of concurrence is just $${\mathbf{a_1}+\mathbf{a_2}+\cdots+\mathbf{a_{N}}}.$$
We might need to rule out, or specify what to do, in uninteresting degenerate cases such as when a centroid is at the origin. | {
"domain": "mathoverflow.net",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9843363545048391,
"lm_q1q2_score": 0.8070508195219033,
"lm_q2_score": 0.8198933381139645,
"openwebmath_perplexity": 177.71381167756837,
"openwebmath_score": 0.7984777688980103,
"tags": null,
"url": "https://mathoverflow.net/questions/188485/ten-concurrent-lines"
} |
differential-geometry, group-theory, lie-algebra
Subsequently as you noted,
\begin{equation}
m=\frac{\,d M(t)}{\,dt}\bigg|_0 = \sum_{i=1}^3 \frac{\partial M}{\partial a_i}\bigg|_0 n_i = \vec{\sigma}\cdot \hat {n}
\end{equation}
where
\begin{equation}
\vec{\sigma}={\Large \nabla}_{\!\!\vec a} ~ M \bigg|_{\vec a =0}\equiv \biggl(\frac{\partial M}{\partial a_1}\bigg|_0,
\frac{\partial M}{\partial a_2}\bigg|_0, \frac{\partial M}{\partial a_1}\bigg|_0\biggr )^T.
\end{equation}
You may now go to the WP article, consider (physicists stick an i in front of the generators)
$$
e^{i\vec \sigma \cdot \vec a }=e^{i\vec \sigma \cdot \hat n ~t}= M(t)=1\!\! 1 \cos t+ i\hat n \cdot \vec\sigma \sin t ,
$$
and illustrate the above statements and relations, especially that the above left-invariant "current" expression in the algebra is actually independent of t, as constructed! | {
"domain": "physics.stackexchange",
"id": 94048,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "differential-geometry, group-theory, lie-algebra",
"url": null
} |
mysql, sql
If I'm right the second version runs the complex (maybe bottleneck) subquery on table test2 twice, so it should be slower than the first query which runs the complex subquery only once. Furthermore, the first one is much easier to read. So, I prefer the first one. (I'm not a MySQL guru, feel free to correct me.) | {
"domain": "codereview.stackexchange",
"id": 894,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "mysql, sql",
"url": null
} |
imu, navigation, robot-localization
Drive your robot in a square, and make sure it comes back more or less exactly to the start location. If your driving pattern differs from this, give me in detail what the robot did, and where it ended up. Otherwise, I have no context for what it means when you say something is "worse."
When you record the bag file, please record only the input topics to ekf_localization_node. Do not record your tf tree, though you should probably provide the values of any static transforms you're broadcasting.
Your launch file.
Thanks!
EDIT 6 (still in response to update 4):
OK, I got some more time to look over your plots and mine, and I believe I've found the issue.
Here's what I did: I played back your Velocities2.bag file that you linked in your question. I then did
rostopic echo /summit_a/summit_xl_controller/odom -p > odom.txt | {
"domain": "robotics.stackexchange",
"id": 20184,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "imu, navigation, robot-localization",
"url": null
} |
c++, performance, c++11, recursion, breadth-first-search
typedef std::vector<KMMove> KMRandomAccessMoveCollection;
typedef std::list<KMMove> KMFastAccessMoveCollection;
#endif /* KMMOVE_H_ */
KMMove.cpp
/*
* KMMove.cpp
*
* Created on: Mar 18, 2016
* Author: pacmaninbw
*/
#include <stdexcept>
#include "KMMove.h"
#include "KMBoardDimensionConstants.h"
KMMove::KMMove()
: m_RowTransition{0},
m_ColumnTransition{0},
m_BoardDimension{DefaultBoardDimensionOnOneSide}
{
}
/**
* BoardDimension is converted to int for type safe comparisions.
*/
KMMove::KMMove(int RowTransition, int ColumnTransition, unsigned int BoardDimension)
: m_RowTransition{RowTransition},
m_ColumnTransition{ColumnTransition},
m_BoardDimension{static_cast<int>(BoardDimension)}
{
} | {
"domain": "codereview.stackexchange",
"id": 21124,
"lm_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, c++11, recursion, breadth-first-search",
"url": null
} |
quantum-field-theory, particle-physics, standard-model, feynman-diagrams, weak-interaction
and $u_L, c_L, t_L, d_L, s_L, b_L$ represent the left-handed projections of Dirac spinors associated to quark types. Actually, the magnitudes of each $V_\text{CKM}$ term are given by
\begin{equation}
V_\text{CKM} \approx \begin{pmatrix}
0.97383^{+0.00024}_{-0.00023} & 0.2272^{+0.0010}_{-0.0010} & (3.96^{+0.09}_{-0.09})\times10^{-3} \\
0.2271^{+0.0010}_{-0.0010} & 0.97296^{+0.00024}_{-0.00024} & (42.21^{+0.10}_{-0.80})\times10^{-3} \\
(8.14^{+0.32}_{-0.64})\times10^{-3} & (41.61^{+0.12}_{-0.78})\times10^{-3} & 0.999100^{+0.000034}_{-0.000034} \\
\end{pmatrix}.
\end{equation}
Moreover, it is useful to consider $V_\text{CKM}$ in the Wolfstein parametrization
\begin{equation}
V_\text{CKM} \approx \begin{pmatrix}
1-\lambda^2/2 & \lambda & A\lambda^3(\rho-i\eta) \\
- \lambda & 1-\lambda^2/2& A \lambda^2 \\
A\lambda^3(1-\rho-i\eta) & -A\lambda^2 & 1 \\
\end{pmatrix} + \mathcal{O}(\lambda^4).
\end{equation} | {
"domain": "physics.stackexchange",
"id": 30047,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "quantum-field-theory, particle-physics, standard-model, feynman-diagrams, weak-interaction",
"url": null
} |
string-theory, gauge-theory, conformal-field-theory, path-integral
If we were talking about a representation of a compact topological group it is clear that this determinant is $1$, but in this case I can't see it.
Moreover, there is indirect evidence that the Fadeev-Popov determinant is not gauge invariant: Apparently it can be written as the partition function of a $c=-26$ CFT, but the partition functions of CFT's are only Weyl-invariant for $c=0$ (or flat background metric which we can't assume since we are integrating over all background metrics).
The question is: am I overlooking something, and if yes, what? To be clear, I am convinced that treating this un-invariance correctly gives the right expression for the gauge fixed pathintegral anyway, but the presentation in Tongs notes seems flawed, even apart from all the assumptions made. | {
"domain": "physics.stackexchange",
"id": 66706,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "string-theory, gauge-theory, conformal-field-theory, path-integral",
"url": null
} |
optics, reflection, curvature, geometric-optics
According to me, the diagram seems to be perfect. From where did this anomaly come from? Please help. You have just shown the effect of spherical aberration.
Here is an accurate drawing showing that even when parallel to the principal axis rays after reflection do not meet at a point.
Here is an example which you may see when having a drink and a caustic is produced. | {
"domain": "physics.stackexchange",
"id": 67393,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "optics, reflection, curvature, geometric-optics",
"url": null
} |
c++, beginner, algorithm
// Take n numbers and decompose each of them
Prime_factorization prime_factorization;
for (int i { 1 }; i <= n; ++i) {
int x;
cin >> x;
decompose(prime_factorization, x);
}
// After decomposing all of the numbers, we check to see if each power can be divided by m(the root)
bool okay { true };
for (auto& i : prime_factorization)
if (i.second % m != 0) {
okay = false;
break;
}
// We must print the base-power combinations in sorted order
sort(prime_factorization.begin(), prime_factorization.end(), [](pair<int, int> p1, pair<int, int> p2) { return p1.first < p2.first; });
if (okay) {
cout << 1 << '\n';
for (auto& i : prime_factorization)
cout << i.first << ' ' << (i.second / m) << '\n';
} else
cout << 0;
} | {
"domain": "codereview.stackexchange",
"id": 29354,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "c++, beginner, algorithm",
"url": null
} |
quantum-field-theory, singularities, correlation-functions, s-matrix-theory
This is the statement I don't understand. If I am not wrong, a branch cut is an interval where the function has a "continuum" of singularities. But I only see a singularity at $\mathbf{k}=\mathbf{p}$. Is it because you can find an arbitrary number of state $\lambda$ with total momentum $\mathbf{k}$ that has energy $E_{\mathbf{p}}$ ? if this is true, isn't $p'= (k^0 , \mathbf{k} )$ with $ k^0 = \sqrt{ \mathbf{k}^2 + m^2}$ a better way of writing it?
Also in that case shouldn't we have a kind of density for the number of states $\lambda$ with momentum $\mathbf{k}$ and energy $E_{\mathbf{p}}$?
Any help will be appreciated. Here is a quick sketch which might help you. We can identify a branch cut by considering the difference between one-sided limits at each side of the cut. For an analytic function(i.e. when there is no cut), such a difference should vanish. I will define the integral in (7.41) as
$$ | {
"domain": "physics.stackexchange",
"id": 85277,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "quantum-field-theory, singularities, correlation-functions, s-matrix-theory",
"url": null
} |
c++, beginner, calculator
}
// division function
int calc_div(){
double x;
double y;
cout<< "enter two numbers to divide."<<endl;
cin>> x >> y;
double div = x/y;
cout << "The quotient is "<< div <<"." <<endl;
}
// Subtraction function
int calc_sub() {
double a;
double b;
cout<< "Enter two numbers to subtract."<< endl;
cin>> a >> b;
double diff = a-b;
cout<< "The difference is "<< diff <<endl;
}
//core function
void core2(){
string choice;
cout<<"Would you like to multiply, divide, add, or subtract? (typer in lowercase)"<<endl;
cin>>choice;
if(choice=="add"){
calc_sum();
core2();
}
else if(choice=="subtract"){
calc_sub();
core2();
}
else if(choice=="multiply"){
calc_pro();
core2();
}
else if(choice=="divide"){
calc_div();
core2();
}
else{
cout<<"USER ERROR"<<endl<< "you typed in something wrong, try again."<<endl;
core2();
}
}
int main(){
core2(); | {
"domain": "codereview.stackexchange",
"id": 33401,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "c++, beginner, calculator",
"url": null
} |
reinforcement-learning, tensorflow, keras, game-ai
Title: Can we use a neural network that is trained using Reinforcement Learning for dynamic game level difficulty designing in realtime? I am a newbie to Machine Learning and AI. As per my understanding, with the use of reinforcement learning
(reward/punishment environment), we can train a neural network to play a game. I would like to know, whether it possible to use this trained model for deciding the difficulty of the next game level dynamically in realtime according to a player's skill level? As an example, please consider a neural network is trained using Reinforcement Learning for playing a mobile game (chess/puzzle, etc.). The game is not consists of a previously designed static set of game levels. After the training, can this model use to detect a particular player's playing style(score, elapsed time) to dynamically decide the difficulty of the next game level and provide customized game levels for each player in realtime? | {
"domain": "ai.stackexchange",
"id": 1894,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "reinforcement-learning, tensorflow, keras, game-ai",
"url": null
} |
newtonian-mechanics, rotational-dynamics, friction
Title: Bodies rolling on an inclined plane So I set up an inclined plane (of cardboard) 10 degrees from the horizontal. I then derived an equation from Newton's Laws of Motion about the displacement along the plane of the objects. The equation I derived for the velocity is $\sqrt{2xg\sin\left(10\right)}$. Where x is the displacement along the inclined plane. This equation doesn't take friction into account though, so when I derived the equation while taking friction into account the velocity is slightly less. That equation is $v\ =\ 9.8t\left(\sin\left(10\right)-k\cos\left(10\right)\right)$. v is velocity, t is time and k is the coefficient of friction. The equations do not have a mass term in them, so they are identical, which must mean that the displacement of the two objects is the same at any instant in time. I then rolled an object with a mass of 103 grams and an object with a mass of 40 grams on the plane. But the object of mass 40 grams turns out to have a larger acceleration | {
"domain": "physics.stackexchange",
"id": 95263,
"lm_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, rotational-dynamics, friction",
"url": null
} |
java
There's nothing about your code that stands out as 'this was written by a C# developer'.
I don't think hierarchies are likely to be deep enough to create a significant performance overhead unless you're declaring lots of these converters that you're not using. You could overcome this with various patterns so that only actually create a single version of a given converter that you'd then reuse for each conversion.
These seem fine to me, although I've not done extensive reflection within Java.
Not that I'm aware of.
You may not need methods at all...
From what I can remember in .Net, you can directly access private members in a class through reflection. Which made me curious, so I did a bit of investigating. It turns out that you can do it in Java as well.
Once you've got access to the field, you can simply tell the field that it's accessible... so:
field.setAccessible(true);
if (field.canAccess(object)) { // will always be true | {
"domain": "codereview.stackexchange",
"id": 41326,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "java",
"url": null
} |
javascript, beginner, jquery, wordpress
$('.nav a').click( function() {
var $this = $( this ),
minus = $( '.minus' ),
getHref = $this.attr( 'href' );
slideDownPhones( $this, minus, getHref );
} );
$( '.nav a .minus' ).click( function ( e ) {
e.preventDefault();
e.stopPropagation();
$( this ).parent( 'a' ).next( '.sub-menu' ).slideUp( 300, function() {
var $this = $( this ),
minus = $( '.minus' );
decorationUp( $this, minus );
} );
} );
}
toggleMenuVisibility();
equalizeHeight_If_Description();
$(window).on( "resize", function() {
var newWindowWidth = $( window ).width();
if ( newWindowWidth !== cachedWindowWidth ) { //Prevent toggleMenuVisibility() from running on window scroll (Android/IOS)
// Update the window width for next time
cachedWindowWidth = $( window ).width();
//Do menu visibility toggle
toggleMenuVisibility(); | {
"domain": "codereview.stackexchange",
"id": 21477,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "javascript, beginner, jquery, wordpress",
"url": null
} |
java, algorithm
This can be implemented with a function I called inverseNMulD below described:
private static Set<String> inverseNMulD(Set<String> n, Set<String> d) {
Set<String> set = new HashSet<>();
for (String s1 : d) {
for (String prefix : n) {
if (s1.startsWith(prefix)) {
set.add(s1.substring(prefix.length()));
}
}
}
return set;
}
After you will have to define a element S succession where S1 is defined in this way:
This can be expressed with a function I called firstSet below described:
private static Set<String> firstSet(Set<String> c) {
Set<String> set = inverseNMulD(c, c);
set.remove(""); <-- I'm removing the empty string
return set;
}
After you have will to define how to calculate the i+1th element of your succession starting from the ith element: | {
"domain": "codereview.stackexchange",
"id": 38098,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "java, algorithm",
"url": null
} |
javascript, beginner, html, css
.grid-container > div {
flex: 1;
display: flex;
flex-direction: column;
}
.grid-container > div > * {
flex: 1;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Etch-a-Sketch</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<script src="index.js" defer></script>
<h1 id="header">Etch-a-sketch!</h1>
<div class="flex-container">
<div class="buttons">
<button class="button" id="sketch">Sketch</button>
<button class="button" id="eraser">Erase</button>
<button class="button" id="reset">Reset</button>
<button class="button" id="gridSize">Grid Size</button>
</div>
<div id="grid-container" class="grid-container"></div>
</div>
</body>
</html> I'm going to only focus on the Javascript code in my answer. | {
"domain": "codereview.stackexchange",
"id": 43712,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "javascript, beginner, html, css",
"url": null
} |
qiskit, vqe
Also note that UCCSD is a chemically motivated Ansatz, so it only makes sense that the starting state, "initial_state" start out as the Hartree-Fock state. | {
"domain": "quantumcomputing.stackexchange",
"id": 2034,
"lm_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, vqe",
"url": null
} |
# norm
Vector and matrix norms
## Description
example
n = norm(v) returns the Euclidean norm of vector v. This norm is also called the 2-norm, vector magnitude, or Euclidean length.
example
n = norm(v,p) returns the generalized vector p-norm.
example
n = norm(X) returns the 2-norm or maximum singular value of matrix X, which is approximately max(svd(X)).
example
n = norm(X,p) returns the p-norm of matrix X, where p is 1, 2, or Inf:
example
n = norm(X,'fro') returns the Frobenius norm of matrix X.
## Examples
collapse all
Create a vector and calculate the magnitude.
v = [1 -2 3];
n = norm(v)
n = 3.7417
Calculate the 1-norm of a vector, which is the sum of the element magnitudes.
X = [-2 3 -1];
n = norm(X,1)
n = 6
Calculate the distance between two points as the norm of the difference between the vector elements.
Create two vectors representing the (x,y) coordinates for two points on the Euclidean plane.
a = [0 3];
b = [-2 1]; | {
"domain": "mathworks.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9935117298270106,
"lm_q1q2_score": 0.830062694189625,
"lm_q2_score": 0.8354835371034368,
"openwebmath_perplexity": 1365.6418922617156,
"openwebmath_score": 0.9064342379570007,
"tags": null,
"url": "https://uk.mathworks.com/help/matlab/ref/norm.html"
} |
ros, navigation, global-planner
Title: Navigation Stack's Global Planning Algorithm
What kind of algorithm is used for global planner?
I've already read a paper on nav stack, "The Office Marathon".
The paper says that global planner assumes that A* algorithm is used.
And it also refer to a paper "A gradient method for realtime robot control".
Once I asked a similar question and got the latter method is used as global planner.
http://answers.ros.org/question/37332/an-algorithm-used-for-navigation-stack/
A* algorithm is used for ... what ?
Thanks in advance.
Originally posted by moyashi on ROS Answers with karma: 721 on 2012-12-19
Post score: 1
By default, the navigation stack's global planner (provided by the navfn package) uses Dijkstra's algorithm. See http://answers.ros.org/question/28366/why-navfn-is-using-dijkstra/ for discussion on why that is the case and some more info about the A* implementation available in that package. | {
"domain": "robotics.stackexchange",
"id": 12166,
"lm_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, global-planner",
"url": null
} |
python, tic-tac-toe
This will allow you to come back to it and add a GUI.
It also becomes easier for anyone reading the code to understand what's happening visually.
Next is your printout of the board. Join will be your friend here.
for row in board:
printout = "\t|\t".join(str(element) for element in row)
print(printout) # this can be reduced to a single line if you want.
ranges
range() accepts 3 variables. START, STOP and INCREMENT AMOUNT
for i in range(0, 9, 3):
You can also reverse with negative values
for i in range(9, 0, -1):
or
for row in board[::-1]:
if statements
In math class you know how you were able to write a < x > b? You can do that in python without requiring and.
if 0 <= number > 10:
Then there is checking the board state if someone has won.
Your current approach requires a lot of coding and can't be expanded on quickly
There are a few different approaches you can do with this. All will "work."
First the rows
for row in board:
if len(set(row)) == 1:
return True | {
"domain": "codereview.stackexchange",
"id": 38870,
"lm_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, tic-tac-toe",
"url": null
} |
encoding-scheme, number-formats
Title: Confusion in "mask bits" This is the question:
By definition of the IEEE754 standard, 32-bit floating point numbers
are represented as follows:
S (1 bit) E (8 bits) M (23 bits) S: Sign bit E: Exponent M:
Mantissa
Which of the following is the correct “mask bits” in hexadecimal to be
used for extracting only the exponent part of the above format?
Here, “mask bits” means a bit pattern which is logically ANDed
withthe 32-bit floating point value.
a) 107FFFFF b) 7F800000 c) FF100000 d) FF800000
The given answer is b : 7F800000, but i have no idea why, can anyone give me an explanation, i'm greatly appreciated!
Is that because :
7F800000 = 0111 1111 1000 (8)
While others answer contain more "1" in binary format? When you bitwise AND a number in this format with 7F800000 you get:
SEEEEEEEEMMMMMMMMMMMMMMMMMMMMMMM
AND 01111111100000000000000000000000
= 0EEEEEEEE00000000000000000000000 | {
"domain": "cs.stackexchange",
"id": 3395,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "encoding-scheme, number-formats",
"url": null
} |
python, performance, parsing, json, ip-address
Your timings already support this.... it takes 1 second to search all records in 1 CIRD, but significantly longer for 2000 CIDRs...
So, you have a performance problem in the order of \$O(mn)\$ where \$m\$ is the number of rows in the file, and \$n\$ is the number of CIDRs.
You can't improve the performance related to the number of rows in the files, but you can improve the cost of the CIDR lookups. What if it was a fixed-cost to check all CIDR matches? Then your overall performance becomes \$O(m)\$ and does not depend on the number of CIDR records.
You can do this by preprocessing the CIDR data in to a structure that allows a fixed-cost lookup.
The structure I would use is a binary tree consisting of nodes representing each bit in the CIDR specs. Each leaf node represents a CIDR to include. I.e. you preprocess the CIDRs in to the tree that at most has 32 levels (for a /32 CIDR). | {
"domain": "codereview.stackexchange",
"id": 44718,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "python, performance, parsing, json, ip-address",
"url": null
} |
It need not be the case that $$f_n \to f$$ in $$L^p$$.For example, consider $$f_n = n^{1/p} \chi_{[0,\frac{1}{n}]}$$ as functions on $$[0,1]$$ with the Lebesgue measure. Then $$f_n \to 0$$ a.e. but $$\|f_n\|_p = 1$$ so that $$f_n$$ is bounded in $$L^p([0,1])$$ but does not converge to $$0$$ in $$L^p([0,1])$$.
In fact, in Royden's book the Riesz representation theorem for $$L^p$$ is presented after this exercise so it's good to guess that we shouldn't use it.
Instead we will make use of Egoroff's theorem. First, since $$g \in L^q$$, for any $$\varepsilon > 0$$ there is a $$\delta > 0$$ such that $$m(E) < \delta$$ implies that $$\int_E |g|^q dm < \bigg(\frac{\varepsilon}{4M}\bigg)^q.$$
Then by Egoroff's theorem there is measurable $$E \subseteq [0,1]$$ such that $$m(E) < \delta$$ and $$f_n \to f$$ uniformly on $$F := [0,1] \setminus E$$. As a result, there is an $$N$$ such that $$n \geq N$$ and $$x \in F$$ implies that $$|f_n(x) - f(x)| \leq \frac{\varepsilon}{2m(F)^{1/p}\|g\|_q}.$$ | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9828232930001333,
"lm_q1q2_score": 0.8012294841575995,
"lm_q2_score": 0.8152324938410784,
"openwebmath_perplexity": 52.85928807785825,
"openwebmath_score": 0.9971558451652527,
"tags": null,
"url": "https://math.stackexchange.com/questions/3542681/does-uniformly-bounded-sequence-in-lp-which-converges-almost-everywhere-converge"
} |
m1 or m2 two pairs of opposite called... And wrote all the mathematical theory, online exercises, formulas and calculators (. Their normal vectors Quiz Factoring Trinomials Quiz Solving Absolute value equations Quiz Order of Operations QuizTypes of angles, 10062... Learn more about the angle of inclination is the angle between y = 2x + and. Two lines is obtained by difference directing vectors of these angles or the acute angle between the lines! Will help you to find how to find acute angle between two lines angle between the lines can be found by using the dot product the... Of Operations QuizTypes of angles about the angle between two straight lines intersect, one of the direction., Volume 2-A, NAVEDTRA 10062, NAVEDTRA 10062 QuizGraphing slope how to find acute angle between two lines Subtracting! Outputs are the acute angle between two planes is equal to a angle between two lines using the directing of! The horizontal with BYJU ’ S – the Learning App today angle denoted by θ | {
"domain": "anekdoty.pro",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9597620539235895,
"lm_q1q2_score": 0.8079523122517204,
"lm_q2_score": 0.8418256472515684,
"openwebmath_perplexity": 742.8682714784669,
"openwebmath_score": 0.5380065441131592,
"tags": null,
"url": "http://anekdoty.pro/site/wkf665.php?a623ad=how-to-find-acute-angle-between-two-lines"
} |
Table[{test2Dx[[row, 2 + col*4]], test2Dx[[row, 4 + col*4]]}, {row, 1, Length@test2Dx}, {col, 0, (Floor[N[Length[test2Dx[[row]]]/4]]) - 1}];
MatrixForm[%, TableAlignments -> Left]
Is there a semantically straightforward way to do this using other functions (e.g., Map or its variants and a pure function)—or is this a use case for which Table makes more sense?
Many index-specific operations can be implemented via MapIndexed with a level specificaton. Your Power example can be written as:
MapIndexed[#1^(#2[[1]]*#2[[2]]) &, test2D, {2}]
If you want better readability of indices you can define an auxiliary function:
myPower[x_, {n1_, n2_}] := x^(n1 n2);
MapIndexed[myPower, test2D, {2}]
Some index-specific operations can be implemented without indices at all. The last example in your question can be coded in a functional form as:
Map[Downsample[#, 2, 2] &, Map[Partition[#, 4] &, test2Dx], {2}]
This expression can be also rewritten in a more verbose way: | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9626731158685837,
"lm_q1q2_score": 0.8063542141624985,
"lm_q2_score": 0.8376199572530448,
"openwebmath_perplexity": 2419.7701793333194,
"openwebmath_score": 0.3594249188899994,
"tags": null,
"url": "https://mathematica.stackexchange.com/questions/203203/map-vs-table-for-index-specific-operations-on-2d-arrays/203213"
} |
energy, variational-principle
Title: Relevance of this equation The book 'The variational princples of mechanics' by Lanczos was recommended to me and I am reading it now. So far it is an enjoyable journey, but I don't see the significance of this equation:
$t = \int \frac{dq}{\phi(E,q)} + \tau \;(53.19)$
which is derived from the energy theorem (which I believe is):
$\sum^n_{i =1} p_i \dot q_i - L = const \; (53.12)$
by rewriting it to:
$f(q,\dot q) = E \; (53.17)$
$\dot q = \phi(E,q)\; (53.18)$
Now I don't see why it would be relevant to express the independent variable $t$ as function of state variables. Especially if simple mass-spring system is inserted into this equation, giving $t$ as a root of the other state variables.
Can someone tell my why this is relevant, or if I am doing something wrong? | {
"domain": "physics.stackexchange",
"id": 16687,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "energy, variational-principle",
"url": null
} |
any additional libraries. If v is an empty symbolic object, such as sym([]), then jacobian returns an empty symbolic object. Solve polynomial and transcendental equations. They are extracted from open source Python projects. Is there a way to block diagonalize a matrix? Symbolic matrices and "integrity" of their inverse. How can I avoid getting "warning: Using rat() heuristics for double-precision input (is this what you wanted?)". You can do statistics, numerical analysis or handle big numbers. Symbolic equations get big and slow really quickly, so this never worked out well for me. If that is the type of thing that you're looking for (ie explicit indices). for_numerical (bool, optional) - A placeholder for the option of numerically computing the gradient. com/sympy/sympy. SymPy is written entirely in Python and does not require any external libraries, which makes it available everywhere Python can be used. The following are code examples for showing how to use sympy. Is there some | {
"domain": "antplus.it",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.963779943094681,
"lm_q1q2_score": 0.815302352218938,
"lm_q2_score": 0.8459424353665381,
"openwebmath_perplexity": 1440.1432832397454,
"openwebmath_score": 0.5822976231575012,
"tags": null,
"url": "http://tjwu.antplus.it/sympy-symbolic-matrix.html"
} |
quantum-mechanics, quantum-spin, hydrogen
I think that the origin of the answer is in the more general question(not necessarily related to hydrogen atom and the hyperfine splitting):
In the case of spin-spin interaction between two fermions($s=\frac{1}{2}$) the operator $\vec{\sigma}_{1}\cdot\vec{\sigma}_{2}$ ($1$ and $2$ denoting each fermion respectively), why does the singlet state have an eigenvalue $-3$ times the eigenvalue of the triplet state? Again, the mathematics are clear to me, I am just seeking to see it intuitively. If you want, you can reason that it's because there's three possibilities for the triplet but only one for the singlet. Quantum mechanics has to divide the triplet eigenvalue among three eigenvectors whereas the singlet eigenvalue belongs entirely to the singlet eigenvector.
Why I think things might be confusing | {
"domain": "physics.stackexchange",
"id": 40146,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "quantum-mechanics, quantum-spin, hydrogen",
"url": null
} |
rust, interpreter
reg += 1;
}
Also, I'm pretty sure you want to skip the increment after a jump, so you probably want to account for that somehow.
I'm not sure why you're passing in the output vector as a reference and then cloning it, I assume it's because you want to enable multiple lines of code acting on the same stack.
You probably should be passing an &str to fn eval, it's just more idiomatic.
words.rs
I'd recommend passing the stack reference as the first parameter in fn parse_number. It's good to have consistent ordering.
I'd also say implementing get_ops as an inline function would be better than using such a trivial macro.
One thing you could do is create a NewType wrapping a vector like Stack(Vec<f64>). You could then implement all of these functions as methods of that struct:
struct Stack(Vec<f64>);
impl Stack {
// helpful alias
#[inline(always])
pub fn push(&mut self, item: f64) {
self.0.push(item);
} | {
"domain": "codereview.stackexchange",
"id": 32450,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "rust, interpreter",
"url": null
} |
vba, excel
Case Is = WsNewClient.Name
Call InitialiseNewClientHeadingsExceptions(colMissingSheetHeadings)
Case Is = WsExistingClient.Name
Call InitialiseExistingClientHeadingsExceptions(colMissingSheetHeadings)
Case Is = WsGroupSchemes.Name
Call InitialiseGroupSchemesHeadingsExceptions(colMissingSheetHeadings)
Case Is = WsOther.Name
Call InitialiseOtherHeadingsExceptions(colMissingSheetHeadings)
Case Is = WsMcOngoing.Name
Call InitialiseMcOngoingHeadingsExceptions(colMissingSheetHeadings)
Case Is = WsJhOngoing.Name
Call InitialiseJhOngoingHeadingsExceptions(colMissingSheetHeadings)
Case Is = WsAegonQuilterArc.Name
Call InitialiseAegonQuilterArcHeadingsExceptions(colMissingSheetHeadings) | {
"domain": "codereview.stackexchange",
"id": 15374,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "vba, excel",
"url": null
} |
quantum-mechanics, wavefunction, schroedinger-equation, fourier-transform, time-evolution
$$
\psi(x,t)=\frac{\sqrt{\frac{1}{\sigma^2}}(\sigma^2)^{3/4}}{2^{1/4}\pi^{3/4}}\int_{-\infty}^{\infty}e^{i(kx-\hbar k^2t/2m_p)-k^2\sigma^2}dk\,.
$$
To derive this, I used the Fourier transform to expand $\psi(x,0)$ in terms of the eigenfunctions of a free particle, which are the plane waves. Then, I computed $\phi(k)$ using the inverse Fourier transform and substituted this back into the Fourier integral for $\psi(x,0)$. To compute $\psi(x,t)$, I realized that the component waves of the wave packet must propagate independently from one another, and the time evolution of a general plane wave is given by $\psi(\vec{r},t)=Ae^{i(\vec{k}\cdot\vec{r}-\omega t)}$. I multiplied this by the integrand of $\psi(x,0)$ to obtain $\psi(x,t)$, where I substituted $\hbar k^2/2m_p$ for $\omega$ (I used the Planck relation and the energy eigenvalues of a free proton). | {
"domain": "physics.stackexchange",
"id": 93691,
"lm_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, wavefunction, schroedinger-equation, fourier-transform, time-evolution",
"url": null
} |
inorganic-chemistry, electrochemistry
Does my reasoning make sense? And if not, what did I get wrong? It's true that when the battery is re-discharged, it's thermodynamically 'easier' to oxidize lithium than lithiated graphite. However, keep in mind that the lithium will react with electrolyte to form an SEI (solid electrolyte interphase) layer. This process consumes lithium ions, so on recharge you don't get all the lithium ions back. This is why the process is considered "irreversible." | {
"domain": "chemistry.stackexchange",
"id": 9119,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "inorganic-chemistry, electrochemistry",
"url": null
} |
complexity-theory, np-complete, np, integer-programming, co-np
The main issue here is that if we take such an $y$ as NP-certificate, it might be of exponential size in terms of the input, but this of course does not mean a certificate cannot exist.
My idea was that if we assume ILP in NP, we can use a discrete version of the Farkas lemma (see here) to transform an ILP instance with the answer NO to an ILP instance with the answer YES, which then would imply that ILP is in coNP. So we get an NP-complete problem in coNP, which implies that $NP=coNP$. Since most people think $NP\neq coNP$, this is 'evidence' for ILP not being in NP. | {
"domain": "cs.stackexchange",
"id": 8194,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "complexity-theory, np-complete, np, integer-programming, co-np",
"url": null
} |
ros, ros-kinetic, callback
/home/mcamurri/catkin_ws/src/transport_hint_test/src/transport_hints.cpp:16:73: note: cannot convert ‘boost::bind(R (T::*)(B1, B2), A1, A2, A3) [with R = void; T = TransportHintsTest; B1 = boost::shared_ptr<const std_msgs::String_<std::allocator<void> > >; B2 = const std::__cxx11::basic_string<char>&; A1 = TransportHintsTest*; A2 = boost::arg<1>; A3 = std::__cxx11::basic_string<char>; typename boost::_bi::list_av_3<A1, A2, A3>::type = boost::_bi::list3<boost::_bi::value<TransportHintsTest*>, boost::arg<1>, boost::_bi::value<std::__cxx11::basic_string<char> > >](((TransportHintsTest*)this), ({anonymous}::_1, boost::arg<1>()), std::__cxx11::basic_string<char>(id))’ (type ‘boost::_bi::bind_t<void, boost::_mfi::mf2<void, TransportHintsTest, boost::shared_ptr<const std_msgs::String_<std::allocator<void> > >, const std::__cxx11::basic_string<char>&>, boost::_bi::list3<boost::_bi::value<TransportHintsTest*>, boost::arg<1>, boost::_bi::value<std::__cxx11::basic_string<char> > > >’) to type | {
"domain": "robotics.stackexchange",
"id": 32480,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "ros, ros-kinetic, callback",
"url": null
} |
joint, urdf, ros-kinetic, solidworks, joint-state-publisher
xyz="-0.04 -0.00079625 -0.00064577"
rpy="-1.5708 -6.5052E-17 -1.5708" />
<parent
link="link4" />
<child
link="link5" />
<axis
xyz="0 0 1" />
<limit
lower="3.1416"
upper="3.1416"
effort="0"
velocity="0" />
</joint>
</robot> | {
"domain": "robotics.stackexchange",
"id": 30861,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "joint, urdf, ros-kinetic, solidworks, joint-state-publisher",
"url": null
} |
vba, excel
Private Sub LogTime(message As String)
Dim timestamp As String, logEntry As String
timestamp = Format(Now, "mm/dd/yyyy HH:mm:ss")
logEntry = message & ": " & timestamp
'Append logEntry to a text file or write them out to an excel sheet
End Sub
Below is the module refactored using some of the ideas described above. I had to stub a few procedures to get the original code to compile - so obviously, the code below does not work.
Option Explicit
Private Const IMPORTANT_OFFSET As Long = 6
Private Property Get RegisterNoError() As Long
RegisterNoError = Worksheets("LOTS").Range("C5").value
End Property
Private Property Let RegisterNoError(value As Long)
Worksheets("LOTS").Range("C5").value = value
End Property
Private Property Get RegisterNumb() As Long
RegisterNoError = Worksheets("LOTS").Range("D5").value
End Property
Private Property Let RegisterNumb(value As Long)
Worksheets("LOTS").Range("D5").value = value
End Property
Sub Import_data() | {
"domain": "codereview.stackexchange",
"id": 38982,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "vba, excel",
"url": null
} |
python, console, timer
sleep(delay_t)
while True:
if t >= next_t:
break
t = clock()
This means that you'll have to change your for loop slightly.
You will need to remove the time.sleep,
and the output is the equivalent of using range(secs + graceperiod).
And so if you put i = int(round(sec - i)) at the beginning of your for loop, it's almost identical.
And so to improve your code further I'd:
Remove the brackets around your if statements.
Use str.format, and change i = -i in your else.
Stop using os.system('clear'), and instead use \r and print '...',.
Change your four print '\a''s to be in a for loop.
Change cl to Color.
Add a main. And use the if __name__ == '__main__': guard.
resulting in:
import os
import time
class Color:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m' | {
"domain": "codereview.stackexchange",
"id": 20673,
"lm_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, console, timer",
"url": null
} |
energy, neutrinos, sun
Title: Neutrino beam energy Neutrino is one of the most mysterious particles in todays physics. Even when values of some parameters like for example mass associated with it are not known (or there is great range of possible values), its existence is not questioned. There is a field of research named neutrino astronomy. Because neutrino interaction with ordinary matter is very weak, sensitivity of detectors is minuscule. The only natural sources of neutrinos we could detect are sun and SN1987A supernova that exploded in year 1987. I am curious what is the total energy of neutrinos flowing to earth from the Sun? For convenience I want this value as power density [W / m2]. For comparison electromagnetic energy flowing to Earth from Sun in upper limits of atmosphere in equator areas is about 1360 W / m2. http://www.ncbi.nlm.nih.gov/pmc/articles/PMC33947/table/T1/ gives a table of neutrino number density for various sources and energies. The flux of solar neutrinos is 5 x | {
"domain": "physics.stackexchange",
"id": 2729,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "energy, neutrinos, sun",
"url": null
} |
quantum-anomalies, bosonization
Title: chiral anomaly and translation symmetry in 1+1D A Luttinger liquid at low energies can be captured by Dirac fermions in 1+1D, where the two component fermion field is given by
$$\Psi(x)=\left(\begin{array}{c}\psi_R(x)\\\psi_L(x)\end{array}\right),$$ where $\psi_{R,L}$ are (slow-moving parts of) the right and left movers near the two Fermi points, i.e.,
$$\phi(x)\sim \psi_R(x)e^{ik_F x}+\psi_L(x)e^{-ik_F x}.$$
In this terminology a translation operation $x\to x+a$ is equivalent to a chiral transformation on the spinor field $\Psi(x)$
$$\Psi(x)\to e^{i\sigma^z\theta}\Psi(x)=\left(\begin{array}{c}e^{i\theta}\psi_R(x)\\e^{-i\theta}\psi_L(x)\end{array}\right),$$
where $\theta=k_F a$.
In 1+1D we know there is chiral anomaly, which means the above chiral transformation is not a symmetry of the system at quantum level. Does it mean then, translational symmetry in the Luttinger liquid is not a real symmetry at quantum level? | {
"domain": "physics.stackexchange",
"id": 33697,
"lm_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-anomalies, bosonization",
"url": null
} |
classical-mechanics, lagrangian-formalism, hamiltonian-formalism, causality
Consider the relativistic Lagrangian
$$L = mc^2 \sqrt{1-\frac{v^2}{c^2}} - U(\mathbf x)$$
Expanding to second order in $v^2/c^2$, this becomes
$$L = \frac{1}{2} mv^2 +\frac{3}{8} m v^4/c^2 - U(\mathbf x)$$
which yields the EL equations
$$-\frac{\partial U}{\partial \mathbf x} = \frac{d}{dt}\left[m\left(1+ \frac{3v^2}{2c^2} \right)\mathbf v\right]$$
This is Newtonian mechanics, except that $m$ has been replaced by $m\left(1+\frac{3v^2}{2c^2}\right)$, giving the lowest-order relativistic correction. | {
"domain": "physics.stackexchange",
"id": 74439,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "classical-mechanics, lagrangian-formalism, hamiltonian-formalism, causality",
"url": null
} |
snr, quantization, cosine, thd
Figure 2. THD (dB) as function of unquantized amplitude $A$. The local maxima are at amplitudes that cause a narrow protrusion to poke out at the extrema of the quantized sinusoid.
Figure 3. Amplitude $a_1$ (blue solid line) of the fundamental frequency in the quantization of a cosine wave of amplitude $A$, with the identity line (orange dashed line) plotted for reference.
Table 2. Optimal $A$ by definition 2 for different $m\le24$ and the resulting THD, with the THD for some common choices of $A$ listed for comparison. Surprisingly, THD is minimized by the same $A$ that maximize SNR (Table 1), also when tested with much higher precision than what is shown here. If the signal is considered to be a sinusoid of amplitude $a_1$ instead of amplitude $A$, then SNR values are obtained by flipping the sign of the THD values.
$$\begin{array}{l|l|l|lll}m&\text{optimal }A&a_1&\rlap{\text{THD (dB)}}&&\\
&&A=\text{optimal}&A=\text{optimal}&2^{m-1}-1&2^{m-1}-0.5\\
\hline | {
"domain": "dsp.stackexchange",
"id": 7360,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "snr, quantization, cosine, thd",
"url": null
} |
algorithms, complexity-theory, combinatorics, statistics
The $x_{(i_1, \dots, i_M)}$ now indicate which row should occur how often, and we get a solution with the minimum number of rows possible. If we can influence the search, we can abort as soon as we find any feasible solution.
This is not likely to be efficient, but there are honed solvers for integer programs around so it's simple to implement. It may be possible to use an LP-solver and round to a feasible solution. | {
"domain": "cs.stackexchange",
"id": 1250,
"lm_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, complexity-theory, combinatorics, statistics",
"url": null
} |
measurement, vqe
Title: Expected Minimum Clique Coverage? I'm curious if there is literature on this and, if there is, where to find it. Here I'm using ``clique" to mean a set of observables which all commute with each other. I also include the identity matrix as the zeroth Pauli.
Problem: Say I randomly generate a list of $P$ different Pauli observables on $M$ qubits. They can be any tensor product of $M$ Paulis. Is there an approximate function of $P,M$ which can give me the expected number of cliques in a minimal clique covering? I'd also be happy with just big-$O$ notation.
Clearly the number of cliques must scale as less than $O(M)$. It also can't just be $1$ or you'd have a very, very simple Hamiltonian... non-contextual is the word I think? Regardless, I feel that the crux of this problem lies in the fact that Paulis either commute or anti-commute. | {
"domain": "quantumcomputing.stackexchange",
"id": 3810,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "measurement, vqe",
"url": null
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.