logarithm

Asymptotic Complexity of Logarithms and Powers

前提是你 提交于 2019-12-18 05:27:16
问题 So, clearly, log(n) is O(n). But, what about (log(n))^2? What about sqrt(n) or log(n)--what bounds what? There's a family of comparisons like this: n^a versus (log(n))^b I run into these comparisons a lot, and I've never come up with a good way to solve them. Hints for tactics for solving the general case? Thanks, Ian EDIT: I'm not talking about the computational complexity of calculating the values of these functions. I'm talking about the functions themselves. E.g., f(n)=n is an upper bound

Logarithmic yscale in imshow [duplicate]

社会主义新天地 提交于 2019-12-18 05:04:46
问题 This question already has answers here : How to plot an image with non-linear y-axis with Matplotlib using imshow? (4 answers) Closed 3 years ago . Possible Duplicate: Plot logarithmic axes with matplotlib in python I have a 50*1050 matrix in which the dimension 50 represents the frequency and 1050 the time. I tried to plot it using imshow and I get this image: But i want to highlight the lower frequencies, which means I need to use the logarithmic scale for the y scale. I searched a lot but

What is O(log* N)?

独自空忆成欢 提交于 2019-12-17 17:26:39
问题 What is O(log* N) ? I know big-Oh, the log* is unknown. 回答1: O( log* N ) is "iterated logarithm": In computer science, the iterated logarithm of n, written log* n (usually read "log star"), is the number of times the logarithm function must be iteratively applied before the result is less than or equal to 1. 回答2: The log* N bit is an iterated algorithm which grows very slowly, much slower than just log N . You basically just keep iteratively 'logging' the answer until it gets below one (E.g:

R ggplot2: using stat_summary (mean) and logarithmic scale

流过昼夜 提交于 2019-12-17 17:13:42
问题 I have a bunch of measurements over time and I want to plot them in R. Here is a sample of my data. I've got 6 measurements for each of 4 time points: values <- c (1012.0, 1644.9, 837.0, 1200.9, 1652.0, 981.5, 2236.9, 1697.5, 2087.7, 1500.8, 2789.3, 1502.9, 2051.3, 3070.7, 3105.4, 2692.5, 1488.5, 1978.1, 1925.4, 1524.3, 2772.0, 1355.3, 2632.4, 2600.1) time <- factor (rep (c(0, 12, 24, 72), c(6, 6, 6, 6))) The scale of these data is arbitrary, and in fact I'm going to normalize it so that the

Fast fixed point pow, log, exp and sqrt

瘦欲@ 提交于 2019-12-17 10:25:28
问题 I've got a fixed point class (10.22) and I have a need of a pow, a sqrt, an exp and a log function. Alas I have no idea where to even start on this. Can anyone provide me with some links to useful articles or, better yet, provide me with some code? I'm assuming that once I have an exp function then it becomes relatively easy to implement pow and sqrt as they just become. pow( x, y ) => exp( y * log( x ) ) sqrt( x ) => pow( x, 0.5 ) Its just those exp and log functions that I'm finding

ValueError: math domain error

半世苍凉 提交于 2019-12-17 10:24:36
问题 I was just testing an example from Numerical Methods in Engineering with Python . from numpy import zeros, array from math import sin, log from newtonRaphson2 import * def f(x): f = zeros(len(x)) f[0] = sin(x[0]) + x[1]**2 + log(x[2]) - 7.0 f[1] = 3.0*x[0] + 2.0**x[1] - x[2]**3 + 1.0 f[2] = x[0] + x[1] + x[2] -5.0 return f x = array([1.0, 1.0, 1.0]) print newtonRaphson2(f,x) When I run it, it shows the following error: File "example NR2method.py", line 8, in f f[0] = sin(x[0]) + x[1]**2 + log

Logarithmic y-axis bins in python

一曲冷凌霜 提交于 2019-12-17 07:26:16
问题 I'm trying to create a histogram of a data column and plot it logarithmically ( y-axis ) and I'm not sure why the following code does not work: import numpy as np import matplotlib.pyplot as plt data = np.loadtxt('foo.bar') fig = plt.figure() ax = fig.add_subplot(111) plt.hist(data, bins=(23.0, 23.5,24.0,24.5,25.0,25.5,26.0,26.5,27.0,27.5,28.0)) ax.set_xlim(23.5, 28) ax.set_ylim(0, 30) ax.grid(True) plt.yscale('log') plt.show() I've also tried instead of plt.yscale('log') adding Log=true in

Logarithmic y-axis bins in python

自古美人都是妖i 提交于 2019-12-17 07:26:03
问题 I'm trying to create a histogram of a data column and plot it logarithmically ( y-axis ) and I'm not sure why the following code does not work: import numpy as np import matplotlib.pyplot as plt data = np.loadtxt('foo.bar') fig = plt.figure() ax = fig.add_subplot(111) plt.hist(data, bins=(23.0, 23.5,24.0,24.5,25.0,25.5,26.0,26.5,27.0,27.5,28.0)) ax.set_xlim(23.5, 28) ax.set_ylim(0, 30) ax.grid(True) plt.yscale('log') plt.show() I've also tried instead of plt.yscale('log') adding Log=true in

How can I compute a base 2 logarithm without using the built-in math functions in C#?

江枫思渺然 提交于 2019-12-14 04:17:54
问题 How can I compute a base 2 logarithm without using the built-in math functions in C#? I use Math.Log and BigInteger.Log repeatedly in an application millions of times and it becomes painfully slow. I am interested in alternatives that use binary manipulation to achieve the same. Please bear in mind that I can make do with Log approximations in case that helps speed up execution times. 回答1: For the BigInteger you could use the toByteArray() method and then manually find the most significant 1

Negative axis in a log plot

我的未来我决定 提交于 2019-12-13 16:24:11
问题 I'm plotting a log plot using matplotlib. My values go from 1 to 35. fig=plt.figure(figsize=(7,7)) fig.subplots_adjust(top=0.75, right=0.9) ax=fig.add_subplot(111) ax.plot(x, y, marker='o', color='black', ls='') ax.set_xscale('log') ax.set_yscale('log') I would like to set the x- and y-axis starting from values lower than 1, but if I use ax.axis([-10,45,-10,45]) it doesn't work. I know that it is because I'm using a log scale, but is there a way to solve the problem obtaining the axis I want?