Solving for two parameters using `optim()` in R?

I'm trying to find shape1 and shape2 in dbeta() such that the answer from dbeta() for the two input values: .6 and .8 become 3. I'm using the below optim() but don't get exact result, that is I expect getting values for shape1 and shape2 that when u...
more »

2017-08-15 01:08 (0) Answers

Generic and non-generic method with similar body

I have a method called ExecuteAsyncServiceRequest with an overload, you'll notice that the body of the both methods are similar. I find myself wondering is there a more concise way of writing these methods? Specifically, to not have to repeat myself ...
more »

2017-08-10 18:08 (1) Answers

How to optimize the unused space in the Java heap

Do not take my word on this. I am just repeating what I have pieced together from different sources. HotSpot JVM uses Thread Local Allocation Buffers (TLABs). TLABs can be synchronized or not. Most of the time the TLABs are not synchronized and h...
more »

2017-08-10 14:08 (2) Answers

Python How to improve numpy array performance?

I have a global numpy.array data which is a 200*200*3 3d-array containing 40000 points in the 3d-space. My goal is to calculate the distance from each point to the four corners of the unit cube ((0, 0, 0),(1, 0, 0),(0, 1, 0),(0, 0, 1)),so I can dete...
more »

2017-08-01 15:08 (1) Answers

How to clear Thumbor cache?

Is there any way to do it like Redis for example: redis-cli flushall ? I did not find anything about clearing cache at Thumbor's official documentation. The only useful thing i found was this parameter: MAX_AGE, but it's not good enough for me, caus...
more »

2017-07-26 13:07 (0) Answers

Which would yield better performance in general?

I have a small dilemma. As we all know, defining variables by types and avoiding the usage of variants is the most obvious performance trick. The problem is I'm trying to write a library of routines that would work with implicitly-typed arguments (ba...
more »

2017-07-25 14:07 (1) Answers

String.replace and same method call mutliple times

I and my friend has written below code to prevent code injection in injection in CSV files. (written in java) For big CSV files (say 400 columns, 10000 rows), the code is taking ~15 seconds in the worst case (all columns and rows are bad). Can anybo...
more »

2017-07-21 13:07 (2) Answers

Ways to optimise this code

I am exploring ways to optimise the code that follows. The code loops over a string. For the ith character in the string, the code increments one entry in a 2D array at the ith column. The exact entry at the ith column that is incremented depends on...
more »

2017-05-26 21:05 (2) Answers

How to randomly shift rows of a numpy array

I am looking for a more pythonic way of randomly shifting rows of a numpy array. The idea is that I have an array of data, and I want to left-shift each row of the array by a random amount. My solution, which works, but I feel is a bit un-pythonic: ...
more »

2017-05-24 00:05 (1) Answers

Can I further simplify this code/expression?

I'm in a DSP context, which I need to speed-up some operations. Here's a formula I have and I execute often: unsigned int pos0 = (unsigned int)round((envelope.mLengths[sectionIndex] * mSampleRate) / gBlockSize) * gBlockSize; unsigned int pos1 = (un...
more »

2017-05-22 13:05 (2) Answers

Optimizing adding dashes to a long Swift String

I am trying to take a hex string and insert dashes between every other character (e.g. "b201a968" to "b2-01-a9-68"). I have found several ways to do it, but the problem is my string is fairly large (8066 characters) and the fastest I can get it to w...
more »

2017-05-19 00:05 (2) Answers