optimization

R stockPortfolio Package not connecting to Yahoo

一个人想着一个人 提交于 2019-12-25 07:03:47
问题 I am trying to replicate this example as I am new to portfolio optimization through R: http://economistatlarge.com/portfolio-theory/r-optimized-portfolio However, I keep getting the following error: R version 3.0.2 (2013-09-25) -- "Frisbee Sailing" Copyright (C) 2013 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or

Fastest way to convert 2D-array into char* array and copy a char into end of string

若如初见. 提交于 2019-12-25 06:55:34
问题 I'm looking for an example code or how to improve the below code (that it's very slow IMO, but it's that I can write) to the fastest way to convert an 2D-array into a char* and copy a char to it. char* join(int c, size_t arrsize, const char* arr[]) { char *buf, *tbuf, *val; size_t i, vsize, total; buf = malloc(1); for(i = total = 0; i < arrsize; ++i) { val = arr[i]; vsize = strlen(val); if((tbuf = realloc(buf, total + vsize + 2)) == NULL) { if(buf != NULL) free(buf); return NULL; } buf = tbuf

Which is fastest for zeroing-out an array?

最后都变了- 提交于 2019-12-25 06:33:53
问题 The question title is quite self-explanatory. I have an run loop that need a dynamic-sized array. But I do know the maximum of that size is going to be, so if needed, I can max it out instead of dynamically-sizing it. Here's my code, I know that clock_t probably not the best choice for timing in terms of portability, but clock_t provide bad accuracy. #include <iostream> #include <cstdlib> #include <cstring> #include <cstdio> #include <ctime> #define TEST_SIZE 1000000 using namespace std; int

Can I optimize these functions?

两盒软妹~` 提交于 2019-12-25 06:26:51
问题 I have 3 functions (they are minimalized so they might be difficult to read) listed below - i0, t0, and is. is() and t0() both pull data from the DOM with this line var c=document.forms[a].elements; would it be better to pull the data from the DOM in i0(), and then pass it to is() and t0()? That way I would only pull data from the DOM once, but then I would need an extra variable to store it in an pass it to the two functions. i0(): function i0() { if(t0()) { var a=is('f0'); s0('bi0.php',a,s2

Code optimisation of math.asin function vb.net

折月煮酒 提交于 2019-12-25 05:59:11
问题 I have the following line of code: SomeDouble= constant1/ ((a * b) * (Math.Asin((c- a) / (a * d)) + constant2)) The two constants are different and calculated out of the loops, a - d are variables that change each time. And on the face of it it's pretty fast 0.002ms on average (47,633.588s for 26,508,249 hits). The issue I'm having is it's going to be called billions of times, literally around 20 billion hits each time the software is run. So if I can cut this down to 0.001ms the difference

Problems with scipy.optimize using matrix as input, bounds, constraints

社会主义新天地 提交于 2019-12-25 05:48:09
问题 I have used Python to perform optimization in the past; however, I am now trying to use a matrix as the input for the objective function as well as set bounds on the individual element values and the sum of the value of each row in the matrix, and I am encountering problems. Specifically, I would like to pass the objective function ObjFunc three parameters - w , p , ret - and then minimize the value of this function (technically I am trying to maximize the function by minimizing the value of

Why should we compute the image mean when we train CNNs?

风流意气都作罢 提交于 2019-12-25 05:44:22
问题 When I use caffe for image classification, it often computes the image mean. Why is that the case? Someone said that it can improve the accuracy, but I don't understand why this should be the case. 回答1: Neural networks (including CNNs) are models with thousands of parameters which we try to optimize with gradient descent. Those models are able to fit a lot of different functions by having a non-linearity φ at their nodes. Without a non-linear activation function, the network collapses to a

Why should we compute the image mean when we train CNNs?

陌路散爱 提交于 2019-12-25 05:44:08
问题 When I use caffe for image classification, it often computes the image mean. Why is that the case? Someone said that it can improve the accuracy, but I don't understand why this should be the case. 回答1: Neural networks (including CNNs) are models with thousands of parameters which we try to optimize with gradient descent. Those models are able to fit a lot of different functions by having a non-linearity φ at their nodes. Without a non-linear activation function, the network collapses to a

'Display Zoom' iPhone 6/6s setting blurs graphics

青春壹個敷衍的年華 提交于 2019-12-25 05:36:12
问题 I'm writing a project in Xcode 7 / Swift 2 that it is optimized for iPhone 6/6s (i.e. the project has a launch screen file and launch screen images for iPhone 6/6s). Fortunately or unfortunately, iPhone 6 users have the ability to turn on the ‘Display Zoom’ setting on device which enlarges elements of the interface. When turned on, this setting effectively enlarges a standard iPhone 5 screen size to fit in the iPhone 6 screen space, upsampling to x1.171875. This upsampling causes elements

Optimize javascript code on searching for matches in array

本秂侑毒 提交于 2019-12-25 05:23:14
问题 Basically, I need to get the words from the array which are contained in the main string I have a looping code here but I think there is a one-liner to do the trick. I need the code to be optimized not only in code length but also in performance. Thanks var aValidWords = ["ex", "exes", "expert", "experts", "expertise", "sex", "sexes", "exchange", "change", "changes"]; var sMainWord = "expertsExchange"; var aPossibleWords = new Array(); var sMainWordLower = sMainWord.toLowerCase(); for(i=0; i