Is there any hash library with 3 wise independent hash functions in python

So I was looking for a hash family with 3 wise independent hash functions and I know the theory behind it and coding it is not super difficult but I actually need very good accuracy. So it would be actually nice if I could use a library which is already defined in python. Is there any such library with 3 wise independent hash functions? I googled it but didn’t get any proper answer.

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 ")