text
stringlengths
49
10.4k
source
dict
grovers-algorithm Title: To program Grover algorithm oracle, we need to know the answer already, if we know the answer then what else do we need? To program Grover algorithm oracle, we need to know the answer already then what is the point of building the oracle. To me its like we are telling the oracle the correct answer and just asking it the correct answer. Please help to understand the point here. In other words, since Grover is a search algorithm and if we already know the answer to build the oracle then why do we even need to search/build oracle to find the same answer that we know. You don't need to know the answer to build the oracle for Grover. The Oracle only needs to only be able to "mark" the state you're looking for. In a real-life application, you wouldn't be looking for a specific bit-string, but rather you're looking for a bit string with a specific property X. Take the following example for instance: You have a function $f(x)$ and you want to solve $f(x) = y$, for some $y$. Now for this specific problem, you can usually solve the problem analytically and it would be kind of dumb to do a search for $x$ but I think this example will demonstrate why you wouldn't need to know the answer. To do this using Grover, you can build a circuit $U$ such that: $$U\vert x\rangle\vert0\rangle = \vert x\rangle \vert f(x)\rangle$$ Then if you prepare the state $(H^{\otimes m}\otimes I^{\otimes n})(\vert 0\rangle^{\otimes m}\otimes \vert 0\rangle^{\otimes n})$, $U$ will map it to: $$\frac{1}{\sqrt{2^m}}\sum_x \vert x\rangle \vert f(x)\rangle$$
{ "domain": "quantumcomputing.stackexchange", "id": 4008, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "grovers-algorithm", "url": null }
python, python-3.x, file Title: File Encryption I'n written this small file encryption module to work on my skills with the os module. It's my very first time using it to navigate files and file structures, so I'm sure some things can be improved. I used the following file structure to ensure it works with multiple directories: File Structure . ├── files │ ├── files │ │ ├── test.txt │ │ ├── test2.txt │ │ └── test3.txt │ ├── files2 │ │ ├── files │ │ │ ├── test.txt │ │ │ ├── test2.txt │ │ │ └── test3.txt │ │ ├── test.txt │ │ ├── test2.txt │ │ └── test3.txt │ ├── test.txt │ ├── test2.txt │ └── test3.txt ├── key.py └── virus.py It works flawlessly. I'm looking for feedback on a couple topics: os module: Are there other functions in the os module that could be used to accomplish the same thing, but easier or faster? file management: Is there a faster way to work with files than I did? The time it takes is noticeable ( 0s < time < 1s for a file of ~2500 characters) but I'm sure it gets longer with bigger files. """ File Encryption & Decryption """ import os from cryptography.fernet import Fernet from key import KEY DIRECTORY = "files" FERNET = Fernet(KEY) def crypt(encrypt=True) -> None: """ Encrypts/Decrypts the files in DIRECTORY """ for root, _, files in os.walk(DIRECTORY, topdown=True): for name in files: file = os.path.join(root, name) with open(file, "rb") as in_file: data = in_file.read() data = FERNET.encrypt(data) if encrypt else FERNET.decrypt(data) with open(file, "wb") as out_file: out_file.write(data) if __name__ == '__main__': # Encrypt # crypt() # Decrypt # crypt(encrypt=False) Some suggestions:
{ "domain": "codereview.stackexchange", "id": 36115, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "python, python-3.x, file", "url": null }
dna, homework, restriction-enzymes Title: Do all restriction enzymes have palindromic recognition sites? I am trying to find out the requirements for a segment of DNA to be the recognition site of a restriction enzyme. Acording to the article on Restriction Enzymes in Wikipedia, "many of them" (referring to recognition sites) are ‘palindromic’ (in the sense that the sequence of nucleotides on one strand should read the same as the that on the other strand, from the opposite direction). Is this true for all recognition sites? The article cited in the question goes on to discuss the different classes of restriction enzyme, for which the recognition ‘style’ differs. Not all recognize palindromic sequences. Type II restriction enzymes These have been divided into a number of subclasses (reviewed by Pingoud and Jeltsch). Those regarded as orthodox — which are the ones generally used in DNA cloning — appear always to require palindromic sequences in their recognition sites, although those in some other classes do not (see list here). This statement is subject to the proviso that you regard as palindromic 5-base recognition sites, such as AlwXI, GCAGC, and others with a ‘non-conforming’ central region, such as ApaBI, GCAN5TGC. The reasons for including the latter (which provides an alternative way of defining the requirements of the recognition sequence) can be seen by examining the symmetrical manner enzymes of this class bind the site, which can tolerate a non-symmetrical central region. This is described in more detail in an answer I gave to another SE question on restriction enzymes. Type I restriction enzymes: …cut at a site that differs, and is a random distance (at least 1000 bp) away, from their recognition site. Cleavage at these random sites follows a process of DNA translocation, which shows that these enzymes are also molecular motors. The recognition site is asymmetrical and is composed of two specific portions—one containing 3–4 nucleotides, and another containing 4–5 nucleotides—separated by a non-specific spacer of about 6–8 nucleotides. Type III restriction enzymes: …recognize two separate non-palindromic sequences that are inversely oriented. They cut DNA about 20–30 base pairs after the recognition site.
{ "domain": "biology.stackexchange", "id": 9765, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "dna, homework, restriction-enzymes", "url": null }
java, parsing, csv Title: System to process data from a specific client I'm working on an important project. We're an IT services provider and we have a project where we have to build a new system to process data from a specific client. The problem is that usually we process their data, but they send us a pre-processed data that's easy to parse, but this time around, they're trying with a new format, which is extremely weird. Anyways, there were two senior programmers that didn't want to mess with the project, and it's been on hold for one whole year. I'm a junior programmer and I managed to build a system that kind of works as intended but I want to improve on it. I don't like the way it ended up, even if it works. The thing is, this format is for generating account statements for a local bank, and they're sending in RAW data. I managed to read and parse the data by using a configuration file that's able to read the data from it's position on the file, which can have up to 500 MB of text data. I built a loadInfo() method that uses reflection to fill in the data in the different classes. The data comes grouped in Registers, which have many fields. Each Register holds specific information, like transactions, client info, balances and stuff. I created a superclass called Register, and then made the other corresponding types of register extend from this superclass. The thing is that there are 17 different kinds of registers, and a Register can have from 1 to more than 30 members. I only use one loadInfo() from the Register superclass, and using reflection I can set the member variables for all the other registers. I feel that my approach is kind of stupid, even if it works, and I'd like to improve it and make it more clean. Right now the whole system has like 25 different classes and I feel that my solution is too disorganized. Any advice on how to improve on my design? I'm going to just include the code for the Registry that contains the information for the client. We are talking about bank data here, and this code is used to generate statement accounts. Please note that the class was designed this way because that's the way the customer documented it, and the way the data is arranged in the text file we receive:
{ "domain": "codereview.stackexchange", "id": 25138, "lm_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, parsing, csv", "url": null }
Hint: Induction $$\begin{eqnarray*} (n+1) \prod_{k=1}^{n+1}(n+1+k)=\left(\prod_{k=1}^{n}(n+k) \right) (2n+1)(2n+2) = \cdots \end{eqnarray*}$$
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9865717444683928, "lm_q1q2_score": 0.8042853347385152, "lm_q2_score": 0.8152324848629215, "openwebmath_perplexity": 214.74539263360057, "openwebmath_score": 0.9394234418869019, "tags": null, "url": "https://math.stackexchange.com/questions/2984508/show-that-prod-k-1n-nk-2n-prod-k-1n-2k-1-for-all-n-in-z" }
material-science, elasticity, continuum-mechanics $$F_{j} = A_0n_{i}C_{ijkl}\epsilon_{kl}$$ If we also approximate that the displacements are approximately linear, that is, that $u_{i,j} \approx \frac{x_i}{(x_0)_j}$ where $x_i$ is a displacement from rest and $(x_0)_j$ is a vector representing rest length in the $j$th coordinate, we can recall the definition of the infinitesimal strain tensor $\epsilon_{ij} = \frac{1}{2}(u_{i,j} + u_{j,i})$ to get a relationship between forces and displacements: $$F_{j} = \frac{1}{2}A_0 n_i C_{ijkl}\left(\frac{x_k}{(x_0)_l} + \frac{x_l}{(x_0)_k}\right)$$ This looks hairy, but the linear relationship you're looking for between forces and displacements is in there! To make it look nicer, let's define a tensor of the form: $$\boxed{k_{jk} = \frac{A_0 n_i C_{ijkl}}{\left(x_0\right)_{l}}}$$ Noting the symmetries of the stiffness matrix, we find that we can rewrite the relationship as: $$F_i = k_{ij}x_j$$ where the previously defined second-order tensor $k_{ij}$ is precisely the tensor you're looking for!
{ "domain": "physics.stackexchange", "id": 54420, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "material-science, elasticity, continuum-mechanics", "url": null }
java, optimization, performance, multithreading, locking } // parse the response and store it in a variable private void parseResponse(String response) { //... ConcurrentHashMap<String, Map<Integer, String>> primaryTables = null; ConcurrentHashMap<String, Map<Integer, String>> secondaryTables = null; ConcurrentHashMap<String, Map<Integer, String>> tertiaryTables = null; //... // store the data in ClientData class variables if anything has changed // which can be used by other threads if(changed) { ClientData.setMappings(primaryTables, secondaryTables, tertiaryTables); } } } Problem Statement: Is there any way I can improve the above ClientData class somehow? Any kind of performance improvements? Or by using any other ways instead of CountDownLatch? I will be using ClientData class in main application thread like this - Mappings mappings = ClientData.getMappings(); // use mappings.primary // use mappings.secondary // use mappings.tertiary I am suspecting, I can avoid AtomicReference here -
{ "domain": "codereview.stackexchange", "id": 7858, "lm_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, optimization, performance, multithreading, locking", "url": null }
general-relativity, cosmology, differential-geometry, astrophysics, curvature Title: What 'sets' the curvature in the FRW metric? In the FRW metric, the way I understand it, there are 4 key quantities, $P$ (pressure), $\rho$ (matter density), $\Lambda$ (the cosmological constant) and $K$ (the curvature constant). $P$ and $\rho$ are fairly self explanatory, while $\Lambda$ we attribute to 'dark energy', whatever that turns out to be. My question is, what is it that 'sets' the value of $K$? Is it the matter density that sets the global curvature, or does the universe simply have a global curvature as an intrinsic property? The curvature is set my the densities of the fluids comprimising the Universe. Consider the first FL-equation \begin{equation} \frac{3}{R^2} \left( k + \frac{\dot{R}^2}{c^2} \right) = \frac{8 \pi G}{c^2}\rho_{tot} \end{equation} with \begin{equation} \rho_{tot}(t) = \rho_{\gamma}(t) + \rho_{M}(t) + \rho_{\Lambda}(t) \end{equation} Some also include the curvature $k$ in the total density. It is clear that there is a critical density such that the Universe is flat: $k=0$, this is \begin{equation} \rho_{crit}(t) = \frac{3H(t)^2}{8\pi G} \end{equation} Now define the dimensionless density \begin{equation} \Omega_{i}(t) = \frac{\rho_{i}(t)}{\rho_{crit}(t)} \end{equation} Then the FL-equations reduces to \begin{equation} \frac{kc^2}{R^2} = H^2 ( \Omega_{tot} - 1) \end{equation}
{ "domain": "physics.stackexchange", "id": 75537, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "general-relativity, cosmology, differential-geometry, astrophysics, curvature", "url": null }
stoichiometry, combustion Title: Balancing octane combustion reaction for internal combustion engine I am trying to balance out the equation for combustion of octane in $120\,\%$ of excess air with products $\ce{CO2},$ $\ce{H2O},$ $\ce{N2},$ and $\ce{O2}$: $$\ce{C8H18 + 1.2$a$(O2 + 3.76 N2) -> $b$ CO_2 + $c$ H2O + $d$ O2 + $e$ N2}$$ My approach was as follows: $$ \begin{align} &\ce{C}: & b &= 8 \\ &\ce{H}: & 2c &= 18 \\ &\ce{O}: & 2b + c + 2d &= 2\times 1.2a \\ &\ce{N}: & e &= 3.76\times 1.2a \end{align} $$ However, I think somewhere in my steps there's something I am not doing correctly as I am unable to determine $a$ with the system of equations I tried developing. Since the reaction is done in excess of air, you can assume complete combustion and accordingly you should break down the reaction to only this. Apparently the question demands an answer in the following form: $$\ce{C8H18 + 1.2$a$ (O2 + 3.76 N2) -> b CO2 + c H2O + d O2 + e N2},$$ however, this is the same as $$\begin{multline} \ce{C8H18 + x O2 + 0.2x O2 + (1.2$x$\times3.76) N2}\\ \ce{-> y CO2 + z H2O + 0.2x O2 + (1.2$x$\times3.76) N2}, \end{multline}$$ which is the same as $$\ce{C8H18 + x O2 -> y CO2 + z H2O},$$ just more complicated. From there you can form \begin{align}
{ "domain": "chemistry.stackexchange", "id": 15781, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "stoichiometry, combustion", "url": null }
python, beginner, python-3.x, calculator, community-challenge def __init__(self): self.operators = Calculator.__operators def evaluate(self, expression: str) -> Decimal: """ Evaluates an expression and returns its result. :param expression: The input expression :return: The output of evaluating the expression """ tokens = self.to_rpn(self.tokenize(expression)) stack = [] for token in tokens: if isinstance(token, ValueToken): stack.append(token.value) elif isinstance(token, OperatorToken): function = self.operators[token.operator][2] argspec = inspect.getargspec(function) argument_count = len(argspec.args) if len(stack) < argument_count: raise RuntimeError("not enough tokens for: " + str(token) + ", expected: " + str(argument_count) + ", actual: " + str(len(tokens))) values = [stack.pop() for x in range(argument_count)] values.reverse() result = function(*values) stack.append(result) else: raise RuntimeError("unexpected token: " + token) return stack.pop() def tokenize(self, expression: str) -> list: """ Tokenizes an expression and produces an output list of tokens. :rtype: list of [Token] :param expression: The input expression """ tokens = [] stripped_expression = expression.replace(' ', '') value_regex = re.compile(r"\d+(\.\d+)?") operator_regex = re.compile(r"[^\d\.\(\)]") left_parentheses_regex = re.compile(r"\(") right_parentheses_regex = re.compile(r"\)")
{ "domain": "codereview.stackexchange", "id": 13726, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "python, beginner, python-3.x, calculator, community-challenge", "url": null }
star, distances, history Title: How were the distances to stars measure before parallax? A comment under When was the distance to a star measured for the first time without using parallax? mentions that the distance to stars was measured before parallax was possible. How was this done? As far as I know direct parallax measurements are the only way to directly measure the distances to stars. Once parallaxs of hundreds of stars were known and diagrams of the relationship between stellar luminosity and spectral types, such as the Hertzsrpung-Russel diagram, were made, it became possible to estimate a star's absolute magnitude more or less accurately and thus calculate its distance from its apparent magnitude. It may be noted that stars in some spectral types can have any one of up to nine luminosity classes. A star's luminosity class is included as Roman numerals in its spectral classification if it is known. Calculating the distance to a star without knowing its luminosity class can be very inaccurate. https://en.wikipedia.org/wiki/Stellar_classification#Yerkes_spectral_classification[1] The heliocentric theory, that the Earth revolves around the Sun, was first suggested in classical Greece. Aristotle (384-322 BC) rejected that theory, because of the lack of detectable stellar parallax caused by Earth's motion around the Sun. Exploration of the Universe Brief Edition, George Abell, 1964, 1969, page 18. That same argument was used against the heliocentric theory in the early modern age. Stellar parallax is so small that it was unobservable until the 19th century, and its apparent absence was used as a scientific argument against heliocentrism during the early modern age. It is clear from Euclid's geometry that the effect would be undetectable if the stars were far enough away, but for various reasons, such gigantic distances involved seemed entirely implausible: it was one of Tycho Brahe's principal objections to Copernican heliocentrism that for it to be compatible with the lack of observable stellar parallax, there would have to be an enormous and unlikely void between the orbit of Saturn and the eighth sphere (the fixed stars).2
{ "domain": "astronomy.stackexchange", "id": 5921, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "star, distances, history", "url": null }
algorithms, graphs, randomness My question is after this loop ends what can we say about uniform randomness of the remaining edges. Are they still uniform random? Let us consider the simplest case, that of a path of length two edges, which are drawn uniformly and independently from $[0,1]$. Let us suppose that the first edge is sub-dominant, which happens with probability 1/2. The probability that the weight of second edge is at most $t \in [0,1]$ is $$ \Pr[x \leq y \leq t \mid x \leq y] = \Pr[x,y \leq t] = t^2. $$ Here $x$ is the weight of the first edge, and $y$ is the weight of the second edge. We see that even before doubling, the distribution of $y$ is non-uniform. Next, let us examine the case of a star with three edges, again drawn uniformly and independently from $[0,1]$. Again suppose that the first edge is sub-dominant, which happens with probability 1/3. The probability that the weight of the second edge is at most $t \in [0,1]$ while that of the third edge is at most $u \in [0,1]$ is $$ \Pr[y \leq t, z \leq u \mid x \leq y,z] = 3 \int_0^{\min(t,u)} (t-x)(u-x) \, dx = \\ 3tum - \frac{3}{2}(t+u)m^2 + m^3. $$ Here $x,y,z$ are the weights of the first, second, and third edges, respectively, and $m = \min(t,u)$. Substituting $u = 1$, we obtain $$ \Pr[y \leq t \mid x \leq y,z] = \frac{3t^2-t^3}{2}. $$ Calculation shows that for generic $t,u$, $$ \Pr[y \leq t, z \leq u \mid x \leq y,z] \neq
{ "domain": "cs.stackexchange", "id": 12299, "lm_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, graphs, randomness", "url": null }
php, laravel Note I am using InvalidArgumentException which is more appropriate here. Before this code however, you again are just assuming that $emailSettings is a valid array with appropriate values in it, so you might consider checking that email settings is indeed an array and that it is not empty. You may also want to check that each of the for expected keys is set (these would be good case for OutOfBoundsException) before trying to validate the content at each of those keys. Or, you move this all into an email configuration class as mentioned earlier and do all that validation there, meaning the only validation you need to do here is make sure you have a valid instance of that class (something that can be enforced via type hinting on the parameter itself). By the way, your domain validation regex is very limited in terms of top-level domains it supports. This might be by design, but if you are looking for any valid host name (by RFC 2396 standards for example), you should consider expanding your regex or possibly using FILTER_VALIDATE_URL. 4) Your overall approach to exceptions needs some refinement. For example, you probably do not want your PhishingController to have to capture and perform different behaviors for all the underlying exceptions that might be thrown by the email class. The email class should perhaps understand these different exception types but ultimately wrap these to a standard exception type (i.e. Exception) or a class-specific exception type you create (i.e. EmailException) but it likely is adding no value to have the PhishingController class have to deal with different exception types.
{ "domain": "codereview.stackexchange", "id": 20959, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "php, laravel", "url": null }
electromagnetism, potential $$ emf(A~to~B) + (\varphi_B-\varphi_A) = RI. $$ Since the right-hand side is not zero in general, emf and potential difference do not cancel each other completely in real inductors. Their algebraic sum can be understood as the "net active force" that pushes the current against the Ohmic resistance. The emf usually acts against the potential difference, so the greater the Ohmic resistance, the greater the difference of magnitudes of emf and potential difference has to be to maintain the same current.
{ "domain": "physics.stackexchange", "id": 60718, "lm_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, potential", "url": null }
python, beginner, game, playing-cards, turtle-graphics Imports Order The order of imports: Standard library imports Third party imports Local application imports Does it matter when you only have 2 import lines? No. Does it keep things easier when you have 20 of them? Definitely. from turtle import * import random Turns into: import random from turtle import * Blanket imports Do you know what you're importing when you use from turtle import *? The entire turtle. You don't need the entire turtle. This is what you need: from turtle import Turtle, ht, speed, write, clear, up, down, left, right, goto, forward And yes, that's quite a mouthful. And longer than 80 characters. So, for small programs which only import from 1 library this way, there's no problem. Import 6 different libraries like that and you're importing a lot of stuff you don't need. What would happen if 2 or 3 libraries have a clear function? By writing out which ones you need, you immediately realize the problem should such a thing happen. Of-course, the obvious solution is simply importing like this: import random import turtle Yes, this will lead to somewhat longer calls. updater = Turtle() turns into updater = turtle.Turtle() and ht() turns into turtle.ht(). But the moment you get multiple from lib import * statements in your code, you got a problem.
{ "domain": "codereview.stackexchange", "id": 30558, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "python, beginner, game, playing-cards, turtle-graphics", "url": null }
c++, library, template-meta-programming, c++17, variadic return min(less, std::min(a, b, less), rems...); Your approach here uses recursion and implementations are permitted to put a recursion depth limit on constexpr calculations. Consider an iterative solution that expands the pack while calculating the minimum. template <typename Comparator, typename First, typename... Rest> constexpr decltype(auto) variadic_min(Comparator cmp, First const& first, Rest const&... rest) { const First* result = std::addressof(first); // cast each evaluated expr to void in case of overloaded comma operator shenanigans ((void)(result = std::addressof(std::min(*result, rest, cmp))), ...); return *result; } An explanation with what is going on with the fold expression: ((void)(result = std::addressof(std::min(*result, rest, cmp))), ...); ^ ^ ^ ^ | | | expand using comma op | | safer than built-in, now constexpr in 17 | evaluate the expression for each pack variable cast to void the entire expression to avoid overloaded comma op. Just thinking beyond the standard library and reinventing the wheel. This min works fine for homogenous packs. What about heterogenous packs? auto& min1 = min(std::less<>{}, 4, 5, -1); // min1 = -1 auto& min2 = min(std::less<>{}, 4, 5, -1.); // candidate template ignored...
{ "domain": "codereview.stackexchange", "id": 33841, "lm_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++, library, template-meta-programming, c++17, variadic", "url": null }
javascript, beginner, html, css, dom .br-3 { border-radius: 8px } .br-4 { border-radius: 12px } .br-5 { border-radius: 20px } .tg-up:after { margin-left: -15px 0 0 -50px; border-left: 15px solid transparent; border-right: 15px solid transparent; border-bottom: 45px solid #999 } .r100, r100 a { color: #FFFFFF } .b100, .b100 a { background-color: #FFFFFF } .r101, r101 a { color: #F8F8FF } .b101, .b101 a { background-color: #F8F8FF } .r102, r102 a { color: #F7F7F7 } .b102, .b102 a { background-color: #F7F7F7 } .r103, r103 a { color: #F0F0F0 } .b103, .b103 a { background-color: #F0F0F0 } .r104, r104 a { color: #F2F2F2 } .b104, .b104 a { background-color: #F2F2F2 } .r105, r105 a { color: #EDEDED } .b105, .b105 a { background-color: #EDEDED } .r106, r106 a { color: #EBEBEB } .b106, .b106 a { background-color: #EBEBEB } .r107, r107 a { color: #E5E5E5 } .b107, .b107 a { background-color: #E5E5E5 } .r108, r108 a { color: #E3E3E3 } .b108, .b108 a { background-color: #E3E3E3 } .r109, r109 a { color: #E0E0E0 } .b109, .b109 a { background-color: #E0E0E0 }
{ "domain": "codereview.stackexchange", "id": 33871, "lm_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, dom", "url": null }
It follows that $$\operatorname{span}\{(x_4,x_5,y)^T: y\in[-1,1]\}$$ must lie inside the column space of $$S$$. In particular, both $$(x_4,x_5,0)^T$$ and $$(0,0,1)^T$$ lie inside the column space of $$S$$. Therefore the augmented matrix $$A=\begin{bmatrix} x_1 & x_2 & x_3 & x_4 & 0\\ x_2 & x_3 & x_4 & x_5 & 0\\ x_3 & x_4 & x_5 & 0 & 1 \end{bmatrix}$$ has rank $$2$$. By elementary column operations, we can reduce $$A$$ to $$B=\begin{bmatrix} x_1 & x_2 & x_3 & x_4 & 0\\ x_2 & x_3 & x_4 & x_5 & 0\\ 0 & 0 & 0 & 0 & 1 \end{bmatrix}.$$ Hence $$\operatorname{rank}(B)=2$$ too and the first two rows of $$B$$ must be linearly dependent. It follows that the last two rows of $$H_0$$ are also linearly dependent. Now we arrive at a contradiction because $$H_0$$ has full row rank. Thus we conclude that $$H_1$$ must have full row rank for some $$y\in[-1,1]$$. • As always, you make it look easy – Ben Grossmann Nov 12 '20 at 20:17 • Smart trick! Thank you for the reply. It's easier in this way to extend it to $\mathbb{R}^n$ – Betelgeuse Nov 13 '20 at 9:55
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9759464485047916, "lm_q1q2_score": 0.8024125704363921, "lm_q2_score": 0.8221891392358015, "openwebmath_perplexity": 46.36903564344159, "openwebmath_score": 0.9857550263404846, "tags": null, "url": "https://math.stackexchange.com/questions/3904578/rank-preservation-of-hankel-matrix-by-adding-constrained-sample" }
javascript, beginner, game <body> <canvas id="game-canvas" height="600px" width="800px" </canvas> <script type="text/javascript"> var canvas = document.getElementById("game-canvas"), ctx = canvas.getContext("2d"), ballR = 10, x = canvas.width / 2, y = canvas.height - 30, dx = 3, dy = -3, pongH = 15, pongW = 80, pongX = (canvas.width - pongW) / 2, rightKey = false, leftKey = false, brickRows = 3, brickCol = 9, brickW = 75, brickH = 20, brickPadding = 10, brickOffsetTop = 30, brickOffsetLeft = 30; var bricks = []; for (c = 0; c < brickCol; c++) { for (r = 0; r < brickRows; r++) { bricks.push({ x: (c * (brickW + brickPadding)) + brickOffsetLeft, y: (r * (brickH + brickPadding)) + brickOffsetTop, status: 1 }); } } // function to draw the ball function drawBall() { ctx.beginPath(); ctx.arc(x, y, ballR, 0, Math.PI * 2); ctx.fillStyle = "red"; ctx.fill(); ctx.closePath(); } // function draw the pong function drawPong() { ctx.beginPath(); ctx.rect(pongX, canvas.height - pongH, pongW, pongH); ctx.fillStyle = "blue"; ctx.fill(); ctx.closePath(); }
{ "domain": "codereview.stackexchange", "id": 16582, "lm_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, game", "url": null }
- Nice! In imitation of the book "Proofs that Really Count", which is an attractive introduction to bijective proofs, I had thought of posting a question about Mean Proofs. This would ask for examples of results not in probability theory that can be proved by using the mean. This (along with I think a few others of your posts) is a contribution to the mean proofs collection. –  André Nicolas Jul 12 '11 at 0:51 @user6312: Thanks. Hopefully, I'll make more contributions of this kind. –  Shai Covo Jul 12 '11 at 1:15
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9915543728093005, "lm_q1q2_score": 0.8700659520203267, "lm_q2_score": 0.877476793890012, "openwebmath_perplexity": 172.77641867966733, "openwebmath_score": 0.9906359910964966, "tags": null, "url": "http://math.stackexchange.com/questions/50919/calculate-the-sum-of-the-infinite-series-sum-n-0-infty-fracn4n" }
general-relativity, black-holes, time-dilation, observers, event-horizon Title: Does an object falling into a black hole appear to become flat for an outside observer? In special relativity when an object moves close to the speed of light it will appear redshifted due to time dilation. In addition the object will also appear to be length contracted. But what about an object that will experience a gravitational time dilation, e.g. an object falling into a black hole? It will appear redshifted for a outside observer. But will it's length also appear to be contracted? If so wouldn't that mean, that an object falling into a black hole would basically appear to become flat (two-dimensional) at the Schwarzschild horizon (for an outside observer at infinity)? to an outside observer, the object falling into the black hole is progressively foreshortened into a pancake, any light coming from it becomes redder and dimmer, and the hands on a clock attached to it appear to go slower and slower as it gets closer and closer to the event horizon.
{ "domain": "physics.stackexchange", "id": 50962, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "general-relativity, black-holes, time-dilation, observers, event-horizon", "url": null }
If $a = d = 0$, then (1) gives us: . $bc \,=\,1\quad\Rightarrow\quad c \,=\,\frac{1}{b}$ . . More solutions: . $\begin{bmatrix}0 & b \\ \frac{1}{b} & 0\end{bmatrix}$ . . . . for $b \neq 0$ . obviously. More solutions are $\begin{bmatrix}\text{-1} &0 \\0&1\end{bmatrix}$ and $\begin{bmatrix}1 & 0\\0&\text{-}1\end{bmatrix}$ and $\begin{bmatrix}a & b \\ \frac{1-a^2}{b} & \text{-}a\end{bmatrix}$ and $\begin{bmatrix}a & \frac{1-a^2}{b} \\ b & \text{-}a\end{bmatrix}$ for $b \neq 0.$
{ "domain": "mathhelpforum.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9867771759145342, "lm_q1q2_score": 0.8179778900262633, "lm_q2_score": 0.8289388019824946, "openwebmath_perplexity": 509.7424156128278, "openwebmath_score": 0.9748798608779907, "tags": null, "url": "http://mathhelpforum.com/advanced-algebra/18497-list-two-different-matrices-s-t-2-i.html" }
Check your derivation by graphing it along with the graph of $y=\dfrac{f(x+0.001)-f(x)}{0.001}$. 11. The diagram below shows a kite 100 ft above the ground moves horizontally away from you at a rate of 8 feet per second. The kite’s height does not change, but the angle made by the ground and the kite string changes as the kite moves away from you. 1. Define a function that gives the rate of change of the string’s angle with the ground at every moment in time. Check your definition by graphing it along with the graph of your function’s approximate rate function. 2. At what rate is the angle between the string and the ground changing when 150 feet of the string has been let out? 12. The animation below shows the hands of a large clock rotating rapidly. The hour hand is 1.5 meters long; the minute hand is 4 meters long. Define a function whose values give the rate at which the distance between the tips of the hour and minute hands changes with respect to the measure of the angle between them. ## 6.3.10 Rate Functions for Exponential and Log Functions In this section we will first review the ideas of exponential and logarithmic functions and then derive rate of change functions for them in closed form. ### Exponential Functions Paal Payasam is an Indian dish made of milk and rice. The  Legend of Paal Payasam illustrates the immensity of exponential growth. The legend is that Lord Krishna played a game of chess against King Rhada for this bet: If Krishna won, the King must give him 1 grain of rice on the board’s first square, 2 grains on the second, 4 grains on the third, and $2^{n-1}$ grains on the $n^{th}$ square, up to $n=64$. Krishna won the game, and King Rhada quickly understood the foolishness of his bet. He foresaw having to put 4.29 billion grains of rice on the $33^{rd}$ square and 9.22 billion billion grains on the $64_{th}$ square--a number of grains of rice that would cover all of India.
{ "domain": "patthompson.net", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9899864276041908, "lm_q1q2_score": 0.822820336777314, "lm_q2_score": 0.8311430478583168, "openwebmath_perplexity": 486.6490195661937, "openwebmath_score": 0.9101719856262207, "tags": null, "url": "http://patthompson.net/ThompsonCalc/section_6_3.html" }
gazebo, sdf, ignition-fortress, stl SOLVED: I made a mistake in my IGN_GAZEBO_RESOURCE_PATH. Here is my correct one: export IGN_GAZEBO_RESOURCE_PATH="$HOME/uchi/hexapod_ws/" If you think your path is correct, make sure to source your workspace before running About your first problem: I think you just have to delete model:// to be able to find your stl file: <mesh> <scale>1 1 1</scale> <uri>hexapod_description/mesh/link1.STL</uri> </mesh> About your second problem with the invisibility: Are your sure your model is invisible? Maybe it's a scaling problem and your imported model is just very small or very large. I faced the same problem while converting some meshes and it turned out there was a problem between US and EU decimal sepearation, so that my model was scaled up about 1000x and I had to zoom out very far to see it.
{ "domain": "robotics.stackexchange", "id": 39047, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "gazebo, sdf, ignition-fortress, stl", "url": null }
python, proteins, sequence-analysis, motifs, multi-fasta It yields the following output below, which I am happy with but now it doesn't give me the total number of sequences: Ref 73 79 PFLPGK Ref 281 287 PLPPKL Ref 288 294 PSSPAH Sequence3 73 79 PFLPGK Sequence3 281 287 PLPPKL Sequence3 288 294 PSSPAH total sequences 0 frequency Counter({'73_79_PFLPGK': 2, '281_287_PLPPKL': 2, '288_294_PSSPAH': 2}) The total sequences should be 5. I used the code below to find out. I do not know where I went wrong since it is not giving me that on the more compact code above. sequence = open('Sequences2.fasta') x = 0 for line in sequence: if line.startswith('>'): x += 1 sequence.close() print(x) The second part of my question is how do I modify my code such that, the matches and frequencies of the reference sequence(Ref) are excluded. The idea would be to get an output such as the one below. I do not even know whether that is possible (A disclaimer this second part is a question on a tutorial that I don't know how to do. I am still learning) Sequence3 73 79 PFLPGK Sequence3 281 287 PLPPKL Sequence3 288 294 PSSPAH total sequences 5 #this would be the total number of sequences in file including the refrence frequency Counter({'73_79_PFLPGK': 1, '281_287_PLPPKL': 1, '288_294_PSSPAH': 1}) #frequency of matches, excluding the reference The first part appears to be a simple bug if there is no copy/paste error in the code: Original code, num_sequence=0 fasta_sequences = SeqIO.parse(open(input_file),'fasta') for fasta in fasta_sequences: num_sequence=+1 # < its here print (num_sequence)
{ "domain": "bioinformatics.stackexchange", "id": 2356, "lm_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, proteins, sequence-analysis, motifs, multi-fasta", "url": null }
python, beginner, performance, sudoku, depth-first-search return rows, columns, groups, untaken CPython doesn't deduplicate repeated constants like PyPy does, so one should deduplicate it manually. We should also move to using zip instead of enumerate: @timeit def create_cells(puzzle): rows = [0] * 9 columns = [0] * 9 groups = [0] * 9 untaken = [] for position, value in zip(INDEX_TO_VALUE, puzzle): if value: row, column, group = position bit = 1<<(value-1) rows[row] |= bit columns[column] |= bit groups[group] |= bit else: untaken.append(position) return rows, columns, groups, untaken CPython is noticably faster: $ python3 p.py Total: 5.9 seconds $ python2 p.py Total: 4.1 seconds CPython is now as fast as PyPy was at the start! I didn't get times for PyPy. It's even a bit faster if we carry the change through; make all operations act on shifted bits and unshift them at the end; eg. bit_counts = tuple(bin(i).count("1") for i in range(512)) @timeit def get_next_moves(puzzle): rows, columns, groups, untaken = create_cells(puzzle) other_option = None len_option = 9 for row, column, group in untaken: missing_values = 0b111111111 & ~rows[row] & ~columns[column] & ~groups[group] set_bits = bit_counts[missing_values] if set_bits == 1: return 9*row+column, missing_values elif set_bits < len_option: len_option = set_bits other_option = 9*row+column, missing_values return other_option and similar for the rest of the code. $ pypy3 p.py Min: 0.11042 seconds $ pypy p.py Min: 0.13626 seconds $ python3 p.py Min: 1.70156 seconds $ python2 p.py Min: 1.24454 seconds
{ "domain": "codereview.stackexchange", "id": 11342, "lm_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, performance, sudoku, depth-first-search", "url": null }
javascript, regex, unicode {'base':'dz','letters':'\u01F3\u01C6'}, {'base':'e', 'letters':'\u0065\u24D4\uFF45\u00E8\u00E9\u00EA\u1EC1\u1EBF\u1EC5\u1EC3\u1EBD\u0113\u1E15\u1E17\u0115\u0117\u00EB\u1EBB\u011B\u0205\u0207\u1EB9\u1EC7\u0229\u1E1D\u0119\u1E19\u1E1B\u0247\u025B\u01DD'}, {'base':'f', 'letters':'\u0066\u24D5\uFF46\u1E1F\u0192\uA77C'}, {'base':'g', 'letters':'\u0067\u24D6\uFF47\u01F5\u011D\u1E21\u011F\u0121\u01E7\u0123\u01E5\u0260\uA7A1\u1D79\uA77F'}, {'base':'h', 'letters':'\u0068\u24D7\uFF48\u0125\u1E23\u1E27\u021F\u1E25\u1E29\u1E2B\u1E96\u0127\u2C68\u2C76\u0265'}, {'base':'hv','letters':'\u0195'},
{ "domain": "codereview.stackexchange", "id": 18293, "lm_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, regex, unicode", "url": null }
c#, strings, programming-challenge IndexOf Returning 0 if pattern is an empty string leads to inconsistent results: IndexOf(text.Substring(1), "") returns 0, so you'd expect the result of IndexOf(text, "") to include 1, but that's not the case. I would throw an exception instead. IndexOf is public, but it doesn't check whether it's arguments are valid. I'd expect an ArgumentNullException if either text or pattern is null. I would rename this method to IndexesOf. It's more accurate, and it allows you to make it an extension method without name-clashes. The if (goodSuffixCheck == 0) check is only useful if the previous check succeeded, so this should be moved into the above if body. This happens inside a loop after all. The name matched sounds like a boolean - matchLength is a more descriptive name. In the bad-character shift lookup, use TryGetValue instead of ContainsKey, so you only need a single lookup. The comment // In case the bad character does exist in the pattern // We find the right most occurence of it and align them is not correct - you don't want the right-most occurrence, but the first occurrence to the left of the current position. if (goodSuffixShifts[matchLength] == 0) { goodSuffixShift = pattern.Length; } - why not store the pattern length in this shift table during pre-processing? While it's useful to see a description of a complicated algorithm, inserting such large comments in-between the code makes it more difficult to get an overview of the code itself, because it's so fragmented. I would prefer fewer and much more succinct in-line comments, and - if necessary - a more extensive explanation elsewhere (such as at the top of the file). BuildBadCharacterShifts
{ "domain": "codereview.stackexchange", "id": 33084, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "c#, strings, programming-challenge", "url": null }
beginner, c, integer printf("Enter a number: "); while (!readline(str, sizeof str)) { printf("Try again...\n"); } char* err = str_to_long(str, &cnvt_numb); if (err) { fprintf(stderr, "That number '%s' was not convertible...\n", str); return EXIT_FAILURE; } else if (errno == ERANGE) { fprintf(stderr, "INPUT OUT OF RANGE...\n"); return EXIT_FAILURE; } else { printf("Your number was: %ld\n", cnvt_numb); return EXIT_SUCCESS; } } It accepts input from -9223372036854775808 to 9223372036854775807 (on this system, where long is 64 bits), and correctly reports a range error for -9223372036854775809 and for 9223372036854775808. 12345aoeu is rejected with That number '12345aoeu' was not convertible...
{ "domain": "codereview.stackexchange", "id": 22315, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "beginner, c, integer", "url": null }
## SEEMOUS 2018 – Problems Problem 1. Let ${f:[0,1] \rightarrow (0,1)}$ be a Riemann integrable function. Show that $\displaystyle \frac{\displaystyle 2\int_0^1 xf^2(x) dx }{\displaystyle \int_0^1 (f^2(x)+1)dx }< \frac{\displaystyle \int_0^1 f^2(x) dx}{\displaystyle \int_0^1 f(x)dx}.$ Problem 2. Let ${m,n,p,q \geq 1}$ and let the matrices ${A \in \mathcal M_{m,n}(\Bbb{R})}$, ${B \in \mathcal M_{n,p}(\Bbb{R})}$, ${C \in \mathcal M_{p,q}(\Bbb{R})}$, ${D \in \mathcal M_{q,m}(\Bbb{R})}$ be such that $\displaystyle A^t = BCD,\ B^t = CDA,\ C^t = DAB,\ D^t = ABC.$ Prove that ${(ABCD)^2 = ABCD}$. Problem 3. Let ${A,B \in \mathcal M_{2018}(\Bbb{R})}$ such that ${AB = BA}$ and ${A^{2018} = B^{2018} = I}$, where ${I}$ is the identity matrix. Prove that if ${\text{tr}(AB) = 2018}$ then ${\text{tr}(A) = \text{tr}(B)}$. Problem 4. (a) Let ${f: \Bbb{R} \rightarrow \Bbb{R}}$ be a polynomial function. Prove that
{ "domain": "wordpress.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9921841100551559, "lm_q1q2_score": 0.806514029594715, "lm_q2_score": 0.8128673110375457, "openwebmath_perplexity": 814.9972035398341, "openwebmath_score": 0.9984534382820129, "tags": null, "url": "https://mathproblems123.wordpress.com/" }
mathematical-physics, mathematics, vector-fields I think (hope) I have proved (here) to myself the validity of such a decomposition for $\boldsymbol{F}\in C^2(\mathbb{R}^3)$ compactly supported. Are such assumptions consistent with the physical applications of the theorem? I suspect that $\boldsymbol{F}$ usually is reasonably supposed to be null outside a bounded domain in application of the decomposition to physics, but I would be very grateful to anybody giving a knowledgeable answer on the issue. In continuum mechanics, you can apply the theorem derived for compact support field to velocity of finite-sized body like raindrop. All realistic models involve finite-sized fluid bodies, so the assumption about compact support is valid there. In electromagnetic theory, fields generally extend to infinity and do not have compact support. Static fields decay as $1/r^2$, but generally fields decay as slow as $1/r$ if accelerated charged particles were present for the infinite past time. So to apply the decomposition to such fields confidently, one should be able to give an explanation that does not depend on the field having compact support, or limit oneself to fields that are finite only in a limited region of space and then drop to zero (which is not very realistic but may work in some practical calculations).
{ "domain": "physics.stackexchange", "id": 29225, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "mathematical-physics, mathematics, vector-fields", "url": null }
quantum-chemistry, molecular-orbital-theory, orbitals Two signals or functions with the same magnitude are said to be perfectly/exactly 'out of phase' if there phases differ by $\pi$ as $e^{i \pi}=-1, and perfectly 'in phase' if they have the same phase. Orbitals Now we can apply this to some orbitals. Consider a cross-section of the 2p$_{\text{x}}$ orbital in the $x$-$y$ plane through $z=0$: $$\psi_{2px}(x,y,z) = r(x,y,z) e^{i \phi(x,y,z)} \propto x \exp\left(-\sqrt{x^2+y^2+z^2}\right)$$
{ "domain": "chemistry.stackexchange", "id": 9123, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "quantum-chemistry, molecular-orbital-theory, orbitals", "url": null }
python, programming-challenge, comparative-review Title: Codility Frog Jump solutions Problem details from Codility: A small frog wants to get to the other side of the road. The frog is currently located at position X and wants to get to a position greater than or equal to Y. The small frog always jumps a fixed distance, D. Count the minimal number of jumps that the small frog must perform to reach its target. Write a function: def solution(X, Y, D) that, given three integers X, Y and D, returns the minimal number of jumps from position X to a position equal to or greater than Y. Method 1: def solution(X, Y, D): if (X == Y): jumps = 0 elif Y-X % D == 0: jumps = (Y-X)/D else: jumps = ((Y-X)/D) + 1 return jumps Method 2: def solution(X, Y, D): d = Y-X jumps=d/D rem=d%D if rem != 0: jumps+=1 return jumps I submitted the Method1 solution and received a 55% score. On the other hand, Method2 got 100%. It's not clear to me why Method2 is better than Method1. Could someone please explain? Method 1 sometimes gives wrong solution because it has a bug: def solution(X, Y, D): if (X == Y): jumps = 0 elif Y-X % D == 0: jumps = (Y-X)/D else: jumps = ((Y-X)/D) + 1 return jumps In the elif there, Y-X should have been within brackets, because % has higher precedence than - operator. In other words, Y - X % D is not the same as (Y - X) % D. Other than that, they are practically equivalent. I would clean up the formatting and remove some obvious temporary variables, like this: def solution(X, Y, D): jumps = (Y - X) / D if (Y - X) % D > 0: return jumps + 1 return jumps In particular, in the if instead of incrementing with jumps += 1, I return the value immediately, because I prefer to avoid mutating variables in general.
{ "domain": "codereview.stackexchange", "id": 11043, "lm_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, programming-challenge, comparative-review", "url": null }
One can check that the `kernel' $k(u,v)=uv/(u^2+v^2)$ is positive semidefinite. For instance by noting that $$\tag{1}k(u,v)=\int_0^\infty (ue^{-u^2x})(ve^{-v^2x})\,dx.$$ See this wikipedia article for basic facts about these functions. The desired inequality is a direct consequence of this: your expectation, $\mathbb Ek(X_1,X_2)$ is one of the quadratic expressions guaranteed to be non-negative by the PSD property of $k$, or is approximated by such expressions. In greater detail: Since the finitely supported probability measures are dense in the space of all probability measures on $\mathbb R$, in the weak topology, there exists a sequence of finitely supported probability measures $P_n$ converging weakly to the probability distribution of $X_1$. Since $k$ is continuous and bounded, we have $$\mathbb E k(X_1,X_2) = \lim_n \iint k(u,v) P_n(du) P_n(dv).$$ Assume $P_n$ assigns measure $p_i$ to $u_i$, for finitely many values of $i$ (I'm suppressing the notation for the dependence on $n$ here), so $P_n = \sum_i p_i \delta_{u_i}$. Then $\iint k(u,v) P_n(du) P_n(dv)=\sum_{i,j} p_i p_j k(u_i,u_j);$ this latter quantity is known to the non-negative by the positive definiteness of $k$. So $\mathbb E k(X_1,X_2)$ is the limit of non-negative quantities, so is also non-negative.
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9773708019443872, "lm_q1q2_score": 0.8420422837079963, "lm_q2_score": 0.86153820232079, "openwebmath_perplexity": 170.55235172009685, "openwebmath_score": 0.9352712035179138, "tags": null, "url": "https://math.stackexchange.com/questions/2893246/minimum-value-of-the-expectation-mathbbe-x-1-x-2-x-12-x-22" }
# Recurrence relation to find ternary strings that do not contains 3 consecutives 0's I'm stuck and I can't find this recurrence relation which is : Find a recurrence relation that count the number of ternary strings $(0,1,2)$ of length n that do not contains three consecutives 0's. I can easily find the recurrence relation for ternary strings that contains two consecutives zeros which is : $$a(n)=2\cdot a(n−1)+2\cdot a(n−2)+3^n−2$$ but I can't find a way to count it for three $0$'s. If someone could give me advice, it would be appreciated. Thanks. • – Yanior Weg Sep 16 '19 at 10:56 In this case I think that a complete solution illustrating a possible approach may be best. Say that a ternary string is good if it does not have three consecutive zeros and bad otherwise. Let $a_n$ be the number of good strings of length $n$ and $b_n$ the number of bad strings of length $n$; clearly $a_n+b_n=3^n$. (Of course this means that there’s no real need to have both $a_n$ and $b_n$, but it’s often easier to think about what’s going on if you give distinct names to things that are likely to be important. You can always get rid of the extras at the end.)
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9820137874059599, "lm_q1q2_score": 0.8118423736995107, "lm_q2_score": 0.8267117876664789, "openwebmath_perplexity": 52.777016814321314, "openwebmath_score": 0.7249417304992676, "tags": null, "url": "https://math.stackexchange.com/questions/1050496/recurrence-relation-to-find-ternary-strings-that-do-not-contains-3-consecutives" }
The central definition in studying modular arithmetic systems establishes a relationship between pairs of numbers with respect to a special number m called the modulus: Definition 25. , a cyclic group.[8]. {\displaystyle n\mathbb {Z} } n Flip to back Flip to front. An odd number is “1 mod 2” (has remainder 1).Why’s this cool? These problems might be NP-intermediate. Topics relating to the group theory behind modular arithmetic: Other important theorems relating to modular arithmetic: This page was last edited on 13 January 2021, at 23:34. The modulo operation (abbreviated “mod”, or “%” in many programming languages) is the remainder when dividing. Algebra Pre-Calculus Geometry Trigonometry Calculus Advanced Algebra Discrete Math Differential Geometry Differential Equations Number Theory Statistics & Probability Business Math Challenge Problems Math Software. F of integers). The set of all congruence classes of the integers for a modulus n is called the ring of integers modulo n,[6] and is denoted Likewise, International Bank Account Numbers (IBANs), for example, make use of modulo 97 arithmetic to spot user input errors in bank account numbers. A network viewpoint emphasizes that the behavior of a complex system is shaped by the interactions among its constituents (Newman, 2003) and offers the possibility to analyze systems of a very different nature within a unifying mathematical framework. We define addition, subtraction, and multiplication on {\displaystyle x,y} ( Home. We use the notation , which fails to be a field because it has zero-divisors. Some operations, like finding a discrete logarithm or a quadratic congruence appear to be as hard as integer factorization and thus are a starting point for cryptographic algorithms and encryption. Menu. ( The formula is based on counting points over finite fields on curves of genus three which are cyclic triple covers of the projective line. Forums Login. Z {\displaystyle \mathbb {Z} /n\mathbb {Z} } It is used by the most efficient implementations of polynomial greatest common divisor, exact linear algebra and Gröbner basis algorithms over the integers and the rational numbers. However, the following is true: For cancellation of common terms, we have the following rules: The modular multiplicative inverse is defined by the following rules: The multiplicative inverse x ≡
{ "domain": "mongegant.cat", "id": null, "lm_label": "1. YES\n2. YES\n\n", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.97364464868338, "lm_q1q2_score": 0.8216539563861993, "lm_q2_score": 0.8438951084436077, "openwebmath_perplexity": 1108.5842234850033, "openwebmath_score": 0.75057053565979, "tags": null, "url": "http://mongegant.cat/7zlvvxkk/jnclacc.php?id=modular-systems-math-d23313" }
quantum-mechanics, fourier-transform, tight-binding Title: Is one-body tight-binding Hamiltonian always diagonal in Fourier space? A generic tight-binding Hamiltonian for one-body operators is (assume one state per site) $$ H=\sum_{ij}C_i^\dagger t_{ij} C_j \quad; \quad t_{ij}=\int d\mathbf{r} \phi_i^*(\mathbf{r}) t(\mathbf{r})\phi_j(\mathbf{r}) $$ here $\phi_i(\mathbf{r})$ is the only atomic orbit at site $i$, and $t(\mathbf{r})$ is operator density. In general, $t(\mathbf{r})$ can be any one-body operator, i.e., for kinetic energy $t(\mathbf{r})=-\frac{\hbar^2\nabla^2}{2m}$ and for external potential or impurity potential $t(\mathbf{r})=V(\mathbf{r})$. In Fourier space $H$ becomes: $$ H=\frac{1}{N}\sum_{\mathbf{k,k'}}\sum_{ij} C_\mathbf{k}^\dagger t_{ij} e^{-i(\mathbf{k\cdot r_i-k'\cdot r_j})} C_\mathbf{k'} $$ If we open the summation over $j$, we always get diagonal Hamiltonian as I argue in the following: $$ H=\frac{1}{N} \sum_{\mathbf{k,k'}}\sum_{i}C_\mathbf{k}^\dagger \left( t_{ii}e^{-i(\mathbf{k\cdot r_i-k'\cdot r_i})}
{ "domain": "physics.stackexchange", "id": 92033, "lm_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, fourier-transform, tight-binding", "url": null }
the-moon, moon-phases, sidereal-period, synodic-period Title: Is it possible to explain the difference between synodic month and sidereal month by degrees? Is it possible to explain the difference between synodic and sidereal month by degrees - in the following way? Just recently I learnt about these two types of months, and I want to see if I can understand the difference by degrees method. Assuming the orbit's moon is 360 degrees, the sidereal month starts from the point where 1st degree to (include) 1st degree, while the synodic month starts from 1st degree to the 0.5 degree (after full orbit's moon, because the angular size of the moon is 0.5 degree). Is it possible to understand why it that's way? A better diagram is something like this: Day 0. The Moon is aligned with the Sun (New Moon) and some star X behind the Sun (of course :-), as shown by the arrow at 1. (Neither the Sun nor the star X are shown in the figure.) Day 27.32. One sidereal month after figure 1. The Moon has travelled through 360 degrees orbiting around the Earth. (During that time, an arrow from the Earth through the Moon is pointing at different stars.) After one sidereal month, the Moon is again aligned with star X, as shown by the solid arrow in figure 2. (The arrow in 1 and 2 are parallel because the star is very far away.) Because the Earth has moved in its orbit around the Sun, the position of the Sun (shown by the dashed arrow in figure 2) has changed relative to figure 1. The Moon is still a few days prior to New Moon. Day 29.53. One synodic month after figure 1. The Moon is again aligned with the Sun (New Moon), as shown by the solid arrow in figure 3. The direction to star X is shown by the dashed arrow which is parallel to the solid arrows in figures 1 and 2.
{ "domain": "astronomy.stackexchange", "id": 4391, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "the-moon, moon-phases, sidereal-period, synodic-period", "url": null }
Which will be the row  2 3 4 5 6 7 8 9 10 11 12 13 So...the 5000th digit will still   = 8 CPhill  Aug 13, 2018 #4 +22550 +1 John counts up from 1 to 13, and then immediately counts down again to 1, and then back up to 13, and so on, alternately counting up and down: What is the 5000th integer in his list? Variation 1: $$[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,][13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1] \ldots$$ $$\text{position = n \pmod{26} \qquad position 0 = position 26} \\ \text{5000th \pmod {26} = position 8}$$ Variation 2: $$[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,][ 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2 ] \ldots$$ $$\text{position = n \pmod{24} \qquad position 0 = position 24} \\ \text{5000th \pmod {24} = position 8}$$ Aug 14, 2018
{ "domain": "0calc.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9755769092358046, "lm_q1q2_score": 0.8129722310655372, "lm_q2_score": 0.8333245932423308, "openwebmath_perplexity": 2022.7801309944432, "openwebmath_score": 0.6390444040298462, "tags": null, "url": "https://web2.0calc.com/questions/math-help_130" }
\begin{array}{rrr} -\lambda & -1 & 1\\ 0 & 2-\lambda & 2-\lambda \\ 0 & 2\lambda-1 & 1-\lambda^2 \\ \end{array}\right|$$ $$=\left| \begin{array}{rrr} -\lambda & -1 & 1\\ 0 & 2-\lambda & 2-\lambda \\ 0 & 0 & -\lambda^2-2\lambda+2\\ \end{array}\right|$$ $$=\left| \begin{array}{rrr} 1 & \lambda^{-1} & -\lambda^{-1}\\ 0 & 2-\lambda & 2-\lambda \\ 0 & 0 & \lambda^2+2\lambda-2\\ \end{array}\right|$$ $$=(2-\lambda)(\lambda^2+2\lambda-2)$$ $$=(2-\lambda)\left(\lambda-\sqrt3+1\right)\left(\lambda+\sqrt3+1\right)$$ In any case, I suggest you look up the properties of the determinant.
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9830850892111574, "lm_q1q2_score": 0.8149173823292495, "lm_q2_score": 0.8289388083214156, "openwebmath_perplexity": 266.9401421652402, "openwebmath_score": 0.8694229125976562, "tags": null, "url": "https://math.stackexchange.com/questions/1509107/making-a-determinant-easier-to-solve-to-find-characteristic-polynomial" }
computability, real-numbers, computable-analysis Title: Decidable properties of computable reals Is "Rice's theorem for the computable reals" -- that is, no nontrivial property of the number represented by a given computable real is decidable -- true? Does this correspond in some direct way to the connectedness of the reals? Yes, Rice's theorem for reals holds in every reasonable version of computable reals. I will first prove a certain theorem and a corollary, and explain what it has to do with computability later. Theorem: Suppose $p : \mathbb{R} \to \{0,1\}$ is a map and $a, b \in \mathbb{R}$ two reals such that $p(a) = 0$ and $p(b) = 1$. Then there exists a Cauchy sequence $(x_i)_i$ such that $p(\lim_i x_i) \neq p(x_j)$ for all $j \in \mathbb{N}$. Proof. We construct a sequence of pairs of reals $(y_i, z_i)_i$ as follows: \begin{align*} (y_0, z_0) &= (a, b) \\ (y_{i+1}, z_{i+1}) &= \begin{cases} (y_i, (y_i + z_i)/2) & \text{if $p((y_i + z_i)/2) = 1$} \\ ((y_i + z_i)/2, z_i) & \text{if $p((y_i + z_i)/2) = 0$} \\ \end{cases} \end{align*} Observe that for all $i \in \mathbb{N}$:
{ "domain": "cs.stackexchange", "id": 9691, "lm_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, real-numbers, computable-analysis", "url": null }
____________________________________________________________________ The Notion of Shrinking The key to the proof is the notion of shrinkable open covers and shrinking spaces. Let $X$ be a space. Let $\mathcal{U}$ be an open cover of $X$. The open cover of $\mathcal{U}$ is said to be shrinkable if there is an open cover $\mathcal{V}=\left\{V(U): U \in \mathcal{U} \right\}$ of $X$ such that $\overline{V(U)} \subset U$ for each $U \in \mathcal{U}$. When this is the case, the open cover $\mathcal{V}$ is said to be a shrinking of $\mathcal{U}$. If an open cover is shrinkable, we also say that the open cover can be shrunk (or has a shrinking). Whenever an open cover has a shrinking, the shrinking is indexed by the open cover that is being shrunk. Thus if the original cover is indexed, e.g. $\left\{U_\alpha: \alpha<\kappa \right\}$, then a shrinking has the same indexing, e.g. $\left\{V_\alpha: \alpha<\kappa \right\}$. A space $X$ is a shrinking space if every open cover of $X$ is shrinkable. Every open cover of a paracompact space has a locally finite open refinement. With a little bit of rearranging, the locally finite open refinement can be made to be a shrinking (see Theorem 2 here). Thus every paracompact space is a shrinking space. For other spaces, the shrinking phenomenon is limited to certain types of open covers. In a normal space, every finite open cover has a shrinking, as stated in the following theorem. Theorem 1 The following conditions are equivalent.
{ "domain": "wordpress.com", "id": null, "lm_label": "1. YES\n2. YES\n\n", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9904406000885707, "lm_q1q2_score": 0.8317066168422892, "lm_q2_score": 0.8397339696776499, "openwebmath_perplexity": 638.3159881490476, "openwebmath_score": 1.000008463859558, "tags": null, "url": "https://dantopology.wordpress.com/category/normality-in-product/" }
transformer I was also confused about this, so I'll try to explain. Say we want to train on a sequence of tokens, i.e. s = [1, 13, 64, 40]. The next token to predict after 40 is 50. Now, instead of having one training sample, s, we can have several sequences from s, such as s1 = [1] (with target 13), s2 = [1, 13] (with target 64) etc., giving a total of 4 sequences. In total we have the following training data sample = [ [1], [1, 13], [1, 13, 64], [1, 13, 64, 40]] targets = [13, 64, 40, 50] As usual, Tensors do not like to have weird shapes. Therefore, the training data will look something like this sample = [ [1, -inf, -inf, -inf], [1, 13, -inf, -inf], [1, 13, 64, -inf], [1, 13, 64, 40]] In this new tensor, the -inf is the masking! Now you might say, "that's just sequence padding", and it is! The only reason that they call it masking instead of padding is because the architecture in the paper has an encoder (next to the decoder), in which the complete sequences are used without masking. However, when only using the decoder (as in LLMs), masking is essentially just padding.
{ "domain": "ai.stackexchange", "id": 3777, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "transformer", "url": null }
diagram. Ib,gross Gross moment of inertia of beam Ib Moment of inertia of a beam Ic Moment of inertia of a column Ic,eff Effective moment of inertia of a cracked RC column Ic,gross Gross moment of inertia of an un-cracked RC column Ig Gross moment of Inertia of an RC section K Initial lateral stiffness L Length of building D Depth of a frame member. 20 In generating thestiffness matrix for the 12 dofof Fig. Numerical problems on SFD(Shear force diagram) and BMD (Bending moment diagram) (Hindi) Strength of Materials (SOM)- (Mechanical and Civil ) 100 lessons • 23 h 17 m. 3 Summary of properties of moment and shear force diagrams 2 1. ForceMethod Page 4. Ref: 2: Meriam Example: Draw the shear and moment diagrams for the following frame: 0. If the concrete ’s shear capacity is smaller then the actual shear force: 3. This interaction is used to estimate the maximum shear and moment that is likely to be developed in the beam during extreme earthquake shaking. This is an example problem that will show you how to graphically draw a shear and moment diagram for a beam. First of all, the video points out the fact that wherever there is zero value at SFD, it always turns a max or min value of moment in BMD. Include all dimensions that indicate the location and direction of forces. You will understand the link between internal stresses and their shear force and bending moment resultants. Also performs service stress analysis for crack. Get more help from Chegg Get 1:1 help now from expert Civil Engineering tutors. 3-1 Simple beam 4 Shear Forces and Bending Moments 259 AB 800 lb 1600 lb 120 in. There are also examples and random beam generators which will allow you to experiment on how different loads affect beam analysis and the shear force and bending moment of a beam. The solution is shown in the next post. SFBM means Shear Force & Bending Moment. The Engineer would then apply the loads on the structure and de. CE 331, Fall 2007 Shear & Moment Diagrams Examples 2 / 7 2. Frame Analysis Example - Shear and Moment Diagram (Part 2) - Structural Analysis Shear and Moment Diagrams of a Frame with Angled Member Shear and Bending Moment Diagrams for Frames. It is envisaged by publishing the English version of “Design Recommendation for Storage Tanks and Their Supports” that the above
{ "domain": "versoteano.it", "id": null, "lm_label": "1. YES\n2. YES\n\n", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.975946444307138, "lm_q1q2_score": 0.8111510941039626, "lm_q2_score": 0.8311430394931456, "openwebmath_perplexity": 1067.4010244498343, "openwebmath_score": 0.6429223418235779, "tags": null, "url": "http://versoteano.it/shear-and-bending-moment-diagrams-for-frames-examples.html" }
homework-and-exercises, waves, acoustics, differentiation My method: Since $v= \sqrt{T/μ}.....(i)$,where T is tension and μ the linear density of the rope,$300=\sqrt{500/μ}$ $312 = \sqrt{T/μ}$Dividing and solving, we get T=540.8 and therefore 40.8N Extra Force Must be provided.BOOK METHOD: By differentiating both sides of velocity equation(i),:$ \frac{dv}{dT}=\frac{1}{\sqrt{μT}}$Dividing original equation(i) with differentiated one,we get,$\frac{dv}{v}=\frac{dT}{2T}$, dT= $(2T)\frac{dv}{v}$ Finally substituting the values $ T=500~, v= 300, ~dv=12$,we will get dT=40 N, which differs from the above answer by 2%. What is wrong with my method? Your method is completely fine and it is the one that should be used. Let me write it down once more $$ v = \sqrt\frac{{T}}{{\mu}}$$ $$ 300 = \sqrt\frac{500}{\mu}$$ $$ \mu = \frac{500}{90000}$$ $$\mu = \frac{5}{900}$$ No we want $v=312$ so let's just put it in the equation which you have stated $$ 312 = \sqrt\frac{900T}{5}$$ $$ \frac{312\times 312\times 5}{900}= T$$ $$T= 540.8$$
{ "domain": "physics.stackexchange", "id": 62520, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "homework-and-exercises, waves, acoustics, differentiation", "url": null }
javascript, jquery, stackexchange, userscript $(this).append("<a class='reminder'\ data-reminderid='" + reminderId + "'\ title='Remind me of this post'\ style=' padding-left:1px;'>\ <i class='fa fa-calendar-plus-o fa-2x' style='padding-top:5px;'></i>\ </a>\ <input type='text' class='datepicker' data-reminderid='" + reminderId + "' data-posttype='" + postType + "' style='display:none;'>") .on('click', '.vote a.reminder', function (e) { $(this).next().show().focus().hide(); }); }); $(".datepicker").datepicker({ minDate: 0, onSelect: function (dateText, inst) { // date selected, add new reminder and save changes. var postId = $(this).data("postid"), postUrl = $(this).closest("tr").find(".post-menu").find(".short-link").attr("href"), postType = $(this).data("posttype"), reminderId = $(this).data("reminderid"), reminderDate = new Date($(this).val()), calendar = $(this).prev(), rem = new Reminder(reminderId, postId, postUrl, title, postType, sitename, reminderDate.getTime()); Reminders.Add(rem); Reminders.Save(); }, beforeShow: function (input, instance) { instance.dpDiv.css({ marginTop: '-35px', marginLeft: '10px' }); } });
{ "domain": "codereview.stackexchange", "id": 17548, "lm_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, stackexchange, userscript", "url": null }
homework-and-exercises, electric-circuits, voltage Title: Voltage between two points in circuit Calculate the voltage between terminals a and b. I am confused about a problem. I've tried to solve this using the second Kirchoff's rule, but my solution is equal to 0. What am doing wrong? E=5V R1=600Ω R2=400Ω My calculations was: U=R*I I=5V/1000Ω=0,005A U=-R1*I+E-R2*I U=-600*0,005+5-400*0,005=-3+5-2=0[V] What is wrong? According to Kirchoff's voltage law, the sum of the potential drops and rises in a circuit is equal to zero. $E -iR_1-iR_2=0$ $U=E-iR_1$ $=iR_2$ where $U$ is the potential difference across resistor $R_2$. For an intuitive basis, think that the charge gets an energy $V$ when it passes through the battery, and it dissipates that when it goes through the resistors. By the end of the journey, it's energy is zero. That's what the rule kind of states.
{ "domain": "physics.stackexchange", "id": 55332, "lm_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, electric-circuits, voltage", "url": null }
plate-tectonics, mountains, tectonics Further north from there, the Dead Sea is a combined transform–rift zone where you have the same thing. Precambrian mountain ranges overlain by Cretaceous sediments (folded into mountain ranges) are being torn apart to form the Dead Sea depression.
{ "domain": "earthscience.stackexchange", "id": 1875, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "plate-tectonics, mountains, tectonics", "url": null }
ros-indigo Title: Ros stereo image proc with two USB Webcams I tried to follow the tutorial: http://wiki.ros.org/stereo_image_proc I am trying to connect two USB Webcams and do stereo image processing aand looking to obtain the point cloud by this tutorial. Each time I do rostopic list, it does NOT show me the following : /stereo/left/image_raw /stereo/left/camera_info /stereo/right/image_raw /stereo/right/camera_info I was wondering that whether it can be used with two webcams or not or is it not meant for that and only recognizes the stereo cameras. It would be great if anyone helps, I have been stuck on this for about few weeks. Originally posted by goelshivam1210 on ROS Answers with karma: 1 on 2016-06-08 Post score: 0 Maybe you should look at this package : http://wiki.ros.org/usb_cam It will allow you to have a camera topic in output. Originally posted by F.Brosseau with karma: 379 on 2016-06-09 This answer was ACCEPTED on the original site Post score: 0
{ "domain": "robotics.stackexchange", "id": 24871, "lm_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-indigo", "url": null }
dft, convolution \end{equation} Now we consider the $\ell^{\textrm{th}}$ entry of the IDFT of this entry-by-entry product: \begin{equation} \begin{split} \mathsf{IDFT}(XY)(\ell) ~=& \frac{1}{N}\sum_{k=0}^{N-1}X(k)Y(k)e^{2\pi i\ell k/N }\\ ~=& \frac{1}{N}\sum_{k=0}^{N-1}\left[\sum_{n=0}^{N-1}\sum_{m=0}^{N-1}x(n)y(m)e^{-2\pi i k(n+m)/N}\right]e^{2\pi i\ell k/N }\\ ~=& \frac{1}{N}\sum_{n=0}^{N-1}\sum_{m=0}^{N-1}x(n)y(m)\sum_{k=0}^{N-1}e^{-2\pi i k(n+m-\ell)/N} \end{split} \end{equation} The sum over $k$ is equal to 0 unless \begin{equation} n+m-\ell=0~\textrm{mod}~N~~~(m=\ell-n~\textrm{mod}~N), \end{equation} in which case it is equal to $N$: \begin{equation} \sum_{k=0}^{N-1}e^{-2\pi i k(n+m-\ell)/N} = N\delta_{m,\ell-n~\textrm{mod}~N}, \end{equation} where $\delta_{a,b}$ is the Kronecker delta. One intuitive way to see this is to see that
{ "domain": "dsp.stackexchange", "id": 8814, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "dft, convolution", "url": null }
$r=3\cos\theta$ ###### 26 $r=2\sin \theta$ ###### 27 $\theta=\dfrac{\pi}{4}$ ###### 28 $\theta=\dfrac{4\pi}{3}$ ###### 29 $r=4$ ###### 30 $r=2$ ###### 31 $r=2+2\sin \theta$ ###### 32 $r=3+3\cos\theta$ ###### 33 $r=2-\cos\theta$ ###### 34 $r=1-3\sin \theta$ ###### 35 $r=3\sin 2\theta$ ###### 36 $r=2\cos 3\theta$ ###### 37 $r=2\cos 5\theta$ ###### 38 $r=4\sin 4\theta$ ###### 39 $r=2+3\sin \theta$ ###### 40 $r=3+2\sin \theta$ ###### 41 $r^2=\cos 2\theta$ ###### 42 $r^2=4\sin2\theta$ For Problems 43–52, identify each curve, and graph it. ###### 43 $r\csc\theta = 2$ ###### 44 $r=2\sec \theta$ ###### 45 $r^2=4,~ 0 \le \theta \le \dfrac{3\pi}{4}$ ###### 46 $\theta = \dfrac{\pi}{4},~ \abs{r} \lt 2$ ###### 47 $r=\sin \theta,~ \dfrac{3\pi}{4} \le \theta \le \dfrac{5\pi}{4}$ ###### 48
{ "domain": "yoshiwarabooks.org", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9884918492405834, "lm_q1q2_score": 0.8127272583619356, "lm_q2_score": 0.822189134878876, "openwebmath_perplexity": 440.1261558904399, "openwebmath_score": 0.7893000841140747, "tags": null, "url": "https://yoshiwarabooks.org/trig/Polar-Graphs.html" }
In the following animation, the red arrow shows how the addition of the $\sin$-scaled vectors changes the curve. cardioid That shape is called a cardioid. It’s a well-known shape that arises in many contexts all over math. But wait – that doesn’t look anything like a flower. Let’s introduce an integer constant $b$. If we plot $\sin\left(bx\right)$ where $b=1,2,3,4$, we get this: wave frequency It multiplies the frequency of the wave by $b$. For example, if $b=3$, the wave will go through $3$ full periods on $0\leq x \leq 2\pi$ instead of just one. Using the same method as before, we can wrap this higher-frequency wave around a circle. Here’s the resulting equation: $$\left(1+\sin\left(bt\right)\right)\cdot \left(\cos\left(t\right),\sin\left(t\right)\right)$$ When plotted, it gives better results. If $b=2$: two petals If $b=3$: three petals If $b=4$: four petals And so on. The value of $b$ equals the number of petals that the flower has. In other words, you could call the cardioid a “one-petal flower”! If you add other circle to the parametric to push it further away from the origin and let $b=14$, you end up with a shape close to the first reference image: ## Other wave shapes As long as the wavy function that we wrap around the circle has a period length that is evenly divides into $2\pi$, the resulting parametric will start and end in the same place to create a closed flower. It doesn’t need to be $\sin\left(x\right)$. We can define the “general single-layer flower function” as $$\operatorname{W}\left(t\right)=\left(2+f\left(bt\right)\right)\cdot\left(\cos\left(t\right),\sin\left(t\right)\right)$$
{ "domain": "sambrunacini.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9814534365728416, "lm_q1q2_score": 0.8024112793144924, "lm_q2_score": 0.8175744761936437, "openwebmath_perplexity": 231.76318019611548, "openwebmath_score": 0.8073153495788574, "tags": null, "url": "http://sambrunacini.com/parametric-flowers/" }
# Is this SISO (single input single output) or MIMO (multiple instead of single) system? If I transform wave equation for vibrating string Mx′′+Cx′+Kx=b(t) in linear system using $x_1(t)=x(t)$ and $x_2(t)=x_1^{'}(t)$ vibrating string equation becomes $Md_tx_2(t)+Cx_2(t)+Kx_1(t)=b(t)$. That is: \begin{align} \frac{d}{dt}\left[ \begin{array}{c} x_1 \\ x_2 \\ \end{array} \right]&= \left[ \begin{array}{cc} 0 & 1 \\ -M^{-1}K& -M^{-1}C \\ \end{array} \right]\left[ \begin{array}{c} x_1 \\ x_2 \\ \end{array} \right]+\left[\begin{array}{c} 0 \\ M^{-1} \end{array}\right]b(t) \end{align} We think of $x(t)$ as the output, $b(t)$ as the input and define output equation as: $y=\left[\begin{array}{cc} 1&0 \end{array}\right]\left[\begin{array}{c} x_1 \\ x_2 \end{array}\right]$ So now, in the standard control theory notation of first equation: $x'=Ax+Bu$ $y=Cx$ We make the following identifications: $A= \left[ \begin{array}{cc} 0 & 1 \\ -M^{-1}K& -M^{-1}C \\ \end{array} \right],$ a $B=\left[\begin{array}{c} 0 \\ M^{-1} \end{array}\right]$
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9719924850731925, "lm_q1q2_score": 0.8035576470081852, "lm_q2_score": 0.8267117898012104, "openwebmath_perplexity": 439.9587898282924, "openwebmath_score": 0.9513809084892273, "tags": null, "url": "https://physics.stackexchange.com/questions/232568/is-this-siso-single-input-single-output-or-mimo-multiple-instead-of-single-s" }
# How many solutions for this equation? $$\frac{x-4}{(x-1)} = \frac{1-4}{(x-1)}$$ Can someone tell me how many solutions are there for the above equation? MY APPROACH: I cross multiplied the equations and re-arranged to get a quadratic eqaution which gave me $x=1$ repeated twice. So I answered the question by telling there are two solutions for this equations where one equals the other. TRAINER'S APPROACH: He cancelled out the denominators on both sides and he imposed a condition that $x \ne 1$ but still ended up with $x = 1$ after solving the remaining parts of the equation. Since the solution itself contradicts the condition imposed upon the cancellation, he told that the equation has no solutions. Which approach is right? And why the other one is wrong? - trainer's one is right. I could not give more explanations than the trainer. – user126154 Mar 17 '14 at 11:27 The problem should be interpreted as "find the extension of the set $\left\{x\in \mathbb R\colon \frac{x-4}{(x-1)} = \frac{1-4}{(x-1)}\right\}$". Certainly $1$ isn't in the set. In fact it is empty. Multiplicity of solutions has no bearing here. – Git Gud Mar 17 '14 at 11:29 Why is my solution wrong? – valyrian Mar 17 '14 at 11:29 @GitGud So the trainer's right? – valyrian Mar 17 '14 at 11:30 For $x=1$ you are multiplying both sides of your equation by $0$. – user127.0.0.1 Mar 17 '14 at 11:30 The trainer is right, there is no solution. Your approach of crossing the equations has an implicit demand that the denominators are nonzero, so your approach should show there are no solutions as well. -
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9615338035725358, "lm_q1q2_score": 0.8153496677141868, "lm_q2_score": 0.8479677622198946, "openwebmath_perplexity": 280.9568728151031, "openwebmath_score": 0.9221193194389343, "tags": null, "url": "http://math.stackexchange.com/questions/715358/how-many-solutions-for-this-equation/715369" }
• Best method indeed. – StubbornAtom Nov 27 '16 at 8:12 • Do you know if the constant difference has a name? – Frank Nov 27 '16 at 21:06 • No, I don’t know if a name other than the $k$-th (backward in this case, because it is the difference $f(x)-f(x-1)$ as opposed to the difference $f(x+1)-f(x)$) difference. – Steve Kass Nov 28 '16 at 3:47 • @SteveKass Either way, this has got to be the best method possible. – Frank Dec 2 '16 at 19:00 There is a conceptually simpler way: do some linear algebra and polynomial arithmetic. Instead of a complex linear system, solve $4$ much simpler linear systems. Namely, solve the following problems: find polynomials $p(x), q(x), r(x), s(x)$ such that: \begin{align} (a)\enspace&\begin{cases}p(3)=1\\p(4)=0\\p(5)=0\\p(6)=0\end{cases} &(b)\enspace&\begin{cases}q(3)=0\\q(4)=1\\q(5)=0\\q(6)=0\end{cases} &(c)\enspace&\begin{cases}r(3)=0\\r(4)=0\\r(5)=1\\r(6)=0\end{cases} &(d)\enspace&\begin{cases}s(3)=0\\s(4)=0\\s(5)=0\\s(6)=1\end{cases} \end{align} Then the solution is $$f(x)=2p(x)+4q(x)-3r(x)+8s(x).$$ Reminder:
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9871787834701878, "lm_q1q2_score": 0.8204867890679168, "lm_q2_score": 0.8311430541321951, "openwebmath_perplexity": 405.9740647523126, "openwebmath_score": 0.8398892283439636, "tags": null, "url": "https://math.stackexchange.com/questions/2032335/constructing-a-cubic-given-four-points" }
music, pitch NOTE 71 PITCH BEND 9065 ... PITCH BEND 10469 ... PITCH BEND 9065 You can think of the MIDI note number as the "integral" part of the pitch ; and the pitch bend as a redundant "fractional" part of the pitch.
{ "domain": "dsp.stackexchange", "id": 202, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "music, pitch", "url": null }
fluid-dynamics, pressure, air, bernoulli-equation Title: Static vs Dynamic pressure According to Bernoulli's law, the narrower the tube where the fluid is flowing the lower its static pressure and the higher its dynamic pressure. Does this make any difference? If the dynamic pressure increases when the static decreases, then nothing changes at all. So what happens then? If the pressure decreases in narrower tubes, why is the refrigerator's evaporator thicker than the condenser if we want it to be at lower pressure to absorb heat? If it increases in narrower tubes, how does the air in carburetors suck fuel if it was lower in pressure than the air? This is really three separate questions. Static and dynamic pressure: It is the static pressure that really matters in practical situations. The dynamic pressure is related to the kinetic energy of the fluid which, when it changes, causes a corresponding change in the static pressure. Condenser/evaporator application: The basic Bernoulli equation applies to situations in which viscous pressure decreases are negligible. In the compressor/evaporator application, there is a valve between the compressor and evaporator that features a very large viscous pressure drop. This pressure change is much larger than the static pressure change associated with the decrease in kinetic energy accompanying the increased diameter. So the viscous pressure decrease dominates. The larger diameter is necessary to accommodate the much higher coolant vapor volume after the valve. Carburator application: The narrower tube is accompanied by a decrease in air pressure in the throat of the carburetor. This lower pressure of the air provides the driving force for sucking in fuel.
{ "domain": "physics.stackexchange", "id": 31823, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "fluid-dynamics, pressure, air, bernoulli-equation", "url": null }
homework-and-exercises, newtonian-mechanics, newtonian-gravity, orbital-motion, celestial-mechanics $$=(r)(\alpha+v_ocos\theta-\alpha cos\theta)$$ From (1), $$r_ov_o\hat{k}=(r)(\alpha+(v_o-\alpha)cos\theta)$$ $$r=\frac{r_ov_o}{\alpha(1+(\frac{v_o-\alpha}{\alpha})cos\theta)}$$ $$Let ~\frac{r_0v_0}{\alpha}=h~~~and ~~~\frac{v_o-\alpha}{\alpha}=p$$ $$Then~~~r=\frac{h}{1+pcos\theta}$$ $$Substituting~~~cos\theta=\frac{x}{r},$$ $$r(1+p\frac{x}{r})=h$$ $$r+px=h$${\tiny } $$r^2=(h-px)^2$$ $$x^2+y^2=h^2+p^2x^2-2hpx$$ $$x^2(1-p^2)+2hpx+y^2=h^2$$ $$When~~~~~(1-p^2)\neq0,$$ $$x^2+\frac{y^2}{1-p^2} +\frac{2hpx}{1-p^2}=\frac{h^2}{1-p^2}$$ $$Adding ~~~\frac{h^2}{(1-p^2)^2} ~~~on ~both~ sides,$$
{ "domain": "physics.stackexchange", "id": 80345, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "homework-and-exercises, newtonian-mechanics, newtonian-gravity, orbital-motion, celestial-mechanics", "url": null }
c++ public: Maze(unsigned int width, unsigned int height); MazePosition at(unsigned int x, unsigned int y) const; private: bool succsesfullyConnectedToNeighbour(Coords& cellCoords); inline void connect(Coords& from, Coords& to, Direction dir); inline bool areCoordsValid(const Coords& coords) const; inline MazeCell& cellAt(const Coords& coords) const; }; void Maze::connect(Coords& from, Coords& to, Direction dir){ cellAt(from).connect(dir); cellAt(to).connect(!dir); } bool Maze::areCoordsValid(const Coords& coords) const { return coords.x >= 0 && coords.y >= 0 && coords.x < (int)width && coords.y < (int)height; } MazeCell& Maze::cellAt(const Coords& coords) const { if(!areCoordsValid(coords)){std::cout << "hit bad";} return cells[coords.x + coords.y*width]; } Maze::Maze(unsigned int width, unsigned int height) : width(width), height(height) { cells = new MazeCell[width*height]; Coords currentCellCoords{0,0}; std::stack<Coords> visitedCellsStack; visitedCellsStack.push(currentCellCoords);
{ "domain": "codereview.stackexchange", "id": 36613, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "c++", "url": null }
[1] (b) Express 2(3+ p 5) (3p 5) in the form b+c p 5, where b and c are integers. The probabilities that they will score a goal in the next match are 0.2 and 0.35 respectively. The player scores points as shown in the table above but they lose 20 points if they miss the board completely. The game costs £4 to play. There are only $$b$$ blue counters and $$y$$ yellow counters in a bag. He continues until he chooses a card with the letter M printed on it. (b) Given that the game is a fair game, find the value of $$x$$, the number of points awarded for hitting the B region of the board. Work out the probability that this book is also available in digital format. (f) Calculate the probability that Neal wears trainers given that he is not wearing a cap. The wording, diagrams and figures used in these questions have been changed from the originals so that students can have fresh, relevant problem solving practice even if they have previously worked through the related exam paper. The table shows the shoe sizes of 35 male teachers. (e) Hence, or otherwise, show that the events $$A$$ and $$B$$ are not independent. (h) Calculate the probability that Neal wears boots on one of the first two days, Corbett Maths offers outstanding, original exam style questions on any topic, as well as videos, past papers and 5-a-day. this is very strong sheet which can be help to improve learning capacity and this sheet is … (a) Work out the number of students in the school who buy lunch from the school canteen. Luka and Donna have an idea. The Corbettmaths Practice Questions on Relative Frequency. (d) Copy and complete the tree diagram below. Videos, worksheets, 5-a-day and much more The manager thinks that the probability that both players will score a goal in the next match is 0.2 + 0.35. Links to the Best Maths Websites in the World, AQA Level 2 Certificate in Further Mathematics, Probability - The probability of her taking 2 orange sweets is $$\frac13$$. There are 11 sweets in this jar. Probability Practice Test Question Answers (Sample Worksheet PDF) The situation that may or may not happen, have a chance of
{ "domain": "unknownfieldsdivision.com", "id": null, "lm_label": "1. YES\n2. YES\n\n", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9748211590308922, "lm_q1q2_score": 0.8080670878337975, "lm_q2_score": 0.828938806208442, "openwebmath_perplexity": 2023.4915167313359, "openwebmath_score": 0.42520537972450256, "tags": null, "url": "http://unknownfieldsdivision.com/the-honey-wduusk/rat-a-tat-tat-meme-58ab94" }
we can obtain when we use sigma notation. This means that we sum up the  ai  terms from  1,  up to  n. A sum in sigma notation looks something like this: X5 k=1 3k The Σ (sigma) indicates that a sum is being taken. A sum in sigma notation looks something like this: X5 k=1 3k The Σ (sigma) indicates that a sum is being taken. So the rule is: n! The Greek capital letter, ∑ , is used to represent the sum. 1) Rule one states that if you're summing a constant from i=1 to n, the sum is equal to the constant multiplied by n. This makes intuitive sense. This symbol is sigma, which is the capital letter “S” in the Greek alphabet. The Greek capital letter, ∑ , is used to represent the sum. Could also have: This notation also has some properties or rules that are handy to remember at certain times. Series are often represented in compact form, called sigma notation, using the Greek letter Σ (sigma) as means of indicating the summation involved. Sigma notation is most useful when the “term number” can be used in some way to calculate each term. No comments. In other words, you’re adding up a series of a values: a 1, a 2, a 3 …a x. i is the index of summation. Combination Formula, Combinations without Repetition. Solution: Solve your math problems using our free math solver with step-by-step solutions. . Source: VanReeel / … Our math solver supports basic math, pre-algebra, algebra, trigonometry, calculus and more. In the figure, six right rectangles approximate the area under. Rules for sigma notation Sigma notation is a very useful and compact notation for writing the sum of a given number of terms of a sequence. If you plug 1 into i, then 2, then 3, and so on up to 6 and do the math, you get the sum of the areas of the rectangles in the above figure. Math 132 Sigma Notation Stewart x4.1, Part 2 Notation for sums. We’ll start out with two integers, $$n$$ and $$m$$, with $$n < m$$ and a list of numbers denoted as follows, Executive in Residence and Director, Center for Quantitative Modeling. But instead, for any such sum, the
{ "domain": "insightcirclepublishing.com", "id": null, "lm_label": "1. YES\n2. YES\n\n", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9793540704659681, "lm_q1q2_score": 0.8006948846396146, "lm_q2_score": 0.8175744695262775, "openwebmath_perplexity": 599.1781939540679, "openwebmath_score": 0.9272029995918274, "tags": null, "url": "http://insightcirclepublishing.com/4kjh3y8/7e8a05-sigma-notation-rules" }
scikit-learn, decision-trees Title: Calculating feature importance with Scikit-Learn's Decision Tree Classifier I am attempting to determine the most useful bands of a multiband image classification (i.e. Red, Green, Blue, Near Infrared, etc. used for classifying pixels) and wrote the following function to build a decision tree. It uses sci-kit learn's Decision Tree Classifier with entropy as the split criterion. Finally, it uses the feature_importances_ function to calculate the importance of each band: def make_tree(X_train, y_train): """prints a decision tree and an array of the helpfulness of each band""" dtc = DecisionTreeClassifier(criterion='entropy') dtc.fit(X_train, y_train) tree.plot_tree(dtc) plt.show() importances = dtc.feature_importances_ large_to_small_idx = np.argsort(importances)[::-1] for idx in large_to_small_idx: print(f"Band {idx + 1}: {importances[idx]}\n") I assumed that since the splitting criterion on the decision tree was set to entropy that feature_importances_ would also be calculated as some form of entropy information gain. However, in sci-kit learn's documentation it mentions how the feature importance is actually calculated: The importance of a feature is computed as the (normalized) total reduction of the criterion brought by that feature. It is also known as the Gini importance.
{ "domain": "datascience.stackexchange", "id": 11739, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "scikit-learn, decision-trees", "url": null }
particle-physics, kinematics, mathematical-physics, lorentz-symmetry, phase-space In any case, if you wanted to hack around with hyperbolic geometry, given your total momentum $P=\tilde P$, distinctly non-null, you have $$ y=1-\frac{2P\cdot p_k}{P^2} =\frac{p_i\cdot p_j}{\tilde p_k\cdot \tilde p_{ij}} ~,\qquad 2P\cdot \tilde p_k = P^2 ,\\ \frac{1}{1-y}= \frac{P^2}{2P\cdot p_k}, \qquad \frac{y}{1-y}=\frac{P^2-2P\cdot p_k}{2P\cdot p_k} ~~. $$
{ "domain": "physics.stackexchange", "id": 53891, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "particle-physics, kinematics, mathematical-physics, lorentz-symmetry, phase-space", "url": null }
If the inputs to a componentwise operation in MATLAB® are symbolic matrix variables, so is the output. These operations are displayed in special notations which follow conventions from textbooks. ```syms A B [3 3] matrix A.*B``` `ans = $A\odot B$` `A./B` `ans = $A\oslash B$` `A.\B` `ans = $B\oslash A$` `A.*hilb(3)` ```ans =  ``` `A.^(2*ones(3))` `ans = ${A}^{\circ 2 {\mathrm{1}}_{3,3}}$` `A.^B` `ans = ${A}^{\circ B}$` `kron(A,B)` `ans = $A\otimes B$` `adjoint(A)` `ans = $\mathrm{adj}\left(A\right)$` `trace(A)` `ans = $\mathrm{Tr}\left(A\right)$`
{ "domain": "mathworks.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9820137900379083, "lm_q1q2_score": 0.8225543607752206, "lm_q2_score": 0.8376199694135332, "openwebmath_perplexity": 1075.1542436230848, "openwebmath_score": 0.7315763831138611, "tags": null, "url": "https://la.mathworks.com/help/symbolic/use-symbolic-matrix-variables.html" }
javascript, jquery For moving from group to group, it's a little different. However, provided you want the current functionality of always moving to the first slide in a group, you can do something like this: var currentSlide = $(".slide.current"), targetSlide = currentSlide.closest(".group").next(".group").find(".slide:first"); if(targetSlide.length === 0) { // no slides to move to! } else { currentSlide.removeClass("current"); targetSlide.addClass("current"); } (With your structure you can simply use .parent() instead of .closest(".group"), and .next() without a selector, but I'm being explicit/verbose to make things clearer. Included the pointless if-block for the same reason; you can obviously just do a !== comparison instead) You'll note that only one line differs between the two, so it's a prime candidate for being factored into a function - or functions, plural. To keep things fairly abstract, I'd refer to the slide changes as simply "next", "previous", "next group" and "previous group". Only when actually adding the event handlers would I link that to an up/down/left/right direction. Again, it's better, I find, to not tie yourself to a notion of how it looks; the groups might be stacked vertically, with the slides running horizontally, but it wouldn't matter to the code above, since it's more abstract. In your case, the visual layout does matter in terms of animation (up/down versus left/right), but like with the event handlers, try to make such distinctions "late" in the code if you can. As for finding a slide's position, you could do something like var currentSlide = $(".current.slide"), slideIndex = currentSlide.prevAll(".slide").length, groupIndex = currentSlide.closest(".group").prevAll(".group").length;
{ "domain": "codereview.stackexchange", "id": 5093, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "javascript, jquery", "url": null }
javascript, strings, regex break; case 'toUnderscoreCase': needle = needleToUnderscore; funct = toUnderscore; break; default: return ''; } return toChange.replace(needle, funct); } // --- Usage-examples and test-cases -------- var tests = [ { toChange: 'get_amount_of_taxes', toCase: '' }, { toChange: 'ThisIsTheSoCalledPascalCase', toCase: 'toCamelCase' }, { toChange: 'thisIsTheSoCalledCamelCase', toCase: 'toPascalCase' }, { toChange: 'set_sum_of_articles', toCase: 'toCamelCase' }, { toChange: 'getAmountOfTaxes', toCase: 'toUnderscoreCase' }, { toChange: 'XMLHttpRequest', toCase: 'toUnderscoreCase' }, { toChange: 'theXMLconnector1ForABC', toCase: 'toUnderscoreCase' }, { toChange: 'aB', toCase: 'toUnderscoreCase' }, { toChange: 'c', toCase: 'toUnderscoreCase' }, { toChange: [2, 3], toCase: 'toUnderscoreCase' }, { toChange: 'abc#123Spec', toCase: 'toUnderscoreCase' }, { toChange: 'abc_890-spec', toCase: 'toCamelCase' }, { toChange: 'get_amount_of_taxes', toCase: 'abc123' } ]; tests.forEach(function(test) { var result = changeCase(test.toChange, test.toCase); var log = console.log; var err = console.error;
{ "domain": "codereview.stackexchange", "id": 19608, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "javascript, strings, regex", "url": null }
mobile-robot, pid Do as you described and have one separate controller for each motor, tuned independently using a test fixture; Use a MIMO PID controller to simultaneously control the four motors; Use two PID controllers, one for linear speed, another for angular. The last option would take advantage of the fact that, according to the kinematic equations for a four-wheeled drive, the front and rear left wheels $W_{LF}$ and $W_{LR}$ can be combined into a single "virtual" wheel $W_L$ such that: $$ \omega W_L = \frac{\omega W_{LF} + \omega W_{LR}}{2} $$ Where $\omega W_L$, $\omega W_{LF}$ and $\omega W_{LR}$ are respectively the angular speeds of the virtual left, left front and left rear wheels. A virtual right wheel $W_R$ can be defined analogously. This reduces the system definition to a differential drive, for which linear and angular speeds can be computed as: $$ v = \frac{r (\omega W_L + \omega W_R)}{2} $$ $$ \omega = \frac{\omega W_R - \omega W_L}{2l} $$ Where $r$ is the wheel radius and $l$ the lateral distance between wheels. From the formulas above you get: $$ \omega W_L = \frac{v}{r} - \omega l $$ $$ \omega W_R = \frac{v}{r} + \omega l $$ Allowing you to use linear and angular speeds as references to control the virtual wheels.
{ "domain": "robotics.stackexchange", "id": 2129, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "mobile-robot, pid", "url": null }
- I edited for proper use of \langle and \rangle in TeX, i.e. where it said $<x,y>$, it now says $\langle x,y \rangle$. – Michael Hardy Sep 19 '11 at 13:42 Can you use Poincaré-Birkhoff-Witt theorem to reach the conclusion of your first question? The Lie algebra would be the span of $\{1,x,y\}$, but we need a method for identifying the generator $1$ with the multiplicative identity. Moding out a suitable ideal out of the universal enveloping algebra should do it? – Jyrki Lahtonen Sep 19 '11 at 14:39 I tidied up the question a bit, because I found it hard to read at first. Hope you don't mind. – George Lowther Sep 20 '11 at 0:05 @GeorgeLowther:Thank you very much for the editing work!By the way,can you tell me how to edit this?I am not very familiar with using Latex here.:) – user14242 Sep 20 '11 at 15:40 @user14242: You should see "edit" below your post, which you can click on and you can see the source. – George Lowther Sep 20 '11 at 19:41 One simple way to do this is to use Bergman's Diamond Lemma, and it works over any commutative ring $k$. If we order monomials in the free algebra $k\langle x,y\rangle$ first by degree and then lexicographically, for example, then the relation $$yx-xy-1$$ gives a 'rewriting rule' of the form $$yx \leadsto xy + 1.$$ It is immediate that there are no ambiguities (in the sense of Bergman) so that it follows at once that the classes of the monomials in $k\langle x,y\rangle$ which do not contain $yx$ as a subword form a basis of the quotient $A_1=k\langle x,y\rangle/(yx-xy-1)$. This is precisely what you want.
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9811668739644684, "lm_q1q2_score": 0.8176304861492899, "lm_q2_score": 0.8333245932423308, "openwebmath_perplexity": 171.51653024210665, "openwebmath_score": 0.9691827893257141, "tags": null, "url": "http://math.stackexchange.com/questions/65790/on-a-proof-of-the-basis-for-the-weyl-algebra" }
python, performance, python-3.x, primes for repeat in range(precision): a = random.randrange(2, n - 2) x = pow(a, d, n) if x == 1 or x == n - 1: continue for r in range(s - 1): x = pow(x, 2, n) if x == 1: return False if x == n - 1: break else: return False return True 3. Comparison I used pip install primefac
{ "domain": "codereview.stackexchange", "id": 20684, "lm_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, python-3.x, primes", "url": null }
python, performance, python-3.x, time-limit-exceeded inputVar = list(map(int, sys.stdin.readlines())) for i in inputVar: if i % k == 0: count += 1 print(count) I think that there must be something wrong with the way CodeChef runs Python, or with the way it reports the times. The time limit for the problem is 8 seconds, but your Python submissions are passing even though they take 55 seconds and so ought to be out of time even with the five times allowance given to Python programs. On my laptop, if I create about 80 megabytes of input: import random n, k = 10**7, 17 f = open('cr93327.data', 'w') f.write('{} {}\n', n, k) for _ in range(n): f.write('{}\n'.format(random.randrange(0, 10**7))) Then this C program runs in 3.3 seconds: #include <stdio.h> int main() { unsigned n, k, i, m, count = 0; scanf("%u %u", &n, &k); for (i = 0; i < n; i++) { scanf("%u", &m); count += (m % k == 0); } printf("%u\n", count); return 0; } And this Python 3 program runs in 6.1 seconds: import sys n, k = map(int, next(sys.stdin.buffer).split()) count = 0 for i in map(int, sys.stdin.buffer): if not i % k: count += 1 print(count) So Python is about twice as slow as C, not ten times as slow.
{ "domain": "codereview.stackexchange", "id": 14107, "lm_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, python-3.x, time-limit-exceeded", "url": null }
structural-engineering, structural-analysis, seismic Title: Accidental Torsion and Equivalent Static Load for an irregular structure Important note: I am writing a structural FEM software from scratch, so I won't able to use existing commercial FEM package. I would need to know how all the important quantities are calculated from the first principles. I would need to determine the accidental torsional effect ( UBC97, 1631.5.6, pp-27, this accidental torsion effect is needed for both response spectrum and linear time history analysis) for seismic dynamic analysis. $M_t=F_xe_y$ Where $F_x$ is the equivalent lateral static force in $x$ direction $e_y$ is the accidental eccentricities in $y$ direction Take note that all these involved quantities are evaluated on floor basis. My structures are quite irregular and general, such as this: For a cantilever column or an one dimensional lumped mass model, the term on floor basis is easy to interpret because there is only 1 node per floor, and the $F_x$ can only be applied on this node itself. Compare this lumped mass model with the above 2D structure FEM model and you can see the difference: But when you have such a 2 dimensional irregular structure, analyzed using FEM, calculating $F_x$ and $M_t$ is no longer easy:
{ "domain": "engineering.stackexchange", "id": 936, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "structural-engineering, structural-analysis, seismic", "url": null }
is denoted as?. Sophisticated method to price options on stocks the simulation, our first step determining... Professionals and academics the model can price the option 's strike price of the world for Britain ''! Think of it this way: in straddle you have to give up one them... Professionals involved in options trading to subscribe to this RSS feed, and. Show the little Dipper '' and Big Dipper '' and Big. On opinion ; back them up with References or personal experience or responding to other answers on its way d1... Simple case, both put and call option are plain vanilla option under what conditions will European! Sr-71 Blackbird be used for nearspace tourism we could easily use this model to price an option did Biden every... That have willing creatures as targets but no ruling for unwilling ones resume, interviews, modeling... To Becoming a financial AnalystHow to become a financial analyst price options stocks!, both put and call option are plain vanilla option you have choose. To change a call into a put a single probability for everything in market! Rss reader ( sudden death, knock out, single or double touch )... '' remove newlines with sed or awk etc to exercise the option will be exercised newlines with sed awk... Call and put options, Hat season is on its way the period ... Tradingtrade order timing refers to the shelf-life of a specific trade order timing refers to the shelf-life of a network. Used in the trading of assets, an investor can either buy asset! Valuation techniques in CFI ’ s Business valuation course brick '' abandoned datacenters 's … options involve risk and not... To make blurry photos/video clear with many periods and simulation in the Mandalorian to become a financial analyst at risk-free! Model to price an option allowing to change a call into a put implies. Will discuss two scenarios: simulation in the continuous time underlying asset either... Probability that the price of option risk can be categorised and even traded separately and strike.. Calculated using the normal cumulative distribution of factors d1 and d2 is another option pricing.... We will use the Geometric Brownian Motion of the max, it has payoff $... A recombining binomial tree model value a company as % a call into
{ "domain": "szczecin.pl", "id": null, "lm_label": "1. Yes\n2. Yes", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9736446425653804, "lm_q1q2_score": 0.8196390256250009, "lm_q2_score": 0.8418256412990657, "openwebmath_perplexity": 1882.683847826571, "openwebmath_score": 0.3040415346622467, "tags": null, "url": "https://www.dentysta.szczecin.pl/hm7ws/chooser-option-pricing-formula-b0ae53" }
$$\;n>K\;,\;\;|x_n-x|<|x|\epsilon M\;\;\implies$$ $$\implies\;\left|\frac1{x_n}-\frac1x\right|=\left|\frac{x-x_n}{xx_n}\right|<\frac{|x|\epsilon M}{|x|M}=\epsilon$$ • How do you always get a positive lower bound for $|x_n|$, what if $\{x_n\}\subset [-3,-1]$?? Mar 3 '15 at 7:24 • @Harry If $\;\{x_n\}\subset [-3,-1]\;$ then $\;\forall\;n\,,\,\,-3<x_n<-1\implies |x_n|<3\;$ , right? Mar 3 '15 at 8:19 • Yes, 3 is an upper bound of $|x_n|$, and the problem is still there as in your proof above you need a lower bound of $|x_n|$ which is positive, you say a $M$, s.t.$|x_n|\geq M$ for all $n$. So that's what I don't understand, can you clear this up for me? Thanks. Mar 3 '15 at 8:25 • @Harry: $$|x_n|\ge M\implies\frac1{|x_n|}\le\frac1M$$ which is what was used in the last inequality. I added some editing for clearity to my answer. Mar 3 '15 at 8:47 Consider the mapping: $g: \mathbb{R}^+\to \mathbb{R}^+, \quad x \mapsto \frac{1}{x}$. $g$ is continuous in its domain. This implies that if $x_n \to x$ then $g(x_n) \to g(x)$, that is your thesis. Same argument can be used in the case of negative values.
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9780517456453798, "lm_q1q2_score": 0.8389415888883605, "lm_q2_score": 0.8577681013541613, "openwebmath_perplexity": 198.04164776864073, "openwebmath_score": 0.8964192271232605, "tags": null, "url": "https://math.stackexchange.com/questions/1171733/convergence-of-inverse-of-convergent-sequence/1171755#1171755" }
differential-geometry, integration Title: Question about exterior derivatives I know from Carroll that the integration in GR is basically a mapping from n-form to the real number. And it's given that $$d^nx=dx^0\wedge\ldots\wedge dx^{n-1}=\frac{1}{n!}\epsilon_{\mu_1\ldots\mu_n}dx^{\mu_1}\ldots dx^{\mu_n}$$ Now, I have an expression that is given in spherical coordinate system, where I have $$\int_\Sigma f(\theta,\phi) d\theta\wedge d\phi$$ when I want to integrate this (the epsilon part is already computed), do I just have $\int\int d\theta d\phi$ to integrate, or do I need to put the part from integration in spherical coordinate system $\int\int\sin\theta d\theta d\phi$? I haven't done much integration that involved forms before, so any help is appreciated :) EDIT: From the article I have: $$k_\xi[h,\bar{g}]=k^{[\nu\mu]}_\xi[h,\bar{g}](d^{n-2}x)_{\nu\mu}$$ $$(d^{n-p}x)_{\mu_1\ldots\mu_p}:=\frac{1}{p!(n-p)!}\epsilon_{\mu_1\ldots\mu_n}dx^{\mu_p+1}\ldots dx^{\mu_n}$$ $$k_\xi^{[\nu\mu]}[h,\bar{g}]=-\frac{\sqrt{-\bar{g}}}{16\pi}\ldots$$ where $\ldots$ is an expression. Does this mean, since I have an $n-2$ form and I'm in 4 dimensional space, I need to include this $\sin\theta$ after all?
{ "domain": "physics.stackexchange", "id": 10467, "lm_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, integration", "url": null }
c++, interpreter, brainfuck Title: Brainfuck interpreter in C++ with namespaces I wrote this small Brainfuck interpreter in C++ where the different op codes are handled in one big switch-case statement instead of something like a tokenizer as Brainfuck is very simple in that regard. Furthermore, I split the logic into namespaces as I wanted to emulate or have the behaviour as if it was a static utility method (like static in Java). My cells array has a size of 30 000 but is technically an infinite tape as I read somewhere that that size is appropriate for Brainfuck. I also differentiate between handling the input and output as ASCII characters or just numbers in case the user wants to just print Hello Word or compute 1+1 but I feel like there must be a better solution. unsigned char is the datatype I store the current values in as it goes from 0 to 255 which is what Brainfuck specifies I believe. brainfuck.h #include <string> namespace Brainfuck { void execute(const std::string &input, std::string &output, const char &ascii); } brainfuck.cpp #include "brainfuck.h" #include <array> #include <string> #include <algorithm> #include <iostream> namespace Brainfuck { namespace { std::array<unsigned char, 30'000> cells; std::string input_; int current_index = 0; int current_char = 0; void remove_spaces(std::string &input) { input.erase(std::remove_if(input.begin(), input.end(), ::isspace), input.end()); } void remove_new_lines(std::string &input) { input.erase(std::remove(input.begin(), input.end(), '\n'), input.end()); }
{ "domain": "codereview.stackexchange", "id": 40602, "lm_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++, interpreter, brainfuck", "url": null }
- Yeah, I saw that already, as I've said – Alen Jan 30 '13 at 18:12 It's not important that $B$ is positive semi-definite. If it's real and symmetric then it has an eigenvalue/eigenvector decomposition $B = X \Lambda X^{-1}$ where the columns of $X$ are eigenvectors of $B$ and $\Lambda$ is diagonal with the eigenvalues of $B$ on its diagonal. Since $B$ is real and symmetric, it is always possible to choose the basis of eigenvectors to be orthonormal (as you mentioned). In this case the matrix $X$ is orthogonal and therefore $X^{-1} = X^T$. Let's rename it $Q$. Thus you obtain $B = Q \Lambda Q^T$. Expanding this expression is exactly what you're looking for. - Suppose $B$ is a $n\times n$ symmetric (hence diagonalizable) matrix. On the one hand $Bq_1=\lambda_ 1q_1$. On the other hand $$(\lambda_ 1 q_1q_1^T + \cdots + \lambda _n q_nq_n^T)q_1=\lambda_ 1 q_1(q_1^Tq_1) + \cdots + \lambda _n q_n(q_n^Tq_1)$$ Now since $q_1$ is orthogonal to $\displaystyle q_2,\dots ,q_n$, only $\lambda_ 1 q_1$ will prevail, because $q_1q_1^T=1$ and $q_i^Tq_1=0$, for all $i\in \{1,\dots , n\} \backslash \{1 \}$. Now recall that $Bq_1=\lambda_ 1q_1$. So you have $Bq_1=(\lambda_ 1 q_1q_1^T + \cdots + \lambda _n q_nq_n^T)q_1$.
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9724147209709196, "lm_q1q2_score": 0.8103371018159462, "lm_q2_score": 0.8333245932423308, "openwebmath_perplexity": 151.03170077109223, "openwebmath_score": 0.94524747133255, "tags": null, "url": "http://math.stackexchange.com/questions/290131/how-to-show-that-a-symmetric-positive-semidefinite-matrix-can-be-written-using-i" }
thermodynamics, newtonian-gravity, planets, hydrogen, states-of-matter Title: How does one calculate where the "surface" of a gas-giant would be? Okay, so Jupiter, Saturn, et. al are gas giants. I understand that they have large gassy atmospheres, which, due to the pressure would eventually become more and more dense as one approaches the center of the planet. Falling into Saturn or Jupiter, would we pass through it until we hit the nucleus? hits my model about right - gas eventually compressed by gravity would form, I suppose, a liquid core, followed by a solid surface. Assuming that Jupiter and Saturn were made of pure hydrogen (It's actually about 90%, but I'll simplify it a bit, how would one go about calculating the distance at which there is a "surface"? Put another way, at some distance, gravity should compress the gas into a liquid, and at a point even lower, I would assume that the liquid would compress into a gas. Is there an equation that would tell me what those points are? And, for bonus points, assuming that Saturn has a diameter of 72,367 miles / 116,464 km, at what distances would the transition points from solid to liquid and liquid to gas be? Full disclosure: I do realize that the same surface pressures would actually implode a human being trying to step on said surface. Despite desires to attempt this in reality, I am not actually going to "try this at home." This is a thought experiment more about how I calculate where gravity forces a compound into a different state of matter. I am curious more about how one models the effect of mass into gravity and compression. As a thought experiment, I suppose technically this is not a 'problem I face,' but I am curious. Thanks in advance :) This might not fully answer your question, but maybe it will be a good start. Things to consider Thermal energy received by Jupiter from the sun Thermal energy radiated by Jupiter (hence, net thermal energy) Jupiter's composition Jupiter's temperature Jupiter's gravitation Hydrogen's thermal properties (among other properties)
{ "domain": "physics.stackexchange", "id": 67019, "lm_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, newtonian-gravity, planets, hydrogen, states-of-matter", "url": null }
python, keras leaky_re_lu_9 (LeakyReLU) (None, 38, 38, 512) 0 batch_normalization_9[0][0] __________________________________________________________________________________________________ conv2d_10 (Conv2D) (None, 38, 38, 256) 131072 leaky_re_lu_9[0][0] __________________________________________________________________________________________________ batch_normalization_10 (BatchNo (None, 38, 38, 256) 1024 conv2d_10[0][0] __________________________________________________________________________________________________ leaky_re_lu_10 (LeakyReLU) (None, 38, 38, 256) 0 batch_normalization_10[0][0]
{ "domain": "datascience.stackexchange", "id": 5709, "lm_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, keras", "url": null }
Answer. Let $$F_X$$ and $$F_Y$$ denote the cumulative distribution functions of $$X$$ and $$Y$$, respectively. Let $$\Phi$$ be the standard normal cumulative distribution function: $$\Phi(z) = \int_{-\infty}^z \frac{1}{\sqrt{2 \pi}} e^{-z^2 / 2} \, dz,$$ so that $$F_X(x) = \Phi\left(\frac{x - \mu}{\sigma}\right)$$ for all $$x \in \mathbb{R}$$. If $$y \in \mathbb{R}$$, then \begin{aligned} F_Y(y) &= P(Y \leq y) \\ &= P(\max\{0, X\} \leq y) \\ &= P(0 \leq y, X \leq y) &&\text{(*)} \\ &= \begin{cases} 0, & \text{if y < 0}, \\ P(X \leq y), & \text{if y \geq 0} \end{cases} \\ &= \begin{cases} 0, & \text{if y < 0}, \\ F_X(y), & \text{if y \geq 0} \end{cases} \\ &= \begin{cases} 0, & \text{if y < 0}, \\ \Phi\left(\frac{y - \mu}{\sigma}\right), & \text{if y \geq 0} \end{cases} \end{aligned} (*) Here we used the fact that $$\max\{a, b\} \leq c$$ if and only if $$a \leq c$$ and $$b \leq c$$ (for any $$a, b, c \in \mathbb{R}$$). It's worth emphasizing that $$F_Y$$ is the cumulative distribution function.
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.980280867283954, "lm_q1q2_score": 0.8125928580892597, "lm_q2_score": 0.8289388125473628, "openwebmath_perplexity": 254.91873716370912, "openwebmath_score": 0.9993870854377747, "tags": null, "url": "https://stats.stackexchange.com/questions/392226/what-would-be-the-output-distribution-of-relu-activation" }
ros, gui, rqt, ros-electric (Added on Jan 12) Another answer based on comments on @alfa_80's answer, is again, rqt. You can open RViz and dynamic_reconfigure's GUI called rqt_reconfigure at the same time on a single window. Using Groovy is ideal though. Originally posted by 130s with karma: 10937 on 2013-01-03 This answer was ACCEPTED on the original site Post score: 4 Original comments Comment by joq on 2013-01-03: Thanks for the useful information, Isaac. Comment by joq on 2013-01-03: BTW, I do not recommend mixing different ROS distros in the same ROS graph. In some cases that may work, but not in general. Comment by 130s on 2013-01-03: Agreed. Unless mixing distros is the only solution..
{ "domain": "robotics.stackexchange", "id": 12240, "lm_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, gui, rqt, ros-electric", "url": null }
general-relativity, gravity, black-holes, newtonian-gravity I'm going to make the assumption that we are adding mass to A by providing more material of the same density $\rho_{A}$, rather than exchanging the current material with denser material or adding varying densities. I don't have to make that assumption, but it seems like it's what you're going for and we'll see where it leads. I'll also let A and B be spherical, to make them planet-like and also stable, so we don't have to worry about their shape changing. (assume a spherical cow, amirite?) Once A is large enough to touch B, the distance between their centers is $r_{A}+r_{B}$. The mass of A is $\rho_{A}(\frac{4}{3} \pi r_{A}^{3})$. So the gravitational force between them is: \begin{equation} F=\frac{G \rho_{A} (\frac{4}{3} \pi r_{A}^{3})m_{B}}{(r_{a}+r_{b})^{2}} \end{equation} It's clear that the top will grow more quickly than the bottom (everything is constant except for the radii). After a certain point, a cube grows faster than a square. Thus, the force will continue to increase, almost linearly. But will A turn into a black hole? The critical point at which A turns into a black hole is when the following equation is satisfied: \begin{equation} \frac{m_{A}}{r_{A}}=\frac{c^{2}}{2G} \end{equation} c is the speed of light, G is the gravitational constant as above. We also know: \begin{equation} \frac{m_{A}}{r_{A}}=\rho_{A}\frac{4\pi r^{2}}{3} \end{equation} (This comes from $V_{A}=\frac{4}{3}\pi r_{A}^{3}$)
{ "domain": "physics.stackexchange", "id": 18713, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "general-relativity, gravity, black-holes, newtonian-gravity", "url": null }
thermodynamics, drag, reversibility So, what do we do in the case of an irreversible change. Basically, for both irreversible and reversible changes, the equation for the work is the same:$$W=\int P_B\rm\; dV\;.$$ This is just the integral of the force the gas exerts on its surroundings over the distance the force is applied. But, unlike a reversible change, we can not depend on the equation of state to control the value of the boundary pressure $P_B$. So we need to control it manually from the outside, using either a pressure transducer at the boundary combined with a feedback control system on the piston movement, or, in simpler cases, by adding or removing a weight to the piston. In the case you were describing, the initial and final temperatures of the gas were the same, so there was no change in internal energy. Therefore, the heat added in the irreversible process as equal to the work:$$Q=\int P_B\;\rm dV\;.$$ Also, because the part of the cylinder where heat transfer is occurring is in contact with a constant temperature bath, $T_B$ is equal to the bath temperature. It is not very widely known, but the Clausius inequality calls for the use of the boundary temperature in comparing $\Delta S$ to the integral of $\rm \partial Q/T.$ In particular, $$\Delta S \geq \int \frac{\rm \partial Q}{T_B}\;.$$ So, how do you get the change in entropy for an irreversible process if you can't use this equation. You start out by forgetting all about the irreversible process and focusing only on the two end states. You then devise a reversible process between these same two end states and calculate the entropy change for that process. This will give you the entropy change for your irreversible process.
{ "domain": "physics.stackexchange", "id": 28012, "lm_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, drag, reversibility", "url": null }
electricity, electrons, potential, capacitance Title: List of questions about charge, voltage, and capacitance Let's just say you run a 5V current from the battery into a circuit. From what I understand, this means that I am essentially pushing high potential electrons into the circuit. These electrons would be able to do work through a resistor like a bulb by dropping from higher potential to lower potential and thus transferring energy to the bulb in terms of light, heat, whatever... so far so good. The problem comes in when I read in the textbook about capacitance.
{ "domain": "physics.stackexchange", "id": 36248, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "electricity, electrons, potential, capacitance", "url": null }
cosmology, nuclear-physics, space-expansion, universe, binding-energy Title: What happens when the universe runs out of fuel? After some X billion years, one would think the stars in the entire universe will run out of hydrogen. What would happen next? Is there any way to get hydrogen out of heavy metals (extreme fission)? Just curious. Then star formation ceases and the universe goes dark. At this stage of the universe's evolution, there'll still be plenty of hydrogen, they just don't form stars. In theory you can create hydrogen out of heavy metals, but it's a process that requires energy. If you have the energy banked somewhere (and you'll need a LOT of energy to make enough hydrogen for a new star) then it's possible.
{ "domain": "physics.stackexchange", "id": 87888, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "cosmology, nuclear-physics, space-expansion, universe, binding-energy", "url": null }
bash, shell, rags-to-riches Title: Rename files by editing their names in an editor Inspired by a recent question to rename files by editing the list of names in an editor, I put together a similar script. Why: if you need to perform some complex renames that are not easy to formulate with patterns (as with the rename.pl utility), it might be handy to be able to edit the list of names in a text editor, where you will see the exact names you will get. Features: Edit names in a text editor Use the names specified as command line arguments, or else the files and directories in the current directory (resolve *) Use a sensible default text editor According to man bash, READLINE commands try $VISUAL or else $EDITOR -> looks like a good example to follow. Abort if cannot determine a suitable editor. Abort (do not rename anything) if the editor exits with error Paths containing newlines are explicitly unsupported Perform basic sanity checks: the edited text should have the same number of lines as the paths to rename Here's the script: #!/usr/bin/env bash # # SCRIPT: mv-many.sh # AUTHOR: Janos Gyerik <info@janosgyerik.com> # DATE: 2019-07-27 # # PLATFORM: Not platform dependent # # PURPOSE: Rename files and directories by editing their names in $VISUAL or $EDITOR # set -euo pipefail usage() { local exitcode=0 if [[ $# != 0 ]]; then echo "$*" >&2 exitcode=1 fi cat << EOF Usage: $0 [OPTION]... [FILES] Rename files and directories by editing their names in $editor Specify the paths to rename, or else * will be used by default. Limitations: the paths must not contain newline characters. EOF if [[ $editor == *vim ]]; then echo "Tip: to abort editing in $editor, exit with :cq command." fi cat << "EOF" Options: -h, --help Print this help EOF exit "$exitcode" } fatal() { echo "Error: $*" >&2 exit 1 } find_editor() { # Following READLINE conventions, try VISUAL first and then EDITOR
{ "domain": "codereview.stackexchange", "id": 42964, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "bash, shell, rags-to-riches", "url": null }
optics, refraction So as $\Delta\phi \to 0$, $$\text{IP}=\cos\phi\frac{d\xi}{d\phi}$$ The sideways displacement of I from the vertical line ON is $$x=\text{NP}-\text{IP}\sin\phi=\xi-\sin\phi\cos\phi \frac{d\xi}{d\phi}$$ that is: $$x=h\tan\theta-\sin\phi \cos\phi \frac{d\xi}{d\theta}\frac{d\theta}{d\phi}$$ We know that $\frac{d\xi}{d\theta}=h\sec^2 \theta$ and we can use Snell's law to find $\frac{d\theta}{d\phi}$ ... $$\sin\phi=n\sin\theta$$ $$\text{So}\ \ \ \frac{d\theta}{d\phi}=\frac 1n \frac{\cos\phi}{\cos\theta}$$ Substituting for $\frac{d\xi}{d\theta}$ and $\frac{d\theta}{d\phi}$ in our expression for $x$, $$x=h\tan\theta-\sin\phi\cos\phi\ h\sec^2\theta \frac 1n \frac{\cos\phi}{\cos\theta}$$ With more use of $\sin\phi=n\sin\theta$, this can be tidied up to yield the rather neat... $$x=h\ (n^2-1)\tan^3 \theta.$$
{ "domain": "physics.stackexchange", "id": 90455, "lm_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, refraction", "url": null }
(D) Manager Joined: 03 Aug 2017 Posts: 64 Re: If 20 typists can type 48 letters in 20 minutes, then how many letters  [#permalink] ### Show Tags 05 Oct 2019, 22:16 Bunuel wrote: If 20 typists can type 48 letters in 20 minutes, then how many letters will 30 typists working at the same rate complete in 1 hour? A. 63 B. 72 C. 144 D. 216 E. 400 This i how i solved... 20 Typist can type 48 letters / 20 Min therofre in 1 Min 20 Typist can type = 48/20 = 2.4 Letters per Min In 60 Min 20 Typist can type = 2.4 *60 =144 Words per min... We are also told now there are 30 Typist so if 20 typist can type 144 words so 30 Typist can type X words per min..... Solve for X 20/144 = 30 / x ..... x = 72*3 = 216 Words per min Re: If 20 typists can type 48 letters in 20 minutes, then how many letters   [#permalink] 05 Oct 2019, 22:16 Display posts from previous: Sort by
{ "domain": "gmatclub.com", "id": null, "lm_label": "1. Yes\n2. Yes\n", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 1, "lm_q1q2_score": 0.8056321889812553, "lm_q2_score": 0.8056321889812553, "openwebmath_perplexity": 8878.642483233722, "openwebmath_score": 0.8259541392326355, "tags": null, "url": "https://gmatclub.com/forum/if-20-typists-can-type-48-letters-in-20-minutes-then-how-many-letters-219909.html" }
Last edited: Mar 7, 2016 2. Mar 7, 2016 ### SteamKing Staff Emeritus Is this a 25 gram burger or a 250 gram burger? A 25 gram burger is about 1 bite. Also, is the consumption rate $100 - (\frac{1}{900}m^2)$ or $(100 - \frac{1}{900m^2})$ 3. Mar 7, 2016 ### chwala consumption rate is $100-(1/900)m^2$ 4. Mar 7, 2016 ### SteamKing Staff Emeritus What about the initial size of the burger - 25 grams or 250 grams? 5. Mar 7, 2016 ### chwala the initial burger is 250grams. it is eaten (all of it) until it becomes 0 grams. 6. Mar 7, 2016 ### SteamKing Staff Emeritus After this point, you have some errors in your integration for the second partial fraction term. 7. Mar 8, 2016 ### chwala I have seen the error: $t=1.5 ln u - 1.5 ln (600-u) + k$ eventually $t = 1.5 ln 300 - 1.5 ln 300 - 1.5 ln 11$ $t = -3.6min$ why do we have a negative? is it taking care of the fact that the burger was initially whole and with every bite it kept on decreasing in mass value until the point $m=0$ ? 8. Mar 8, 2016 ### Samy_A $m$ is the mass eaten: 9. Mar 8, 2016 ### chwala am not getting you $dt/dm=1.5/(300+m)-1.5/(300-m)$ and which is equal to $1.5/u+1.5/(300-(u-300)$ = $1.5/u-1.5/(600-u)$ = $900/(u(600-u))$ = $900/(300+m)(300-m)$ = $900/(90000-m^2)$ as indicated in my original post. my question still is why do we have $-3.6$minutes? 10. Mar 8, 2016 ### Samy_A
{ "domain": "physicsforums.com", "id": null, "lm_label": "1. YES\n2. YES\n\n", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9830850877244272, "lm_q1q2_score": 0.801442901103841, "lm_q2_score": 0.8152324871074608, "openwebmath_perplexity": 3521.391921039265, "openwebmath_score": 0.6890898942947388, "tags": null, "url": "https://www.physicsforums.com/threads/a-problem-on-differential-equations.860943/" }
python, python-3.x, primes, generator with: # We only need to check odd numbers, because all evens > 2 are not prime Use keyword arguments for clarity. Your call to itertools.count() is clearer like so: itertools.count(start=3, step=2) I was able to sort-of guess based on the comment, but keyword arguments always improve clarity and reduce ambiguity.
{ "domain": "codereview.stackexchange", "id": 22738, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "python, python-3.x, primes, generator", "url": null }
radiation, units, dimensional-analysis $$\lim_{n\to\infty}P_n(\text{undecayed}) = \lim_{n\to\infty}(1 - \lambda\Delta t)^n = \lim_{n\to\infty}\biggl(1 - \frac{\lambda T}{n}\biggr)^n = e^{-\lambda T}$$ So the equation for exponential decay emerges naturally from the fact that the decay constant is the decay probability per unit time for an undecayed nucleus. (Or of course the same argument applies to any other system that undergoes exponential decay, not just nuclei.)
{ "domain": "physics.stackexchange", "id": 11116, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "radiation, units, dimensional-analysis", "url": null }
human-biology, history As part of the judgment, the court issued the celebrated Nuremberg Code in 1947—the first, shortest, and in many ways most uncompromising of the major ethical codes and regulations for the conduct of medical research on humans. Although the code had no legal authority in any country, it had great influence on ideas about human experimentation, and subsequent international codes and legislation. In particular, the concept of "informed consent" is directly traceable to the Nuremberg Code: The first provision of the Nuremberg Code is unqualified: “The voluntary consent of the human subject is absolutely essential.” No exceptions are permitted... Furthermore, the code is clear that consent must be given by subjects who are fully informed. *I should note that the article is from a Jewish law website, so some may discount that as not a perfectly neutral source. Which is silly.
{ "domain": "biology.stackexchange", "id": 1369, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "human-biology, history", "url": null }
python, json, file, csv def is_zip_code(token): """Determines if the passed in string represents a properly formatted 5-digit zip code. Takes a string and validates that it matches the valid formats specified for a zip code. Validates that the string doesn't contain more than 5 numbers. Args: token: A fragment of a line of a file Returns: A boolean indicating if the string is a properly formatted zip code. """ token = token.strip(" ") digit_count = 0 for digit in token: if digit != "," and digit != "\n": if represents_int(digit): digit_count += 1 else: return False if digit_count != 5: return False return True def represents_int(char): """Determines if the passed in character represents an integer. Takes a char and attempts to convert it to an integer. Args: char: A character Returns: A boolean indicating if the passed in character represents an integer. Raises: ValueError: An error occured when trying to convert the character to an integer. """ try: int(char) return True except ValueError: return False if __name__ == "__main__": formatter= FileFormatter("data.in","result.out") formatter.parse_file() Your function is_phone_number is the prime example for the usage of regular expressions. You are basically trying to implement it yourself here! You can either use two different patterns here: import re def is_phone_number(token): token = token.strip(" ") return (re.match(r'\(\d{3}\)-\d{3}-\d{4}$', token) is not None or re.match(r'\d{3} \d{3} \d{4}$', token) is not None)
{ "domain": "codereview.stackexchange", "id": 25058, "lm_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, json, file, csv", "url": null }
quantum-algorithms, quantum-gate, simulation, speedup Title: New algorithm for faster QC simulation by IBM This new algorithm for QC calculation was introduced recently (2017 4Q) by IBM/ Pednault et al. to great fanfare. The paper seems more couched in the language of physics. Are there any basic overview/analyses of this by computer scientists about the general "design pattern" utilized, vs the prior algorithmic techniques for the problem, or can someone provide one? What about the complexity analysis of the techniques? "Breaking the 49-Qubit Barrier in the Simulation of Quantum Circuits" From a computer science perspective, the calculation of quantum-state amplitudes can be related to group-by aggregation queries in relational database systems, and the techniques we developed to reorganize calculations can be related to algebraic manipulations that are performed by database query optimizers. The general “design pattern” is thus analogous: convert quantum circuits into graph-based algebraic representations that can be readily manipulated and then use those representations to generate optimized execution plans for their simulation. A complexity analysis could then be approached from this perspective. I included a simple example in a reply to a question posted on the IBM Q Experience Forum: Equations for Bristle Brush Example
{ "domain": "quantumcomputing.stackexchange", "id": 30, "lm_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-algorithms, quantum-gate, simulation, speedup", "url": null }
fluid-dynamics, astrophysics, shock-waves, interstellar-matter and Please explain when it is possible to find self-similar flows with variable Mach numbers?
{ "domain": "physics.stackexchange", "id": 29087, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "fluid-dynamics, astrophysics, shock-waves, interstellar-matter", "url": null }
# Is there no solution to the blue-eyed islander puzzle? Text below copied from here The Blue-Eyed Islander problem is one of my favorites. You can read about it here on Terry Tao's website, along with some discussion. I'll copy the problem here as well. There is an island upon which a tribe resides. The tribe consists of 1000 people, with various eye colours. Yet, their religion forbids them to know their own eye color, or even to discuss the topic; thus, each resident can (and does) see the eye colors of all other residents, but has no way of discovering his or her own (there are no reflective surfaces). If a tribesperson does discover his or her own eye color, then their religion compels them to commit ritual suicide at noon the following day in the village square for all to witness. All the tribespeople are highly logical and devout, and they all know that each other is also highly logical and devout (and they all know that they all know that each other is highly logical and devout, and so forth). [For the purposes of this logic puzzle, "highly logical" means that any conclusion that can logically deduced from the information and observations available to an islander, will automatically be known to that islander.] Of the 1000 islanders, it turns out that 100 of them have blue eyes and 900 of them have brown eyes, although the islanders are not initially aware of these statistics (each of them can of course only see 999 of the 1000 tribespeople). One day, a blue-eyed foreigner visits to the island and wins the complete trust of the tribe. One evening, he addresses the entire tribe to thank them for their hospitality. However, not knowing the customs, the foreigner makes the mistake of mentioning eye color in his address, remarking “how unusual it is to see another blue-eyed person like myself in this region of the world”. What effect, if anything, does this faux pas have on the tribe? The possible options are Argument 1. The foreigner has no effect, because his comments do not tell the tribe anything that they do not already know (everyone in the tribe can already see that there are several blue-eyed people in their tribe). Argument 2. 100 days after the address, all the blue eyed people commit suicide. This is proven as a special case of
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9799765546169712, "lm_q1q2_score": 0.8123406035791126, "lm_q2_score": 0.8289388146603365, "openwebmath_perplexity": 1074.8680345047208, "openwebmath_score": 0.6402588486671448, "tags": null, "url": "http://math.stackexchange.com/questions/238288/is-there-no-solution-to-the-blue-eyed-islander-puzzle/238330" }
+ n\cdot (\bar{Y}-\mu)^2 +2 (\bar{Y}-\mu)\cancelto{0}{\sum_{i=1}^n (Y_i-\bar{Y})}\\ &= \sum_{i=1}^n (Y_i-\bar{Y})^2 + n\cdot (\bar{Y}-\mu)^2\\ &\Downarrow\\ \frac{1}{n-1}\sum_{i=1}^n (Y_i-\bar{Y})^2 &= \frac{1}{n-1}\left[\sum_{i=1}^n (Y_i-\mu)^2 - n\cdot (\bar{Y}-\mu)^2\right]. \end{align} Note that the proof works for all choices of number $\mu$; there is no requirement that $\mu$ equal the expected value of anything.
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9732407152622597, "lm_q1q2_score": 0.8067570048886756, "lm_q2_score": 0.8289388146603365, "openwebmath_perplexity": 829.3749740238325, "openwebmath_score": 0.998529851436615, "tags": null, "url": "https://stats.stackexchange.com/questions/291164/distribution-of-independent-random-variables-textbook-question" }
c# lock (this.padLock) { lenCounts = (long)this.counts.Count; observedTotal = this.currentTotal; } if (lenCounts == 0) { throw new InvalidOperationException("No counts to average."); } else if (lenCounts == 1) { return (int)observedTotal; } else { return (int)(observedTotal / lenCounts); } } } public void Clear() { lock (this.padLock) { this.currentTotal = 0L; this.counts.Clear(); } } } -Edit- Fixed inconsistent use of "this.". To answer your questions: It's hard to say. If you expect a large number of values or moderate number of large values, you could potentially overflow an int. Otherwise, you may be fine using int instead of long. Yes, it's overkill, since dividing the total by the count would yield the correct answer anyways. Unfortunately, no. You need to lock anything which can be mutated by other threads, and you're doing precisely that. I would do a few things: Use a different naming format for fields than you do for local variables. The most common format I have seen with .NET code is an underscore prefix, though the naming guidelines do not have any particular rule for private fields. Once that is done, you can drop all the this references. Constants should use different casing from fields. SCREAMING CASE is the one I follow and see most often, but the framework isn't really consistent. There appears to be a mix of PascalCase and SCREAMING_CASE, depending on which class you look at in ILDASM, even just within mscorlib.dll. Avoid unnecessary casting. .NET performs implicit casting in many cases, so there is no need to use most of the casts. The only exception is casting the calculated average to int (from long). Use proper exceptions. The exception in the constructor should instead be ArgumentOutOfRangeException, as it more clearly states what the problem was. Returning from within a lock works, so there is no need to define local variables for the total in the CurrentAverage property public sealed class RollingAverage { public RollingAverage() : this(DEFAULT_MAX_CAPACITY) { }
{ "domain": "codereview.stackexchange", "id": 5834, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "c#", "url": null }
I believed that the percentage is $\left(\frac 14\right)^n \cdot 100.$ Am I missing something? Or is this correct? • Assuming perfect mixing, you are correct – siegehalver Jun 10 '17 at 15:47 • Should we separately take into account the amount of old water that is retained? Or is that included when we multiply by 1/4? – coldspeed Jun 10 '17 at 15:49 • Yeah, you are correct. You can just imagine having two bottles that together always add up to 1L. The first bottle starts out with 1L of pure "old water", while the other just has 0L of fresh, new water. Removing 3/4 of your water bottle, could then be imagined as removing 3/4 of the old water battle and 3/4 the new water bottle, as they always add up to 1. You can now easily see that your reasoning is correct. – Imago Jun 10 '17 at 15:53 • Whatever proportion of the the day before was, after emptying it and refilling the proportion will be 1/4 of the that. Before you start the proportion was all of it. After the first day it wias 1/4 of all. After the second day it was 14 of 14 of all. After n days is was 1/4 of 1/4 of 1/4 of ...... of 1/4 of all (n times). That's is $(\frac 14)^n$. To convert to precentages (which have no innate mathematical meaning and are just a bookkeeping convention) we multiply by 100 (i.e. a percentage is a "so many parts out of 100" ) So your reasoning is perfectly correct. – fleablood Jun 10 '17 at 15:57
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9883127409715955, "lm_q1q2_score": 0.8257190225671024, "lm_q2_score": 0.8354835350552603, "openwebmath_perplexity": 558.9999585683272, "openwebmath_score": 0.6428505182266235, "tags": null, "url": "https://math.stackexchange.com/questions/2317419/how-much-old-water-do-i-have" }
$$B_1 + 2B_2 + ... + zB_z = y.$$ There are $$\frac{(B_1 + B_2 + ... + B_z)!}{B_1! B_2! ... B_z!}$$ ways that we can order the blocks within the sequence, and adjacent blocks must use different letters. So we can pick the first block to be any of the $$x$$ letters, and each new block must use a different letter from the preceding block, of which there are $$(x-1)$$. Since the total number of blocks is $$B_1 + ... + B_z$$, we thus have, for a specific sequence of blocks, that there are $$x(x-1)^{B_1 + ... + B_z - 1}$$ ways to pick the letter for each block. So if I know the block sizes $$B_1$$ through $$B_z$$, the number of possible sequences with those block sizes is given by $$\frac{(B_1 + B_2 + ... + B_z)!}{B_1! B_2! ... B_k!} * x(x-1)^{B_1 + ... + B_z - 1},$$ and the answer to OP's question is then the sum $$\sum_{B_1 + 2B_2 + ... + zB_z = y} \frac{(B_1 + B_2 + ... + B_z)!}{B_1! B_2! ... B_k!} * x(x-1)^{B_1 + ... + B_z - 1}$$ over all tuples of nonnegative integers $$(B_1, ..., B_z)$$ satisfying the condition $$B_1 + 2B_2 + ... + zB_z = y$$.
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9857180671237785, "lm_q1q2_score": 0.803589387023111, "lm_q2_score": 0.8152324826183821, "openwebmath_perplexity": 402.8925181759791, "openwebmath_score": 0.9805252552032471, "tags": null, "url": "https://math.stackexchange.com/questions/3751109/generalized-repetitions-of-letters-with-limited-amount-of-adjacent-letters" }
Let's call this square $E$, in honor of its status as an invariant set. We can get a deterministic understanding of the distribution of points on $E$ by thinking in terms of a mass distribution on the square (technically, a measure). Start with a uniform mass distribution throughout the square. Generate a second mass distribution on $E$ by distributing $1/3$ of the mass to $f_0(E)$ and $1/6$ of the mass to each of $f_i(E)$ for $i=1,2,3,4$. We can then iterate this procedure. The step from the original distribution to the next to the next might look like so: The evolution of the first 8 steps looks like • A "solid square"? Surely this process can only produce points with dyadic rational coordinates. – David Zhang May 22 '16 at 15:09 • @DavidZhang I agree, but there is a limiting object. – Mark McClure May 22 '16 at 15:10 • If you remove the first generator, you get the same square, just with a uniform distribution – John Dvorak May 22 '16 at 17:56 • @DavidZhang Surely, my 'limiting object' comment makes perfect sense? The square in question is just the closure of that set of dyadic points. Similarly, the closed unit interval can be described at the attractor of the IFS with functions $f_1(x)=x/2$ and $f_2(x)=x/2+1/2$. But, if we play the chaos game starting at the origin, we can generate only dyadic rationals. Similarly, the classic chaos game that generates the Sierpinski triangle approximates that uncountable set with only countably many points. This is pretty fundamental. – Mark McClure May 22 '16 at 20:04 • @MarkMcClure Oh yes, your first comment made perfect sense. I just hadn't gotten around to replying until now, thanks. – David Zhang May 23 '16 at 0:56
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9796676419082933, "lm_q1q2_score": 0.8421847540126272, "lm_q2_score": 0.8596637451167997, "openwebmath_perplexity": 298.8489057032838, "openwebmath_score": 0.9700760245323181, "tags": null, "url": "https://math.stackexchange.com/questions/1795276/does-this-fractal-have-a-name" }