exponential

How to find the Longest Common Subsequence in Exponential time?

天大地大妈咪最大 提交于 2019-12-05 14:28:44
I can do this the proper way using dynamic programming but I can't figure out how to do it in exponential time. I'm looking to find the largest common sub-sequence between two strings. Note: I mean subsequences and not sub-strings the symbols that make up a sequence need not be consecutive. Just replace the lookups in the table in your dynamic programming code with recursive calls. In other words, just implement the recursive formulation of the LCS problem: EDIT In pseudocode (almost-python, actually): def lcs(s1, s2): if len(s1)==0 or len(s2)==0: return 0 if s1[0] == s2[0]: return 1 + lcs(s1

Pandas: Exponentially decaying sum with variable weights

混江龙づ霸主 提交于 2019-12-05 08:35:24
Similar to this question Exponential Decay on Python Pandas DataFrame , I would like to quickly compute exponentially decaying sums for some columns in a data frame. However, the rows in the data frame are not evenly spaced in time. Hence while exponential_sum[i] = column_to_sum[i] + np.exp(-const*(time[i]-time[i-1])) * exponential_sum[i-1] , the weight np.exp(...) does not factor out and it's not obvious to me how to change to that question and still take advantage of pandas/numpy vectorization. Is there a pandas vectorized solution to this problem? To illustrate the desired calculation, here

geom_smooth and exponential fits

此生再无相见时 提交于 2019-12-05 06:09:04
I am new to R and I'm having some difficulty plotting an exponential curve using ggplot2. I have a set of data below. DATA X Y x y 1 0.6168111 37.20637 0.6168111 37.20637 2 0.5478698 24.17084 0.5478698 24.17084 3 0.6082697 26.21261 0.6082697 26.21261 4 0.6094899 26.14065 0.6094899 26.14065 5 0.6095040 38.56314 0.6095040 38.56314 6 0.6933108 36.78443 0.6933108 36.78443 7 0.5796637 27.82840 0.5796637 27.82840 8 0.4716866 30.63080 0.4716866 30.63080 9 0.5291792 29.78255 0.5291792 29.78255 10 1.2520000 33.12657 1.2520000 33.12657 11 1.2260000 31.81066 1.2260000 31.81066 12 1.2690000 59.91388 1

Calculating 2^N in C# with long data type where N is 1929439432949324 [closed]

这一生的挚爱 提交于 2019-12-04 06:59:49
问题 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 months ago . Currently I need to calculate 2^N , however N can be as large as 1929238932899 and I'm stuck using a long data type which can't hold a number that large. I've currently tried converting to 'BigInt' however I'm still stuck with the long data type restriction from what I've seen as well. I have a

Force exponential format of ticks LIKE MATLAB does it automatically

最后都变了- 提交于 2019-12-04 05:57:39
I have two plots. In the first plot the values for the y-axis go up to 30000. Therefor, Matlab is labeling the axis instead of '30000' with '3' and the 'x10^4' ABOVE the plot. In the second plot the y-values just go til 10000. Due to the fact that this value is too low to automatically switch to exponential format it really prints '10000'. I would like to know if there is a way to force the exponential formatting. This will result in THE SAME FORMAT as Matlab does it automatically. I am asking this because I have seen solutions where you can make Matlab print '10^3' directly as Y-label, but I

JAVA - exponential distribution

自古美人都是妖i 提交于 2019-12-04 03:38:17
问题 I need to find formula for exponential distribution of probability, but i don´t know how to find it :( This formula have to have a powerful statistical properties(it can´t throw away any result from random to keep indistructed seek of random instance) i am trying to find formula, which will work in method like this: rand.getNextDuobleExpDistrib(); I have this code for now, but according to "input analyser" it doesn´t work correctly public double getNext() { return -lampda * Math.log(rand

1e-9 or -1e9, which one is correct? [closed]

蓝咒 提交于 2019-12-03 07:15:21
问题 This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 7 years ago . I am assigned some old code and when I was reading through it, I noticed it had these in the form of: float low = 1e-9; float high = 1e9; float lowB = 1e

1e-9 or -1e9, which one is correct? [closed]

匆匆过客 提交于 2019-12-02 21:59:35
I am assigned some old code and when I was reading through it, I noticed it had these in the form of: float low = 1e-9; float high = 1e9; float lowB = 1e-9; float highB = 1e9; float lowL = 1e-9; float highL = 1e9; So I see that it's trying to define some ranges using the e notation, right? But isn't 1e-9 supposed to be -1e9 ? Then the values would be between -1000000000 and 1000000000 , right? I am not sure what 1e-9 is meant for? Neither is more correct than the other. They just represent different values. 1e-9 is 0.000000001 ; the minus sign applies to the exponent. -1e9 is -1000000000.0 ;

exponential fit in ggplot R

走远了吗. 提交于 2019-12-02 19:53:06
问题 I've been trying to fit an exponential curve to my data using ggplot and geom_smooth. I'm trying to replicate the answer to a similar problem (geom_smooth and exponential fits) but keep getting following error message: > exp.model <-lm(y ~ exp(x), df) Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) : NA/NaN/Inf in 'x' I don't understand the error, as there is not NA/NaN/Inf values in the dataset: >df x y 1 1981 3.262897 2 1990 2.570096 3 2000 7.098903 4 2001 5.428424 5

Estimating rate of occurrence of an event with exponential smoothing and irregular events

天大地大妈咪最大 提交于 2019-12-02 18:23:40
Imagine that I have a set of measurements of x that are taken by many processes x 0 ... x N at times t 0 ... t N . Let's assume that at time t I want to make an estimate of the current value of x , based on the assumption that there is no long term trend I know about and that x can be predicted from an algorithm such as exponential smoothing. As we have many processes, and N can get very large, I can't store more than a few values (e.g. the previous state). One approach here would be to adapt the normal exponential smoothing algorithm. If samples are taken regularly, I would maintain an