optimization

I have to compare data from each row of a Pandas DataFrame with data from the rest of the rows, is there a way to speed up the computation?

前提是你 提交于 2021-02-07 20:38:04
问题 Let's say I have a pandas DataFrame (loaded from a csv file) with this structure (the number of var and err columns is not fixed, and it varies from file to file): var_0; var_1; var_2; 32; 9; 41; 47; 22; 41; 15; 12; 32; 3; 4; 4; 10; 9; 41; 43; 21; 45; 32; 14; 32; 51; 20; 40; Let's discard the err_ds_j and the err_mean columns for the sake of this question. I have to perform an automatic comparison of the values of each row, with the values of the other rows; as an example: I have to compare

Timing vs the “as-if” rule

只谈情不闲聊 提交于 2021-02-07 17:54:28
问题 There is a great question about the "as-if" rule in general, but I wonder if there are any excpetions when it comes to measuring time. Consider this (taken from here slightly modified): using std::chrono; auto begin = steady_clock::now(); auto result = some_lengthy_calculation(some_params); auto end= std::chrono::steady_clock::now(); std::cout << "Time diff = " << duration_cast<microseconds>(end - begin).count() <<std::endl; std::cout << "Result = " << result; The compiler is allowed to apply

Good sentinel value for double if prefer to use -ffast-math

前提是你 提交于 2021-02-07 11:58:38
问题 Since the gcc option -ffast-math effectively disables NaN and -/+inf , I'm looking for maybe the next best option for representing NaN in my performance-critical math code. Ideally the sentinel value if operated on (add, mul, div, sub, etc..) would yield the sentinel value as NaN would do but I doubt this would be possible since I think NaN is the only value that accomplishes this. -0.0 might not be a good fit as it's also disabled in -ffast-math and could prevent certain optimizations like

How can I optimize parallel sorting to improve temporal performance?

亡梦爱人 提交于 2021-02-07 11:54:08
问题 I have an algorithm for parallel sorting a list of a given length: import Control.Parallel (par, pseq) import Data.Time.Clock (diffUTCTime, getCurrentTime) import System.Environment (getArgs) import System.Random (StdGen, getStdGen, randoms) parSort :: (Ord a) => [a] -> [a] parSort (x:xs) = force greater `par` (force lesser `pseq` (lesser ++ x:greater)) where lesser = parSort [y | y <- xs, y < x] greater = parSort [y | y <- xs, y >= x] parSort _ = [] sort :: (Ord a) => [a] -> [a] sort (x:xs)

Warning lme4: Model failed to converge with max|grad|

两盒软妹~` 提交于 2021-02-07 09:14:05
问题 I have to run a lmer with a log transformed response variable, a continuous variable as fixed effect and and a nested random effect: first<-lmer(logterrisize~spm + (1|studyarea/teriid), data = Data_table_for_analysis_Character_studyarea, control=lmerControl(optimizer="Nelder_Mead", optCtrl=list(maxfun=1e4))) I got this error message: Error in length(value <- as.numeric(value)) == 1L : Downdated VtV is not positive definite I tried this with bobyqa() as optimization argument and got this

Plotting one sigma error bars on a curve fit line in scipy

不打扰是莪最后的温柔 提交于 2021-02-07 09:09:58
问题 I plotted a linear least square fit curve using scipy.optimize.curve_fit() . My data has some error associated to it and I added those while plotting the fit curve. Next, I want to plot two dashed lines representing one sigma error bar on the curve fit and shade region between those two lines. This is what I have tried so far: import sys import os import numpy import matplotlib.pyplot as plt from pylab import * import scipy.optimize as optimization from scipy.optimize import curve_fit xdata =

Warning lme4: Model failed to converge with max|grad|

南楼画角 提交于 2021-02-07 09:06:17
问题 I have to run a lmer with a log transformed response variable, a continuous variable as fixed effect and and a nested random effect: first<-lmer(logterrisize~spm + (1|studyarea/teriid), data = Data_table_for_analysis_Character_studyarea, control=lmerControl(optimizer="Nelder_Mead", optCtrl=list(maxfun=1e4))) I got this error message: Error in length(value <- as.numeric(value)) == 1L : Downdated VtV is not positive definite I tried this with bobyqa() as optimization argument and got this

Scipy minimize fmin - problems with syntax

末鹿安然 提交于 2021-02-07 06:52:17
问题 I have a function which takes several arguments (one array and two floats) and returns a scalar (float). Now I want to minimize this function by varying two of the arguments: the two floats. The array is "unpacked" inside the function at its contents (arrays and floats) are then used. How can this be done using SciPy's fmin function? I am having a very hard time figuring out the right syntax for this.. The function is something like: def func(x, y, data) data1=data[0] data2=data[...] ... ...

What's the fastest way to do a right bit rotation/circular shift on a byte array

[亡魂溺海] 提交于 2021-02-07 05:45:21
问题 If I have the array: {01101111,11110000,00001111} // {111, 240, 15} The result for a 1 bit shift is: {10110111,11111000,00000111} // {183, 248, 7} The array size is not fixed, and the shifting will be from 1 to 7 inclusive. Currently I have the following code (which works fine): private static void shiftBitsRight(byte[] bytes, final int rightShifts) { assert rightShifts >= 1 && rightShifts <= 7; final int leftShifts = 8 - rightShifts; byte previousByte = bytes[0]; // keep the byte before

Why is tailcall optimization not performed for types of class MEMORY?

 ̄綄美尐妖づ 提交于 2021-02-07 05:20:43
问题 I'm trying to understand the implication of System V AMD64 - ABI for returning by value from a function. For the following data type struct Vec3{ double x, y, z; }; the type Vec3 is of class MEMORY and thus the following is specified by the ABI concerning "Returning of Values": If the type has class MEMORY, then the caller provides space for the return value and passes the address of this storage in %rdi as if it were the first argument to the function. In effect, this address becomes a