logarithm

Logarithmic plot of a cumulative distribution function in matplotlib

佐手、 提交于 2019-11-29 17:22:56
问题 I have a file containing logged events. Each entry has a time and latency. I'm interested in plotting the cumulative distribution function of the latencies. I'm most interested in tail latencies so I want the plot to have a logarithmic y-axis. I'm interested in the latencies at the following percentiles: 90th, 99th, 99.9th, 99.99th, and 99.999th. Here is my code so far that generates a regular CDF plot: # retrieve event times and latencies from the file times, latencies = read_in_data_from

Logarithm in C++ and assembly

…衆ロ難τιáo~ 提交于 2019-11-29 17:06:13
Apparently MSVC++2017 toolset v141 (x64 Release configuration) doesn't use FYL2X x86_64 assembly instruction via a C/C++ intrinsic, but rather C++ log() or log2() usages result in a real call to a long function which seems to implement an approximation of logarithm (without using FYL2X ). The performance I measured is also strange: log() (natural logarithm) is 1.7667 times faster than log2() (base 2 logarithm), even though base 2 logarithm should be easier for the processor because it stores the exponent in binary format (and mantissa too), and that seems why the CPU instruction FYL2X

java.lang.Math.log replaced by intrinsic call, why not java.lang.Math.exp()?

故事扮演 提交于 2019-11-29 16:11:51
I'm reasking a question that had too little attention I think: Why does this simple code (simply a call to Math.log() ): Double thisdouble = Math.log(10); With a breakpoint on line 275 of Math.class of the jdk1.7.0_11: 274 public static double log(double a) { 275 return StrictMath.log(a); // default impl. delegates to StrictMath 276 } Not stop execution in debug mode? Can somebody try this on his/her own machine (I'm using Eclipse)? Calling Math.exp() and debugging the Math.exp (line 254) function does work... EDIT: The answer to the above is that Math.log is replaced by an intrinsic call by

Time Complexity of a loop that integer divides the loop counter by a constant

↘锁芯ラ 提交于 2019-11-29 16:08:00
I'm trying to calculate the time complexity of a simple algorithm in big O notation, but one part of it is seriously boggling my mind. Here is a simplified version of the algorithm: int a=n while(a>0) { //for loop with time complexity n^3 a = a/8 } In this instance, it's integer division, so the while loop will terminate after a's value drops below 8. I'm not sure how to express this in terms of n. I'd also like to know how to tackle future calculations like this, where the number of loops isn't too easy to define. I find it easier to do it the other way around in cases like this. What is the

Is Swift dictionary of indexed for performance? Even for exotic types (UUID)?

◇◆丶佛笑我妖孽 提交于 2019-11-29 15:56:34
I want to construct some arrays that will remain in order to get fast searches. If I use something like this: let dictionary: [Int:Int] = [:] for i in 0 ..< 10000000 { dictionary[i] = 0 } Would the query: dictionary[n] == nil be performed in logarithmic time? If yes, is it the same for other types: Float, Double, String. And finally, I need it to work with the UUID type, will it work? Hamish Swift's Dictionary is implemented with a hash table , therefore lookups will typically be done in O(1) time, assuming a good hashing algorithm. As @rmaddy says , this therefore means that the type of key

Logarithm of the very-very large number

亡梦爱人 提交于 2019-11-29 15:28:37
I have to find log of very large number. I do this in C++ I have already made a function of multiplication, addition, subtraction, division, but there were problems with the logarithm. I do not need code, I need a simple idea how to do it using these functions. Thanks. P.S. Sorry, i forgot to tell you: i have to find only binary logarithm of that number P.S.-2 I found in Wikipedia : int floorLog2(unsigned int n) { if (n == 0) return -1; int pos = 0; if (n >= (1 <<16)) { n >>= 16; pos += 16; } if (n >= (1 << 8)) { n >>= 8; pos += 8; } if (n >= (1 << 4)) { n >>= 4; pos += 4; } if (n >= (1 << 2))

Make y-axis logarithmic in histogram using R [duplicate]

大憨熊 提交于 2019-11-29 12:13:03
问题 This question already has an answer here: Histogram with Logarithmic Scale and custom breaks 7 answers Hi I'm making histogram using R, but the number of Y axis is so large that I need to turn it into logarithmic.See below my script: hplot<-read.table("libl") hplot pdf("first_end") hist(hplot$V1, breaks=24, xlim=c(0,250000000), ylim=c(0,2000000),main="first end mapping", xlab="Coordinates") dev.off() So how should I change my script? thx 回答1: You can save the histogram data to tweak it before

Highcharts: Displaying zero values in logarithmic scale

天大地大妈咪最大 提交于 2019-11-29 12:06:32
I am working with logarithmic scale in the y-axis I know that log(0) doesn't exist but I need to draw 0 values, and I need a log scale. I read in other answers that changing the zero values to null solve the problem, but it is not working for me. See the example: http://jsfiddle.net/QEK3x/15/ Thank you in advance. SteveP Although not perfect, the best I came up with was to set the zero point to 0.0001 and then set the y-axis min to 0.0001: http://jsfiddle.net/6LHT8/ yAxis: { min:0.0001, type: 'logarithmic' }, series: [{ data: [100,10,0.0001,0.1,0.01,0.1] }] Also, this answer may nelp:

Finding the exponent of n = 2**x using bitwise operations [logarithm in base 2 of n]

你。 提交于 2019-11-29 11:55:49
问题 Is there a straightforward way to extracting the exponent from a power of 2 using bitwise operations only? EDIT: Although the question was originally about bitwise operations, the thread is a good read also if you are wondering "What's the fastest way to find X given Y = 2 X in Python ?"** I am currently trying to optimize a routine (Rabin-Miller primality test) that reduces an even number N in the forms 2**s * d . I can get the 2**s part by: two_power_s = N & -N but I can't find a way to

Log of a very large number

旧巷老猫 提交于 2019-11-29 11:21:25
I'm dealing with the BigInteger class with numbers in the order of 2 raised to the power 10,000,000. The BigInteger Log function is now the most expensive function in my algorithm and I am desperately looking for an alternative. Since I only need the integral part of the log, I came across this answer which seems brilliant in terms of speed but for some reason I am not getting accurate values. I do not care about the decimal part but I do need to get an accurate integral part whether the value is floored or ceiled as long as I know which. Here is the function I implemented: public static