logarithm

Matplotlib logarithmic scale with zero value [duplicate]

旧城冷巷雨未停 提交于 2019-11-27 07:10:26
问题 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

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

ε祈祈猫儿з 提交于 2019-11-27 06:41:54
问题 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

Log to the base 2 in python

一个人想着一个人 提交于 2019-11-27 05:13:04
问题 How should I compute log to the base two in python. Eg. I have this equation where I am using log base 2 import math e = -(t/T)* math.log((t/T)[, 2]) 回答1: It's good to know that but also know that math.log takes an optional second argument which allows you to specify the base: In [22]: import math In [23]: math.log? Type: builtin_function_or_method Base Class: <type 'builtin_function_or_method'> String Form: <built-in function log> Namespace: Interactive Docstring: log(x[, base]) -> the

Logarithmic y-axis bins in python

一世执手 提交于 2019-11-27 04:21:39
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 the plt.hist line and also I tried ax.set_yscale('log') , but nothing seems to work. I either get an

What kind of logarithm functions / methods are available in objective-c / cocoa-touch?

强颜欢笑 提交于 2019-11-26 23:35:13
问题 I've tried searching for logarithm + objective-c, but all I get is math test pages from teachers, or explanations what a logarithm is ;) I've got some measurements that are like 83912.41234 and others are 32.94232. I need to press down this huge spectrum into something between 0 and 100, and that 32.94232 would habe to be at least something bigger than 2, where the 83912.41234 would be something near 100. So I think a logarithm function will be my friend here. UPDATE: I've came across the

How can I specify the base for Math.log() in JavaScript?

廉价感情. 提交于 2019-11-26 23:23:45
I need a log function for JavaScript, but it needs to be base 10. I can't see any listing for this, so I'm assuming it's not possible. Are there any math wizards out there who know a solution for this? Peter "Change of Base" Formula / Identity The numerical value for logarithm to the base 10 can be calculated with the following identity. Since Math.log(x) in JavaScript returns the natural logarithm of x (same as ln(x) ), for base 10 you can divide by Math.log(10) (same as ln(10) ): function log10(val) { return Math.log(val) / Math.LN10; } Math.LN10 is a built-in precomputed constant for Math

NumPy: Logarithm with base n

人盡茶涼 提交于 2019-11-26 20:22:55
问题 From the numpy documentation on logarithms, I have found functions to take the logarithm with base e, 2, and 10: import numpy as np np.log(np.e**3) #3.0 np.log2(2**3) #3.0 np.log10(10**3) #3.0 However, how do I take the logarithm with base n (e.g. 42) in numpy? 回答1: To get the logarithm with a custom base using math.log: import math number = 74088 # = 42**3 base = 42 exponent = math.log(number, base) # = 3 To get the logarithm with a custom base using numpy.log: import numpy as np array = np

Histogram with Logarithmic Scale and custom breaks

天大地大妈咪最大 提交于 2019-11-26 20:14:49
I'm trying to generate a histogram in R with a logarithmic scale for y. Currently I do: hist(mydata$V3, breaks=c(0,1,2,3,4,5,25)) This gives me a histogram, but the density between 0 to 1 is so great (about a million values difference) that you can barely make out any of the other bars. Then I've tried doing: mydata_hist <- hist(mydata$V3, breaks=c(0,1,2,3,4,5,25), plot=FALSE) plot(rpd_hist$counts, log="xy", pch=20, col="blue") It gives me sorta what I want, but the bottom shows me the values 1-6 rather than 0, 1, 2, 3, 4, 5, 25. It's also showing the data as points rather than bars. barplot

Big O notation Log Base 2 or Log Base 10 [duplicate]

拈花ヽ惹草 提交于 2019-11-26 19:50:25
问题 This question already has an answer here: Is Big O(logn) log base e? 7 answers When articles/question state that the Big O running time of the algorithm is O(LogN) . For example Quicksort has a Big O running time of O (LogN) where the it is Log base 10 but Height of binary tree is O(LogN+1) where it is Log base 2 Question 1)I am confused over whether is it Log base 10 or Log base 2 as different articles use different bases for their Logarithm . 2) Does it make a difference if its Log base 2

What would cause an algorithm to have O(log n) complexity?

柔情痞子 提交于 2019-11-26 19:16:39
My knowledge of big-O is limited, and when log terms show up in the equation it throws me off even more. Can someone maybe explain to me in simple terms what a O(log n) algorithm is? Where does the logarithm come from? This specifically came up when I was trying to solve this midterm practice question: Let X(1..n) and Y(1..n) contain two lists of integers, each sorted in nondecreasing order. Give an O(log n)-time algorithm to find the median (or the nth smallest integer) of all 2n combined elements. For ex, X = (4, 5, 7, 8, 9) and Y = (3, 5, 8, 9, 10), then 7 is the median of the combined list