logarithm

Matlab: making the grid in plot logarithmic

梦想的初衷 提交于 2019-12-02 04:22:53
I have plotted to vectors against each other, and they are already logarithmic and everything is fine with that. But now that I have my plot i want the grid to be logarithmic. I write "grid on" in my code, and I think there should be a way to do this in the plot, but I can't remember how. How do I make the grid logarithmic? If you use loglog , semilogx or semilogy instead of plot , the grid will automatically be on a log scale for the corresponding axes when using grid on . If you have already plotted the axes, you can execute the following on the command line: set(gca,'yscale','log') %# to

How to plot a linear regression to a double logarithmic R plot?

我只是一个虾纸丫 提交于 2019-12-01 21:55:13
I have the following data: someFactor = 500 x = c(1:250) y = x^-.25 * someFactor which I show in a double logarithmic plot: plot(x, y, log="xy") Now I "find out" the slope of the data using a linear model: model = lm(log(y) ~ log(x)) model which gives: Call: lm(formula = log(y) ~ log(x)) Coefficients: (Intercept) log(x) 6.215 -0.250 Now I'd like to plot the linear regression as a red line, but abline does not work: abline(model, col="red") What is the easiest way to add a regression line to my plot? lines(log(x), exp(predict(model, newdata=list(x=log(x)))) ,col="red") The range of values for x

How do I calculate a logarithm in iOS? [duplicate]

戏子无情 提交于 2019-12-01 17:29:28
问题 This question already has answers here : What kind of logarithm functions / methods are available in objective-c / cocoa-touch? (3 answers) Closed 5 years ago . I want to calculate a logarithm in iOS. Can Objective-C do this? 回答1: You can use the C functions for calculating logarithms #import <math.h> double myLog = log(10); You can also see here: What kind of logarithm functions / methods are available in objective-c / cocoa-touch? 回答2: We can use the same math functions which are available

How to find antilog for a number using java programm?

前提是你 提交于 2019-12-01 11:51:27
can someone please tell me How to find antilog for a number using java program? i am new to this java Math.log(10) gives the log value. now I want to take this output and verify using antilog that program is giving right value.please help me. mathematically: e^(ln x) = x in java: Math.pow(Math.E, (Math.log(x)) == x; //equals true You can use Logarithm class in Java to calculate log and antilog. More on this is provided here . 来源: https://stackoverflow.com/questions/18209676/how-to-find-antilog-for-a-number-using-java-programm

log2 of an integer that is a power of 2 [duplicate]

白昼怎懂夜的黑 提交于 2019-12-01 04:15:41
This question already has an answer here: Is there any fast algorithm to compute log2 for numbers that are all power of 2? 2 answers Fastest way of computing the power that a “power of 2” number used? 5 answers Is there an efficient way to find the log2 of a number assuming it's a power of 2. I know the obvious ways like having a table or for (log2=0;x!=1;x>>=1,log2++); But I am wondering if there is a more efficient/elegant way. You can just count the number of leading or trailing zero bits, because any exact power-of-two is represented as a single 1 bit, with all other bits 0. Many CPUs have

O(n log log n) time complexity

耗尽温柔 提交于 2019-12-01 03:34:28
I have a short program here: Given any n: i = 0; while (i < n) { k = 2; while (k < n) { sum += a[j] * b[k] k = k * k; } i++; } The asymptotic running time of this is O(n log log n). Why is this the case? I get that the entire program will at least run n times. But I'm not sure how to find log log n. The inner loop is depending on k * k, so it's obviously going to be less than n. And it would just be n log n if it was k / 2 each time. But how would you figure out the answer to be log log n? For mathematical proof, inner loop can be written as: T(n) = T(sqrt(n)) + 1 w.l.o.g assume 2 ^ 2 ^ (t-1)<

Time complexity for dependant nested for loop?

对着背影说爱祢 提交于 2019-12-01 03:10:12
问题 Can you explain me how to find time complexity for this? sum=0; for(k=1;k<=n;k*=2) for(j=1;j<=k;j++) sum++; So, i know the outer loop has time complexity of O(logn), but since the iterations of the inner loop depends on the value of the outer loop, the complexity of this algorithm is not O(nlogn). The book says it is O(n). I really dont understand how it is O(n)...Can someone please explain it... I'll be really grateful if u could go into the details btw :D A mathematical solution would help

log2 of an integer that is a power of 2 [duplicate]

非 Y 不嫁゛ 提交于 2019-12-01 02:28:49
问题 This question already has answers here : Is there any fast algorithm to compute log2 for numbers that are all power of 2? (2 answers) Fastest way of computing the power that a “power of 2” number used? (5 answers) Closed 2 years ago . Is there an efficient way to find the log2 of a number assuming it's a power of 2. I know the obvious ways like having a table or for (log2=0;x!=1;x>>=1,log2++); But I am wondering if there is a more efficient/elegant way. 回答1: You can just count the number of

Using log base 10 in a formula in Java

余生颓废 提交于 2019-12-01 02:05:40
I'm trying to write a Java program that can take values and put them into a formula involving log base 10. How can I calculate log 10 in Java? Mysticial It looks like Java actually has a log10 function: Math.log10(x) Otherwise, just use math: Math.log(x) / Math.log(10) http://docs.oracle.com/javase/7/docs/api/java/lang/Math.html Louis Wasserman Math.log10(x) suffices for floating-point numbers. If you need integer log base 10, and you can use third-party libraries, Guava provides IntMath.log10(int, RoundingMode) . (Disclosure: I contribute to Guava.) sri You can do this too class log { public

O(n log log n) time complexity

为君一笑 提交于 2019-12-01 00:21:34
问题 I have a short program here: Given any n: i = 0; while (i < n) { k = 2; while (k < n) { sum += a[j] * b[k] k = k * k; } i++; } The asymptotic running time of this is O(n log log n). Why is this the case? I get that the entire program will at least run n times. But I'm not sure how to find log log n. The inner loop is depending on k * k, so it's obviously going to be less than n. And it would just be n log n if it was k / 2 each time. But how would you figure out the answer to be log log n?