Python cmath.e() Examples
The following are 18
code examples of cmath.e().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
cmath
, or try the search function
.
Example #1
Source File: test_cmath.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_constants(self): e_expected = 2.71828182845904523536 pi_expected = 3.14159265358979323846 self.assertAlmostEqual(cmath.pi, pi_expected, places=9, msg="cmath.pi is {}; should be {}".format(cmath.pi, pi_expected)) self.assertAlmostEqual(cmath.e, e_expected, places=9, msg="cmath.e is {}; should be {}".format(cmath.e, e_expected))
Example #2
Source File: test_cmath.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def test_constants(self): e_expected = 2.71828182845904523536 pi_expected = 3.14159265358979323846 self.assertAlmostEqual(cmath.pi, pi_expected, places=9, msg="cmath.pi is {}; should be {}".format(cmath.pi, pi_expected)) self.assertAlmostEqual(cmath.e, e_expected, places=9, msg="cmath.e is {}; should be {}".format(cmath.e, e_expected))
Example #3
Source File: statistics.py From altanalyze with Apache License 2.0 | 5 votes |
def getModeratedStandardDeviation(comparison_db,probability_statistic): variance_ls=[]; e_sum=0; d0_2nd_moment_gene_sum = 0 for uid in comparison_db: gs = comparison_db[uid] ### Object containing summary statistics needed for each uid (aka feature) if 'Welch' in probability_statistic: df = gs.DF() else: try: df = (gs.N1() + gs.N2()) - 2 except Exception,e: print e, gs, [gs.N1(), gs.N2()];kill sg_squared = gs.FeatureVariance() #print uid, df, sg_squared;kill ###calculate s0 and d0 if sg_squared > 1e-11: zg = math.log(sg_squared) eg = zg - psi(0,df/2.0) + math.log(df/2.0) variance_ls.append((eg,df)) n = len(variance_ls) ### number of uids analyzed ### Get the mean eg for all IDs for (eg,df) in variance_ls: e_sum+=eg e_avg = e_sum/len(variance_ls) ### Calculate the d0 2nd derivitive that will later need to be solved for d0 for (eg,df) in variance_ls: d0_2nd_moment_gene_sum += ((math.pow(eg-e_avg,2)*n)/(n-1)) - psi(1,df/2) d0_2nd_moment_solve = d0_2nd_moment_gene_sum/len(variance_ls) #print [d0_2nd_moment_solve] d0 = NewtonInteration(d0_2nd_moment_solve)*2 #print [d0] d0 = float(d0) e = cm.e s0_squared = math.pow(e,e_avg+psi(0,d0/2) - math.log(d0/2)) return d0, s0_squared
Example #4
Source File: statistics.py From altanalyze with Apache License 2.0 | 5 votes |
def moderateTestStats(pval_db,probability_statistic): """ Calculate a moderated variance for each biological comparison based, based on the average variance of all genes or molecules. This calculation should be identical for moderated student t-test p-values from the R package limma. Small variances might arrise from differences in the precision float values stored by the different languages and threshold from the Newton Iteration step. This implementation currently relies on first, second and third derivitive calculations (e.g., polygamma aka psi functions) from mpmath.""" #tst = salstat_stats.TwoSampleTests([],[]) ### Create object with two empty lists - will analyze in object database afterwards #d0, s0_squared = tst.getModeratedStandardDeviation(pval_db) d0, s0_squared = getModeratedStandardDeviation(pval_db,probability_statistic) #print 'Prior degrees of freedom:',d0, 'and Prior s0 squared:',s0_squared #d0 = 2.054191 #s0_squared = 0.01090202 for uid in pval_db: gs = pval_db[uid] if 'Welch' in probability_statistic: ModeratedWelchTest(gs,d0, s0_squared) else: #tst.ModeratedTTestUnpaired(gs,d0, s0_squared) ModeratedTTestUnpaired(gs,d0,s0_squared) """ if uid == '10367120': print gs.Avg1(), gs.Avg2(), gs.FeatureVariance(), math.sqrt(gs.FeatureVariance()), gs.AdjP() #gs.setFeatureVariance(math.sqrt(gs.FeatureVariance())) #tst.ModeratedTTestUnpaired(gs,d0, s0_squared) #print gs.Avg1(), gs.Avg2(), gs.FeatureVariance(), math.sqrt(gs.FeatureVariance()), gs.AdjP() """
Example #5
Source File: statistics.py From altanalyze with Apache License 2.0 | 5 votes |
def setPval(self,p): self.p = p ### Typically re-set when a moderated statistic is calculated (e.g., emperical Bayesian - eBayes)
Example #6
Source File: test_cmath.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def test_constants(self): e_expected = 2.71828182845904523536 pi_expected = 3.14159265358979323846 self.assertAlmostEqual(cmath.pi, pi_expected, places=9, msg="cmath.pi is {}; should be {}".format(cmath.pi, pi_expected)) self.assertAlmostEqual(cmath.e, e_expected, places=9, msg="cmath.e is {}; should be {}".format(cmath.e, e_expected))
Example #7
Source File: test_cmath.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def check_polar(self, func): def check(arg, expected): got = func(arg) for e, g in zip(expected, got): self.rAssertAlmostEqual(e, g) check(0, (0., 0.)) check(1, (1., 0.)) check(-1, (1., pi)) check(1j, (1., pi / 2)) check(-3j, (3., -pi / 2)) inf = float('inf') check(complex(inf, 0), (inf, 0.)) check(complex(-inf, 0), (inf, pi)) check(complex(3, inf), (inf, pi / 2)) check(complex(5, -inf), (inf, -pi / 2)) check(complex(inf, inf), (inf, pi / 4)) check(complex(inf, -inf), (inf, -pi / 4)) check(complex(-inf, inf), (inf, 3 * pi / 4)) check(complex(-inf, -inf), (inf, -3 * pi / 4)) nan = float('nan') check(complex(nan, 0), (nan, nan)) check(complex(0, nan), (nan, nan)) check(complex(nan, nan), (nan, nan)) check(complex(inf, nan), (inf, nan)) check(complex(-inf, nan), (inf, nan)) check(complex(nan, inf), (inf, nan)) check(complex(nan, -inf), (inf, nan))
Example #8
Source File: test_cmath.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def test_constants(self): e_expected = 2.71828182845904523536 pi_expected = 3.14159265358979323846 self.assertAlmostEqual(cmath.pi, pi_expected, places=9, msg="cmath.pi is {}; should be {}".format(cmath.pi, pi_expected)) self.assertAlmostEqual(cmath.e, e_expected, places=9, msg="cmath.e is {}; should be {}".format(cmath.e, e_expected))
Example #9
Source File: test_cmath.py From ironpython2 with Apache License 2.0 | 5 votes |
def test_constants(self): e_expected = 2.71828182845904523536 pi_expected = 3.14159265358979323846 self.assertAlmostEqual(cmath.pi, pi_expected, places=9, msg="cmath.pi is {}; should be {}".format(cmath.pi, pi_expected)) self.assertAlmostEqual(cmath.e, e_expected, places=9, msg="cmath.e is {}; should be {}".format(cmath.e, e_expected))
Example #10
Source File: test_cmath.py From ironpython3 with Apache License 2.0 | 5 votes |
def check_polar(self, func): def check(arg, expected): got = func(arg) for e, g in zip(expected, got): self.rAssertAlmostEqual(e, g) check(0, (0., 0.)) check(1, (1., 0.)) check(-1, (1., pi)) check(1j, (1., pi / 2)) check(-3j, (3., -pi / 2)) inf = float('inf') check(complex(inf, 0), (inf, 0.)) check(complex(-inf, 0), (inf, pi)) check(complex(3, inf), (inf, pi / 2)) check(complex(5, -inf), (inf, -pi / 2)) check(complex(inf, inf), (inf, pi / 4)) check(complex(inf, -inf), (inf, -pi / 4)) check(complex(-inf, inf), (inf, 3 * pi / 4)) check(complex(-inf, -inf), (inf, -3 * pi / 4)) nan = float('nan') check(complex(nan, 0), (nan, nan)) check(complex(0, nan), (nan, nan)) check(complex(nan, nan), (nan, nan)) check(complex(inf, nan), (inf, nan)) check(complex(-inf, nan), (inf, nan)) check(complex(nan, inf), (inf, nan)) check(complex(nan, -inf), (inf, nan))
Example #11
Source File: test_cmath.py From ironpython3 with Apache License 2.0 | 5 votes |
def test_constants(self): e_expected = 2.71828182845904523536 pi_expected = 3.14159265358979323846 self.assertAlmostEqual(cmath.pi, pi_expected, places=9, msg="cmath.pi is {}; should be {}".format(cmath.pi, pi_expected)) self.assertAlmostEqual(cmath.e, e_expected, places=9, msg="cmath.e is {}; should be {}".format(cmath.e, e_expected))
Example #12
Source File: AdaBoost.py From statistical-learning-methods-note with Apache License 2.0 | 5 votes |
def computeBaseClassifierCoefficient(self, classifierIdx): ''' 输入当前正在训练的基分类器下标(从0开始),计算当前的基分类器系数 alpha 。 :param classifierIdx: 当前分类器下标(从0开始) :return: ''' self.alphaList[classifierIdx] = (1.0 / 2 * \ cmath.log((1.0-self.eList[classifierIdx])/self.eList[classifierIdx], cmath.e)\ ).real
Example #13
Source File: test_cmath.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def check_polar(self, func): def check(arg, expected): got = func(arg) for e, g in zip(expected, got): self.rAssertAlmostEqual(e, g) check(0, (0., 0.)) check(1, (1., 0.)) check(-1, (1., pi)) check(1j, (1., pi / 2)) check(-3j, (3., -pi / 2)) inf = float('inf') check(complex(inf, 0), (inf, 0.)) check(complex(-inf, 0), (inf, pi)) check(complex(3, inf), (inf, pi / 2)) check(complex(5, -inf), (inf, -pi / 2)) check(complex(inf, inf), (inf, pi / 4)) check(complex(inf, -inf), (inf, -pi / 4)) check(complex(-inf, inf), (inf, 3 * pi / 4)) check(complex(-inf, -inf), (inf, -3 * pi / 4)) nan = float('nan') check(complex(nan, 0), (nan, nan)) check(complex(0, nan), (nan, nan)) check(complex(nan, nan), (nan, nan)) check(complex(inf, nan), (inf, nan)) check(complex(-inf, nan), (inf, nan)) check(complex(nan, inf), (inf, nan)) check(complex(nan, -inf), (inf, nan))
Example #14
Source File: test_cmath.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def test_constants(self): e_expected = 2.71828182845904523536 pi_expected = 3.14159265358979323846 self.assertAlmostEqual(cmath.pi, pi_expected, places=9, msg="cmath.pi is {}; should be {}".format(cmath.pi, pi_expected)) self.assertAlmostEqual(cmath.e, e_expected, places=9, msg="cmath.e is {}; should be {}".format(cmath.e, e_expected))
Example #15
Source File: test_cmath.py From oss-ftp with MIT License | 5 votes |
def test_constants(self): e_expected = 2.71828182845904523536 pi_expected = 3.14159265358979323846 self.assertAlmostEqual(cmath.pi, pi_expected, places=9, msg="cmath.pi is {}; should be {}".format(cmath.pi, pi_expected)) self.assertAlmostEqual(cmath.e, e_expected, places=9, msg="cmath.e is {}; should be {}".format(cmath.e, e_expected))
Example #16
Source File: test_cmath.py From BinderFilter with MIT License | 5 votes |
def test_constants(self): e_expected = 2.71828182845904523536 pi_expected = 3.14159265358979323846 self.assertAlmostEqual(cmath.pi, pi_expected, places=9, msg="cmath.pi is {}; should be {}".format(cmath.pi, pi_expected)) self.assertAlmostEqual(cmath.e, e_expected, places=9, msg="cmath.e is {}; should be {}".format(cmath.e, e_expected))
Example #17
Source File: test_cmath.py From ironpython2 with Apache License 2.0 | 5 votes |
def check_polar(self, func): def check(arg, expected): got = func(arg) for e, g in zip(expected, got): self.rAssertAlmostEqual(e, g) check(0, (0., 0.)) check(1, (1., 0.)) check(-1, (1., pi)) check(1j, (1., pi / 2)) check(-3j, (3., -pi / 2)) inf = float('inf') check(complex(inf, 0), (inf, 0.)) check(complex(-inf, 0), (inf, pi)) check(complex(3, inf), (inf, pi / 2)) check(complex(5, -inf), (inf, -pi / 2)) check(complex(inf, inf), (inf, pi / 4)) check(complex(inf, -inf), (inf, -pi / 4)) check(complex(-inf, inf), (inf, 3 * pi / 4)) check(complex(-inf, -inf), (inf, -3 * pi / 4)) nan = float('nan') check(complex(nan, 0), (nan, nan)) check(complex(0, nan), (nan, nan)) check(complex(nan, nan), (nan, nan)) check(complex(inf, nan), (inf, nan)) check(complex(-inf, nan), (inf, nan)) check(complex(nan, inf), (inf, nan)) check(complex(nan, -inf), (inf, nan))
Example #18
Source File: salstat_stats.py From altanalyze with Apache License 2.0 | 4 votes |
def chisqprob(chisq,df): """ Returns the (1-tailed) probability value associated with the provided chi-square value and df. Adapted from chisq.c in Gary Perlman's |Stat. Usage: chisqprob(chisq,df) """ BIG = 20.0 def ex(x): BIG = 20.0 if x < -BIG: return 0.0 else: return math.exp(x) if chisq <=0 or df < 1: return 1.0 a = 0.5 * chisq if df%2 == 0: even = 1 else: even = 0 if df > 1: y = ex(-a) if even: s = y else: s = 2.0 * zprob(-math.sqrt(chisq)) if (df > 2): chisq = 0.5 * (df - 1.0) if even: z = 1.0 else: z = 0.5 if a > BIG: if even: e = 0.0 else: e = math.log(math.sqrt(math.pi)) c = math.log(a) while (z <= chisq): e = math.log(z) + e s = s + ex(c*z-a-e) z = z + 1.0 return s else: if even: e = 1.0 else: e = 1.0 / math.sqrt(math.pi) / math.sqrt(a) c = 0.0 while (z <= chisq): e = e * (a/float(z)) c = c + e z = z + 1.0 return (c*y+s) else: return s