turing machines – Determine if a language is Context-free

Consider the language A on {0,1} such that #zeros >= 2 * #ones
Is this regular, context-free, Turing decidable ?

My Idea –
It’s not regular. Because we need to track the number of zeros and so it cannot be done with
a finite number of states.
I am not sure if this argument is a formal one.

Turing Decidable – Yes
Take a machine which reads 1 from the end writes an X there and then traverses the tape and X two 0’s
So after all ones are gone there are still #zeros >=0 then it’s accepted. Otherwise if the #ones >=0
on tape after this operation it’s rejected.

Context-Free
I am unable to find any context free grammar for it. Neither prove that it’s not context-free.

legacy code – How to determine if module within the application is wort refactoring or rewriting?

We all know Joel Spolsky famous article to never rewrite working code.

How about if we don’t consider overall project but a module within? Module can be e.g.:

  • payment handling microservice in e-commerce application
  • data access layer (inline SQL to ORM)
  • front-end layer (MVC to Angular)

Are there circumstances that justifies module (not full project or system) rewrite?

What is the best way to determine if a script is being run by cron in Magento2?

I need a piece of code to execute differently if it’s being run by cron, what is the best way to check programmatically that cron is the execution source?

I know that it can be done by checking for website or session being unavailable, but I’m concerned these seem a bit hacky. I’m wondering if there’s some clean isRunningFromCron kind of function that abstracts this to dependency-inject, or if the aforementioned hacks would be robust enough that I’m being over-cautious.

Thanks!

EDIT:
It may actually not be possible to use the current store ID check in my circumstance, as the script is otherwise being run from adminhtml, which I think would also have a store_id of 0

calculus – Determine if the function $f(x)$ is integrable in $[0,1]$

Determine if the function $f(x)$ is integrable in $(0,1)$

$$displaystyle f( x) =begin{cases}
frac{1}{x^{2}} & x >0\
0 & x=0
end{cases}$$


Attempt:

Let’s check the limits of each side $0^+,0^-$ to show that $frac{1}{x^2}$ is not bounded.

$$displaystyle lim _{xrightarrow 0^{+}}frac{1}{x^{2}} =infty $$

$$displaystyle lim _{xrightarrow 0^{-}}frac{1}{x^{2}} =infty $$

Therefore, the function is not bounded when $lim_{xrightarrow 0^{+/-}}$
, and is not integrable in $(0,1)$

In addition, there is a well-known theorem:

If $f$ is a continuous function except for the finite number of unconsciously points $Rightarrow$ $f$ is integrable.

Which contradicts the attempt.

statistics – How to determine whether to use complement of event when calculating probability?

A sample problem in my textbook states: In a recent year, there were 18,187 U.S. allopathic medical school seniors who applied to residency programs and submitted their residency program choices. Of these seniors, 17,057 were matched with residency positions, with about 79.2% getting one of their top three choices. Medical students rank the residency programs in their order of preference, and program directors in the United States rank the students. The term “match” refers to the process whereby a student’s preference list and a program director’s preference list overlap, resulting in the placement of the student in a residency position.

  1. Find the probability that a randomly selected senior was matched with a residency position and it was one of the senior’s top three choices.

  2. Find the probability that a randomly selected senior who was matched with a residency position did not get matched with one of the senior’s top three choices.

1 is obvious: $(frac{17057}{18187})(0.792) approx 0.743$

For 2, the textbook says to take the complement of 0.792: $1 – 0.792 = 0.208$

But my question is: why wouldn’t you solve this one the same way as part 1? As in:
$$(frac{17057}{18187})(1 – 0.792) approx 0.195$$

why wouldn’t you do that?

architecture – Eventing: Determine if Set of Messages has been Processed

Given a Set of messages sent to a Queue, what are good ways to determine all of the messages have been processed?

Constraints:

  • Large number of messages
  • Other messages besides those in the Set will be in the queue (queue size may never be 0)
  • Queue does not guarantee ordering of messages

The best solution I have thought of so far is: give each message a GUID, when posting message to the Queue also add an entry to an “Unprocessed” table with the GUID key and a “SetId” column. When the message is processed, delete the “Unprocessed” table entry for that GUID. Query if all messages have been processed by “Any(unprocessed where SetId={id})”.

The reason I am asking is for the following workflow: the user triggers an automation, which itself triggers numerous events for actions to perform on the system, and then we want to display to the user whether the automation has completed. Backend microservice system. Open to alternative techniques besides the general problem I proposed as well. I am also open to suggestions like: choose a different queue that enforces ordering, if that is a practical solution you would use.

matlab – How do you determine misplaced objects in clustering?

I am trying to implement an external quality measure called error rate(ER) to check if the clustering algorithm I am using is effective.

ER=(number of misplaced objects/total number of object within the dataset)x100

How do I determine the number of misplaced objects in this result I get? Is there an algorithm I could use or an equation for this?