an algorithm for detecting if noisy univariate data is constant or is sum of step functions

In an explicit algorithm i’m writing, there is a certain stage where i need to determine whether or not a certain noisy univariate data is constant or is sum of step functions.

For example, defining foo as the algorithm i’m after (writing in python): assert foo([0]*20) == False assert foo([0]*20 + [1]*20) == True assert foo([0]*20 + [5]*30 + [1]*70) == True

  • The data in the examples is not noisy, but assume the real one is (just a bit, one can pinpoint where a step might take place by observing the plot of the data.

I’d be happy to hear any ideas, thank you.


Are there more languages than functions?

My gut says “no”, but I don’t know why.

For any function $ f$ over strings on an alphabet, one can define a language in which every word is just the concatenation of a string $ s$ , a delimiter, and $ f(s)$ , or the empty string if $ f(s)$ is undefined. So there at least as many languages as functions. How can we define a function for every language? (Forgive my ignorance about languages, automata, etc. I have not studied in that area. Perhaps my question is poorly constrained.)

Applying rules to functions with non numeric arguments

I am trying to do the following (it’s a simplified version):

In[1]:= rulepositive = { f[a_?Positive]:> f[a] }; In[2]:= rulenegative = { f[a_?Negative]:> 0 };  In[3]:= $  Assumptions = Elements[w,Positive];  In[4]:= f[w]/.rulepositive In[5]:= f[w]/.rulenegative 

where I expect

Out[4]:= f[w] Out[5]:= 0 

But it doesn’t work. In words I want to apply a set of mapping rules in functions with non numeric arguments, which nevertheless have definite nature (e.g. Positive/Negative). How could I do it?

Why do we need value-returning functions?

I’m just a beginner at C++ programming. I am currently having hard time grasping the usage of value returning function and non-value returning function. Void functions are called non-value returning function but they can return value if we assign certain parameters, compute the parameters and call them in the main function. So, doesn’t this defeat the purpose? I feel like I am getting this wrong, so some explanation here would be great!

Also, I see that void functions are easier to use, since I don’t need to use ” cout<< ‘the void function’ << endl; ” It seems easier and the value-returning function seems useless. I need explanation here as well as to why we need value-returning function.

Please bear with my questions and I am always ready to learn!

Primitive Recursion of two functions $g,h$


Which function is created when applying Primitive Recursion $ PR(g,h)$ to $ \begin{align}g:\mathbb{N}\to \mathbb{N}, \quad g(n)&=\mathrm{zero}_1(n)\ h:\mathbb{N}^3\to\mathbb{N}, \quad h(n,m,l)&=P_2^{(3)}(n,m,l)+\mathrm{succ}\circ P_2^{(3)}(n,m,l)+P_3^{(3)}(n,m,l) ?\end{align}$

My idea: $ f(x,0)=g(x)=zero_1(x)=0$ , $ f(x,t+1)=h(x,t,f(x,t))=t+t+1+f(x,t)=2t+1+f(x,t)$ , but what is $ f(x,t)$ and how do I derive that?

Finding longest word without help of library functions or regex?

Have the function LongestWord(sen) take the sen parameter being passed and return the largest word in the string. If there are two or more words that are the same length, return the first word from the string with that length. Ignore punctuation and assume sen will not be empty.

**Examples**

Taken from here https://coderbyte.com/information/Longest%20Word

Every single solution that came across in Javascript or C# are the ones which use regex. Is it possible to solve this without regex?

I gave it a shot but could not make it work:

function LongestWord(sen) {   let word = [];   let longestword = "";   let longestwordlen = 0;   let wordlen = 0;   for (let i = 0; i < sen.length - 1; i++) {      if (isAlphabet(sen[i]) && !isInvalidChar(sen[i + 1])) {       wordlen++;       word.push(sen[i]);     }     if (isSpace(sen[i + 1])) {       if (wordlen > longestwordlen) {         longestwordlen = wordlen;         longestword = word.join('')       }       wordlen = 0;       word = [];     }    }    return longestword; }  function isSpace(char) {   if (char.charCodeAt(0) == 32) return true   else return false } function isInvalidChar(char) {   if (!isSpace(char) && !isAlphabet(char)) return true   else return false } function isAlphabet(char) {   if ((char.charCodeAt(0) >= 65 && char.charCodeAt(0) <= 90) || (char.charCodeAt(0) >= 97 && char.charCodeAt(0) <= 122)) return true   else return false }  LongestWord("I am going to kill youeeeeee ") 

Do exponential functions grow faster than logarithmic?

For example:

$ f(n) = n(log_2 n)^4$ vs $ g(n) = n^{1/3}$

Does f(n) grow slower than g(n) as a general rule, even for decimal exponents? I tried doing a limit test but symbolab limit calculator is saying that Steps are currently not supported for this problem.

I graphed them over a large range and it does appear that g(n) grows asymptotically faster.

How do I use Mathematica computation of special functions in Microsoft Excel computation?

I have a model equation which I find somehow easier to compute with some experimental data in Microsoft Excel. I had an initial model which is basically a Bessel function. In Mathematica, I was able to compute the model equation with this code:

With[{s = {i, 0, 15, 0.5}}, Table[{i^2, i^3, BesselJ[i, 5.2]}, s]] 

I was as well able to compute the model for experimental data without smooth ranges. The current model is essentially a Legendre equation which I could not find in the Excel formula bar. The challenge I have with the current model is that I have experimental data (of 300 rows) which do not have smooth ranges and I need to use them to determine the model function using Legendre function (a special function). Hence, is it possible to use the incredible computational power of Wolfram Mathematica within the formula bar of Excel or vice versa? Your kind suggestions would be greatly appreciated.

Prove that for all functions g: N -> R>=0, and all numbers a in R>=0, if g in Omega(1) then a + g in Theta(g)

Here is a more readable version of the question:

Prove that for all functions $ g: \mathbb{N}\to\mathbb{R}^{\geq 0}$ , and all numbers $ a \in \mathbb{R}^{\geq 0}$ , if $ g \in \Omega(1)$ then $ a + g \in \Theta(g)$

What I’ve done so far:

In order for $ a + g\in\Theta(g)$ , $ a+g \in \mathcal{O}(g) \wedge a + g \in \Omega(g)$ .

Expanding our assumption, we get:

$ \exists c_1, n_1 \in \mathbb{R}^{+}, \forall n \in \mathbb{N}, n \geq n_1 \implies g(n) \geq c_1$

Proving $ a + g \in \Omega(g)$ :

Expanding the definition, we get:

$ \exists c_2,n_2 \in \mathbb{R}^{+}, \forall n \in \mathbb{N}, n \geq n_2 \implies a + g(n) \geq c_2*g(n)$

Let $ c_1 = 1$ and $ n_2 = n_1$ . Let $ n \in \mathbb{N}$ . Assume $ n \geq n_2$ . Prove $ a + g(n) \geq c_2 * g(n)$ .

$ g(n) = g(n)\ \implies g(n) \geq g(n)\ \Leftrightarrow c_1 * g(n) \geq c_1 * g(n)\ \Leftrightarrow g(n) \geq g(n) \text{ (since $ c_1 = 1$ )}\\Leftrightarrow a+g(n) \geq g(n) \text{ (making left side bigger since $ a \in \mathbb{R}^{\geq 0}$ )}$

Proving $ a+g \in \mathcal{O}(g)$ :

Expanding the definition, we get:

$ \exists c_3,n_3 \in \mathbb{R}^+, \forall n \in \mathbb{N}, n \geq n_3 \implies a + g(n) \leq c_3 * g(n)$

I’m struggling here since I’m not really sure what value of $ c_3$ I should be using or how to derive one. (I’ve tried using my assumption of $ g(n) \geq c_1$ but I don’t really know where to go from there). Any help is greatly appreciated and I apologize for any formatting errors in advance. Thank you.