logarithm

Logarithmic sampling

白昼怎懂夜的黑 提交于 2019-12-06 17:14:39
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? 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, the sharper curve. Then shift and multiply to get into your desired min-max range. Pseudocode: min = 1.0 max =

How to plot x=0 in semilogx plot?

本秂侑毒 提交于 2019-12-06 14:16:56
I need to plot a graph using semilogx(x,y) . I have x=[0 1 2 ... 10 15 20 30 50 75 100] . The problem is that MATLAB does not plot x=0 , which I understand because log(0)=undef . So is there another method in MATLAB to spread my points? Because using linear scale squeezes all first points in 1/10th of the graph's width! Usually, what is done in cases like this is adding 1 to all x , so the first value (originally 0 ) appears at the origin, and also the back-transformation is the same for all values. You can add any other small values than 1 , and get a similar result. However, you don't want

Trying to Calculate logarithm base 10 without Math.h (Really close) Just having problems with connecting functions [closed]

最后都变了- 提交于 2019-12-06 11:32:48
Closed . This question needs details or clarity . It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post . Closed 3 years ago . I'm trying to learn how to calculate the logarithm base 10 of any numbers that I enter via scanf to my code. I figure that I could calculate the ln(a) a being the number input. I have a working code that calculates this; however now i just want to divide any numbers that my ln(a) code outputs by the defined LN10. This is because the natural log of a number divided by the natural log of 10 will

How to draw a circle in a log-log plot in R?

本秂侑毒 提交于 2019-12-06 04:48:37
问题 I have a plot with two logarithmic axes. I'd like to add a circle to a certain position of the plot. I tried to use plotrix , but this does not give options for "log-radius". # data to plot x = 10^(-1 * c(5:0)) y = x ^-1.5 #install.packages("plotrix", dependencies=T) # use require() within functions library("plotrix") plot (x, y, log="xy", type="o") draw.circle(x=1e-2, y=1e2, radius=1e1, col=2) How can I add a circle to my log-log plot? 回答1: As krlmlr suggests, the easiest solution is to

Rotating text onto a line on a log scale in Matplotlib

回眸只為那壹抹淺笑 提交于 2019-12-06 01:11:53
Problem I am working with data on a logarithmic scale and would like to rotate it to fit a line. I know the model but am unsure quite what angle I should be plugging into transform_angles to recover the correct rotation. After a bit of trial and error I know the answer is around 10 degrees for the axes limits I require. MWE import matplotlib.pylab as plt import numpy as np plt.clf() plt.yscale('log') plt.ylim((1e-11, 1e-1)) # Other data is usually plotted and these are the ranges I need. plt.xlim((-0.2, 7.2)) x_fit = np.linspace(0.8, 3.2, 1000) y_ols = (lambda x: np.exp(np.log(2)*(-20.8 + -1

Taking logs and adding versus multiplying

有些话、适合烂在心里 提交于 2019-12-05 18:21:47
If I want to take the product of a list of floating point numbers, what's the worst-case/average-case precision lost by adding their logs and then taking exp of the sum as opposed to just multiplying them. Is there ever a case when this is actually more precise? tmyklebu Absent any overflow or underflow shenanigans, if a and b are floating-point numbers, then the product a*b will be computed to within a relative error of 1/2 ulp. A crude bound on the relative error after multiplying a chain of N double s therefore results in answer off by a factor of at most (1 - epsilon/2) -N , which is about

axis equal in a Matlab loglog plot

◇◆丶佛笑我妖孽 提交于 2019-12-05 12:09:47
问题 In Matlab the command 'axis equal': sets the aspect ratio so that equal tick mark increments on the x-,y- and z-axis are equal in size. This makes SPHERE(25) look like a sphere, instead of an ellipsoid However, when using the loglog plotting function, this doesn't work "properly". What I would like to happen is that I get an aspect ratio so that a given factor occupies the same visual distance. What actually happens is that >> loglog(2.^[1:20]*1e10,(2.^[1:20]).^2) >> axis equal results in

Problem with arithmetic using logarithms to avoid numerical underflow (take 2)

不羁的心 提交于 2019-12-05 05:59:33
I have two lists of fractions; say A = [ 1/212, 5/212, 3/212, ... ] and B = [ 4/143, 7/143, 2/143, ... ] . If we define A' = a[0] * a[1] * a[2] * ... and B' = b[0] * b[1] * b[2] * ... I want to calculate a normalised value of A' and B' ie specifically the values of A' / (A'+B') and B' / (A'+B') My trouble is A are B are both quite long and each value is small so calculating the product causes numerical underflow very quickly... I understand turning the product into a sum through logarithms can help me determine which of A' or B' is greater ie max( log(a[0])+log(a[1])+..., log(b[0])+log(b[1])+.

Compute logarithmic expression without floating point arithmetics or log

安稳与你 提交于 2019-12-05 02:54:22
问题 I need to compute the mathematical expression floor(ln(u)/ln(1-p)) for 0 < u < 1 and 0 < p < 1 in C on an embedded processor with no floating point arithmetics and no ln function. The result is a positive integer. I know about the limit cases (p=0), I'll deal with them later... I imagine that the solution involves having u and p range over 0..UINT16_MAX , and appeal to a lookup table for the logarithm, but I cannot figure out how exactly: what does the lookup table map to? The result needs

Python math module

余生颓废 提交于 2019-12-04 22:32:54
Whenever I try to use any of the built-in functions of Python's exponentiation and logarithms module, I get an error like this: NameError: name 'sqrt' is not defined I have tried using math.sqrt(4) , sqrt(4) and sqrt(4.0) , but none of them work. The exception is pow , which works as it's supposed to. This is really strange and I'm not sure what's wrong. pow is built into the language(not part of the math library). The problem is that you haven't imported math. Try this: import math math.sqrt(4) You can also import as from math import * Then you can use any mathematical function without