logarithm

Adding a log in asymptotic analysis

荒凉一梦 提交于 2019-12-13 05:01:54
问题 Have a problem I'm trying to work through and would very much appreciate some assistance! What's the time complexity of... for (int j = 1 to n) { k = j; while (k < n) { sum += a[k] * b[k]; k += log n; } } The outer for loop runs n times. I'm not sure how to deal with k+= log n in the inner loop. My thought is that it's O(n^2). Adding log(n) to k isn't quite getting an additional n loops, but I think it is less than O(n*log n) would be. Obviously, that's just a guess, and any help in figuring

Extend an axis limit to -1 when that axis is logarithmic in R

房东的猫 提交于 2019-12-13 01:42:50
问题 I am doing the following: x = c(0, 1, 2, 3, 4, 5) y = x ^ 2 plot(x, y, log="y") What I want is that the graph also show me the scatter point at (x, y)=(0, 0). I know that log(0) = -Inf . This will be the case when I am doing log(x) but here I am not doing log(x) . Rather, I am just changing the scale of y-axis to be logarithmic. Therefore, I need to know if there is some way for me to display the scatter point (x, y) = (0, 0) as well. 回答1: No, what you are asking is mathematically impossible,

Log base n of x [closed]

柔情痞子 提交于 2019-12-12 13:21:01
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . I have a little problem. Who knows how we can calculate the log base n with Shift_L or Shift_R? for example: for n=2 we had this solution: int log(int n){ int res = 0; while((n>>=1)) res++; return res; } 回答1: You don't seem to want the logarithm for a base b , but the largest integer n so that n <= log_b(x) . If

Logarithmic sampling

三世轮回 提交于 2019-12-12 10:18:57
问题 I am working with values between [minValue,maxValue] and I want to create a vector of values in between this range. But I want more values near to the minValue. Example: min = 1 max = 100 vector = [1,1.1,1.5,2,3,5,10,15,30,50,100]; Something like that. The goal is to be more accurate around the minimum. Is that possible to implement that? 回答1: You can start with by generating numbers from 0 to 1 with constant step (for example 0.1). Then power them with some exponent - the bigger exponent,

Logarithm of the very-very large number

為{幸葍}努か 提交于 2019-12-12 07:07:18
问题 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; }

min and max axis value not respected in HighCharts chart with a logarithmic axis

大兔子大兔子 提交于 2019-12-12 02:49:17
问题 I have the a stacked column chart with a logarithmic scaled y axis (JSFiddle here, adapted from a basic demo chart) $(function () { $('#container').highcharts({ chart: { type: 'column' }, yAxis: { type:'logarithmic', min: 0.3, // I WANT THE Y-AXIS TO START AT 0.3 min: 25, // I WANT THE Y-AXIS TO END AT 25 endOfTick:false, maxPadding:0, tickInterval:0.1, }, plotOptions: { column: { stacking: 'normal', } }, series: [{ data: [5, 3, 4, 7, 2] }, { data: [2, 2, 3, 2, 1] }, { data: [3, 4, 4, 2, 5] }

Log-log plot/graph of algorithm time complexity [closed]

我的未来我决定 提交于 2019-12-12 01:14:13
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 5 years ago . I just wrote the quick and merge sort algorithms and I want to make a log-log plot of their run time vs size of array to sort. As I have never done this my question is does it matter if I choose arbitrary numbers for the array length (size of input) or should I follow a

Logarithmic Axis on Visiblox

眉间皱痕 提交于 2019-12-11 22:32:32
问题 I'm having trouble setting the range of an axis so that the minimum is below 1. I understand that no value less than 0 can be plotted by I don't understand why values below 1 cannot be viewed unless I can pan to them. Is there any reason for this? Or a way of resolving it? 回答1: While this may be as designed, you could still achieve the affect you're looking for by scaling your data up into the valid range for the logarithmic axis. Then you could override the label function to set the labels

time complexity for this algorithm with two for loops

99封情书 提交于 2019-12-11 12:16:28
问题 Can you explain me how to find time complexity for this sum1=0; for(k=1;k<=n;k*=2) for(j=1;j<n;j++) sum++ I am taking consideration of N as base, and tried calculating how many iteration happens when n=1,2,3...n But i am not able to genralize it. PLease some one explain me, thoroughly. I have even checked other queries of similar type like: saying it follows 1,2,4,8...n so it will be 2^n nlogn But i dint understand. I dont know how they say 2^n=logn . Please any properly explain how to

Calling a function from a macro

∥☆過路亽.° 提交于 2019-12-11 12:12:50
问题 Hi I am trying to create a macro that computes the base 2 logarithm of a number in C. The number is supposed to be the size of a table that is #defined also as seen below. I searched around and found this site that contains an implementation of base2log https://graphics.stanford.edu/~seander/bithacks.html uint8_t base2log(uint16_t value){ uint8_t result = 0; // r will be lg(v) while (value >>= 1) { result++; } return result; } My first idea is to now create the macro as: #define SIZE 256