exponential

Pandas: Exponentially decaying sum with variable weights

情到浓时终转凉″ 提交于 2020-01-02 04:09:06
问题 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

Fitting distribution with fixed parameters in SciPy

僤鯓⒐⒋嵵緔 提交于 2019-12-31 02:26:30
问题 Is it possible to fix parameters while fitting distributions in SciPy? For example, this code: import scipy.stats as st xx = st.expon.rvs(size=100) print st.expon.fit(xx, loc=0) results in non-zero location ( loc ). When some parameter is provided to the fit function it is considered as an initial guess. And if it is provided to the constructor ( st.expon(loc=0) ) the distribution becomes "frozen" and can not be used for fitting. 回答1: To fix loc , use the argument floc : print st.expon.fit(xx

Fast SSE low precision exponential using double precision operations

与世无争的帅哥 提交于 2019-12-30 09:07:35
问题 I am looking for for a fast-SSE-low-precision (~1e-3) exponential function. I came across this great answer: /* max. rel. error = 3.55959567e-2 on [-87.33654, 88.72283] */ __m128 FastExpSse (__m128 x) { __m128 a = _mm_set1_ps (12102203.0f); /* (1 << 23) / log(2) */ __m128i b = _mm_set1_epi32 (127 * (1 << 23) - 298765); __m128i t = _mm_add_epi32 (_mm_cvtps_epi32 (_mm_mul_ps (a, x)), b); return _mm_castsi128_ps (t); } Based on the work of Nicol N. Schraudolph: N. N. Schraudolph. "A fast,

geom_smooth and exponential fits

血红的双手。 提交于 2019-12-29 07:43:06
问题 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

Does Pandas calculate ewm wrong?

霸气de小男生 提交于 2019-12-28 02:04:21
问题 When trying to calculate the exponential moving average (EMA) from financial data in a dataframe it seems that Pandas' ewm approach is incorrect. The basics are well explained in the following link: http://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:moving_averages When going to Pandas explanation, the approach taken is as follows (using the "adjust" parameter as False): weighted_average[0] = arg[0]; weighted_average[i] = (1-alpha) * weighted_average[i-1] + alpha *

finding power of a number

…衆ロ難τιáo~ 提交于 2019-12-25 04:24:56
问题 I have a very big number which is a product of several small primes. I know the number and also I know the prime factors but I don't know their powers. for example: (2^a)x(3^b)x(5^c)x(7^d)x(11^e)x .. = 2310 Now I want to recover the exponents in a very fast and efficient manner. I want to implement it in an FPGA. Regards, 回答1: The issue is that you are doing a linear search for the right power when you should be doing a binary search. Below is an example showing how to the case where the

PHP how to convert number exponential number to string?

余生长醉 提交于 2019-12-23 17:18:35
问题 I have a number stored in scientific notation 2.01421700079E+14 I've tried using float, string, int and I can't get 0201421700079085 from 2.01421700079E+14 1. echo (float)$awb; 2. echo number_format($awb, 0, '', ''); 3. echo (int)$awb; 4. echo (string)$awb; 2.01421700079E+14 = float 201421700079085 = number 201421700079085 = int 2.01421700079E+14 = string 回答1: printf and friends will do this: <?php $awb = 2.01421700079E+14; $str = sprintf("%d", $awb); var_dump($str); Output: string(15)

Setinterval with exponential time decrease

早过忘川 提交于 2019-12-23 10:16:15
问题 I've got a mousedown event with a setinterval. I want the time of intervals to be variable. So the first one is 500, the second one 500/2 = 250, etc. Any tips? $plus.mousedown(function(e) { increment(20) timeout = setInterval(function(){ increment(20) }, 500); }); $(document).mouseup(function(){ clearInterval(timeout); return false; }); Cheers! EDIT: sorry for the ambiguity. I want the time of interval to change during the mousedown. So while the mousedown is being performed the intervaltime