logarithm

Highcharts - best way to handle and display zero (or negative) values in a line chart series with logarithmic Y axis

懵懂的女人 提交于 2019-11-29 10:38:46
In my HighChart line graphs, the series data is being fed from my Ruby on Rails application dynamically. Sometimes the series values are zeros or less which is a problem for HighCharts and it throws the following exception: Highcharts Error #10 Can't plot zero or subzero values on a logarithmic axis So as a work-around, I process my ruby array to conditionally replace a zero of less value with an insignificant positive number, .e.g. 0.00001 as shown below: oil_vol_array = d_array[1].map { |e| (e < 0.0001) ? 0.0001 : e.round(3) } This prevents the exception being thrown, but the display shows

Asymptotic Complexity of Logarithms and Powers

青春壹個敷衍的年華 提交于 2019-11-29 08:52:01
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 on g(n)=log(n) because f(n)<=c*g(n) for c=1 and n0 > 0. log(n)^a is always O(n^b), for any positive

I need help proving that if f(n) = O(g(n)) implies 2^(f(n)) = O(2^g(n)))

China☆狼群 提交于 2019-11-29 08:40:23
问题 In a previous problem, I showed (hopefully correctly) that f(n) = O(g(n)) implies lg(f(n)) = O(lg(g(n))) with sufficient conditions (e.g., lg(g(n)) >= 1, f(n) >= 1 , and sufficiently large n). Now, I need to prove OR disprove that f(n) = O(g(n)) implies 2^(f(n)) = O(2^g(n))) . Intuitively, this makes sense, so I figured I could prove it with help from the previous theorem. I noticed that f(n) can be rewritten as lg(2^f(n)) and that g(n) is just lg(2^g(n)) , which got me excited...this is

Logarithmic yscale in imshow [duplicate]

不打扰是莪最后的温柔 提交于 2019-11-29 07:38:36
This question already has an answer here: How to plot an image with non-linear y-axis with Matplotlib using imshow? 4 answers 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 I didn't find any effective solution yet. What I need exactly is that the first row of the matrix should occupy the biggest

How to expand and compute log(a + b)? [closed]

半世苍凉 提交于 2019-11-28 17:44:43
I would like to know the complete expansion of log(a + b) . For example log(a * b) = log(a) + log(b); log(a / b) = log(a) - log(b); Similar to this, is there any expansion for log(a + b)? In general, one doesn't expand out log(a + b) ; you just deal with it as is. That said, there are occasionally circumstances where it makes sense to use the following identity: log(a + b) = log(a * (1 + b/a)) = log a + log(1 + b/a) (In fact, this identity is often used when implementing log in math libraries). Why would you ever want to do this? The property that log (a*b) = log a + log b is only useful

De Bruijn-like sequence for `2^n - 1`: how is it constructed?

混江龙づ霸主 提交于 2019-11-28 16:51:56
I'm looking at the entry Find the log base 2 of an N-bit integer in O(lg(N)) operations with multiply and lookup from Bit Twiddling hacks . I can easily see how the second algorithm in that entry works static const int MultiplyDeBruijnBitPosition2[32] = { 0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9 }; r = MultiplyDeBruijnBitPosition2[(uint32_t)(v * 0x077CB531U) >> 27]; which calculates n = log2 v where v is known to be a power of 2. In this case 0x077CB531 is an ordinary De Bruijn sequence, and the rest is obvious.

Difference between O(n) and O(log(n)) - which is better and what exactly is O(log(n))?

你离开我真会死。 提交于 2019-11-28 15:56:30
问题 This is my first course in data structures and every lecture / TA lecture , we talk about O(log(n)) . This is probably a dumb question but I'd appreciate if someone can explain to me exactly what does it mean !? 回答1: It means that the thing in question (usually running time) scales in a manner that is consistent with the logarithm of its input size. Big-O notation doesn't mean an exact equation, but rather a bound . For instance, the output of the following functions is all O(n): f(x) = 3x g

Matplotlib logarithmic scale with zero value [duplicate]

旧街凉风 提交于 2019-11-28 12:36:39
This question already has an answer here: Logscale plots with zero values in matplotlib 1 answer I have a very large and sparse dataset of spam twitter accounts and it requires me to scale the x axis in order to be able to visualize the distribution (histogram, kde etc) and cdf of the various variables (tweets_count, number of followers/following etc). > describe(spammers_class1$tweets_count) var n mean sd median trimmed mad min max range skew kurtosis se 1 1 1076817 443.47 3729.05 35 57.29 43 0 669873 669873 53.23 5974.73 3.59 In this dataset, the value 0 has a huge importance (actually 0

ggplot barplot : How to display small positive numbers with log scaled y-axis

寵の児 提交于 2019-11-28 12:26:43
问题 Main issue: I want to display the data from 0 to 1.0 as an upward bar (starting from 0) but do not want the intervals to be equally spaced but log spaced. I am trying to display the column labeled "mean" in the dataset below as a bar plot in ggplot but as the numbers are very small, I would like to show the y-axis on a log scale rather than log transform the data itself. In other words, I want to have upright bars with y-axis labels as 0, 1e-8, 1e-6 1e-4 1e-2 and 1e-0 (i.e. from 0 to 1.0 but

How can I compare the performance of log() and fp division in C++?

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-28 12:00:44
I’m using a log-based class in C++ to store very small floating-point values (as the values otherwise go beyond the scope of double ). As I’m performing a large number of multiplications, this has the added benefit of converting the multiplications to sums. However, at a certain point in my algorithm, I need to divide a standard double value by an integer value and than do a *= to a log-based value. I have overloaded the *= operator for my log-based class and the right-hand side value is first converted to a log-based value by running log() and than added to the left-hand side value. Thus the