-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.py
82 lines (67 loc) · 1.76 KB
/
functions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
from integration import *
import numpy as np
e = 2.71828182845904523536
π = 3.1415926535897932384626433
ϕ = 1.6180339887498948482
def gamma(z, top = 10):
Γ = lambda x : x**(z-1)*e**(-x)
return integrate(Γ, (10**-9,top))
def zeta(s, max = 1000000):
"""
Riemanns Zeta function - takes a complex argument s (and an optional integer argument 'max') and calculates the sum:
ζ(s)=∑_{n=1}^{∞} \frac{1}{n^{s}}
"""
temp = 0
for i in range(1,max+1):
temp += 1/(i**(s))
return temp
#def bessel(x, order = 1)
def zeta_cont(s):
return integrate()
def primality(n):
for i in range(2,round(np.sqrt(n))+1):
if (n%i == 0):
return False
return True
def totient(n):
"""
Euler's Totient Function - takes an integer argument 'n' and returns the list of numbers upto 'n' which are prime relative to it
(i.e. do not exactly divide 'n')
"""
totives = []
for i in range(1,n):
if (n%i != 0):
totives.append(i)
return totives
def around(y,x, ϵ = 0.001):
if y<x and y>x-ϵ:
return True
if y>x and y<x+ϵ:
return True
return False
def avg(x):
return sum(x)/len(x)
def summation(func, integers):
n = integers
tot = 0
for i in n:
tot += func(i)
def binco(n, k):
return fact(n)/(fact(k)*fact(n-k))
def fact(x):
temp = 1
for i in np.arange(1, x+1, dtype = 'complex128'):
temp *= i
return temp
def find_peaks(data, func_fit, ϵ):
x = data[0]
y = data[1]
z = func_fit(x)
peaks = []
adj = False
adj_start = 0
for i in range(len(y)):
if around(y[i],z[i],ϵ):
peaks.append((i,y[i]))
return pd.DataFrame(peaks)
ζlist = lambda x, n : [(1/(i**(x))) for i in n]