[Returnanalytics-commits] r2774 - in pkg/PerformanceAnalytics/sandbox/pulkit: week1/code week3_4/code week3_4/tests

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Aug 13 19:03:10 CEST 2013


Author: pulkit
Date: 2013-08-13 19:03:10 +0200 (Tue, 13 Aug 2013)
New Revision: 2774

Added:
   pkg/PerformanceAnalytics/sandbox/pulkit/week3_4/tests/tests.TriplePenance.R
Modified:
   pkg/PerformanceAnalytics/sandbox/pulkit/week1/code/chart.SharpeEfficient.R
   pkg/PerformanceAnalytics/sandbox/pulkit/week3_4/code/TuW.R
Log:
unit tests for triple penance

Modified: pkg/PerformanceAnalytics/sandbox/pulkit/week1/code/chart.SharpeEfficient.R
===================================================================
--- pkg/PerformanceAnalytics/sandbox/pulkit/week1/code/chart.SharpeEfficient.R	2013-08-13 00:18:13 UTC (rev 2773)
+++ pkg/PerformanceAnalytics/sandbox/pulkit/week1/code/chart.SharpeEfficient.R	2013-08-13 17:03:10 UTC (rev 2774)
@@ -2,18 +2,22 @@
 
     x = checkData(R)
     columns = ncol(x)
-    com
-    permutations<-function (n, r, v = 1:n) 
-    { 
-      if (r == 1) 
-        matrix(v, n, 1) 
-      else if (n == 1) 
-        matrix(v, 1, r) 
-      else { 
-        X <- NULL 
-        for (i in 1:n) X <- rbind(X, cbind(v[i], fn_perm_list(n - 
-                                                                1, r - 1, v[-i]))) 
-        X 
-      } 
-    } 
+
+    mat<-NULL
+    subset_sum<-function(numbers,target,partial){
+        s = sum(partial)
+        print(s)
+        if(s==target){
+            mat = rbind(mat,partial)
+        }
+      
+        x<-NULL
+        for(i in 1:length(numbers)){
+            n = numbers[i]
+            remaining = numbers[(i+1):length(numbers)]
+            subset_sum(remaining,target,c(partial,n))
+        }
+    }
+    subset_sum(c(1:10),10,0)
+}
     

Modified: pkg/PerformanceAnalytics/sandbox/pulkit/week3_4/code/TuW.R
===================================================================
--- pkg/PerformanceAnalytics/sandbox/pulkit/week3_4/code/TuW.R	2013-08-13 00:18:13 UTC (rev 2773)
+++ pkg/PerformanceAnalytics/sandbox/pulkit/week3_4/code/TuW.R	2013-08-13 17:03:10 UTC (rev 2774)
@@ -31,7 +31,7 @@
 #' 
 #' @examples
 #' TuW(edhec,0.95,"ar")
-#' uW(edhec[,1],0.95,"normal") # expected value 103.2573 
+#' TuW(edhec[,1],0.95,"normal") # expected value 103.2573 
 
 TuW<-function(R,confidence,type=c("ar","normal"),...){
   x = checkData(R)

Added: pkg/PerformanceAnalytics/sandbox/pulkit/week3_4/tests/tests.TriplePenance.R
===================================================================
--- pkg/PerformanceAnalytics/sandbox/pulkit/week3_4/tests/tests.TriplePenance.R	                        (rev 0)
+++ pkg/PerformanceAnalytics/sandbox/pulkit/week3_4/tests/tests.TriplePenance.R	2013-08-13 17:03:10 UTC (rev 2774)
@@ -0,0 +1,11 @@
+library(RUnit)
+library(PerformanceAnalytics)
+data(edhec)
+
+test_MaxDD<-function(){ 
+ checkEqualsNumeric(MaxDD(edhec[,1],0.95,"normal"),6.618966,tolerance = 1.0e-6)
+}
+
+test_MinTRL<-function(){  
+  checkEqualsNumeric(TuW(edhec[,1],0.95,"normal"),103.2573,tolerance = 1.0e-3)
+}



More information about the Returnanalytics-commits mailing list