Parcourir la source

first version

astron il y a 7 ans
commit
86a8466168
96 fichiers modifiés avec 11921 ajouts et 0 suppressions
  1. BIN
      machine learning/Machine Learning - Home _ Coursera-quiz-lesson 2.pdf
  2. BIN
      machine learning/Machine Learning - Home _ Coursera-quiz-lesson 3.pdf
  3. BIN
      machine learning/machine-learning-ex1/ex1.pdf
  4. 25 0
      machine learning/machine-learning-ex1/ex1/computeCost.m
  5. 22 0
      machine learning/machine-learning-ex1/ex1/computeCostMulti.m
  6. 135 0
      machine learning/machine-learning-ex1/ex1/ex1.m
  7. 159 0
      machine learning/machine-learning-ex1/ex1/ex1_multi.m
  8. 97 0
      machine learning/machine-learning-ex1/ex1/ex1data1.txt
  9. 47 0
      machine learning/machine-learning-ex1/ex1/ex1data2.txt
  10. 39 0
      machine learning/machine-learning-ex1/ex1/featureNormalize.m
  11. 41 0
      machine learning/machine-learning-ex1/ex1/gradientDescent.m
  12. 37 0
      machine learning/machine-learning-ex1/ex1/gradientDescentMulti.m
  13. 41 0
      machine learning/machine-learning-ex1/ex1/lib/jsonlab/AUTHORS.txt
  14. 74 0
      machine learning/machine-learning-ex1/ex1/lib/jsonlab/ChangeLog.txt
  15. 25 0
      machine learning/machine-learning-ex1/ex1/lib/jsonlab/LICENSE_BSD.txt
  16. 394 0
      machine learning/machine-learning-ex1/ex1/lib/jsonlab/README.txt
  17. 32 0
      machine learning/machine-learning-ex1/ex1/lib/jsonlab/jsonopt.m
  18. 566 0
      machine learning/machine-learning-ex1/ex1/lib/jsonlab/loadjson.m
  19. 528 0
      machine learning/machine-learning-ex1/ex1/lib/jsonlab/loadubjson.m
  20. 33 0
      machine learning/machine-learning-ex1/ex1/lib/jsonlab/mergestruct.m
  21. 475 0
      machine learning/machine-learning-ex1/ex1/lib/jsonlab/savejson.m
  22. 504 0
      machine learning/machine-learning-ex1/ex1/lib/jsonlab/saveubjson.m
  23. 40 0
      machine learning/machine-learning-ex1/ex1/lib/jsonlab/varargin2struct.m
  24. 30 0
      machine learning/machine-learning-ex1/ex1/lib/makeValidFieldName.m
  25. 179 0
      machine learning/machine-learning-ex1/ex1/lib/submitWithConfiguration.m
  26. 24 0
      machine learning/machine-learning-ex1/ex1/my_ex1.m
  27. 23 0
      machine learning/machine-learning-ex1/ex1/normalEqn.m
  28. BIN
      machine learning/machine-learning-ex1/ex1/octave-workspace
  29. 27 0
      machine learning/machine-learning-ex1/ex1/plotData.m
  30. 69 0
      machine learning/machine-learning-ex1/ex1/submit.m
  31. 15 0
      machine learning/machine-learning-ex1/ex1/token.mat
  32. 21 0
      machine learning/machine-learning-ex1/ex1/warmUpExercise.m
  33. BIN
      machine learning/machine-learning-ex2/ex2.pdf
  34. 47 0
      machine learning/machine-learning-ex2/ex2/costFunction.m
  35. 73 0
      machine learning/machine-learning-ex2/ex2/costFunctionReg.m
  36. 151 0
      machine learning/machine-learning-ex2/ex2/ex2.m
  37. 136 0
      machine learning/machine-learning-ex2/ex2/ex2_reg.m
  38. 100 0
      machine learning/machine-learning-ex2/ex2/ex2data1.txt
  39. 118 0
      machine learning/machine-learning-ex2/ex2/ex2data2.txt
  40. 41 0
      machine learning/machine-learning-ex2/ex2/lib/jsonlab/AUTHORS.txt
  41. 74 0
      machine learning/machine-learning-ex2/ex2/lib/jsonlab/ChangeLog.txt
  42. 25 0
      machine learning/machine-learning-ex2/ex2/lib/jsonlab/LICENSE_BSD.txt
  43. 394 0
      machine learning/machine-learning-ex2/ex2/lib/jsonlab/README.txt
  44. 32 0
      machine learning/machine-learning-ex2/ex2/lib/jsonlab/jsonopt.m
  45. 566 0
      machine learning/machine-learning-ex2/ex2/lib/jsonlab/loadjson.m
  46. 528 0
      machine learning/machine-learning-ex2/ex2/lib/jsonlab/loadubjson.m
  47. 33 0
      machine learning/machine-learning-ex2/ex2/lib/jsonlab/mergestruct.m
  48. 475 0
      machine learning/machine-learning-ex2/ex2/lib/jsonlab/savejson.m
  49. 504 0
      machine learning/machine-learning-ex2/ex2/lib/jsonlab/saveubjson.m
  50. 40 0
      machine learning/machine-learning-ex2/ex2/lib/jsonlab/varargin2struct.m
  51. 30 0
      machine learning/machine-learning-ex2/ex2/lib/makeValidFieldName.m
  52. 179 0
      machine learning/machine-learning-ex2/ex2/lib/submitWithConfiguration.m
  53. 21 0
      machine learning/machine-learning-ex2/ex2/mapFeature.m
  54. 91 0
      machine learning/machine-learning-ex2/ex2/myex2.m
  55. 39 0
      machine learning/machine-learning-ex2/ex2/myex22.m
  56. BIN
      machine learning/machine-learning-ex2/ex2/octave-workspace
  57. 33 0
      machine learning/machine-learning-ex2/ex2/plotData.m
  58. 48 0
      machine learning/machine-learning-ex2/ex2/plotDecisionBoundary.m
  59. 27 0
      machine learning/machine-learning-ex2/ex2/predict.m
  60. 18 0
      machine learning/machine-learning-ex2/ex2/sigmoid.m
  61. 62 0
      machine learning/machine-learning-ex2/ex2/submit.m
  62. 15 0
      machine learning/machine-learning-ex2/ex2/token.mat
  63. BIN
      machine learning/machine-learning-ex3/ex3.pdf
  64. 59 0
      machine learning/machine-learning-ex3/ex3/displayData.m
  65. 88 0
      machine learning/machine-learning-ex3/ex3/ex3.m
  66. 90 0
      machine learning/machine-learning-ex3/ex3/ex3_nn.m
  67. BIN
      machine learning/machine-learning-ex3/ex3/ex3data1.mat
  68. BIN
      machine learning/machine-learning-ex3/ex3/ex3weights.mat
  69. 175 0
      machine learning/machine-learning-ex3/ex3/fmincg.m
  70. 41 0
      machine learning/machine-learning-ex3/ex3/lib/jsonlab/AUTHORS.txt
  71. 74 0
      machine learning/machine-learning-ex3/ex3/lib/jsonlab/ChangeLog.txt
  72. 25 0
      machine learning/machine-learning-ex3/ex3/lib/jsonlab/LICENSE_BSD.txt
  73. 394 0
      machine learning/machine-learning-ex3/ex3/lib/jsonlab/README.txt
  74. 32 0
      machine learning/machine-learning-ex3/ex3/lib/jsonlab/jsonopt.m
  75. 566 0
      machine learning/machine-learning-ex3/ex3/lib/jsonlab/loadjson.m
  76. 528 0
      machine learning/machine-learning-ex3/ex3/lib/jsonlab/loadubjson.m
  77. 33 0
      machine learning/machine-learning-ex3/ex3/lib/jsonlab/mergestruct.m
  78. 475 0
      machine learning/machine-learning-ex3/ex3/lib/jsonlab/savejson.m
  79. 504 0
      machine learning/machine-learning-ex3/ex3/lib/jsonlab/saveubjson.m
  80. 40 0
      machine learning/machine-learning-ex3/ex3/lib/jsonlab/varargin2struct.m
  81. 30 0
      machine learning/machine-learning-ex3/ex3/lib/makeValidFieldName.m
  82. 179 0
      machine learning/machine-learning-ex3/ex3/lib/submitWithConfiguration.m
  83. 60 0
      machine learning/machine-learning-ex3/ex3/lrCostFunction.m
  84. 83 0
      machine learning/machine-learning-ex3/ex3/myex3.m
  85. 72 0
      machine learning/machine-learning-ex3/ex3/myex3nn.m
  86. 0 0
      machine learning/machine-learning-ex3/ex3/octave-workspace
  87. 77 0
      machine learning/machine-learning-ex3/ex3/oneVsAll.m
  88. 45 0
      machine learning/machine-learning-ex3/ex3/predict.m
  89. 51 0
      machine learning/machine-learning-ex3/ex3/predictOneVsAll.m
  90. 6 0
      machine learning/machine-learning-ex3/ex3/sigmoid.m
  91. 56 0
      machine learning/machine-learning-ex3/ex3/submit.m
  92. 15 0
      machine learning/machine-learning-ex3/ex3/token.mat
  93. BIN
      machine learning/machine-learning-week4/Machine Learning - Home _ Coursera-quiz2.pdf
  94. 18 0
      machine learning/machine-learning-week4/sigmoid.m
  95. 7 0
      machine learning/machine-learning-week4/xnor.m
  96. 496 0
      machine learning/ml workspace

BIN
machine learning/Machine Learning - Home _ Coursera-quiz-lesson 2.pdf


BIN
machine learning/Machine Learning - Home _ Coursera-quiz-lesson 3.pdf


BIN
machine learning/machine-learning-ex1/ex1.pdf


+ 25 - 0
machine learning/machine-learning-ex1/ex1/computeCost.m

@@ -0,0 +1,25 @@
+function J = computeCost(X, y, theta)
+%COMPUTECOST Compute cost for linear regression
+%   J = COMPUTECOST(X, y, theta) computes the cost of using theta as the
+%   parameter for linear regression to fit the data points in X and y
+
+% Initialize some useful values
+m = length(y); % number of training examples
+
+% You need to return the following variables correctly 
+J = 0;
+
+% ====================== YOUR CODE HERE ======================
+% Instructions: Compute the cost of a particular choice of theta
+%               You should set J to the cost.
+h_theta = X * theta;
+hy = h_theta - y;
+hysq = hy.^2;
+J = 1 / (2 * m) * sum(hysq);
+
+
+
+
+% =========================================================================
+
+end

+ 22 - 0
machine learning/machine-learning-ex1/ex1/computeCostMulti.m

@@ -0,0 +1,22 @@
+function J = computeCostMulti(X, y, theta)
+%COMPUTECOSTMULTI Compute cost for linear regression with multiple variables
+%   J = COMPUTECOSTMULTI(X, y, theta) computes the cost of using theta as the
+%   parameter for linear regression to fit the data points in X and y
+
+% Initialize some useful values
+m = length(y); % number of training examples
+
+% You need to return the following variables correctly 
+J = 0;
+
+% ====================== YOUR CODE HERE ======================
+% Instructions: Compute the cost of a particular choice of theta
+%               You should set J to the cost.
+
+
+
+
+
+% =========================================================================
+
+end

+ 135 - 0
machine learning/machine-learning-ex1/ex1/ex1.m

@@ -0,0 +1,135 @@
+%% Machine Learning Online Class - Exercise 1: Linear Regression
+
+%  Instructions
+%  ------------
+%
+%  This file contains code that helps you get started on the
+%  linear exercise. You will need to complete the following functions
+%  in this exericse:
+%
+%     warmUpExercise.m
+%     plotData.m
+%     gradientDescent.m
+%     computeCost.m
+%     gradientDescentMulti.m
+%     computeCostMulti.m
+%     featureNormalize.m
+%     normalEqn.m
+%
+%  For this exercise, you will not need to change any code in this file,
+%  or any other files other than those mentioned above.
+%
+% x refers to the population size in 10,000s
+% y refers to the profit in $10,000s
+%
+
+%% Initialization
+clear ; close all; clc
+
+%% ==================== Part 1: Basic Function ====================
+% Complete warmUpExercise.m
+fprintf('Running warmUpExercise ... \n');
+fprintf('5x5 Identity Matrix: \n');
+warmUpExercise()
+
+fprintf('Program paused. Press enter to continue.\n');
+%pause;
+
+
+%% ======================= Part 2: Plotting =======================
+fprintf('Plotting Data ...\n')
+data = load('ex1data1.txt');
+X = data(:, 1); y = data(:, 2);
+m = length(y); % number of training examples
+
+% Plot Data
+% Note: You have to complete the code in plotData.m
+plotData(X, y);
+
+%fprintf('Program paused. Press enter to continue.\n');
+pause;
+
+%% =================== Part 3: Cost and Gradient descent ===================
+
+X = [ones(m, 1), data(:,1)]; % Add a column of ones to x
+theta = zeros(2, 1); % initialize fitting parameters
+
+% Some gradient descent settings
+iterations = 1500;
+alpha = 0.01;
+
+fprintf('\nTesting the cost function ...\n')
+% compute and display initial cost
+J = computeCost(X, y, theta);
+fprintf('With theta = [0 ; 0]\nCost computed = %f\n', J);
+fprintf('Expected cost value (approx) 32.07\n');
+
+% further testing of the cost function
+J = computeCost(X, y, [-1 ; 2]);
+fprintf('\nWith theta = [-1 ; 2]\nCost computed = %f\n', J);
+fprintf('Expected cost value (approx) 54.24\n');
+
+fprintf('Program paused. Press enter to continue.\n');
+pause;
+
+fprintf('\nRunning Gradient Descent ...\n')
+% run gradient descent
+theta = gradientDescent(X, y, theta, alpha, iterations);
+
+% print theta to screen
+fprintf('Theta found by gradient descent:\n');
+fprintf('%f\n', theta);
+fprintf('Expected theta values (approx)\n');
+fprintf(' -3.6303\n  1.1664\n\n');
+
+% Plot the linear fit
+hold on; % keep previous plot visible
+plot(X(:,2), X*theta, '-')
+legend('Training data', 'Linear regression')
+hold off % don't overlay any more plots on this figure
+
+% Predict values for population sizes of 35,000 and 70,000
+predict1 = [1, 3.5] *theta;
+fprintf('For population = 35,000, we predict a profit of %f\n',...
+    predict1*10000);
+predict2 = [1, 7] * theta;
+fprintf('For population = 70,000, we predict a profit of %f\n',...
+    predict2*10000);
+
+fprintf('Program paused. Press enter to continue.\n');
+pause;
+
+%% ============= Part 4: Visualizing J(theta_0, theta_1) =============
+fprintf('Visualizing J(theta_0, theta_1) ...\n')
+
+% Grid over which we will calculate J
+theta0_vals = linspace(-10, 10, 100);
+theta1_vals = linspace(-1, 4, 100);
+
+% initialize J_vals to a matrix of 0's
+J_vals = zeros(length(theta0_vals), length(theta1_vals));
+
+% Fill out J_vals
+for i = 1:length(theta0_vals)
+    for j = 1:length(theta1_vals)
+	  t = [theta0_vals(i); theta1_vals(j)];
+	  J_vals(i,j) = computeCost(X, y, t);
+    end
+end
+
+
+% Because of the way meshgrids work in the surf command, we need to
+% transpose J_vals before calling surf, or else the axes will be flipped
+J_vals = J_vals';
+% Surface plot
+figure;
+surf(theta0_vals, theta1_vals, J_vals)
+xlabel('\theta_0'); ylabel('\theta_1');
+
+% Contour plot
+figure;
+% Plot J_vals as 15 contours spaced logarithmically between 0.01 and 100
+contour(theta0_vals, theta1_vals, J_vals, logspace(-2, 3, 20))
+xlabel('\theta_0'); ylabel('\theta_1');
+hold on;
+plot(theta(1), theta(2), 'rx', 'MarkerSize', 10, 'LineWidth', 2);

+ 159 - 0
machine learning/machine-learning-ex1/ex1/ex1_multi.m

@@ -0,0 +1,159 @@
+%% Machine Learning Online Class
+%  Exercise 1: Linear regression with multiple variables
+%
+%  Instructions
+%  ------------
+% 
+%  This file contains code that helps you get started on the
+%  linear regression exercise. 
+%
+%  You will need to complete the following functions in this 
+%  exericse:
+%
+%     warmUpExercise.m
+%     plotData.m
+%     gradientDescent.m
+%     computeCost.m
+%     gradientDescentMulti.m
+%     computeCostMulti.m
+%     featureNormalize.m
+%     normalEqn.m
+%
+%  For this part of the exercise, you will need to change some
+%  parts of the code below for various experiments (e.g., changing
+%  learning rates).
+%
+
+%% Initialization
+
+%% ================ Part 1: Feature Normalization ================
+
+%% Clear and Close Figures
+clear ; close all; clc
+
+fprintf('Loading data ...\n');
+
+%% Load Data
+data = load('ex1data2.txt');
+X = data(:, 1:2);
+y = data(:, 3);
+m = length(y);
+
+% Print out some data points
+fprintf('First 10 examples from the dataset: \n');
+fprintf(' x = [%.0f %.0f], y = %.0f \n', [X(1:10,:) y(1:10,:)]');
+
+fprintf('Program paused. Press enter to continue.\n');
+pause;
+
+% Scale features and set them to zero mean
+fprintf('Normalizing Features ...\n');
+
+[X mu sigma] = featureNormalize(X);
+
+% Add intercept term to X
+X = [ones(m, 1) X];
+
+
+%% ================ Part 2: Gradient Descent ================
+
+% ====================== YOUR CODE HERE ======================
+% Instructions: We have provided you with the following starter
+%               code that runs gradient descent with a particular
+%               learning rate (alpha). 
+%
+%               Your task is to first make sure that your functions - 
+%               computeCost and gradientDescent already work with 
+%               this starter code and support multiple variables.
+%
+%               After that, try running gradient descent with 
+%               different values of alpha and see which one gives
+%               you the best result.
+%
+%               Finally, you should complete the code at the end
+%               to predict the price of a 1650 sq-ft, 3 br house.
+%
+% Hint: By using the 'hold on' command, you can plot multiple
+%       graphs on the same figure.
+%
+% Hint: At prediction, make sure you do the same feature normalization.
+%
+
+fprintf('Running gradient descent ...\n');
+
+% Choose some alpha value
+alpha = 0.01;
+num_iters = 400;
+
+% Init Theta and Run Gradient Descent 
+theta = zeros(3, 1);
+[theta, J_history] = gradientDescentMulti(X, y, theta, alpha, num_iters);
+
+% Plot the convergence graph
+figure;
+plot(1:numel(J_history), J_history, '-b', 'LineWidth', 2);
+xlabel('Number of iterations');
+ylabel('Cost J');
+
+% Display gradient descent's result
+fprintf('Theta computed from gradient descent: \n');
+fprintf(' %f \n', theta);
+fprintf('\n');
+
+% Estimate the price of a 1650 sq-ft, 3 br house
+% ====================== YOUR CODE HERE ======================
+% Recall that the first column of X is all-ones. Thus, it does
+% not need to be normalized.
+price = 0; % You should change this
+
+
+% ============================================================
+
+fprintf(['Predicted price of a 1650 sq-ft, 3 br house ' ...
+         '(using gradient descent):\n $%f\n'], price);
+
+fprintf('Program paused. Press enter to continue.\n');
+pause;
+
+%% ================ Part 3: Normal Equations ================
+
+fprintf('Solving with normal equations...\n');
+
+% ====================== YOUR CODE HERE ======================
+% Instructions: The following code computes the closed form 
+%               solution for linear regression using the normal
+%               equations. You should complete the code in 
+%               normalEqn.m
+%
+%               After doing so, you should complete this code 
+%               to predict the price of a 1650 sq-ft, 3 br house.
+%
+
+%% Load Data
+data = csvread('ex1data2.txt');
+X = data(:, 1:2);
+y = data(:, 3);
+m = length(y);
+
+% Add intercept term to X
+X = [ones(m, 1) X];
+
+% Calculate the parameters from the normal equation
+theta = normalEqn(X, y);
+
+% Display normal equation's result
+fprintf('Theta computed from the normal equations: \n');
+fprintf(' %f \n', theta);
+fprintf('\n');
+
+
+% Estimate the price of a 1650 sq-ft, 3 br house
+% ====================== YOUR CODE HERE ======================
+price = 0; % You should change this
+
+
+% ============================================================
+
+fprintf(['Predicted price of a 1650 sq-ft, 3 br house ' ...
+         '(using normal equations):\n $%f\n'], price);
+

+ 97 - 0
machine learning/machine-learning-ex1/ex1/ex1data1.txt

@@ -0,0 +1,97 @@
+6.1101,17.592
+5.5277,9.1302
+8.5186,13.662
+7.0032,11.854
+5.8598,6.8233
+8.3829,11.886
+7.4764,4.3483
+8.5781,12
+6.4862,6.5987
+5.0546,3.8166
+5.7107,3.2522
+14.164,15.505
+5.734,3.1551
+8.4084,7.2258
+5.6407,0.71618
+5.3794,3.5129
+6.3654,5.3048
+5.1301,0.56077
+6.4296,3.6518
+7.0708,5.3893
+6.1891,3.1386
+20.27,21.767
+5.4901,4.263
+6.3261,5.1875
+5.5649,3.0825
+18.945,22.638
+12.828,13.501
+10.957,7.0467
+13.176,14.692
+22.203,24.147
+5.2524,-1.22
+6.5894,5.9966
+9.2482,12.134
+5.8918,1.8495
+8.2111,6.5426
+7.9334,4.5623
+8.0959,4.1164
+5.6063,3.3928
+12.836,10.117
+6.3534,5.4974
+5.4069,0.55657
+6.8825,3.9115
+11.708,5.3854
+5.7737,2.4406
+7.8247,6.7318
+7.0931,1.0463
+5.0702,5.1337
+5.8014,1.844
+11.7,8.0043
+5.5416,1.0179
+7.5402,6.7504
+5.3077,1.8396
+7.4239,4.2885
+7.6031,4.9981
+6.3328,1.4233
+6.3589,-1.4211
+6.2742,2.4756
+5.6397,4.6042
+9.3102,3.9624
+9.4536,5.4141
+8.8254,5.1694
+5.1793,-0.74279
+21.279,17.929
+14.908,12.054
+18.959,17.054
+7.2182,4.8852
+8.2951,5.7442
+10.236,7.7754
+5.4994,1.0173
+20.341,20.992
+10.136,6.6799
+7.3345,4.0259
+6.0062,1.2784
+7.2259,3.3411
+5.0269,-2.6807
+6.5479,0.29678
+7.5386,3.8845
+5.0365,5.7014
+10.274,6.7526
+5.1077,2.0576
+5.7292,0.47953
+5.1884,0.20421
+6.3557,0.67861
+9.7687,7.5435
+6.5159,5.3436
+8.5172,4.2415
+9.1802,6.7981
+6.002,0.92695
+5.5204,0.152
+5.0594,2.8214
+5.7077,1.8451
+7.6366,4.2959
+5.8707,7.2029
+5.3054,1.9869
+8.2934,0.14454
+13.394,9.0551
+5.4369,0.61705

+ 47 - 0
machine learning/machine-learning-ex1/ex1/ex1data2.txt

@@ -0,0 +1,47 @@
+2104,3,399900
+1600,3,329900
+2400,3,369000
+1416,2,232000
+3000,4,539900
+1985,4,299900
+1534,3,314900
+1427,3,198999
+1380,3,212000
+1494,3,242500
+1940,4,239999
+2000,3,347000
+1890,3,329999
+4478,5,699900
+1268,3,259900
+2300,4,449900
+1320,2,299900
+1236,3,199900
+2609,4,499998
+3031,4,599000
+1767,3,252900
+1888,2,255000
+1604,3,242900
+1962,4,259900
+3890,3,573900
+1100,3,249900
+1458,3,464500
+2526,3,469000
+2200,3,475000
+2637,3,299900
+1839,2,349900
+1000,1,169900
+2040,4,314900
+3137,3,579900
+1811,4,285900
+1437,3,249900
+1239,3,229900
+2132,4,345000
+4215,4,549000
+2162,4,287000
+1664,2,368500
+2238,3,329900
+2567,4,314000
+1200,3,299000
+852,2,179900
+1852,4,299900
+1203,3,239500

+ 39 - 0
machine learning/machine-learning-ex1/ex1/featureNormalize.m

@@ -0,0 +1,39 @@
+function [X_norm, mu, sigma] = featureNormalize(X)
+%FEATURENORMALIZE Normalizes the features in X 
+%   FEATURENORMALIZE(X) returns a normalized version of X where
+%   the mean value of each feature is 0 and the standard deviation
+%   is 1. This is often a good preprocessing step to do when
+%   working with learning algorithms.
+
+% You need to set these values correctly
+X_norm = X;
+mu = zeros(1, size(X, 2));
+sigma = zeros(1, size(X, 2));
+
+% ====================== YOUR CODE HERE ======================
+% Instructions: First, for each feature dimension, compute the mean
+%               of the feature and subtract it from the dataset,
+%               storing the mean value in mu. Next, compute the 
+%               standard deviation of each feature and divide
+%               each feature by it's standard deviation, storing
+%               the standard deviation in sigma. 
+%
+%               Note that X is a matrix where each column is a 
+%               feature and each row is an example. You need 
+%               to perform the normalization separately for 
+%               each feature. 
+%
+% Hint: You might find the 'mean' and 'std' functions useful.
+%       
+
+
+
+
+
+
+
+
+
+% ============================================================
+
+end

+ 41 - 0
machine learning/machine-learning-ex1/ex1/gradientDescent.m

@@ -0,0 +1,41 @@
+function [theta, J_history] = gradientDescent(X, y, theta, alpha, num_iters)
+%GRADIENTDESCENT Performs gradient descent to learn theta
+%   theta = GRADIENTDESCENT(X, y, theta, alpha, num_iters) updates theta by 
+%   taking num_iters gradient steps with learning rate alpha
+
+% Initialize some useful values
+m = length(y); % number of training examples
+J_history = zeros(num_iters, 1);
+
+for iter = 1:num_iters
+
+    % ====================== YOUR CODE HERE ======================
+    % Instructions: Perform a single gradient step on the parameter vector
+    %               theta. 
+    %
+    % Hint: While debugging, it can be useful to print out the values
+    %       of the cost function (computeCost) and gradient here.
+    %
+
+    
+    h_theta = X * theta;
+    hy = (h_theta - y);
+    
+    % https://octave.org/doc/v4.0.3/Arithmetic-Ops.html
+    % use .* to do element by element multiplicaton
+    
+    temp0 = theta(1,1) - alpha / m * sum(hy .* X(:,1));
+    temp1 = theta(2,1) - alpha / m * sum(hy .* X(:,2));
+    %fprintf ("temp0/1: %f // %f / %f\n", temp0, temp1, temp1 + temp0);
+    theta = [temp0;temp1];
+    
+
+
+    % ============================================================
+
+    % Save the cost J in every iteration    
+    J_history(iter) = computeCost(X, y, theta);
+
+end
+
+end

+ 37 - 0
machine learning/machine-learning-ex1/ex1/gradientDescentMulti.m

@@ -0,0 +1,37 @@
+function [theta, J_history] = gradientDescentMulti(X, y, theta, alpha, num_iters)
+%GRADIENTDESCENTMULTI Performs gradient descent to learn theta
+%   theta = GRADIENTDESCENTMULTI(x, y, theta, alpha, num_iters) updates theta by
+%   taking num_iters gradient steps with learning rate alpha
+
+% Initialize some useful values
+m = length(y); % number of training examples
+J_history = zeros(num_iters, 1);
+
+for iter = 1:num_iters
+
+    % ====================== YOUR CODE HERE ======================
+    % Instructions: Perform a single gradient step on the parameter vector
+    %               theta. 
+    %
+    % Hint: While debugging, it can be useful to print out the values
+    %       of the cost function (computeCostMulti) and gradient here.
+    %
+
+
+
+
+
+
+
+
+
+
+
+    % ============================================================
+
+    % Save the cost J in every iteration    
+    J_history(iter) = computeCostMulti(X, y, theta);
+
+end
+
+end

+ 41 - 0
machine learning/machine-learning-ex1/ex1/lib/jsonlab/AUTHORS.txt

@@ -0,0 +1,41 @@
+The author of "jsonlab" toolbox is Qianqian Fang. Qianqian
+is currently an Assistant Professor at Massachusetts General Hospital, 
+Harvard Medical School.
+
+Address: Martinos Center for Biomedical Imaging, 
+         Massachusetts General Hospital, 
+         Harvard Medical School
+         Bldg 149, 13th St, Charlestown, MA 02129, USA
+URL: http://nmr.mgh.harvard.edu/~fangq/
+Email: <fangq at nmr.mgh.harvard.edu> or <fangqq at gmail.com>
+
+
+The script loadjson.m was built upon previous works by
+
+- Nedialko Krouchev: http://www.mathworks.com/matlabcentral/fileexchange/25713
+       date: 2009/11/02
+- François Glineur: http://www.mathworks.com/matlabcentral/fileexchange/23393
+       date: 2009/03/22
+- Joel Feenstra: http://www.mathworks.com/matlabcentral/fileexchange/20565
+       date: 2008/07/03
+
+
+This toolbox contains patches submitted by the following contributors:
+
+- Blake Johnson <bjohnso at bbn.com>
+  part of revision 341
+
+- Niclas Borlin <Niclas.Borlin at cs.umu.se>
+  various fixes in revision 394, including
+  - loadjson crashes for all-zero sparse matrix.
+  - loadjson crashes for empty sparse matrix.
+  - Non-zero size of 0-by-N and N-by-0 empty matrices is lost after savejson/loadjson.
+  - loadjson crashes for sparse real column vector.
+  - loadjson crashes for sparse complex column vector.
+  - Data is corrupted by savejson for sparse real row vector.
+  - savejson crashes for sparse complex row vector. 
+
+- Yul Kang <yul.kang.on at gmail.com>
+  patches for svn revision 415.
+  - savejson saves an empty cell array as [] instead of null
+  - loadjson differentiates an empty struct from an empty array

+ 74 - 0
machine learning/machine-learning-ex1/ex1/lib/jsonlab/ChangeLog.txt

@@ -0,0 +1,74 @@
+============================================================================
+
+   JSONlab - a toolbox to encode/decode JSON/UBJSON files in MATLAB/Octave
+
+----------------------------------------------------------------------------
+
+JSONlab ChangeLog (key features marked by *):
+
+== JSONlab 1.0 (codename: Optimus - Final), FangQ <fangq (at) nmr.mgh.harvard.edu> ==
+
+ 2015/01/02 polish help info for all major functions, update examples, finalize 1.0
+ 2014/12/19 fix a bug to strictly respect NoRowBracket in savejson
+
+== JSONlab 1.0.0-RC2 (codename: Optimus - RC2), FangQ <fangq (at) nmr.mgh.harvard.edu> ==
+
+ 2014/11/22 show progress bar in loadjson ('ShowProgress') 
+ 2014/11/17 add Compact option in savejson to output compact JSON format ('Compact')
+ 2014/11/17 add FastArrayParser in loadjson to specify fast parser applicable levels
+ 2014/09/18 start official github mirror: https://github.com/fangq/jsonlab
+
+== JSONlab 1.0.0-RC1 (codename: Optimus - RC1), FangQ <fangq (at) nmr.mgh.harvard.edu> ==
+
+ 2014/09/17  fix several compatibility issues when running on octave versions 3.2-3.8
+ 2014/09/17  support 2D cell and struct arrays in both savejson and saveubjson
+ 2014/08/04  escape special characters in a JSON string
+ 2014/02/16  fix a bug when saving ubjson files
+
+== JSONlab 0.9.9 (codename: Optimus - beta), FangQ <fangq (at) nmr.mgh.harvard.edu> ==
+
+ 2014/01/22  use binary read and write in saveubjson and loadubjson
+
+== JSONlab 0.9.8-1 (codename: Optimus - alpha update 1), FangQ <fangq (at) nmr.mgh.harvard.edu> ==
+
+ 2013/10/07 better round-trip conservation for empty arrays and structs (patch submitted by Yul Kang)
+
+== JSONlab 0.9.8 (codename: Optimus - alpha), FangQ <fangq (at) nmr.mgh.harvard.edu> ==
+ 2013/08/23 *universal Binary JSON (UBJSON) support, including both saveubjson and loadubjson
+
+== JSONlab 0.9.1 (codename: Rodimus, update 1), FangQ <fangq (at) nmr.mgh.harvard.edu> ==
+ 2012/12/18 *handling of various empty and sparse matrices (fixes submitted by Niclas Borlin)
+
+== JSONlab 0.9.0 (codename: Rodimus), FangQ <fangq (at) nmr.mgh.harvard.edu> ==
+
+ 2012/06/17 *new format for an invalid leading char, unpacking hex code in savejson
+ 2012/06/01  support JSONP in savejson
+ 2012/05/25  fix the empty cell bug (reported by Cyril Davin)
+ 2012/04/05  savejson can save to a file (suggested by Patrick Rapin)
+
+== JSONlab 0.8.1 (codename: Sentiel, Update 1), FangQ <fangq (at) nmr.mgh.harvard.edu> ==
+
+ 2012/02/28  loadjson quotation mark escape bug, see http://bit.ly/yyk1nS
+ 2012/01/25  patch to handle root-less objects, contributed by Blake Johnson
+
+== JSONlab 0.8.0 (codename: Sentiel), FangQ <fangq (at) nmr.mgh.harvard.edu> ==
+
+ 2012/01/13 *speed up loadjson by 20 fold when parsing large data arrays in matlab
+ 2012/01/11  remove row bracket if an array has 1 element, suggested by Mykel Kochenderfer
+ 2011/12/22 *accept sequence of 'param',value input in savejson and loadjson
+ 2011/11/18  fix struct array bug reported by Mykel Kochenderfer
+
+== JSONlab 0.5.1 (codename: Nexus Update 1), FangQ <fangq (at) nmr.mgh.harvard.edu> ==
+
+ 2011/10/21  fix a bug in loadjson, previous code does not use any of the acceleration
+ 2011/10/20  loadjson supports JSON collections - concatenated JSON objects
+
+== JSONlab 0.5.0 (codename: Nexus), FangQ <fangq (at) nmr.mgh.harvard.edu> ==
+
+ 2011/10/16  package and release jsonlab 0.5.0
+ 2011/10/15 *add json demo and regression test, support cpx numbers, fix double quote bug
+ 2011/10/11 *speed up readjson dramatically, interpret _Array* tags, show data in root level
+ 2011/10/10  create jsonlab project, start jsonlab website, add online documentation
+ 2011/10/07 *speed up savejson by 25x using sprintf instead of mat2str, add options support
+ 2011/10/06 *savejson works for structs, cells and arrays
+ 2011/09/09  derive loadjson from JSON parser from MATLAB Central, draft savejson.m

+ 25 - 0
machine learning/machine-learning-ex1/ex1/lib/jsonlab/LICENSE_BSD.txt

@@ -0,0 +1,25 @@
+Copyright 2011-2015 Qianqian Fang <fangq at nmr.mgh.harvard.edu>. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are
+permitted provided that the following conditions are met:
+
+   1. Redistributions of source code must retain the above copyright notice, this list of
+      conditions and the following disclaimer.
+
+   2. Redistributions in binary form must reproduce the above copyright notice, this list
+      of conditions and the following disclaimer in the documentation and/or other materials
+      provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS 
+OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+The views and conclusions contained in the software and documentation are those of the
+authors and should not be interpreted as representing official policies, either expressed
+or implied, of the copyright holders.

+ 394 - 0
machine learning/machine-learning-ex1/ex1/lib/jsonlab/README.txt

@@ -0,0 +1,394 @@
+===============================================================================
+=                                 JSONLab                                     =
+=           An open-source MATLAB/Octave JSON encoder and decoder             =
+===============================================================================
+
+*Copyright (C) 2011-2015  Qianqian Fang <fangq at nmr.mgh.harvard.edu>
+*License: BSD License, see License_BSD.txt for details
+*Version: 1.0 (Optimus - Final)
+
+-------------------------------------------------------------------------------
+
+Table of Content:
+
+I.  Introduction
+II. Installation
+III.Using JSONLab
+IV. Known Issues and TODOs
+V.  Contribution and feedback
+
+-------------------------------------------------------------------------------
+
+I.  Introduction
+
+JSON ([http://www.json.org/ JavaScript Object Notation]) is a highly portable, 
+human-readable and "[http://en.wikipedia.org/wiki/JSON fat-free]" text format 
+to represent complex and hierarchical data. It is as powerful as 
+[http://en.wikipedia.org/wiki/XML XML], but less verbose. JSON format is widely 
+used for data-exchange in applications, and is essential for the wild success 
+of [http://en.wikipedia.org/wiki/Ajax_(programming) Ajax] and 
+[http://en.wikipedia.org/wiki/Web_2.0 Web2.0]. 
+
+UBJSON (Universal Binary JSON) is a binary JSON format, specifically 
+optimized for compact file size and better performance while keeping
+the semantics as simple as the text-based JSON format. Using the UBJSON
+format allows to wrap complex binary data in a flexible and extensible
+structure, making it possible to process complex and large dataset 
+without accuracy loss due to text conversions.
+
+We envision that both JSON and its binary version will serve as part of 
+the mainstream data-exchange formats for scientific research in the future. 
+It will provide the flexibility and generality achieved by other popular 
+general-purpose file specifications, such as
+[http://www.hdfgroup.org/HDF5/whatishdf5.html HDF5], with significantly 
+reduced complexity and enhanced performance.
+
+JSONLab is a free and open-source implementation of a JSON/UBJSON encoder 
+and a decoder in the native MATLAB language. It can be used to convert a MATLAB 
+data structure (array, struct, cell, struct array and cell array) into 
+JSON/UBJSON formatted strings, or to decode a JSON/UBJSON file into MATLAB 
+data structure. JSONLab supports both MATLAB and  
+[http://www.gnu.org/software/octave/ GNU Octave] (a free MATLAB clone).
+
+-------------------------------------------------------------------------------
+
+II. Installation
+
+The installation of JSONLab is no different than any other simple
+MATLAB toolbox. You only need to download/unzip the JSONLab package
+to a folder, and add the folder's path to MATLAB/Octave's path list
+by using the following command:
+
+    addpath('/path/to/jsonlab');
+
+If you want to add this path permanently, you need to type "pathtool", 
+browse to the jsonlab root folder and add to the list, then click "Save".
+Then, run "rehash" in MATLAB, and type "which loadjson", if you see an 
+output, that means JSONLab is installed for MATLAB/Octave.
+
+-------------------------------------------------------------------------------
+
+III.Using JSONLab
+
+JSONLab provides two functions, loadjson.m -- a MATLAB->JSON decoder, 
+and savejson.m -- a MATLAB->JSON encoder, for the text-based JSON, and 
+two equivallent functions -- loadubjson and saveubjson for the binary 
+JSON. The detailed help info for the four functions can be found below:
+
+=== loadjson.m ===
+<pre>
+  data=loadjson(fname,opt)
+     or
+  data=loadjson(fname,'param1',value1,'param2',value2,...)
+ 
+  parse a JSON (JavaScript Object Notation) file or string
+ 
+  authors:Qianqian Fang (fangq<at> nmr.mgh.harvard.edu)
+  created on 2011/09/09, including previous works from 
+ 
+          Nedialko Krouchev: http://www.mathworks.com/matlabcentral/fileexchange/25713
+             created on 2009/11/02
+          François Glineur: http://www.mathworks.com/matlabcentral/fileexchange/23393
+             created on  2009/03/22
+          Joel Feenstra:
+          http://www.mathworks.com/matlabcentral/fileexchange/20565
+             created on 2008/07/03
+ 
+  $Id: loadjson.m 452 2014-11-22 16:43:33Z fangq $
+ 
+  input:
+       fname: input file name, if fname contains "{}" or "[]", fname
+              will be interpreted as a JSON string
+       opt: a struct to store parsing options, opt can be replaced by 
+            a list of ('param',value) pairs - the param string is equivallent
+            to a field in opt. opt can have the following 
+            fields (first in [.|.] is the default)
+ 
+            opt.SimplifyCell [0|1]: if set to 1, loadjson will call cell2mat
+                          for each element of the JSON data, and group 
+                          arrays based on the cell2mat rules.
+            opt.FastArrayParser [1|0 or integer]: if set to 1, use a
+                          speed-optimized array parser when loading an 
+                          array object. The fast array parser may 
+                          collapse block arrays into a single large
+                          array similar to rules defined in cell2mat; 0 to 
+                          use a legacy parser; if set to a larger-than-1
+                          value, this option will specify the minimum
+                          dimension to enable the fast array parser. For
+                          example, if the input is a 3D array, setting
+                          FastArrayParser to 1 will return a 3D array;
+                          setting to 2 will return a cell array of 2D
+                          arrays; setting to 3 will return to a 2D cell
+                          array of 1D vectors; setting to 4 will return a
+                          3D cell array.
+            opt.ShowProgress [0|1]: if set to 1, loadjson displays a progress bar.
+ 
+  output:
+       dat: a cell array, where {...} blocks are converted into cell arrays,
+            and [...] are converted to arrays
+ 
+  examples:
+       dat=loadjson('{"obj":{"string":"value","array":[1,2,3]}}')
+       dat=loadjson(['examples' filesep 'example1.json'])
+       dat=loadjson(['examples' filesep 'example1.json'],'SimplifyCell',1)
+</pre>
+
+=== savejson.m ===
+
+<pre>
+  json=savejson(rootname,obj,filename)
+     or
+  json=savejson(rootname,obj,opt)
+  json=savejson(rootname,obj,'param1',value1,'param2',value2,...)
+ 
+  convert a MATLAB object (cell, struct or array) into a JSON (JavaScript
+  Object Notation) string
+ 
+  author: Qianqian Fang (fangq<at> nmr.mgh.harvard.edu)
+  created on 2011/09/09
+ 
+  $Id: savejson.m 458 2014-12-19 22:17:17Z fangq $
+ 
+  input:
+       rootname: the name of the root-object, when set to '', the root name
+         is ignored, however, when opt.ForceRootName is set to 1 (see below),
+         the MATLAB variable name will be used as the root name.
+       obj: a MATLAB object (array, cell, cell array, struct, struct array).
+       filename: a string for the file name to save the output JSON data.
+       opt: a struct for additional options, ignore to use default values.
+         opt can have the following fields (first in [.|.] is the default)
+ 
+         opt.FileName [''|string]: a file name to save the output JSON data
+         opt.FloatFormat ['%.10g'|string]: format to show each numeric element
+                          of a 1D/2D array;
+         opt.ArrayIndent [1|0]: if 1, output explicit data array with
+                          precedent indentation; if 0, no indentation
+         opt.ArrayToStruct[0|1]: when set to 0, savejson outputs 1D/2D
+                          array in JSON array format; if sets to 1, an
+                          array will be shown as a struct with fields
+                          "_ArrayType_", "_ArraySize_" and "_ArrayData_"; for
+                          sparse arrays, the non-zero elements will be
+                          saved to _ArrayData_ field in triplet-format i.e.
+                          (ix,iy,val) and "_ArrayIsSparse_" will be added
+                          with a value of 1; for a complex array, the 
+                          _ArrayData_ array will include two columns 
+                          (4 for sparse) to record the real and imaginary 
+                          parts, and also "_ArrayIsComplex_":1 is added. 
+         opt.ParseLogical [0|1]: if this is set to 1, logical array elem
+                          will use true/false rather than 1/0.
+         opt.NoRowBracket [1|0]: if this is set to 1, arrays with a single
+                          numerical element will be shown without a square
+                          bracket, unless it is the root object; if 0, square
+                          brackets are forced for any numerical arrays.
+         opt.ForceRootName [0|1]: when set to 1 and rootname is empty, savejson
+                          will use the name of the passed obj variable as the 
+                          root object name; if obj is an expression and 
+                          does not have a name, 'root' will be used; if this 
+                          is set to 0 and rootname is empty, the root level 
+                          will be merged down to the lower level.
+         opt.Inf ['"$1_Inf_"'|string]: a customized regular expression pattern
+                          to represent +/-Inf. The matched pattern is '([-+]*)Inf'
+                          and $1 represents the sign. For those who want to use
+                          1e999 to represent Inf, they can set opt.Inf to '$11e999'
+         opt.NaN ['"_NaN_"'|string]: a customized regular expression pattern
+                          to represent NaN
+         opt.JSONP [''|string]: to generate a JSONP output (JSON with padding),
+                          for example, if opt.JSONP='foo', the JSON data is
+                          wrapped inside a function call as 'foo(...);'
+         opt.UnpackHex [1|0]: conver the 0x[hex code] output by loadjson 
+                          back to the string form
+         opt.SaveBinary [0|1]: 1 - save the JSON file in binary mode; 0 - text mode.
+         opt.Compact [0|1]: 1- out compact JSON format (remove all newlines and tabs)
+ 
+         opt can be replaced by a list of ('param',value) pairs. The param 
+         string is equivallent to a field in opt and is case sensitive.
+  output:
+       json: a string in the JSON format (see http://json.org)
+ 
+  examples:
+       jsonmesh=struct('MeshNode',[0 0 0;1 0 0;0 1 0;1 1 0;0 0 1;1 0 1;0 1 1;1 1 1],... 
+                'MeshTetra',[1 2 4 8;1 3 4 8;1 2 6 8;1 5 6 8;1 5 7 8;1 3 7 8],...
+                'MeshTri',[1 2 4;1 2 6;1 3 4;1 3 7;1 5 6;1 5 7;...
+                           2 8 4;2 8 6;3 8 4;3 8 7;5 8 6;5 8 7],...
+                'MeshCreator','FangQ','MeshTitle','T6 Cube',...
+                'SpecialData',[nan, inf, -inf]);
+       savejson('jmesh',jsonmesh)
+       savejson('',jsonmesh,'ArrayIndent',0,'FloatFormat','\t%.5g')
+ </pre>
+
+=== loadubjson.m ===
+
+<pre>
+  data=loadubjson(fname,opt)
+     or
+  data=loadubjson(fname,'param1',value1,'param2',value2,...)
+ 
+  parse a JSON (JavaScript Object Notation) file or string
+ 
+  authors:Qianqian Fang (fangq<at> nmr.mgh.harvard.edu)
+  created on 2013/08/01
+ 
+  $Id: loadubjson.m 436 2014-08-05 20:51:40Z fangq $
+ 
+  input:
+       fname: input file name, if fname contains "{}" or "[]", fname
+              will be interpreted as a UBJSON string
+       opt: a struct to store parsing options, opt can be replaced by 
+            a list of ('param',value) pairs - the param string is equivallent
+            to a field in opt. opt can have the following 
+            fields (first in [.|.] is the default)
+ 
+            opt.SimplifyCell [0|1]: if set to 1, loadubjson will call cell2mat
+                          for each element of the JSON data, and group 
+                          arrays based on the cell2mat rules.
+            opt.IntEndian [B|L]: specify the endianness of the integer fields
+                          in the UBJSON input data. B - Big-Endian format for 
+                          integers (as required in the UBJSON specification); 
+                          L - input integer fields are in Little-Endian order.
+ 
+  output:
+       dat: a cell array, where {...} blocks are converted into cell arrays,
+            and [...] are converted to arrays
+ 
+  examples:
+       obj=struct('string','value','array',[1 2 3]);
+       ubjdata=saveubjson('obj',obj);
+       dat=loadubjson(ubjdata)
+       dat=loadubjson(['examples' filesep 'example1.ubj'])
+       dat=loadubjson(['examples' filesep 'example1.ubj'],'SimplifyCell',1)
+</pre>
+
+=== saveubjson.m ===
+
+<pre>
+  json=saveubjson(rootname,obj,filename)
+     or
+  json=saveubjson(rootname,obj,opt)
+  json=saveubjson(rootname,obj,'param1',value1,'param2',value2,...)
+ 
+  convert a MATLAB object (cell, struct or array) into a Universal 
+  Binary JSON (UBJSON) binary string
+ 
+  author: Qianqian Fang (fangq<at> nmr.mgh.harvard.edu)
+  created on 2013/08/17
+ 
+  $Id: saveubjson.m 440 2014-09-17 19:59:45Z fangq $
+ 
+  input:
+       rootname: the name of the root-object, when set to '', the root name
+         is ignored, however, when opt.ForceRootName is set to 1 (see below),
+         the MATLAB variable name will be used as the root name.
+       obj: a MATLAB object (array, cell, cell array, struct, struct array)
+       filename: a string for the file name to save the output UBJSON data
+       opt: a struct for additional options, ignore to use default values.
+         opt can have the following fields (first in [.|.] is the default)
+ 
+         opt.FileName [''|string]: a file name to save the output JSON data
+         opt.ArrayToStruct[0|1]: when set to 0, saveubjson outputs 1D/2D
+                          array in JSON array format; if sets to 1, an
+                          array will be shown as a struct with fields
+                          "_ArrayType_", "_ArraySize_" and "_ArrayData_"; for
+                          sparse arrays, the non-zero elements will be
+                          saved to _ArrayData_ field in triplet-format i.e.
+                          (ix,iy,val) and "_ArrayIsSparse_" will be added
+                          with a value of 1; for a complex array, the 
+                          _ArrayData_ array will include two columns 
+                          (4 for sparse) to record the real and imaginary 
+                          parts, and also "_ArrayIsComplex_":1 is added. 
+         opt.ParseLogical [1|0]: if this is set to 1, logical array elem
+                          will use true/false rather than 1/0.
+         opt.NoRowBracket [1|0]: if this is set to 1, arrays with a single
+                          numerical element will be shown without a square
+                          bracket, unless it is the root object; if 0, square
+                          brackets are forced for any numerical arrays.
+         opt.ForceRootName [0|1]: when set to 1 and rootname is empty, saveubjson
+                          will use the name of the passed obj variable as the 
+                          root object name; if obj is an expression and 
+                          does not have a name, 'root' will be used; if this 
+                          is set to 0 and rootname is empty, the root level 
+                          will be merged down to the lower level.
+         opt.JSONP [''|string]: to generate a JSONP output (JSON with padding),
+                          for example, if opt.JSON='foo', the JSON data is
+                          wrapped inside a function call as 'foo(...);'
+         opt.UnpackHex [1|0]: conver the 0x[hex code] output by loadjson 
+                          back to the string form
+ 
+         opt can be replaced by a list of ('param',value) pairs. The param 
+         string is equivallent to a field in opt and is case sensitive.
+  output:
+       json: a binary string in the UBJSON format (see http://ubjson.org)
+ 
+  examples:
+       jsonmesh=struct('MeshNode',[0 0 0;1 0 0;0 1 0;1 1 0;0 0 1;1 0 1;0 1 1;1 1 1],... 
+                'MeshTetra',[1 2 4 8;1 3 4 8;1 2 6 8;1 5 6 8;1 5 7 8;1 3 7 8],...
+                'MeshTri',[1 2 4;1 2 6;1 3 4;1 3 7;1 5 6;1 5 7;...
+                           2 8 4;2 8 6;3 8 4;3 8 7;5 8 6;5 8 7],...
+                'MeshCreator','FangQ','MeshTitle','T6 Cube',...
+                'SpecialData',[nan, inf, -inf]);
+       saveubjson('jsonmesh',jsonmesh)
+       saveubjson('jsonmesh',jsonmesh,'meshdata.ubj')
+</pre>
+
+
+=== examples ===
+
+Under the "examples" folder, you can find several scripts to demonstrate the
+basic utilities of JSONLab. Running the "demo_jsonlab_basic.m" script, you 
+will see the conversions from MATLAB data structure to JSON text and backward.
+In "jsonlab_selftest.m", we load complex JSON files downloaded from the Internet
+and validate the loadjson/savejson functions for regression testing purposes.
+Similarly, a "demo_ubjson_basic.m" script is provided to test the saveubjson
+and loadubjson pairs for various matlab data structures.
+
+Please run these examples and understand how JSONLab works before you use
+it to process your data.
+
+-------------------------------------------------------------------------------
+
+IV. Known Issues and TODOs
+
+JSONLab has several known limitations. We are striving to make it more general
+and robust. Hopefully in a few future releases, the limitations become less.
+
+Here are the known issues:
+
+# 3D or higher dimensional cell/struct-arrays will be converted to 2D arrays;
+# When processing names containing multi-byte characters, Octave and MATLAB \
+can give different field-names; you can use feature('DefaultCharacterSet','latin1') \
+in MATLAB to get consistant results
+# savejson can not handle class and dataset.
+# saveubjson converts a logical array into a uint8 ([U]) array
+# an unofficial N-D array count syntax is implemented in saveubjson. We are \
+actively communicating with the UBJSON spec maintainer to investigate the \
+possibility of making it upstream
+# loadubjson can not parse all UBJSON Specification (Draft 9) compliant \
+files, however, it can parse all UBJSON files produced by saveubjson.
+
+-------------------------------------------------------------------------------
+
+V. Contribution and feedback
+
+JSONLab is an open-source project. This means you can not only use it and modify
+it as you wish, but also you can contribute your changes back to JSONLab so
+that everyone else can enjoy the improvement. For anyone who want to contribute,
+please download JSONLab source code from it's subversion repository by using the
+following command:
+
+ svn checkout svn://svn.code.sf.net/p/iso2mesh/code/trunk/jsonlab jsonlab
+
+You can make changes to the files as needed. Once you are satisfied with your
+changes, and ready to share it with others, please cd the root directory of 
+JSONLab, and type
+
+ svn diff > yourname_featurename.patch
+
+You then email the .patch file to JSONLab's maintainer, Qianqian Fang, at
+the email address shown in the beginning of this file. Qianqian will review 
+the changes and commit it to the subversion if they are satisfactory.
+
+We appreciate any suggestions and feedbacks from you. Please use iso2mesh's
+mailing list to report any questions you may have with JSONLab:
+
+http://groups.google.com/group/iso2mesh-users?hl=en&pli=1
+
+(Subscription to the mailing list is needed in order to post messages).

+ 32 - 0
machine learning/machine-learning-ex1/ex1/lib/jsonlab/jsonopt.m

@@ -0,0 +1,32 @@
+function val=jsonopt(key,default,varargin)
+%
+% val=jsonopt(key,default,optstruct)
+%
+% setting options based on a struct. The struct can be produced
+% by varargin2struct from a list of 'param','value' pairs
+%
+% authors:Qianqian Fang (fangq<at> nmr.mgh.harvard.edu)
+%
+% $Id: loadjson.m 371 2012-06-20 12:43:06Z fangq $
+%
+% input:
+%      key: a string with which one look up a value from a struct
+%      default: if the key does not exist, return default
+%      optstruct: a struct where each sub-field is a key 
+%
+% output:
+%      val: if key exists, val=optstruct.key; otherwise val=default
+%
+% license:
+%     BSD, see LICENSE_BSD.txt files for details
+%
+% -- this function is part of jsonlab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)
+% 
+
+val=default;
+if(nargin<=2) return; end
+opt=varargin{1};
+if(isstruct(opt) && isfield(opt,key))
+    val=getfield(opt,key);
+end
+

+ 566 - 0
machine learning/machine-learning-ex1/ex1/lib/jsonlab/loadjson.m

@@ -0,0 +1,566 @@
+function data = loadjson(fname,varargin)
+%
+% data=loadjson(fname,opt)
+%    or
+% data=loadjson(fname,'param1',value1,'param2',value2,...)
+%
+% parse a JSON (JavaScript Object Notation) file or string
+%
+% authors:Qianqian Fang (fangq<at> nmr.mgh.harvard.edu)
+% created on 2011/09/09, including previous works from 
+%
+%         Nedialko Krouchev: http://www.mathworks.com/matlabcentral/fileexchange/25713
+%            created on 2009/11/02
+%         François Glineur: http://www.mathworks.com/matlabcentral/fileexchange/23393
+%            created on  2009/03/22
+%         Joel Feenstra:
+%         http://www.mathworks.com/matlabcentral/fileexchange/20565
+%            created on 2008/07/03
+%
+% $Id: loadjson.m 460 2015-01-03 00:30:45Z fangq $
+%
+% input:
+%      fname: input file name, if fname contains "{}" or "[]", fname
+%             will be interpreted as a JSON string
+%      opt: a struct to store parsing options, opt can be replaced by 
+%           a list of ('param',value) pairs - the param string is equivallent
+%           to a field in opt. opt can have the following 
+%           fields (first in [.|.] is the default)
+%
+%           opt.SimplifyCell [0|1]: if set to 1, loadjson will call cell2mat
+%                         for each element of the JSON data, and group 
+%                         arrays based on the cell2mat rules.
+%           opt.FastArrayParser [1|0 or integer]: if set to 1, use a
+%                         speed-optimized array parser when loading an 
+%                         array object. The fast array parser may 
+%                         collapse block arrays into a single large
+%                         array similar to rules defined in cell2mat; 0 to 
+%                         use a legacy parser; if set to a larger-than-1
+%                         value, this option will specify the minimum
+%                         dimension to enable the fast array parser. For
+%                         example, if the input is a 3D array, setting
+%                         FastArrayParser to 1 will return a 3D array;
+%                         setting to 2 will return a cell array of 2D
+%                         arrays; setting to 3 will return to a 2D cell
+%                         array of 1D vectors; setting to 4 will return a
+%                         3D cell array.
+%           opt.ShowProgress [0|1]: if set to 1, loadjson displays a progress bar.
+%
+% output:
+%      dat: a cell array, where {...} blocks are converted into cell arrays,
+%           and [...] are converted to arrays
+%
+% examples:
+%      dat=loadjson('{"obj":{"string":"value","array":[1,2,3]}}')
+%      dat=loadjson(['examples' filesep 'example1.json'])
+%      dat=loadjson(['examples' filesep 'example1.json'],'SimplifyCell',1)
+%
+% license:
+%     BSD, see LICENSE_BSD.txt files for details 
+%
+% -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)
+%
+
+global pos inStr len  esc index_esc len_esc isoct arraytoken
+
+if(regexp(fname,'[\{\}\]\[]','once'))
+   string=fname;
+elseif(exist(fname,'file'))
+   fid = fopen(fname,'rb');
+   string = fread(fid,inf,'uint8=>char')';
+   fclose(fid);
+else
+   error('input file does not exist');
+end
+
+pos = 1; len = length(string); inStr = string;
+isoct=exist('OCTAVE_VERSION','builtin');
+arraytoken=find(inStr=='[' | inStr==']' | inStr=='"');
+jstr=regexprep(inStr,'\\\\','  ');
+escquote=regexp(jstr,'\\"');
+arraytoken=sort([arraytoken escquote]);
+
+% String delimiters and escape chars identified to improve speed:
+esc = find(inStr=='"' | inStr=='\' ); % comparable to: regexp(inStr, '["\\]');
+index_esc = 1; len_esc = length(esc);
+
+opt=varargin2struct(varargin{:});
+
+if(jsonopt('ShowProgress',0,opt)==1)
+    opt.progressbar_=waitbar(0,'loading ...');
+end
+jsoncount=1;
+while pos <= len
+    switch(next_char)
+        case '{'
+            data{jsoncount} = parse_object(opt);
+        case '['
+            data{jsoncount} = parse_array(opt);
+        otherwise
+            error_pos('Outer level structure must be an object or an array');
+    end
+    jsoncount=jsoncount+1;
+end % while
+
+jsoncount=length(data);
+if(jsoncount==1 && iscell(data))
+    data=data{1};
+end
+
+if(~isempty(data))
+      if(isstruct(data)) % data can be a struct array
+          data=jstruct2array(data);
+      elseif(iscell(data))
+          data=jcell2array(data);
+      end
+end
+if(isfield(opt,'progressbar_'))
+    close(opt.progressbar_);
+end
+
+%%
+function newdata=jcell2array(data)
+len=length(data);
+newdata=data;
+for i=1:len
+      if(isstruct(data{i}))
+          newdata{i}=jstruct2array(data{i});
+      elseif(iscell(data{i}))
+          newdata{i}=jcell2array(data{i});
+      end
+end
+
+%%-------------------------------------------------------------------------
+function newdata=jstruct2array(data)
+fn=fieldnames(data);
+newdata=data;
+len=length(data);
+for i=1:length(fn) % depth-first
+    for j=1:len
+        if(isstruct(getfield(data(j),fn{i})))
+            newdata(j)=setfield(newdata(j),fn{i},jstruct2array(getfield(data(j),fn{i})));
+        end
+    end
+end
+if(~isempty(strmatch('x0x5F_ArrayType_',fn)) && ~isempty(strmatch('x0x5F_ArrayData_',fn)))
+  newdata=cell(len,1);
+  for j=1:len
+    ndata=cast(data(j).x0x5F_ArrayData_,data(j).x0x5F_ArrayType_);
+    iscpx=0;
+    if(~isempty(strmatch('x0x5F_ArrayIsComplex_',fn)))
+        if(data(j).x0x5F_ArrayIsComplex_)
+           iscpx=1;
+        end
+    end
+    if(~isempty(strmatch('x0x5F_ArrayIsSparse_',fn)))
+        if(data(j).x0x5F_ArrayIsSparse_)
+            if(~isempty(strmatch('x0x5F_ArraySize_',fn)))
+                dim=data(j).x0x5F_ArraySize_;
+                if(iscpx && size(ndata,2)==4-any(dim==1))
+                    ndata(:,end-1)=complex(ndata(:,end-1),ndata(:,end));
+                end
+                if isempty(ndata)
+                    % All-zeros sparse
+                    ndata=sparse(dim(1),prod(dim(2:end)));
+                elseif dim(1)==1
+                    % Sparse row vector
+                    ndata=sparse(1,ndata(:,1),ndata(:,2),dim(1),prod(dim(2:end)));
+                elseif dim(2)==1
+                    % Sparse column vector
+                    ndata=sparse(ndata(:,1),1,ndata(:,2),dim(1),prod(dim(2:end)));
+                else
+                    % Generic sparse array.
+                    ndata=sparse(ndata(:,1),ndata(:,2),ndata(:,3),dim(1),prod(dim(2:end)));
+                end
+            else
+                if(iscpx && size(ndata,2)==4)
+                    ndata(:,3)=complex(ndata(:,3),ndata(:,4));
+                end
+                ndata=sparse(ndata(:,1),ndata(:,2),ndata(:,3));
+            end
+        end
+    elseif(~isempty(strmatch('x0x5F_ArraySize_',fn)))
+        if(iscpx && size(ndata,2)==2)
+             ndata=complex(ndata(:,1),ndata(:,2));
+        end
+        ndata=reshape(ndata(:),data(j).x0x5F_ArraySize_);
+    end
+    newdata{j}=ndata;
+  end
+  if(len==1)
+      newdata=newdata{1};
+  end
+end
+
+%%-------------------------------------------------------------------------
+function object = parse_object(varargin)
+    parse_char('{');
+    object = [];
+    if next_char ~= '}'
+        while 1
+            str = parseStr(varargin{:});
+            if isempty(str)
+                error_pos('Name of value at position %d cannot be empty');
+            end
+            parse_char(':');
+            val = parse_value(varargin{:});
+            eval( sprintf( 'object.%s  = val;', valid_field(str) ) );
+            if next_char == '}'
+                break;
+            end
+            parse_char(',');
+        end
+    end
+    parse_char('}');
+
+%%-------------------------------------------------------------------------
+
+function object = parse_array(varargin) % JSON array is written in row-major order
+global pos inStr isoct
+    parse_char('[');
+    object = cell(0, 1);
+    dim2=[];
+    arraydepth=jsonopt('JSONLAB_ArrayDepth_',1,varargin{:});
+    pbar=jsonopt('progressbar_',-1,varargin{:});
+
+    if next_char ~= ']'
+	if(jsonopt('FastArrayParser',1,varargin{:})>=1 && arraydepth>=jsonopt('FastArrayParser',1,varargin{:}))
+            [endpos, e1l, e1r, maxlevel]=matching_bracket(inStr,pos);
+            arraystr=['[' inStr(pos:endpos)];
+            arraystr=regexprep(arraystr,'"_NaN_"','NaN');
+            arraystr=regexprep(arraystr,'"([-+]*)_Inf_"','$1Inf');
+            arraystr(arraystr==sprintf('\n'))=[];
+            arraystr(arraystr==sprintf('\r'))=[];
+            %arraystr=regexprep(arraystr,'\s*,',','); % this is slow,sometimes needed
+            if(~isempty(e1l) && ~isempty(e1r)) % the array is in 2D or higher D
+        	astr=inStr((e1l+1):(e1r-1));
+        	astr=regexprep(astr,'"_NaN_"','NaN');
+        	astr=regexprep(astr,'"([-+]*)_Inf_"','$1Inf');
+        	astr(astr==sprintf('\n'))=[];
+        	astr(astr==sprintf('\r'))=[];
+        	astr(astr==' ')='';
+        	if(isempty(find(astr=='[', 1))) % array is 2D
+                    dim2=length(sscanf(astr,'%f,',[1 inf]));
+        	end
+            else % array is 1D
+        	astr=arraystr(2:end-1);
+        	astr(astr==' ')='';
+        	[obj, count, errmsg, nextidx]=sscanf(astr,'%f,',[1,inf]);
+        	if(nextidx>=length(astr)-1)
+                    object=obj;
+                    pos=endpos;
+                    parse_char(']');
+                    return;
+        	end
+            end
+            if(~isempty(dim2))
+        	astr=arraystr;
+        	astr(astr=='[')='';
+        	astr(astr==']')='';
+        	astr(astr==' ')='';
+        	[obj, count, errmsg, nextidx]=sscanf(astr,'%f,',inf);
+        	if(nextidx>=length(astr)-1)
+                    object=reshape(obj,dim2,numel(obj)/dim2)';
+                    pos=endpos;
+                    parse_char(']');
+                    if(pbar>0)
+                        waitbar(pos/length(inStr),pbar,'loading ...');
+                    end
+                    return;
+        	end
+            end
+            arraystr=regexprep(arraystr,'\]\s*,','];');
+	else
+            arraystr='[';
+	end
+        try
+           if(isoct && regexp(arraystr,'"','once'))
+                error('Octave eval can produce empty cells for JSON-like input');
+           end
+           object=eval(arraystr);
+           pos=endpos;
+        catch
+         while 1
+            newopt=varargin2struct(varargin{:},'JSONLAB_ArrayDepth_',arraydepth+1);
+            val = parse_value(newopt);
+            object{end+1} = val;
+            if next_char == ']'
+                break;
+            end
+            parse_char(',');
+         end
+        end
+    end
+    if(jsonopt('SimplifyCell',0,varargin{:})==1)
+      try
+        oldobj=object;
+        object=cell2mat(object')';
+        if(iscell(oldobj) && isstruct(object) && numel(object)>1 && jsonopt('SimplifyCellArray',1,varargin{:})==0)
+            object=oldobj;
+        elseif(size(object,1)>1 && ndims(object)==2)
+            object=object';
+        end
+      catch
+      end
+    end
+    parse_char(']');
+    
+    if(pbar>0)
+        waitbar(pos/length(inStr),pbar,'loading ...');
+    end
+%%-------------------------------------------------------------------------
+
+function parse_char(c)
+    global pos inStr len
+    skip_whitespace;
+    if pos > len || inStr(pos) ~= c
+        error_pos(sprintf('Expected %c at position %%d', c));
+    else
+        pos = pos + 1;
+        skip_whitespace;
+    end
+
+%%-------------------------------------------------------------------------
+
+function c = next_char
+    global pos inStr len
+    skip_whitespace;
+    if pos > len
+        c = [];
+    else
+        c = inStr(pos);
+    end
+
+%%-------------------------------------------------------------------------
+
+function skip_whitespace
+    global pos inStr len
+    while pos <= len && isspace(inStr(pos))
+        pos = pos + 1;
+    end
+
+%%-------------------------------------------------------------------------
+function str = parseStr(varargin)
+    global pos inStr len  esc index_esc len_esc
+ % len, ns = length(inStr), keyboard
+    if inStr(pos) ~= '"'
+        error_pos('String starting with " expected at position %d');
+    else
+        pos = pos + 1;
+    end
+    str = '';
+    while pos <= len
+        while index_esc <= len_esc && esc(index_esc) < pos
+            index_esc = index_esc + 1;
+        end
+        if index_esc > len_esc
+            str = [str inStr(pos:len)];
+            pos = len + 1;
+            break;
+        else
+            str = [str inStr(pos:esc(index_esc)-1)];
+            pos = esc(index_esc);
+        end
+        nstr = length(str); switch inStr(pos)
+            case '"'
+                pos = pos + 1;
+                if(~isempty(str))
+                    if(strcmp(str,'_Inf_'))
+                        str=Inf;
+                    elseif(strcmp(str,'-_Inf_'))
+                        str=-Inf;
+                    elseif(strcmp(str,'_NaN_'))
+                        str=NaN;
+                    end
+                end
+                return;
+            case '\'
+                if pos+1 > len
+                    error_pos('End of file reached right after escape character');
+                end
+                pos = pos + 1;
+                switch inStr(pos)
+                    case {'"' '\' '/'}
+                        str(nstr+1) = inStr(pos);
+                        pos = pos + 1;
+                    case {'b' 'f' 'n' 'r' 't'}
+                        str(nstr+1) = sprintf(['\' inStr(pos)]);
+                        pos = pos + 1;
+                    case 'u'
+                        if pos+4 > len
+                            error_pos('End of file reached in escaped unicode character');
+                        end
+                        str(nstr+(1:6)) = inStr(pos-1:pos+4);
+                        pos = pos + 5;
+                end
+            otherwise % should never happen
+                str(nstr+1) = inStr(pos), keyboard
+                pos = pos + 1;
+        end
+    end
+    error_pos('End of file while expecting end of inStr');
+
+%%-------------------------------------------------------------------------
+
+function num = parse_number(varargin)
+    global pos inStr len isoct
+    currstr=inStr(pos:end);
+    numstr=0;
+    if(isoct~=0)
+        numstr=regexp(currstr,'^\s*-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+\-]?\d+)?','end');
+        [num, one] = sscanf(currstr, '%f', 1);
+        delta=numstr+1;
+    else
+        [num, one, err, delta] = sscanf(currstr, '%f', 1);
+        if ~isempty(err)
+            error_pos('Error reading number at position %d');
+        end
+    end
+    pos = pos + delta-1;
+
+%%-------------------------------------------------------------------------
+
+function val = parse_value(varargin)
+    global pos inStr len
+    true = 1; false = 0;
+    
+    pbar=jsonopt('progressbar_',-1,varargin{:});
+    if(pbar>0)
+        waitbar(pos/len,pbar,'loading ...');
+    end
+    
+    switch(inStr(pos))
+        case '"'
+            val = parseStr(varargin{:});
+            return;
+        case '['
+            val = parse_array(varargin{:});
+            return;
+        case '{'
+            val = parse_object(varargin{:});
+            if isstruct(val)
+                if(~isempty(strmatch('x0x5F_ArrayType_',fieldnames(val), 'exact')))
+                    val=jstruct2array(val);
+                end
+            elseif isempty(val)
+                val = struct;
+            end
+            return;
+        case {'-','0','1','2','3','4','5','6','7','8','9'}
+            val = parse_number(varargin{:});
+            return;
+        case 't'
+            if pos+3 <= len && strcmpi(inStr(pos:pos+3), 'true')
+                val = true;
+                pos = pos + 4;
+                return;
+            end
+        case 'f'
+            if pos+4 <= len && strcmpi(inStr(pos:pos+4), 'false')
+                val = false;
+                pos = pos + 5;
+                return;
+            end
+        case 'n'
+            if pos+3 <= len && strcmpi(inStr(pos:pos+3), 'null')
+                val = [];
+                pos = pos + 4;
+                return;
+            end
+    end
+    error_pos('Value expected at position %d');
+%%-------------------------------------------------------------------------
+
+function error_pos(msg)
+    global pos inStr len
+    poShow = max(min([pos-15 pos-1 pos pos+20],len),1);
+    if poShow(3) == poShow(2)
+        poShow(3:4) = poShow(2)+[0 -1];  % display nothing after
+    end
+    msg = [sprintf(msg, pos) ': ' ...
+    inStr(poShow(1):poShow(2)) '<error>' inStr(poShow(3):poShow(4)) ];
+    error( ['JSONparser:invalidFormat: ' msg] );
+
+%%-------------------------------------------------------------------------
+
+function str = valid_field(str)
+global isoct
+% From MATLAB doc: field names must begin with a letter, which may be
+% followed by any combination of letters, digits, and underscores.
+% Invalid characters will be converted to underscores, and the prefix
+% "x0x[Hex code]_" will be added if the first character is not a letter.
+    pos=regexp(str,'^[^A-Za-z]','once');
+    if(~isempty(pos))
+        if(~isoct)
+            str=regexprep(str,'^([^A-Za-z])','x0x${sprintf(''%X'',unicode2native($1))}_','once');
+        else
+            str=sprintf('x0x%X_%s',char(str(1)),str(2:end));
+        end
+    end
+    if(isempty(regexp(str,'[^0-9A-Za-z_]', 'once' ))) return;  end
+    if(~isoct)
+        str=regexprep(str,'([^0-9A-Za-z_])','_0x${sprintf(''%X'',unicode2native($1))}_');
+    else
+        pos=regexp(str,'[^0-9A-Za-z_]');
+        if(isempty(pos)) return; end
+        str0=str;
+        pos0=[0 pos(:)' length(str)];
+        str='';
+        for i=1:length(pos)
+            str=[str str0(pos0(i)+1:pos(i)-1) sprintf('_0x%X_',str0(pos(i)))];
+        end
+        if(pos(end)~=length(str))
+            str=[str str0(pos0(end-1)+1:pos0(end))];
+        end
+    end
+    %str(~isletter(str) & ~('0' <= str & str <= '9')) = '_';
+
+%%-------------------------------------------------------------------------
+function endpos = matching_quote(str,pos)
+len=length(str);
+while(pos<len)
+    if(str(pos)=='"')
+        if(~(pos>1 && str(pos-1)=='\'))
+            endpos=pos;
+            return;
+        end        
+    end
+    pos=pos+1;
+end
+error('unmatched quotation mark');
+%%-------------------------------------------------------------------------
+function [endpos, e1l, e1r, maxlevel] = matching_bracket(str,pos)
+global arraytoken
+level=1;
+maxlevel=level;
+endpos=0;
+bpos=arraytoken(arraytoken>=pos);
+tokens=str(bpos);
+len=length(tokens);
+pos=1;
+e1l=[];
+e1r=[];
+while(pos<=len)
+    c=tokens(pos);
+    if(c==']')
+        level=level-1;
+        if(isempty(e1r)) e1r=bpos(pos); end
+        if(level==0)
+            endpos=bpos(pos);
+            return
+        end
+    end
+    if(c=='[')
+        if(isempty(e1l)) e1l=bpos(pos); end
+        level=level+1;
+        maxlevel=max(maxlevel,level);
+    end
+    if(c=='"')
+        pos=matching_quote(tokens,pos+1);
+    end
+    pos=pos+1;
+end
+if(endpos==0) 
+    error('unmatched "]"');
+end
+

+ 528 - 0
machine learning/machine-learning-ex1/ex1/lib/jsonlab/loadubjson.m

@@ -0,0 +1,528 @@
+function data = loadubjson(fname,varargin)
+%
+% data=loadubjson(fname,opt)
+%    or
+% data=loadubjson(fname,'param1',value1,'param2',value2,...)
+%
+% parse a JSON (JavaScript Object Notation) file or string
+%
+% authors:Qianqian Fang (fangq<at> nmr.mgh.harvard.edu)
+% created on 2013/08/01
+%
+% $Id: loadubjson.m 460 2015-01-03 00:30:45Z fangq $
+%
+% input:
+%      fname: input file name, if fname contains "{}" or "[]", fname
+%             will be interpreted as a UBJSON string
+%      opt: a struct to store parsing options, opt can be replaced by 
+%           a list of ('param',value) pairs - the param string is equivallent
+%           to a field in opt. opt can have the following 
+%           fields (first in [.|.] is the default)
+%
+%           opt.SimplifyCell [0|1]: if set to 1, loadubjson will call cell2mat
+%                         for each element of the JSON data, and group 
+%                         arrays based on the cell2mat rules.
+%           opt.IntEndian [B|L]: specify the endianness of the integer fields
+%                         in the UBJSON input data. B - Big-Endian format for 
+%                         integers (as required in the UBJSON specification); 
+%                         L - input integer fields are in Little-Endian order.
+%
+% output:
+%      dat: a cell array, where {...} blocks are converted into cell arrays,
+%           and [...] are converted to arrays
+%
+% examples:
+%      obj=struct('string','value','array',[1 2 3]);
+%      ubjdata=saveubjson('obj',obj);
+%      dat=loadubjson(ubjdata)
+%      dat=loadubjson(['examples' filesep 'example1.ubj'])
+%      dat=loadubjson(['examples' filesep 'example1.ubj'],'SimplifyCell',1)
+%
+% license:
+%     BSD, see LICENSE_BSD.txt files for details 
+%
+% -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)
+%
+
+global pos inStr len  esc index_esc len_esc isoct arraytoken fileendian systemendian
+
+if(regexp(fname,'[\{\}\]\[]','once'))
+   string=fname;
+elseif(exist(fname,'file'))
+   fid = fopen(fname,'rb');
+   string = fread(fid,inf,'uint8=>char')';
+   fclose(fid);
+else
+   error('input file does not exist');
+end
+
+pos = 1; len = length(string); inStr = string;
+isoct=exist('OCTAVE_VERSION','builtin');
+arraytoken=find(inStr=='[' | inStr==']' | inStr=='"');
+jstr=regexprep(inStr,'\\\\','  ');
+escquote=regexp(jstr,'\\"');
+arraytoken=sort([arraytoken escquote]);
+
+% String delimiters and escape chars identified to improve speed:
+esc = find(inStr=='"' | inStr=='\' ); % comparable to: regexp(inStr, '["\\]');
+index_esc = 1; len_esc = length(esc);
+
+opt=varargin2struct(varargin{:});
+fileendian=upper(jsonopt('IntEndian','B',opt));
+[os,maxelem,systemendian]=computer;
+
+jsoncount=1;
+while pos <= len
+    switch(next_char)
+        case '{'
+            data{jsoncount} = parse_object(opt);
+        case '['
+            data{jsoncount} = parse_array(opt);
+        otherwise
+            error_pos('Outer level structure must be an object or an array');
+    end
+    jsoncount=jsoncount+1;
+end % while
+
+jsoncount=length(data);
+if(jsoncount==1 && iscell(data))
+    data=data{1};
+end
+
+if(~isempty(data))
+      if(isstruct(data)) % data can be a struct array
+          data=jstruct2array(data);
+      elseif(iscell(data))
+          data=jcell2array(data);
+      end
+end
+
+
+%%
+function newdata=parse_collection(id,data,obj)
+
+if(jsoncount>0 && exist('data','var')) 
+    if(~iscell(data))
+       newdata=cell(1);
+       newdata{1}=data;
+       data=newdata;
+    end
+end
+
+%%
+function newdata=jcell2array(data)
+len=length(data);
+newdata=data;
+for i=1:len
+      if(isstruct(data{i}))
+          newdata{i}=jstruct2array(data{i});
+      elseif(iscell(data{i}))
+          newdata{i}=jcell2array(data{i});
+      end
+end
+
+%%-------------------------------------------------------------------------
+function newdata=jstruct2array(data)
+fn=fieldnames(data);
+newdata=data;
+len=length(data);
+for i=1:length(fn) % depth-first
+    for j=1:len
+        if(isstruct(getfield(data(j),fn{i})))
+            newdata(j)=setfield(newdata(j),fn{i},jstruct2array(getfield(data(j),fn{i})));
+        end
+    end
+end
+if(~isempty(strmatch('x0x5F_ArrayType_',fn)) && ~isempty(strmatch('x0x5F_ArrayData_',fn)))
+  newdata=cell(len,1);
+  for j=1:len
+    ndata=cast(data(j).x0x5F_ArrayData_,data(j).x0x5F_ArrayType_);
+    iscpx=0;
+    if(~isempty(strmatch('x0x5F_ArrayIsComplex_',fn)))
+        if(data(j).x0x5F_ArrayIsComplex_)
+           iscpx=1;
+        end
+    end
+    if(~isempty(strmatch('x0x5F_ArrayIsSparse_',fn)))
+        if(data(j).x0x5F_ArrayIsSparse_)
+            if(~isempty(strmatch('x0x5F_ArraySize_',fn)))
+                dim=double(data(j).x0x5F_ArraySize_);
+                if(iscpx && size(ndata,2)==4-any(dim==1))
+                    ndata(:,end-1)=complex(ndata(:,end-1),ndata(:,end));
+                end
+                if isempty(ndata)
+                    % All-zeros sparse
+                    ndata=sparse(dim(1),prod(dim(2:end)));
+                elseif dim(1)==1
+                    % Sparse row vector
+                    ndata=sparse(1,ndata(:,1),ndata(:,2),dim(1),prod(dim(2:end)));
+                elseif dim(2)==1
+                    % Sparse column vector
+                    ndata=sparse(ndata(:,1),1,ndata(:,2),dim(1),prod(dim(2:end)));
+                else
+                    % Generic sparse array.
+                    ndata=sparse(ndata(:,1),ndata(:,2),ndata(:,3),dim(1),prod(dim(2:end)));
+                end
+            else
+                if(iscpx && size(ndata,2)==4)
+                    ndata(:,3)=complex(ndata(:,3),ndata(:,4));
+                end
+                ndata=sparse(ndata(:,1),ndata(:,2),ndata(:,3));
+            end
+        end
+    elseif(~isempty(strmatch('x0x5F_ArraySize_',fn)))
+        if(iscpx && size(ndata,2)==2)
+             ndata=complex(ndata(:,1),ndata(:,2));
+        end
+        ndata=reshape(ndata(:),data(j).x0x5F_ArraySize_);
+    end
+    newdata{j}=ndata;
+  end
+  if(len==1)
+      newdata=newdata{1};
+  end
+end
+
+%%-------------------------------------------------------------------------
+function object = parse_object(varargin)
+    parse_char('{');
+    object = [];
+    type='';
+    count=-1;
+    if(next_char == '$')
+        type=inStr(pos+1); % TODO
+        pos=pos+2;
+    end
+    if(next_char == '#')
+        pos=pos+1;
+        count=double(parse_number());
+    end
+    if next_char ~= '}'
+        num=0;
+        while 1
+            str = parseStr(varargin{:});
+            if isempty(str)
+                error_pos('Name of value at position %d cannot be empty');
+            end
+            %parse_char(':');
+            val = parse_value(varargin{:});
+            num=num+1;
+            eval( sprintf( 'object.%s  = val;', valid_field(str) ) );
+            if next_char == '}' || (count>=0 && num>=count)
+                break;
+            end
+            %parse_char(',');
+        end
+    end
+    if(count==-1)
+        parse_char('}');
+    end
+
+%%-------------------------------------------------------------------------
+function [cid,len]=elem_info(type)
+id=strfind('iUIlLdD',type);
+dataclass={'int8','uint8','int16','int32','int64','single','double'};
+bytelen=[1,1,2,4,8,4,8];
+if(id>0)
+    cid=dataclass{id};
+    len=bytelen(id);
+else
+    error_pos('unsupported type at position %d');
+end
+%%-------------------------------------------------------------------------
+
+
+function [data adv]=parse_block(type,count,varargin)
+global pos inStr isoct fileendian systemendian
+[cid,len]=elem_info(type);
+datastr=inStr(pos:pos+len*count-1);
+if(isoct)
+    newdata=int8(datastr);
+else
+    newdata=uint8(datastr);
+end
+id=strfind('iUIlLdD',type);
+if(id<=5 && fileendian~=systemendian)
+    newdata=swapbytes(typecast(newdata,cid));
+end
+data=typecast(newdata,cid);
+adv=double(len*count);
+
+%%-------------------------------------------------------------------------
+
+
+function object = parse_array(varargin) % JSON array is written in row-major order
+global pos inStr isoct
+    parse_char('[');
+    object = cell(0, 1);
+    dim=[];
+    type='';
+    count=-1;
+    if(next_char == '$')
+        type=inStr(pos+1);
+        pos=pos+2;
+    end
+    if(next_char == '#')
+        pos=pos+1;
+        if(next_char=='[')
+            dim=parse_array(varargin{:});
+            count=prod(double(dim));
+        else
+            count=double(parse_number());
+        end
+    end
+    if(~isempty(type))
+        if(count>=0)
+            [object adv]=parse_block(type,count,varargin{:});
+            if(~isempty(dim))
+                object=reshape(object,dim);
+            end
+            pos=pos+adv;
+            return;
+        else
+            endpos=matching_bracket(inStr,pos);
+            [cid,len]=elem_info(type);
+            count=(endpos-pos)/len;
+            [object adv]=parse_block(type,count,varargin{:});
+            pos=pos+adv;
+            parse_char(']');
+            return;
+        end
+    end
+    if next_char ~= ']'
+         while 1
+            val = parse_value(varargin{:});
+            object{end+1} = val;
+            if next_char == ']'
+                break;
+            end
+            %parse_char(',');
+         end
+    end
+    if(jsonopt('SimplifyCell',0,varargin{:})==1)
+      try
+        oldobj=object;
+        object=cell2mat(object')';
+        if(iscell(oldobj) && isstruct(object) && numel(object)>1 && jsonopt('SimplifyCellArray',1,varargin{:})==0)
+            object=oldobj;
+        elseif(size(object,1)>1 && ndims(object)==2)
+            object=object';
+        end
+      catch
+      end
+    end
+    if(count==-1)
+        parse_char(']');
+    end
+
+%%-------------------------------------------------------------------------
+
+function parse_char(c)
+    global pos inStr len
+    skip_whitespace;
+    if pos > len || inStr(pos) ~= c
+        error_pos(sprintf('Expected %c at position %%d', c));
+    else
+        pos = pos + 1;
+        skip_whitespace;
+    end
+
+%%-------------------------------------------------------------------------
+
+function c = next_char
+    global pos inStr len
+    skip_whitespace;
+    if pos > len
+        c = [];
+    else
+        c = inStr(pos);
+    end
+
+%%-------------------------------------------------------------------------
+
+function skip_whitespace
+    global pos inStr len
+    while pos <= len && isspace(inStr(pos))
+        pos = pos + 1;
+    end
+
+%%-------------------------------------------------------------------------
+function str = parseStr(varargin)
+    global pos inStr esc index_esc len_esc
+ % len, ns = length(inStr), keyboard
+    type=inStr(pos);
+    if type ~= 'S' && type ~= 'C' && type ~= 'H'
+        error_pos('String starting with S expected at position %d');
+    else
+        pos = pos + 1;
+    end
+    if(type == 'C')
+        str=inStr(pos);
+        pos=pos+1;
+        return;
+    end
+    bytelen=double(parse_number());
+    if(length(inStr)>=pos+bytelen-1)
+        str=inStr(pos:pos+bytelen-1);
+        pos=pos+bytelen;
+    else
+        error_pos('End of file while expecting end of inStr');
+    end
+
+%%-------------------------------------------------------------------------
+
+function num = parse_number(varargin)
+    global pos inStr len isoct fileendian systemendian
+    id=strfind('iUIlLdD',inStr(pos));
+    if(isempty(id))
+        error_pos('expecting a number at position %d');
+    end
+    type={'int8','uint8','int16','int32','int64','single','double'};
+    bytelen=[1,1,2,4,8,4,8];
+    datastr=inStr(pos+1:pos+bytelen(id));
+    if(isoct)
+        newdata=int8(datastr);
+    else
+        newdata=uint8(datastr);
+    end
+    if(id<=5 && fileendian~=systemendian)
+        newdata=swapbytes(typecast(newdata,type{id}));
+    end
+    num=typecast(newdata,type{id});
+    pos = pos + bytelen(id)+1;
+
+%%-------------------------------------------------------------------------
+
+function val = parse_value(varargin)
+    global pos inStr len
+    true = 1; false = 0;
+
+    switch(inStr(pos))
+        case {'S','C','H'}
+            val = parseStr(varargin{:});
+            return;
+        case '['
+            val = parse_array(varargin{:});
+            return;
+        case '{'
+            val = parse_object(varargin{:});
+            if isstruct(val)
+                if(~isempty(strmatch('x0x5F_ArrayType_',fieldnames(val), 'exact')))
+                    val=jstruct2array(val);
+                end
+            elseif isempty(val)
+                val = struct;
+            end
+            return;
+        case {'i','U','I','l','L','d','D'}
+            val = parse_number(varargin{:});
+            return;
+        case 'T'
+            val = true;
+            pos = pos + 1;
+            return;
+        case 'F'
+            val = false;
+            pos = pos + 1;
+            return;
+        case {'Z','N'}
+            val = [];
+            pos = pos + 1;
+            return;
+    end
+    error_pos('Value expected at position %d');
+%%-------------------------------------------------------------------------
+
+function error_pos(msg)
+    global pos inStr len
+    poShow = max(min([pos-15 pos-1 pos pos+20],len),1);
+    if poShow(3) == poShow(2)
+        poShow(3:4) = poShow(2)+[0 -1];  % display nothing after
+    end
+    msg = [sprintf(msg, pos) ': ' ...
+    inStr(poShow(1):poShow(2)) '<error>' inStr(poShow(3):poShow(4)) ];
+    error( ['JSONparser:invalidFormat: ' msg] );
+
+%%-------------------------------------------------------------------------
+
+function str = valid_field(str)
+global isoct
+% From MATLAB doc: field names must begin with a letter, which may be
+% followed by any combination of letters, digits, and underscores.
+% Invalid characters will be converted to underscores, and the prefix
+% "x0x[Hex code]_" will be added if the first character is not a letter.
+    pos=regexp(str,'^[^A-Za-z]','once');
+    if(~isempty(pos))
+        if(~isoct)
+            str=regexprep(str,'^([^A-Za-z])','x0x${sprintf(''%X'',unicode2native($1))}_','once');
+        else
+            str=sprintf('x0x%X_%s',char(str(1)),str(2:end));
+        end
+    end
+    if(isempty(regexp(str,'[^0-9A-Za-z_]', 'once' ))) return;  end
+    if(~isoct)
+        str=regexprep(str,'([^0-9A-Za-z_])','_0x${sprintf(''%X'',unicode2native($1))}_');
+    else
+        pos=regexp(str,'[^0-9A-Za-z_]');
+        if(isempty(pos)) return; end
+        str0=str;
+        pos0=[0 pos(:)' length(str)];
+        str='';
+        for i=1:length(pos)
+            str=[str str0(pos0(i)+1:pos(i)-1) sprintf('_0x%X_',str0(pos(i)))];
+        end
+        if(pos(end)~=length(str))
+            str=[str str0(pos0(end-1)+1:pos0(end))];
+        end
+    end
+    %str(~isletter(str) & ~('0' <= str & str <= '9')) = '_';
+
+%%-------------------------------------------------------------------------
+function endpos = matching_quote(str,pos)
+len=length(str);
+while(pos<len)
+    if(str(pos)=='"')
+        if(~(pos>1 && str(pos-1)=='\'))
+            endpos=pos;
+            return;
+        end        
+    end
+    pos=pos+1;
+end
+error('unmatched quotation mark');
+%%-------------------------------------------------------------------------
+function [endpos e1l e1r maxlevel] = matching_bracket(str,pos)
+global arraytoken
+level=1;
+maxlevel=level;
+endpos=0;
+bpos=arraytoken(arraytoken>=pos);
+tokens=str(bpos);
+len=length(tokens);
+pos=1;
+e1l=[];
+e1r=[];
+while(pos<=len)
+    c=tokens(pos);
+    if(c==']')
+        level=level-1;
+        if(isempty(e1r)) e1r=bpos(pos); end
+        if(level==0)
+            endpos=bpos(pos);
+            return
+        end
+    end
+    if(c=='[')
+        if(isempty(e1l)) e1l=bpos(pos); end
+        level=level+1;
+        maxlevel=max(maxlevel,level);
+    end
+    if(c=='"')
+        pos=matching_quote(tokens,pos+1);
+    end
+    pos=pos+1;
+end
+if(endpos==0) 
+    error('unmatched "]"');
+end
+

+ 33 - 0
machine learning/machine-learning-ex1/ex1/lib/jsonlab/mergestruct.m

@@ -0,0 +1,33 @@
+function s=mergestruct(s1,s2)
+%
+% s=mergestruct(s1,s2)
+%
+% merge two struct objects into one
+%
+% authors:Qianqian Fang (fangq<at> nmr.mgh.harvard.edu)
+% date: 2012/12/22
+%
+% input:
+%      s1,s2: a struct object, s1 and s2 can not be arrays
+%
+% output:
+%      s: the merged struct object. fields in s1 and s2 will be combined in s.
+%
+% license:
+%     BSD, see LICENSE_BSD.txt files for details 
+%
+% -- this function is part of jsonlab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)
+%
+
+if(~isstruct(s1) || ~isstruct(s2))
+    error('input parameters contain non-struct');
+end
+if(length(s1)>1 || length(s2)>1)
+    error('can not merge struct arrays');
+end
+fn=fieldnames(s2);
+s=s1;
+for i=1:length(fn)              
+    s=setfield(s,fn{i},getfield(s2,fn{i}));
+end
+

+ 475 - 0
machine learning/machine-learning-ex1/ex1/lib/jsonlab/savejson.m

@@ -0,0 +1,475 @@
+function json=savejson(rootname,obj,varargin)
+%
+% json=savejson(rootname,obj,filename)
+%    or
+% json=savejson(rootname,obj,opt)
+% json=savejson(rootname,obj,'param1',value1,'param2',value2,...)
+%
+% convert a MATLAB object (cell, struct or array) into a JSON (JavaScript
+% Object Notation) string
+%
+% author: Qianqian Fang (fangq<at> nmr.mgh.harvard.edu)
+% created on 2011/09/09
+%
+% $Id: savejson.m 460 2015-01-03 00:30:45Z fangq $
+%
+% input:
+%      rootname: the name of the root-object, when set to '', the root name
+%        is ignored, however, when opt.ForceRootName is set to 1 (see below),
+%        the MATLAB variable name will be used as the root name.
+%      obj: a MATLAB object (array, cell, cell array, struct, struct array).
+%      filename: a string for the file name to save the output JSON data.
+%      opt: a struct for additional options, ignore to use default values.
+%        opt can have the following fields (first in [.|.] is the default)
+%
+%        opt.FileName [''|string]: a file name to save the output JSON data
+%        opt.FloatFormat ['%.10g'|string]: format to show each numeric element
+%                         of a 1D/2D array;
+%        opt.ArrayIndent [1|0]: if 1, output explicit data array with
+%                         precedent indentation; if 0, no indentation
+%        opt.ArrayToStruct[0|1]: when set to 0, savejson outputs 1D/2D
+%                         array in JSON array format; if sets to 1, an
+%                         array will be shown as a struct with fields
+%                         "_ArrayType_", "_ArraySize_" and "_ArrayData_"; for
+%                         sparse arrays, the non-zero elements will be
+%                         saved to _ArrayData_ field in triplet-format i.e.
+%                         (ix,iy,val) and "_ArrayIsSparse_" will be added
+%                         with a value of 1; for a complex array, the 
+%                         _ArrayData_ array will include two columns 
+%                         (4 for sparse) to record the real and imaginary 
+%                         parts, and also "_ArrayIsComplex_":1 is added. 
+%        opt.ParseLogical [0|1]: if this is set to 1, logical array elem
+%                         will use true/false rather than 1/0.
+%        opt.NoRowBracket [1|0]: if this is set to 1, arrays with a single
+%                         numerical element will be shown without a square
+%                         bracket, unless it is the root object; if 0, square
+%                         brackets are forced for any numerical arrays.
+%        opt.ForceRootName [0|1]: when set to 1 and rootname is empty, savejson
+%                         will use the name of the passed obj variable as the 
+%                         root object name; if obj is an expression and 
+%                         does not have a name, 'root' will be used; if this 
+%                         is set to 0 and rootname is empty, the root level 
+%                         will be merged down to the lower level.
+%        opt.Inf ['"$1_Inf_"'|string]: a customized regular expression pattern
+%                         to represent +/-Inf. The matched pattern is '([-+]*)Inf'
+%                         and $1 represents the sign. For those who want to use
+%                         1e999 to represent Inf, they can set opt.Inf to '$11e999'
+%        opt.NaN ['"_NaN_"'|string]: a customized regular expression pattern
+%                         to represent NaN
+%        opt.JSONP [''|string]: to generate a JSONP output (JSON with padding),
+%                         for example, if opt.JSONP='foo', the JSON data is
+%                         wrapped inside a function call as 'foo(...);'
+%        opt.UnpackHex [1|0]: conver the 0x[hex code] output by loadjson 
+%                         back to the string form
+%        opt.SaveBinary [0|1]: 1 - save the JSON file in binary mode; 0 - text mode.
+%        opt.Compact [0|1]: 1- out compact JSON format (remove all newlines and tabs)
+%
+%        opt can be replaced by a list of ('param',value) pairs. The param 
+%        string is equivallent to a field in opt and is case sensitive.
+% output:
+%      json: a string in the JSON format (see http://json.org)
+%
+% examples:
+%      jsonmesh=struct('MeshNode',[0 0 0;1 0 0;0 1 0;1 1 0;0 0 1;1 0 1;0 1 1;1 1 1],... 
+%               'MeshTetra',[1 2 4 8;1 3 4 8;1 2 6 8;1 5 6 8;1 5 7 8;1 3 7 8],...
+%               'MeshTri',[1 2 4;1 2 6;1 3 4;1 3 7;1 5 6;1 5 7;...
+%                          2 8 4;2 8 6;3 8 4;3 8 7;5 8 6;5 8 7],...
+%               'MeshCreator','FangQ','MeshTitle','T6 Cube',...
+%               'SpecialData',[nan, inf, -inf]);
+%      savejson('jmesh',jsonmesh)
+%      savejson('',jsonmesh,'ArrayIndent',0,'FloatFormat','\t%.5g')
+%
+% license:
+%     BSD, see LICENSE_BSD.txt files for details
+%
+% -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)
+%
+
+if(nargin==1)
+   varname=inputname(1);
+   obj=rootname;
+   if(isempty(varname)) 
+      varname='root';
+   end
+   rootname=varname;
+else
+   varname=inputname(2);
+end
+if(length(varargin)==1 && ischar(varargin{1}))
+   opt=struct('FileName',varargin{1});
+else
+   opt=varargin2struct(varargin{:});
+end
+opt.IsOctave=exist('OCTAVE_VERSION','builtin');
+rootisarray=0;
+rootlevel=1;
+forceroot=jsonopt('ForceRootName',0,opt);
+if((isnumeric(obj) || islogical(obj) || ischar(obj) || isstruct(obj) || iscell(obj)) && isempty(rootname) && forceroot==0)
+    rootisarray=1;
+    rootlevel=0;
+else
+    if(isempty(rootname))
+        rootname=varname;
+    end
+end
+if((isstruct(obj) || iscell(obj))&& isempty(rootname) && forceroot)
+    rootname='root';
+end
+
+whitespaces=struct('tab',sprintf('\t'),'newline',sprintf('\n'),'sep',sprintf(',\n'));
+if(jsonopt('Compact',0,opt)==1)
+    whitespaces=struct('tab','','newline','','sep',',');
+end
+if(~isfield(opt,'whitespaces_'))
+    opt.whitespaces_=whitespaces;
+end
+
+nl=whitespaces.newline;
+
+json=obj2json(rootname,obj,rootlevel,opt);
+if(rootisarray)
+    json=sprintf('%s%s',json,nl);
+else
+    json=sprintf('{%s%s%s}\n',nl,json,nl);
+end
+
+jsonp=jsonopt('JSONP','',opt);
+if(~isempty(jsonp))
+    json=sprintf('%s(%s);%s',jsonp,json,nl);
+end
+
+% save to a file if FileName is set, suggested by Patrick Rapin
+if(~isempty(jsonopt('FileName','',opt)))
+    if(jsonopt('SaveBinary',0,opt)==1)
+	    fid = fopen(opt.FileName, 'wb');
+	    fwrite(fid,json);
+    else
+	    fid = fopen(opt.FileName, 'wt');
+	    fwrite(fid,json,'char');
+    end
+    fclose(fid);
+end
+
+%%-------------------------------------------------------------------------
+function txt=obj2json(name,item,level,varargin)
+
+if(iscell(item))
+    txt=cell2json(name,item,level,varargin{:});
+elseif(isstruct(item))
+    txt=struct2json(name,item,level,varargin{:});
+elseif(ischar(item))
+    txt=str2json(name,item,level,varargin{:});
+else
+    txt=mat2json(name,item,level,varargin{:});
+end
+
+%%-------------------------------------------------------------------------
+function txt=cell2json(name,item,level,varargin)
+txt='';
+if(~iscell(item))
+        error('input is not a cell');
+end
+
+dim=size(item);
+if(ndims(squeeze(item))>2) % for 3D or higher dimensions, flatten to 2D for now
+    item=reshape(item,dim(1),numel(item)/dim(1));
+    dim=size(item);
+end
+len=numel(item);
+ws=jsonopt('whitespaces_',struct('tab',sprintf('\t'),'newline',sprintf('\n'),'sep',sprintf(',\n')),varargin{:});
+padding0=repmat(ws.tab,1,level);
+padding2=repmat(ws.tab,1,level+1);
+nl=ws.newline;
+if(len>1)
+    if(~isempty(name))
+        txt=sprintf('%s"%s": [%s',padding0, checkname(name,varargin{:}),nl); name=''; 
+    else
+        txt=sprintf('%s[%s',padding0,nl); 
+    end
+elseif(len==0)
+    if(~isempty(name))
+        txt=sprintf('%s"%s": []',padding0, checkname(name,varargin{:})); name=''; 
+    else
+        txt=sprintf('%s[]',padding0); 
+    end
+end
+for j=1:dim(2)
+    if(dim(1)>1) txt=sprintf('%s%s[%s',txt,padding2,nl); end
+    for i=1:dim(1)
+       txt=sprintf('%s%s',txt,obj2json(name,item{i,j},level+(dim(1)>1)+1,varargin{:}));
+       if(i<dim(1)) txt=sprintf('%s%s',txt,sprintf(',%s',nl)); end
+    end
+    if(dim(1)>1) txt=sprintf('%s%s%s]',txt,nl,padding2); end
+    if(j<dim(2)) txt=sprintf('%s%s',txt,sprintf(',%s',nl)); end
+    %if(j==dim(2)) txt=sprintf('%s%s',txt,sprintf(',%s',nl)); end
+end
+if(len>1) txt=sprintf('%s%s%s]',txt,nl,padding0); end
+
+%%-------------------------------------------------------------------------
+function txt=struct2json(name,item,level,varargin)
+txt='';
+if(~isstruct(item))
+	error('input is not a struct');
+end
+dim=size(item);
+if(ndims(squeeze(item))>2) % for 3D or higher dimensions, flatten to 2D for now
+    item=reshape(item,dim(1),numel(item)/dim(1));
+    dim=size(item);
+end
+len=numel(item);
+ws=struct('tab',sprintf('\t'),'newline',sprintf('\n'));
+ws=jsonopt('whitespaces_',ws,varargin{:});
+padding0=repmat(ws.tab,1,level);
+padding2=repmat(ws.tab,1,level+1);
+padding1=repmat(ws.tab,1,level+(dim(1)>1)+(len>1));
+nl=ws.newline;
+
+if(~isempty(name)) 
+    if(len>1) txt=sprintf('%s"%s": [%s',padding0,checkname(name,varargin{:}),nl); end
+else
+    if(len>1) txt=sprintf('%s[%s',padding0,nl); end
+end
+for j=1:dim(2)
+  if(dim(1)>1) txt=sprintf('%s%s[%s',txt,padding2,nl); end
+  for i=1:dim(1)
+    names = fieldnames(item(i,j));
+    if(~isempty(name) && len==1)
+        txt=sprintf('%s%s"%s": {%s',txt,padding1, checkname(name,varargin{:}),nl); 
+    else
+        txt=sprintf('%s%s{%s',txt,padding1,nl); 
+    end
+    if(~isempty(names))
+      for e=1:length(names)
+	    txt=sprintf('%s%s',txt,obj2json(names{e},getfield(item(i,j),...
+             names{e}),level+(dim(1)>1)+1+(len>1),varargin{:}));
+        if(e<length(names)) txt=sprintf('%s%s',txt,','); end
+        txt=sprintf('%s%s',txt,nl);
+      end
+    end
+    txt=sprintf('%s%s}',txt,padding1);
+    if(i<dim(1)) txt=sprintf('%s%s',txt,sprintf(',%s',nl)); end
+  end
+  if(dim(1)>1) txt=sprintf('%s%s%s]',txt,nl,padding2); end
+  if(j<dim(2)) txt=sprintf('%s%s',txt,sprintf(',%s',nl)); end
+end
+if(len>1) txt=sprintf('%s%s%s]',txt,nl,padding0); end
+
+%%-------------------------------------------------------------------------
+function txt=str2json(name,item,level,varargin)
+txt='';
+if(~ischar(item))
+        error('input is not a string');
+end
+item=reshape(item, max(size(item),[1 0]));
+len=size(item,1);
+ws=struct('tab',sprintf('\t'),'newline',sprintf('\n'),'sep',sprintf(',\n'));
+ws=jsonopt('whitespaces_',ws,varargin{:});
+padding1=repmat(ws.tab,1,level);
+padding0=repmat(ws.tab,1,level+1);
+nl=ws.newline;
+sep=ws.sep;
+
+if(~isempty(name)) 
+    if(len>1) txt=sprintf('%s"%s": [%s',padding1,checkname(name,varargin{:}),nl); end
+else
+    if(len>1) txt=sprintf('%s[%s',padding1,nl); end
+end
+isoct=jsonopt('IsOctave',0,varargin{:});
+for e=1:len
+    if(isoct)
+        val=regexprep(item(e,:),'\\','\\');
+        val=regexprep(val,'"','\"');
+        val=regexprep(val,'^"','\"');
+    else
+        val=regexprep(item(e,:),'\\','\\\\');
+        val=regexprep(val,'"','\\"');
+        val=regexprep(val,'^"','\\"');
+    end
+    val=escapejsonstring(val);
+    if(len==1)
+        obj=['"' checkname(name,varargin{:}) '": ' '"',val,'"'];
+	if(isempty(name)) obj=['"',val,'"']; end
+        txt=sprintf('%s%s%s%s',txt,padding1,obj);
+    else
+        txt=sprintf('%s%s%s%s',txt,padding0,['"',val,'"']);
+    end
+    if(e==len) sep=''; end
+    txt=sprintf('%s%s',txt,sep);
+end
+if(len>1) txt=sprintf('%s%s%s%s',txt,nl,padding1,']'); end
+
+%%-------------------------------------------------------------------------
+function txt=mat2json(name,item,level,varargin)
+if(~isnumeric(item) && ~islogical(item))
+        error('input is not an array');
+end
+ws=struct('tab',sprintf('\t'),'newline',sprintf('\n'),'sep',sprintf(',\n'));
+ws=jsonopt('whitespaces_',ws,varargin{:});
+padding1=repmat(ws.tab,1,level);
+padding0=repmat(ws.tab,1,level+1);
+nl=ws.newline;
+sep=ws.sep;
+
+if(length(size(item))>2 || issparse(item) || ~isreal(item) || ...
+   isempty(item) ||jsonopt('ArrayToStruct',0,varargin{:}))
+    if(isempty(name))
+    	txt=sprintf('%s{%s%s"_ArrayType_": "%s",%s%s"_ArraySize_": %s,%s',...
+              padding1,nl,padding0,class(item),nl,padding0,regexprep(mat2str(size(item)),'\s+',','),nl);
+    else
+    	txt=sprintf('%s"%s": {%s%s"_ArrayType_": "%s",%s%s"_ArraySize_": %s,%s',...
+              padding1,checkname(name,varargin{:}),nl,padding0,class(item),nl,padding0,regexprep(mat2str(size(item)),'\s+',','),nl);
+    end
+else
+    if(numel(item)==1 && jsonopt('NoRowBracket',1,varargin{:})==1 && level>0)
+        numtxt=regexprep(regexprep(matdata2json(item,level+1,varargin{:}),'^\[',''),']','');
+    else
+        numtxt=matdata2json(item,level+1,varargin{:});
+    end
+    if(isempty(name))
+    	txt=sprintf('%s%s',padding1,numtxt);
+    else
+        if(numel(item)==1 && jsonopt('NoRowBracket',1,varargin{:})==1)
+           	txt=sprintf('%s"%s": %s',padding1,checkname(name,varargin{:}),numtxt);
+        else
+    	    txt=sprintf('%s"%s": %s',padding1,checkname(name,varargin{:}),numtxt);
+        end
+    end
+    return;
+end
+dataformat='%s%s%s%s%s';
+
+if(issparse(item))
+    [ix,iy]=find(item);
+    data=full(item(find(item)));
+    if(~isreal(item))
+       data=[real(data(:)),imag(data(:))];
+       if(size(item,1)==1)
+           % Kludge to have data's 'transposedness' match item's.
+           % (Necessary for complex row vector handling below.)
+           data=data';
+       end
+       txt=sprintf(dataformat,txt,padding0,'"_ArrayIsComplex_": ','1', sep);
+    end
+    txt=sprintf(dataformat,txt,padding0,'"_ArrayIsSparse_": ','1', sep);
+    if(size(item,1)==1)
+        % Row vector, store only column indices.
+        txt=sprintf(dataformat,txt,padding0,'"_ArrayData_": ',...
+           matdata2json([iy(:),data'],level+2,varargin{:}), nl);
+    elseif(size(item,2)==1)
+        % Column vector, store only row indices.
+        txt=sprintf(dataformat,txt,padding0,'"_ArrayData_": ',...
+           matdata2json([ix,data],level+2,varargin{:}), nl);
+    else
+        % General case, store row and column indices.
+        txt=sprintf(dataformat,txt,padding0,'"_ArrayData_": ',...
+           matdata2json([ix,iy,data],level+2,varargin{:}), nl);
+    end
+else
+    if(isreal(item))
+        txt=sprintf(dataformat,txt,padding0,'"_ArrayData_": ',...
+            matdata2json(item(:)',level+2,varargin{:}), nl);
+    else
+        txt=sprintf(dataformat,txt,padding0,'"_ArrayIsComplex_": ','1', sep);
+        txt=sprintf(dataformat,txt,padding0,'"_ArrayData_": ',...
+            matdata2json([real(item(:)) imag(item(:))],level+2,varargin{:}), nl);
+    end
+end
+txt=sprintf('%s%s%s',txt,padding1,'}');
+
+%%-------------------------------------------------------------------------
+function txt=matdata2json(mat,level,varargin)
+
+ws=struct('tab',sprintf('\t'),'newline',sprintf('\n'),'sep',sprintf(',\n'));
+ws=jsonopt('whitespaces_',ws,varargin{:});
+tab=ws.tab;
+nl=ws.newline;
+
+if(size(mat,1)==1)
+    pre='';
+    post='';
+    level=level-1;
+else
+    pre=sprintf('[%s',nl);
+    post=sprintf('%s%s]',nl,repmat(tab,1,level-1));
+end
+
+if(isempty(mat))
+    txt='null';
+    return;
+end
+floatformat=jsonopt('FloatFormat','%.10g',varargin{:});
+%if(numel(mat)>1)
+    formatstr=['[' repmat([floatformat ','],1,size(mat,2)-1) [floatformat sprintf('],%s',nl)]];
+%else
+%    formatstr=[repmat([floatformat ','],1,size(mat,2)-1) [floatformat sprintf(',\n')]];
+%end
+
+if(nargin>=2 && size(mat,1)>1 && jsonopt('ArrayIndent',1,varargin{:})==1)
+    formatstr=[repmat(tab,1,level) formatstr];
+end
+
+txt=sprintf(formatstr,mat');
+txt(end-length(nl):end)=[];
+if(islogical(mat) && jsonopt('ParseLogical',0,varargin{:})==1)
+   txt=regexprep(txt,'1','true');
+   txt=regexprep(txt,'0','false');
+end
+%txt=regexprep(mat2str(mat),'\s+',',');
+%txt=regexprep(txt,';',sprintf('],\n['));
+% if(nargin>=2 && size(mat,1)>1)
+%     txt=regexprep(txt,'\[',[repmat(sprintf('\t'),1,level) '[']);
+% end
+txt=[pre txt post];
+if(any(isinf(mat(:))))
+    txt=regexprep(txt,'([-+]*)Inf',jsonopt('Inf','"$1_Inf_"',varargin{:}));
+end
+if(any(isnan(mat(:))))
+    txt=regexprep(txt,'NaN',jsonopt('NaN','"_NaN_"',varargin{:}));
+end
+
+%%-------------------------------------------------------------------------
+function newname=checkname(name,varargin)
+isunpack=jsonopt('UnpackHex',1,varargin{:});
+newname=name;
+if(isempty(regexp(name,'0x([0-9a-fA-F]+)_','once')))
+    return
+end
+if(isunpack)
+    isoct=jsonopt('IsOctave',0,varargin{:});
+    if(~isoct)
+        newname=regexprep(name,'(^x|_){1}0x([0-9a-fA-F]+)_','${native2unicode(hex2dec($2))}');
+    else
+        pos=regexp(name,'(^x|_){1}0x([0-9a-fA-F]+)_','start');
+        pend=regexp(name,'(^x|_){1}0x([0-9a-fA-F]+)_','end');
+        if(isempty(pos)) return; end
+        str0=name;
+        pos0=[0 pend(:)' length(name)];
+        newname='';
+        for i=1:length(pos)
+            newname=[newname str0(pos0(i)+1:pos(i)-1) char(hex2dec(str0(pos(i)+3:pend(i)-1)))];
+        end
+        if(pos(end)~=length(name))
+            newname=[newname str0(pos0(end-1)+1:pos0(end))];
+        end
+    end
+end
+
+%%-------------------------------------------------------------------------
+function newstr=escapejsonstring(str)
+newstr=str;
+isoct=exist('OCTAVE_VERSION','builtin');
+if(isoct)
+   vv=sscanf(OCTAVE_VERSION,'%f');
+   if(vv(1)>=3.8) isoct=0; end
+end
+if(isoct)
+  escapechars={'\a','\f','\n','\r','\t','\v'};
+  for i=1:length(escapechars);
+    newstr=regexprep(newstr,escapechars{i},escapechars{i});
+  end
+else
+  escapechars={'\a','\b','\f','\n','\r','\t','\v'};
+  for i=1:length(escapechars);
+    newstr=regexprep(newstr,escapechars{i},regexprep(escapechars{i},'\\','\\\\'));
+  end
+end

+ 504 - 0
machine learning/machine-learning-ex1/ex1/lib/jsonlab/saveubjson.m

@@ -0,0 +1,504 @@
+function json=saveubjson(rootname,obj,varargin)
+%
+% json=saveubjson(rootname,obj,filename)
+%    or
+% json=saveubjson(rootname,obj,opt)
+% json=saveubjson(rootname,obj,'param1',value1,'param2',value2,...)
+%
+% convert a MATLAB object (cell, struct or array) into a Universal 
+% Binary JSON (UBJSON) binary string
+%
+% author: Qianqian Fang (fangq<at> nmr.mgh.harvard.edu)
+% created on 2013/08/17
+%
+% $Id: saveubjson.m 460 2015-01-03 00:30:45Z fangq $
+%
+% input:
+%      rootname: the name of the root-object, when set to '', the root name
+%        is ignored, however, when opt.ForceRootName is set to 1 (see below),
+%        the MATLAB variable name will be used as the root name.
+%      obj: a MATLAB object (array, cell, cell array, struct, struct array)
+%      filename: a string for the file name to save the output UBJSON data
+%      opt: a struct for additional options, ignore to use default values.
+%        opt can have the following fields (first in [.|.] is the default)
+%
+%        opt.FileName [''|string]: a file name to save the output JSON data
+%        opt.ArrayToStruct[0|1]: when set to 0, saveubjson outputs 1D/2D
+%                         array in JSON array format; if sets to 1, an
+%                         array will be shown as a struct with fields
+%                         "_ArrayType_", "_ArraySize_" and "_ArrayData_"; for
+%                         sparse arrays, the non-zero elements will be
+%                         saved to _ArrayData_ field in triplet-format i.e.
+%                         (ix,iy,val) and "_ArrayIsSparse_" will be added
+%                         with a value of 1; for a complex array, the 
+%                         _ArrayData_ array will include two columns 
+%                         (4 for sparse) to record the real and imaginary 
+%                         parts, and also "_ArrayIsComplex_":1 is added. 
+%        opt.ParseLogical [1|0]: if this is set to 1, logical array elem
+%                         will use true/false rather than 1/0.
+%        opt.NoRowBracket [1|0]: if this is set to 1, arrays with a single
+%                         numerical element will be shown without a square
+%                         bracket, unless it is the root object; if 0, square
+%                         brackets are forced for any numerical arrays.
+%        opt.ForceRootName [0|1]: when set to 1 and rootname is empty, saveubjson
+%                         will use the name of the passed obj variable as the 
+%                         root object name; if obj is an expression and 
+%                         does not have a name, 'root' will be used; if this 
+%                         is set to 0 and rootname is empty, the root level 
+%                         will be merged down to the lower level.
+%        opt.JSONP [''|string]: to generate a JSONP output (JSON with padding),
+%                         for example, if opt.JSON='foo', the JSON data is
+%                         wrapped inside a function call as 'foo(...);'
+%        opt.UnpackHex [1|0]: conver the 0x[hex code] output by loadjson 
+%                         back to the string form
+%
+%        opt can be replaced by a list of ('param',value) pairs. The param 
+%        string is equivallent to a field in opt and is case sensitive.
+% output:
+%      json: a binary string in the UBJSON format (see http://ubjson.org)
+%
+% examples:
+%      jsonmesh=struct('MeshNode',[0 0 0;1 0 0;0 1 0;1 1 0;0 0 1;1 0 1;0 1 1;1 1 1],... 
+%               'MeshTetra',[1 2 4 8;1 3 4 8;1 2 6 8;1 5 6 8;1 5 7 8;1 3 7 8],...
+%               'MeshTri',[1 2 4;1 2 6;1 3 4;1 3 7;1 5 6;1 5 7;...
+%                          2 8 4;2 8 6;3 8 4;3 8 7;5 8 6;5 8 7],...
+%               'MeshCreator','FangQ','MeshTitle','T6 Cube',...
+%               'SpecialData',[nan, inf, -inf]);
+%      saveubjson('jsonmesh',jsonmesh)
+%      saveubjson('jsonmesh',jsonmesh,'meshdata.ubj')
+%
+% license:
+%     BSD, see LICENSE_BSD.txt files for details
+%
+% -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)
+%
+
+if(nargin==1)
+   varname=inputname(1);
+   obj=rootname;
+   if(isempty(varname)) 
+      varname='root';
+   end
+   rootname=varname;
+else
+   varname=inputname(2);
+end
+if(length(varargin)==1 && ischar(varargin{1}))
+   opt=struct('FileName',varargin{1});
+else
+   opt=varargin2struct(varargin{:});
+end
+opt.IsOctave=exist('OCTAVE_VERSION','builtin');
+rootisarray=0;
+rootlevel=1;
+forceroot=jsonopt('ForceRootName',0,opt);
+if((isnumeric(obj) || islogical(obj) || ischar(obj) || isstruct(obj) || iscell(obj)) && isempty(rootname) && forceroot==0)
+    rootisarray=1;
+    rootlevel=0;
+else
+    if(isempty(rootname))
+        rootname=varname;
+    end
+end
+if((isstruct(obj) || iscell(obj))&& isempty(rootname) && forceroot)
+    rootname='root';
+end
+json=obj2ubjson(rootname,obj,rootlevel,opt);
+if(~rootisarray)
+    json=['{' json '}'];
+end
+
+jsonp=jsonopt('JSONP','',opt);
+if(~isempty(jsonp))
+    json=[jsonp '(' json ')'];
+end
+
+% save to a file if FileName is set, suggested by Patrick Rapin
+if(~isempty(jsonopt('FileName','',opt)))
+    fid = fopen(opt.FileName, 'wb');
+    fwrite(fid,json);
+    fclose(fid);
+end
+
+%%-------------------------------------------------------------------------
+function txt=obj2ubjson(name,item,level,varargin)
+
+if(iscell(item))
+    txt=cell2ubjson(name,item,level,varargin{:});
+elseif(isstruct(item))
+    txt=struct2ubjson(name,item,level,varargin{:});
+elseif(ischar(item))
+    txt=str2ubjson(name,item,level,varargin{:});
+else
+    txt=mat2ubjson(name,item,level,varargin{:});
+end
+
+%%-------------------------------------------------------------------------
+function txt=cell2ubjson(name,item,level,varargin)
+txt='';
+if(~iscell(item))
+        error('input is not a cell');
+end
+
+dim=size(item);
+if(ndims(squeeze(item))>2) % for 3D or higher dimensions, flatten to 2D for now
+    item=reshape(item,dim(1),numel(item)/dim(1));
+    dim=size(item);
+end
+len=numel(item); % let's handle 1D cell first
+if(len>1) 
+    if(~isempty(name))
+        txt=[S_(checkname(name,varargin{:})) '[']; name=''; 
+    else
+        txt='['; 
+    end
+elseif(len==0)
+    if(~isempty(name))
+        txt=[S_(checkname(name,varargin{:})) 'Z']; name=''; 
+    else
+        txt='Z'; 
+    end
+end
+for j=1:dim(2)
+    if(dim(1)>1) txt=[txt '[']; end
+    for i=1:dim(1)
+       txt=[txt obj2ubjson(name,item{i,j},level+(len>1),varargin{:})];
+    end
+    if(dim(1)>1) txt=[txt ']']; end
+end
+if(len>1) txt=[txt ']']; end
+
+%%-------------------------------------------------------------------------
+function txt=struct2ubjson(name,item,level,varargin)
+txt='';
+if(~isstruct(item))
+	error('input is not a struct');
+end
+dim=size(item);
+if(ndims(squeeze(item))>2) % for 3D or higher dimensions, flatten to 2D for now
+    item=reshape(item,dim(1),numel(item)/dim(1));
+    dim=size(item);
+end
+len=numel(item);
+
+if(~isempty(name)) 
+    if(len>1) txt=[S_(checkname(name,varargin{:})) '[']; end
+else
+    if(len>1) txt='['; end
+end
+for j=1:dim(2)
+  if(dim(1)>1) txt=[txt '[']; end
+  for i=1:dim(1)
+     names = fieldnames(item(i,j));
+     if(~isempty(name) && len==1)
+        txt=[txt S_(checkname(name,varargin{:})) '{']; 
+     else
+        txt=[txt '{']; 
+     end
+     if(~isempty(names))
+       for e=1:length(names)
+	     txt=[txt obj2ubjson(names{e},getfield(item(i,j),...
+             names{e}),level+(dim(1)>1)+1+(len>1),varargin{:})];
+       end
+     end
+     txt=[txt '}'];
+  end
+  if(dim(1)>1) txt=[txt ']']; end
+end
+if(len>1) txt=[txt ']']; end
+
+%%-------------------------------------------------------------------------
+function txt=str2ubjson(name,item,level,varargin)
+txt='';
+if(~ischar(item))
+        error('input is not a string');
+end
+item=reshape(item, max(size(item),[1 0]));
+len=size(item,1);
+
+if(~isempty(name)) 
+    if(len>1) txt=[S_(checkname(name,varargin{:})) '[']; end
+else
+    if(len>1) txt='['; end
+end
+isoct=jsonopt('IsOctave',0,varargin{:});
+for e=1:len
+    val=item(e,:);
+    if(len==1)
+        obj=['' S_(checkname(name,varargin{:})) '' '',S_(val),''];
+	if(isempty(name)) obj=['',S_(val),'']; end
+        txt=[txt,'',obj];
+    else
+        txt=[txt,'',['',S_(val),'']];
+    end
+end
+if(len>1) txt=[txt ']']; end
+
+%%-------------------------------------------------------------------------
+function txt=mat2ubjson(name,item,level,varargin)
+if(~isnumeric(item) && ~islogical(item))
+        error('input is not an array');
+end
+
+if(length(size(item))>2 || issparse(item) || ~isreal(item) || ...
+   isempty(item) || jsonopt('ArrayToStruct',0,varargin{:}))
+      cid=I_(uint32(max(size(item))));
+      if(isempty(name))
+    	txt=['{' S_('_ArrayType_'),S_(class(item)),S_('_ArraySize_'),I_a(size(item),cid(1)) ];
+      else
+          if(isempty(item))
+              txt=[S_(checkname(name,varargin{:})),'Z'];
+              return;
+          else
+    	      txt=[S_(checkname(name,varargin{:})),'{',S_('_ArrayType_'),S_(class(item)),S_('_ArraySize_'),I_a(size(item),cid(1))];
+          end
+      end
+else
+    if(isempty(name))
+    	txt=matdata2ubjson(item,level+1,varargin{:});
+    else
+        if(numel(item)==1 && jsonopt('NoRowBracket',1,varargin{:})==1)
+            numtxt=regexprep(regexprep(matdata2ubjson(item,level+1,varargin{:}),'^\[',''),']','');
+           	txt=[S_(checkname(name,varargin{:})) numtxt];
+        else
+    	    txt=[S_(checkname(name,varargin{:})),matdata2ubjson(item,level+1,varargin{:})];
+        end
+    end
+    return;
+end
+if(issparse(item))
+    [ix,iy]=find(item);
+    data=full(item(find(item)));
+    if(~isreal(item))
+       data=[real(data(:)),imag(data(:))];
+       if(size(item,1)==1)
+           % Kludge to have data's 'transposedness' match item's.
+           % (Necessary for complex row vector handling below.)
+           data=data';
+       end
+       txt=[txt,S_('_ArrayIsComplex_'),'T'];
+    end
+    txt=[txt,S_('_ArrayIsSparse_'),'T'];
+    if(size(item,1)==1)
+        % Row vector, store only column indices.
+        txt=[txt,S_('_ArrayData_'),...
+           matdata2ubjson([iy(:),data'],level+2,varargin{:})];
+    elseif(size(item,2)==1)
+        % Column vector, store only row indices.
+        txt=[txt,S_('_ArrayData_'),...
+           matdata2ubjson([ix,data],level+2,varargin{:})];
+    else
+        % General case, store row and column indices.
+        txt=[txt,S_('_ArrayData_'),...
+           matdata2ubjson([ix,iy,data],level+2,varargin{:})];
+    end
+else
+    if(isreal(item))
+        txt=[txt,S_('_ArrayData_'),...
+            matdata2ubjson(item(:)',level+2,varargin{:})];
+    else
+        txt=[txt,S_('_ArrayIsComplex_'),'T'];
+        txt=[txt,S_('_ArrayData_'),...
+            matdata2ubjson([real(item(:)) imag(item(:))],level+2,varargin{:})];
+    end
+end
+txt=[txt,'}'];
+
+%%-------------------------------------------------------------------------
+function txt=matdata2ubjson(mat,level,varargin)
+if(isempty(mat))
+    txt='Z';
+    return;
+end
+if(size(mat,1)==1)
+    level=level-1;
+end
+type='';
+hasnegtive=(mat<0);
+if(isa(mat,'integer') || isinteger(mat) || (isfloat(mat) && all(mod(mat(:),1) == 0)))
+    if(isempty(hasnegtive))
+       if(max(mat(:))<=2^8)
+           type='U';
+       end
+    end
+    if(isempty(type))
+        % todo - need to consider negative ones separately
+        id= histc(abs(max(mat(:))),[0 2^7 2^15 2^31 2^63]);
+        if(isempty(find(id)))
+            error('high-precision data is not yet supported');
+        end
+        key='iIlL';
+	type=key(find(id));
+    end
+    txt=[I_a(mat(:),type,size(mat))];
+elseif(islogical(mat))
+    logicalval='FT';
+    if(numel(mat)==1)
+        txt=logicalval(mat+1);
+    else
+        txt=['[$U#' I_a(size(mat),'l') typecast(swapbytes(uint8(mat(:)')),'uint8')];
+    end
+else
+    if(numel(mat)==1)
+        txt=['[' D_(mat) ']'];
+    else
+        txt=D_a(mat(:),'D',size(mat));
+    end
+end
+
+%txt=regexprep(mat2str(mat),'\s+',',');
+%txt=regexprep(txt,';',sprintf('],['));
+% if(nargin>=2 && size(mat,1)>1)
+%     txt=regexprep(txt,'\[',[repmat(sprintf('\t'),1,level) '[']);
+% end
+if(any(isinf(mat(:))))
+    txt=regexprep(txt,'([-+]*)Inf',jsonopt('Inf','"$1_Inf_"',varargin{:}));
+end
+if(any(isnan(mat(:))))
+    txt=regexprep(txt,'NaN',jsonopt('NaN','"_NaN_"',varargin{:}));
+end
+
+%%-------------------------------------------------------------------------
+function newname=checkname(name,varargin)
+isunpack=jsonopt('UnpackHex',1,varargin{:});
+newname=name;
+if(isempty(regexp(name,'0x([0-9a-fA-F]+)_','once')))
+    return
+end
+if(isunpack)
+    isoct=jsonopt('IsOctave',0,varargin{:});
+    if(~isoct)
+        newname=regexprep(name,'(^x|_){1}0x([0-9a-fA-F]+)_','${native2unicode(hex2dec($2))}');
+    else
+        pos=regexp(name,'(^x|_){1}0x([0-9a-fA-F]+)_','start');
+        pend=regexp(name,'(^x|_){1}0x([0-9a-fA-F]+)_','end');
+        if(isempty(pos)) return; end
+        str0=name;
+        pos0=[0 pend(:)' length(name)];
+        newname='';
+        for i=1:length(pos)
+            newname=[newname str0(pos0(i)+1:pos(i)-1) char(hex2dec(str0(pos(i)+3:pend(i)-1)))];
+        end
+        if(pos(end)~=length(name))
+            newname=[newname str0(pos0(end-1)+1:pos0(end))];
+        end
+    end
+end
+%%-------------------------------------------------------------------------
+function val=S_(str)
+if(length(str)==1)
+  val=['C' str];
+else
+  val=['S' I_(int32(length(str))) str];
+end
+%%-------------------------------------------------------------------------
+function val=I_(num)
+if(~isinteger(num))
+    error('input is not an integer');
+end
+if(num>=0 && num<255)
+   val=['U' data2byte(swapbytes(cast(num,'uint8')),'uint8')];
+   return;
+end
+key='iIlL';
+cid={'int8','int16','int32','int64'};
+for i=1:4
+  if((num>0 && num<2^(i*8-1)) || (num<0 && num>=-2^(i*8-1)))
+    val=[key(i) data2byte(swapbytes(cast(num,cid{i})),'uint8')];
+    return;
+  end
+end
+error('unsupported integer');
+
+%%-------------------------------------------------------------------------
+function val=D_(num)
+if(~isfloat(num))
+    error('input is not a float');
+end
+
+if(isa(num,'single'))
+  val=['d' data2byte(num,'uint8')];
+else
+  val=['D' data2byte(num,'uint8')];
+end
+%%-------------------------------------------------------------------------
+function data=I_a(num,type,dim,format)
+id=find(ismember('iUIlL',type));
+
+if(id==0)
+  error('unsupported integer array');
+end
+
+% based on UBJSON specs, all integer types are stored in big endian format
+
+if(id==1)
+  data=data2byte(swapbytes(int8(num)),'uint8');
+  blen=1;
+elseif(id==2)
+  data=data2byte(swapbytes(uint8(num)),'uint8');
+  blen=1;
+elseif(id==3)
+  data=data2byte(swapbytes(int16(num)),'uint8');
+  blen=2;
+elseif(id==4)
+  data=data2byte(swapbytes(int32(num)),'uint8');
+  blen=4;
+elseif(id==5)
+  data=data2byte(swapbytes(int64(num)),'uint8');
+  blen=8;
+end
+
+if(nargin>=3 && length(dim)>=2 && prod(dim)~=dim(2))
+  format='opt';
+end
+if((nargin<4 || strcmp(format,'opt')) && numel(num)>1)
+  if(nargin>=3 && (length(dim)==1 || (length(dim)>=2 && prod(dim)~=dim(2))))
+      cid=I_(uint32(max(dim)));
+      data=['$' type '#' I_a(dim,cid(1)) data(:)'];
+  else
+      data=['$' type '#' I_(int32(numel(data)/blen)) data(:)'];
+  end
+  data=['[' data(:)'];
+else
+  data=reshape(data,blen,numel(data)/blen);
+  data(2:blen+1,:)=data;
+  data(1,:)=type;
+  data=data(:)';
+  data=['[' data(:)' ']'];
+end
+%%-------------------------------------------------------------------------
+function data=D_a(num,type,dim,format)
+id=find(ismember('dD',type));
+
+if(id==0)
+  error('unsupported float array');
+end
+
+if(id==1)
+  data=data2byte(single(num),'uint8');
+elseif(id==2)
+  data=data2byte(double(num),'uint8');
+end
+
+if(nargin>=3 && length(dim)>=2 && prod(dim)~=dim(2))
+  format='opt';
+end
+if((nargin<4 || strcmp(format,'opt')) && numel(num)>1)
+  if(nargin>=3 && (length(dim)==1 || (length(dim)>=2 && prod(dim)~=dim(2))))
+      cid=I_(uint32(max(dim)));
+      data=['$' type '#' I_a(dim,cid(1)) data(:)'];
+  else
+      data=['$' type '#' I_(int32(numel(data)/(id*4))) data(:)'];
+  end
+  data=['[' data];
+else
+  data=reshape(data,(id*4),length(data)/(id*4));
+  data(2:(id*4+1),:)=data;
+  data(1,:)=type;
+  data=data(:)';
+  data=['[' data(:)' ']'];
+end
+%%-------------------------------------------------------------------------
+function bytes=data2byte(varargin)
+bytes=typecast(varargin{:});
+bytes=bytes(:)';

+ 40 - 0
machine learning/machine-learning-ex1/ex1/lib/jsonlab/varargin2struct.m

@@ -0,0 +1,40 @@
+function opt=varargin2struct(varargin)
+%
+% opt=varargin2struct('param1',value1,'param2',value2,...)
+%   or
+% opt=varargin2struct(...,optstruct,...)
+%
+% convert a series of input parameters into a structure
+%
+% authors:Qianqian Fang (fangq<at> nmr.mgh.harvard.edu)
+% date: 2012/12/22
+%
+% input:
+%      'param', value: the input parameters should be pairs of a string and a value
+%       optstruct: if a parameter is a struct, the fields will be merged to the output struct
+%
+% output:
+%      opt: a struct where opt.param1=value1, opt.param2=value2 ...
+%
+% license:
+%     BSD, see LICENSE_BSD.txt files for details 
+%
+% -- this function is part of jsonlab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)
+%
+
+len=length(varargin);
+opt=struct;
+if(len==0) return; end
+i=1;
+while(i<=len)
+    if(isstruct(varargin{i}))
+        opt=mergestruct(opt,varargin{i});
+    elseif(ischar(varargin{i}) && i<len)
+        opt=setfield(opt,varargin{i},varargin{i+1});
+        i=i+1;
+    else
+        error('input must be in the form of ...,''name'',value,... pairs or structs');
+    end
+    i=i+1;
+end
+

+ 30 - 0
machine learning/machine-learning-ex1/ex1/lib/makeValidFieldName.m

@@ -0,0 +1,30 @@
+function str = makeValidFieldName(str)
+% From MATLAB doc: field names must begin with a letter, which may be
+% followed by any combination of letters, digits, and underscores.
+% Invalid characters will be converted to underscores, and the prefix
+% "x0x[Hex code]_" will be added if the first character is not a letter.
+    isoct=exist('OCTAVE_VERSION','builtin');
+    pos=regexp(str,'^[^A-Za-z]','once');
+    if(~isempty(pos))
+        if(~isoct)
+            str=regexprep(str,'^([^A-Za-z])','x0x${sprintf(''%X'',unicode2native($1))}_','once');
+        else
+            str=sprintf('x0x%X_%s',char(str(1)),str(2:end));
+        end
+    end
+    if(isempty(regexp(str,'[^0-9A-Za-z_]', 'once' ))) return;  end
+    if(~isoct)
+        str=regexprep(str,'([^0-9A-Za-z_])','_0x${sprintf(''%X'',unicode2native($1))}_');
+    else
+        pos=regexp(str,'[^0-9A-Za-z_]');
+        if(isempty(pos)) return; end
+        str0=str;
+        pos0=[0 pos(:)' length(str)];
+        str='';
+        for i=1:length(pos)
+            str=[str str0(pos0(i)+1:pos(i)-1) sprintf('_0x%X_',str0(pos(i)))];
+        end
+        if(pos(end)~=length(str))
+            str=[str str0(pos0(end-1)+1:pos0(end))];
+        end
+    end

+ 179 - 0
machine learning/machine-learning-ex1/ex1/lib/submitWithConfiguration.m

@@ -0,0 +1,179 @@
+function submitWithConfiguration(conf)
+  addpath('./lib/jsonlab');
+
+  parts = parts(conf);
+
+  fprintf('== Submitting solutions | %s...\n', conf.itemName);
+
+  tokenFile = 'token.mat';
+  if exist(tokenFile, 'file')
+    load(tokenFile);
+    [email token] = promptToken(email, token, tokenFile);
+  else
+    [email token] = promptToken('', '', tokenFile);
+  end
+
+  if isempty(token)
+    fprintf('!! Submission Cancelled\n');
+    return
+  end
+
+  try
+    response = submitParts(conf, email, token, parts);
+  catch
+    e = lasterror();
+    fprintf('\n!! Submission failed: %s\n', e.message);
+    fprintf('\n\nFunction: %s\nFileName: %s\nLineNumber: %d\n', ...
+      e.stack(1,1).name, e.stack(1,1).file, e.stack(1,1).line);
+    fprintf('\nPlease correct your code and resubmit.\n');
+    return
+  end
+
+  if isfield(response, 'errorMessage')
+    fprintf('!! Submission failed: %s\n', response.errorMessage);
+  elseif isfield(response, 'errorCode')
+    fprintf('!! Submission failed: %s\n', response.message);
+  else
+    showFeedback(parts, response);
+    save(tokenFile, 'email', 'token');
+  end
+end
+
+function [email token] = promptToken(email, existingToken, tokenFile)
+  if (~isempty(email) && ~isempty(existingToken))
+    prompt = sprintf( ...
+      'Use token from last successful submission (%s)? (Y/n): ', ...
+      email);
+    reenter = input(prompt, 's');
+
+    if (isempty(reenter) || reenter(1) == 'Y' || reenter(1) == 'y')
+      token = existingToken;
+      return;
+    else
+      delete(tokenFile);
+    end
+  end
+  email = input('Login (email address): ', 's');
+  token = input('Token: ', 's');
+end
+
+function isValid = isValidPartOptionIndex(partOptions, i)
+  isValid = (~isempty(i)) && (1 <= i) && (i <= numel(partOptions));
+end
+
+function response = submitParts(conf, email, token, parts)
+  body = makePostBody(conf, email, token, parts);
+  submissionUrl = submissionUrl();
+
+  responseBody = getResponse(submissionUrl, body);
+  jsonResponse = validateResponse(responseBody);
+  response = loadjson(jsonResponse);
+end
+
+function body = makePostBody(conf, email, token, parts)
+  bodyStruct.assignmentSlug = conf.assignmentSlug;
+  bodyStruct.submitterEmail = email;
+  bodyStruct.secret = token;
+  bodyStruct.parts = makePartsStruct(conf, parts);
+
+  opt.Compact = 1;
+  body = savejson('', bodyStruct, opt);
+end
+
+function partsStruct = makePartsStruct(conf, parts)
+  for part = parts
+    partId = part{:}.id;
+    fieldName = makeValidFieldName(partId);
+    outputStruct.output = conf.output(partId);
+    partsStruct.(fieldName) = outputStruct;
+  end
+end
+
+function [parts] = parts(conf)
+  parts = {};
+  for partArray = conf.partArrays
+    part.id = partArray{:}{1};
+    part.sourceFiles = partArray{:}{2};
+    part.name = partArray{:}{3};
+    parts{end + 1} = part;
+  end
+end
+
+function showFeedback(parts, response)
+  fprintf('== \n');
+  fprintf('== %43s | %9s | %-s\n', 'Part Name', 'Score', 'Feedback');
+  fprintf('== %43s | %9s | %-s\n', '---------', '-----', '--------');
+  for part = parts
+    score = '';
+    partFeedback = '';
+    partFeedback = response.partFeedbacks.(makeValidFieldName(part{:}.id));
+    partEvaluation = response.partEvaluations.(makeValidFieldName(part{:}.id));
+    score = sprintf('%d / %3d', partEvaluation.score, partEvaluation.maxScore);
+    fprintf('== %43s | %9s | %-s\n', part{:}.name, score, partFeedback);
+  end
+  evaluation = response.evaluation;
+  totalScore = sprintf('%d / %d', evaluation.score, evaluation.maxScore);
+  fprintf('==                                   --------------------------------\n');
+  fprintf('== %43s | %9s | %-s\n', '', totalScore, '');
+  fprintf('== \n');
+end
+
+% use urlread or curl to send submit results to the grader and get a response
+function response = getResponse(url, body)
+% try using urlread() and a secure connection
+  params = {'jsonBody', body};
+  [response, success] = urlread(url, 'post', params);
+
+  if (success == 0)
+    % urlread didn't work, try curl & the peer certificate patch
+    if ispc
+      % testing note: use 'jsonBody =' for a test case
+      json_command = sprintf('echo jsonBody=%s | curl -k -X POST -d @- %s', body, url);
+    else
+      % it's linux/OS X, so use the other form
+      json_command = sprintf('echo ''jsonBody=%s'' | curl -k -X POST -d @- %s', body, url);
+    end
+    % get the response body for the peer certificate patch method
+    [code, response] = system(json_command);
+    % test the success code
+    if (code ~= 0)
+      fprintf('[error] submission with curl() was not successful\n');
+    end
+  end
+end
+
+% validate the grader's response
+function response = validateResponse(resp)
+  % test if the response is json or an HTML page
+  isJson = length(resp) > 0 && resp(1) == '{';
+  isHtml = findstr(lower(resp), '<html');
+
+  if (isJson)
+    response = resp;
+  elseif (isHtml)
+    % the response is html, so it's probably an error message
+    printHTMLContents(resp);
+    error('Grader response is an HTML message');
+  else
+    error('Grader sent no response');
+  end
+end
+
+% parse a HTML response and print it's contents
+function printHTMLContents(response)
+  strippedResponse = regexprep(response, '<[^>]+>', ' ');
+  strippedResponse = regexprep(strippedResponse, '[\t ]+', ' ');
+  fprintf(strippedResponse);
+end
+
+
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% Service configuration
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+function submissionUrl = submissionUrl()
+  submissionUrl = 'https://www-origin.coursera.org/api/onDemandProgrammingImmediateFormSubmissions.v1';
+end

+ 24 - 0
machine learning/machine-learning-ex1/ex1/my_ex1.m

@@ -0,0 +1,24 @@
+data = load('ex1data1.txt');
+X = data(:, 1); y = data(:, 2);
+m = length(y); % number of training examples
+
+X = [ones(m, 1), data(:,1)]; % Add a column of ones to x
+theta = zeros(2, 1); % initialize fitting parameters
+
+% Some gradient descent settings
+iterations = 1500;
+alpha = 0.01;
+
+fprintf('\nTesting the cost function ...\n')
+% compute and display initial cost
+J = computeCost(X, y, theta);
+fprintf('With theta = [0 ; 0]\nCost computed = %f\n', J);
+fprintf('Expected cost value (approx) 32.07\n');
+% run gradient descent
+theta = gradientDescent(X, y, theta, alpha, iterations);
+
+% print theta to screen
+fprintf('Theta found by gradient descent:\n');
+fprintf('%f\n', theta);
+fprintf('Expected theta values (approx)\n');
+fprintf(' -3.6303\n  1.1664\n\n');

+ 23 - 0
machine learning/machine-learning-ex1/ex1/normalEqn.m

@@ -0,0 +1,23 @@
+function [theta] = normalEqn(X, y)
+%NORMALEQN Computes the closed-form solution to linear regression 
+%   NORMALEQN(X,y) computes the closed-form solution to linear 
+%   regression using the normal equations.
+
+theta = zeros(size(X, 2), 1);
+
+% ====================== YOUR CODE HERE ======================
+% Instructions: Complete the code to compute the closed form solution
+%               to linear regression and put the result in theta.
+%
+
+% ---------------------- Sample Solution ----------------------
+
+
+
+
+% -------------------------------------------------------------
+
+
+% ============================================================
+
+end

BIN
machine learning/machine-learning-ex1/ex1/octave-workspace


+ 27 - 0
machine learning/machine-learning-ex1/ex1/plotData.m

@@ -0,0 +1,27 @@
+function plotData(x, y)
+%PLOTDATA Plots the data points x and y into a new figure 
+%   PLOTDATA(x,y) plots the data points and gives the figure axes labels of
+%   population and profit.
+
+figure; % open a new figure window
+
+% ====================== YOUR CODE HERE ======================
+% Instructions: Plot the training data into a figure using the 
+%               "figure" and "plot" commands. Set the axes labels using
+%               the "xlabel" and "ylabel" commands. Assume the 
+%               population and revenue data have been passed in
+%               as the x and y arguments of this function.
+%
+% Hint: You can use the 'rx' option with plot to have the markers
+%       appear as red crosses. Furthermore, you can make the
+%       markers larger by using plot(..., 'rx', 'MarkerSize', 10);
+
+plot(x,y,'rx','MarkerSize', 10);
+ylabel('profit in $10,000s');
+xlabel('population of city in 10,000s');
+
+
+
+% ============================================================
+
+end

+ 69 - 0
machine learning/machine-learning-ex1/ex1/submit.m

@@ -0,0 +1,69 @@
+function submit()
+  addpath('./lib');
+
+  conf.assignmentSlug = 'linear-regression';
+  conf.itemName = 'Linear Regression with Multiple Variables';
+  conf.partArrays = { ...
+    { ...
+      '1', ...
+      { 'warmUpExercise.m' }, ...
+      'Warm-up Exercise', ...
+    }, ...
+    { ...
+      '2', ...
+      { 'computeCost.m' }, ...
+      'Computing Cost (for One Variable)', ...
+    }, ...
+    { ...
+      '3', ...
+      { 'gradientDescent.m' }, ...
+      'Gradient Descent (for One Variable)', ...
+    }, ...
+    { ...
+      '4', ...
+      { 'featureNormalize.m' }, ...
+      'Feature Normalization', ...
+    }, ...
+    { ...
+      '5', ...
+      { 'computeCostMulti.m' }, ...
+      'Computing Cost (for Multiple Variables)', ...
+    }, ...
+    { ...
+      '6', ...
+      { 'gradientDescentMulti.m' }, ...
+      'Gradient Descent (for Multiple Variables)', ...
+    }, ...
+    { ...
+      '7', ...
+      { 'normalEqn.m' }, ...
+      'Normal Equations', ...
+    }, ...
+  };
+  conf.output = @output;
+
+  submitWithConfiguration(conf);
+end
+
+function out = output(partId)
+  % Random Test Cases
+  X1 = [ones(20,1) (exp(1) + exp(2) * (0.1:0.1:2))'];
+  Y1 = X1(:,2) + sin(X1(:,1)) + cos(X1(:,2));
+  X2 = [X1 X1(:,2).^0.5 X1(:,2).^0.25];
+  Y2 = Y1.^0.5 + Y1;
+  if partId == '1'
+    out = sprintf('%0.5f ', warmUpExercise());
+  elseif partId == '2'
+    out = sprintf('%0.5f ', computeCost(X1, Y1, [0.5 -0.5]'));
+  elseif partId == '3'
+    out = sprintf('%0.5f ', gradientDescent(X1, Y1, [0.5 -0.5]', 0.01, 10));
+  elseif partId == '4'
+    out = sprintf('%0.5f ', featureNormalize(X2(:,2:4)));
+  elseif partId == '5'
+    out = sprintf('%0.5f ', computeCostMulti(X2, Y2, [0.1 0.2 0.3 0.4]'));
+  elseif partId == '6'
+    out = sprintf('%0.5f ', gradientDescentMulti(X2, Y2, [-0.1 -0.2 -0.3 -0.4]', 0.01, 10));
+  elseif partId == '7'
+    out = sprintf('%0.5f ', normalEqn(X2, Y2));
+  end 
+end

+ 15 - 0
machine learning/machine-learning-ex1/ex1/token.mat

@@ -0,0 +1,15 @@
+# Created by Octave 4.2.2, Sat Nov 03 21:56:51 2018 HKT <astron@astron>
+# name: email
+# type: sq_string
+# elements: 1
+# length: 20
+larry1chan@gmail.com
+
+
+# name: token
+# type: sq_string
+# elements: 1
+# length: 16
+yZQkhkMXMKfFaIlx
+
+

+ 21 - 0
machine learning/machine-learning-ex1/ex1/warmUpExercise.m

@@ -0,0 +1,21 @@
+function A = warmUpExercise()
+%WARMUPEXERCISE Example function in octave
+%   A = WARMUPEXERCISE() is an example function that returns the 5x5 identity matrix
+
+A = [];
+% ============= YOUR CODE HERE ==============
+% Instructions: Return the 5x5 identity matrix 
+%               In octave, we return values by defining which variables
+%               represent the return values (at the top of the file)
+%               and then set them accordingly. 
+A = eye(5);
+
+
+
+
+
+
+% ===========================================
+
+
+end

BIN
machine learning/machine-learning-ex2/ex2.pdf


+ 47 - 0
machine learning/machine-learning-ex2/ex2/costFunction.m

@@ -0,0 +1,47 @@
+function [J, grad] = costFunction(theta, X, y)
+%COSTFUNCTION Compute cost and gradient for logistic regression
+%   J = COSTFUNCTION(theta, X, y) computes the cost of using theta as the
+%   parameter for logistic regression and the gradient of the cost
+%   w.r.t. to the parameters.
+
+% Initialize some useful values
+m = length(y); % number of training examples
+
+% You need to return the following variables correctly 
+J = 0;
+grad = zeros(size(theta));
+
+% ====================== YOUR CODE HERE ======================
+% Instructions: Compute the cost of a particular choice of theta.
+%               You should set J to the cost.
+%               Compute the partial derivatives and set grad to the partial
+%               derivatives of the cost w.r.t. each parameter in theta
+%
+% Note: grad should have the same dimensions as theta
+%
+
+
+% refer to the vectorized function in Week 3|Logistic Regression Model|
+% Simplified Cost Function and Gradient Descent
+% h = g(X * theta)
+
+
+J = 1 / m * (-1 .* y' * log(sigmoid(X*theta)) - (1 .- y)' * log(1 .- sigmoid(X*theta)));
+
+% compute the gradient only
+
+% 1. vector method
+% grad = 1/m * X' * (sigmoid(X*theta) - y);
+
+%
+% 2. sum method
+grad = 1/m * sum((sigmoid(X*theta) - y ).* X);
+
+
+
+
+
+
+% =============================================================
+
+end

+ 73 - 0
machine learning/machine-learning-ex2/ex2/costFunctionReg.m

@@ -0,0 +1,73 @@
+function [J, grad] = costFunctionReg(theta, X, y, lambda)
+%COSTFUNCTIONREG Compute cost and gradient for logistic regression with regularization
+%   J = COSTFUNCTIONREG(theta, X, y, lambda) computes the cost of using
+%   theta as the parameter for regularized logistic regression and the
+%   gradient of the cost w.r.t. to the parameters. 
+
+% Initialize some useful values
+m = length(y); % number of training examples
+
+% You need to return the following variables correctly 
+J = 0;
+grad = zeros(size(theta));
+
+% ====================== YOUR CODE HERE ======================
+% Instructions: Compute the cost of a particular choice of theta.
+%               You should set J to the cost.
+%               Compute the partial derivatives and set grad to the partial
+%               derivatives of the cost w.r.t. each parameter in theta
+
+
+
+%J = 1 / m * ((-1 .* y') * log(sigmoid(X * theta)) - (1 .- y)' * log(1 .- sigmoid(X * theta))) %...
+    %+ lambda / (2 * m) * [0; (theta([2, rows(theta)],:) .^ 2)];
+    
+    
+J = 1 / m * sum(((-1 .* y') * log(sigmoid(X * theta)) - (1 .- y)' * log(1 .- sigmoid(X * theta)))) ...    
+    + lambda / (2 * m) * sum(theta([2: rows(theta)]) .^ 2);
+
+%size(J)
+
+%
+% the dumb way
+% first attempt:
+% two step process: compute j0 without regularization and then j1-n with regularization
+% 1. set up a matrix X1 of the same size as X. Next copy the row values from the first column of X into the matrix X1
+% and fill the rest of the rows/columns with zeros. Apply the gradient formula, 
+% Use X as the parameter in the sigmoid function 
+% this result in an 1x1 matrix
+% 2. set up a 2nd matrix X2N. It contains 0 in its first column, and data copied from col2 to col end of X
+% apply the graident function
+% this result in a 28x1 matrix
+% finally,
+% discard the first row of gradient X2N in Step 2 as it contains the regularized value
+% return the gradient by adding the first result and X2N[2:end]
+%
+%
+% 
+X1 = [X(:, 1) zeros(m, columns(X) - 1)];
+grad1 = 1 / m * X1' * (sigmoid(X * theta) - y);
+%fprintf ('grad1: %f\n', grad1);
+
+
+X2N = [[zeros(m, 1)] X(:, 2:end)];
+%X2N
+grad2N = 1 / m * X2N' * (sigmoid(X * theta) - y) + lambda / m * theta;
+%grad2N
+grad = [grad1(1, 1);  grad2N(2:end, 1)];
+%fprintf ('------------> %f\n', grad(1:5));
+
+
+%
+%
+% the quick way
+% 
+%
+
+%grad =1/m * X' * (sigmoid(X* theta) - y) + lambda/m * theta .* [0; ones(length(theta)-1, 1)];
+%fprintf ('------------> %f\n', grad(1:5));
+
+
+% =============================================================
+
+end

+ 151 - 0
machine learning/machine-learning-ex2/ex2/ex2.m

@@ -0,0 +1,151 @@
+%% Machine Learning Online Class - Exercise 2: Logistic Regression
+%
+%  Instructions
+%  ------------
+% 
+%  This file contains code that helps you get started on the logistic
+%  regression exercise. You will need to complete the following functions 
+%  in this exericse:
+%
+%     sigmoid.m
+%     costFunction.m
+%     predict.m
+%     costFunctionReg.m
+%
+%  For this exercise, you will not need to change any code in this file,
+%  or any other files other than those mentioned above.
+%
+
+%% Initialization
+clear ; close all; clc
+
+%% Load Data
+%  The first two columns contains the exam scores and the third column
+%  contains the label.
+
+data = load('ex2data1.txt');
+X = data(:, [1, 2]); y = data(:, 3);
+
+%% ==================== Part 1: Plotting ====================
+%  We start the exercise by first plotting the data to understand the 
+%  the problem we are working with.
+
+fprintf(['Plotting data with + indicating (y = 1) examples and o ' ...
+         'indicating (y = 0) examples.\n']);
+
+plotData(X, y);
+
+% Put some labels 
+hold on;
+% Labels and Legend
+xlabel('Exam 1 score')
+ylabel('Exam 2 score')
+
+% Specified in plot order
+legend('Admitted', 'Not admitted')
+hold off;
+
+fprintf('\nProgram paused. Press enter to continue.\n');
+pause;
+
+
+%% ============ Part 2: Compute Cost and Gradient ============
+%  In this part of the exercise, you will implement the cost and gradient
+%  for logistic regression. You neeed to complete the code in 
+%  costFunction.m
+
+%  Setup the data matrix appropriately, and add ones for the intercept term
+[m, n] = size(X);
+
+% Add intercept term to x and X_test
+X = [ones(m, 1) X];
+
+% Initialize fitting parameters
+initial_theta = zeros(n + 1, 1);
+
+% Compute and display initial cost and gradient
+[cost, grad] = costFunction(initial_theta, X, y);
+
+fprintf('Cost at initial theta (zeros): %f\n', cost);
+fprintf('Expected cost (approx): 0.693\n');
+fprintf('Gradient at initial theta (zeros): \n');
+fprintf(' %f \n', grad);
+fprintf('Expected gradients (approx):\n -0.1000\n -12.0092\n -11.2628\n');
+
+% Compute and display cost and gradient with non-zero theta
+test_theta = [-24; 0.2; 0.2];
+[cost, grad] = costFunction(test_theta, X, y);
+
+fprintf('\nCost at test theta: %f\n', cost);
+fprintf('Expected cost (approx): 0.218\n');
+fprintf('Gradient at test theta: \n');
+fprintf(' %f \n', grad);
+fprintf('Expected gradients (approx):\n 0.043\n 2.566\n 2.647\n');
+
+fprintf('\nProgram paused. Press enter to continue.\n');
+pause;
+
+
+%% ============= Part 3: Optimizing using fminunc  =============
+%  In this exercise, you will use a built-in function (fminunc) to find the
+%  optimal parameters theta.
+
+%  Set options for fminunc
+options = optimset('GradObj', 'on', 'MaxIter', 400);
+
+%  Run fminunc to obtain the optimal theta
+%  This function will return theta and the cost 
+[theta, cost] = ...
+	fminunc(@(t)(costFunction(t, X, y)), initial_theta, options);
+
+% Print theta to screen
+fprintf('Cost at theta found by fminunc: %f\n', cost);
+fprintf('Expected cost (approx): 0.203\n');
+fprintf('theta: \n');
+fprintf(' %f \n', theta);
+fprintf('Expected theta (approx):\n');
+fprintf(' -25.161\n 0.206\n 0.201\n');
+
+% Plot Boundary
+plotDecisionBoundary(theta, X, y);
+
+% Put some labels 
+hold on;
+% Labels and Legend
+xlabel('Exam 1 score')
+ylabel('Exam 2 score')
+
+% Specified in plot order
+legend('Admitted', 'Not admitted')
+hold off;
+
+fprintf('\nProgram paused. Press enter to continue.\n');
+pause;
+
+%% ============== Part 4: Predict and Accuracies ==============
+%  After learning the parameters, you'll like to use it to predict the outcomes
+%  on unseen data. In this part, you will use the logistic regression model
+%  to predict the probability that a student with score 45 on exam 1 and 
+%  score 85 on exam 2 will be admitted.
+%
+%  Furthermore, you will compute the training and test set accuracies of 
+%  our model.
+%
+%  Your task is to complete the code in predict.m
+
+%  Predict probability for a student with score 45 on exam 1 
+%  and score 85 on exam 2 
+
+prob = sigmoid([1 45 85] * theta);
+fprintf(['For a student with scores 45 and 85, we predict an admission ' ...
+         'probability of %f\n'], prob);
+fprintf('Expected value: 0.775 +/- 0.002\n\n');
+
+% Compute accuracy on our training set
+p = predict(theta, X);
+
+fprintf('Train Accuracy: %f\n', mean(double(p == y)) * 100);
+fprintf('Expected accuracy (approx): 89.0\n');
+fprintf('\n');
+
+

+ 136 - 0
machine learning/machine-learning-ex2/ex2/ex2_reg.m

@@ -0,0 +1,136 @@
+%% Machine Learning Online Class - Exercise 2: Logistic Regression
+%
+%  Instructions
+%  ------------
+%
+%  This file contains code that helps you get started on the second part
+%  of the exercise which covers regularization with logistic regression.
+%
+%  You will need to complete the following functions in this exericse:
+%
+%     sigmoid.m
+%     costFunction.m
+%     predict.m
+%     costFunctionReg.m
+%
+%  For this exercise, you will not need to change any code in this file,
+%  or any other files other than those mentioned above.
+%
+
+%% Initialization
+clear ; close all; clc
+
+%% Load Data
+%  The first two columns contains the X values and the third column
+%  contains the label (y).
+
+data = load('ex2data2.txt');
+X = data(:, [1, 2]); y = data(:, 3);
+
+plotData(X, y);
+
+% Put some labels
+hold on;
+
+% Labels and Legend
+xlabel('Microchip Test 1')
+ylabel('Microchip Test 2')
+
+% Specified in plot order
+legend('y = 1', 'y = 0')
+hold off;
+
+
+%% =========== Part 1: Regularized Logistic Regression ============
+%  In this part, you are given a dataset with data points that are not
+%  linearly separable. However, you would still like to use logistic
+%  regression to classify the data points.
+%
+%  To do so, you introduce more features to use -- in particular, you add
+%  polynomial features to our data matrix (similar to polynomial
+%  regression).
+%
+
+% Add Polynomial Features
+
+% Note that mapFeature also adds a column of ones for us, so the intercept
+% term is handled
+X = mapFeature(X(:,1), X(:,2));
+
+% Initialize fitting parameters
+initial_theta = zeros(size(X, 2), 1);
+
+% Set regularization parameter lambda to 1
+lambda = 1;
+
+% Compute and display initial cost and gradient for regularized logistic
+% regression
+[cost, grad] = costFunctionReg(initial_theta, X, y, lambda);
+
+fprintf('Cost at initial theta (zeros): %f\n', cost);
+fprintf('Expected cost (approx): 0.693\n');
+fprintf('Gradient at initial theta (zeros) - first five values only:\n');
+fprintf(' %f \n', grad(1:5));
+fprintf('Expected gradients (approx) - first five values only:\n');
+fprintf(' 0.0085\n 0.0188\n 0.0001\n 0.0503\n 0.0115\n');
+
+fprintf('\nProgram paused. Press enter to continue.\n');
+pause;
+
+% Compute and display cost and gradient
+% with all-ones theta and lambda = 10
+test_theta = ones(size(X,2),1);
+[cost, grad] = costFunctionReg(test_theta, X, y, 10);
+
+fprintf('\nCost at test theta (with lambda = 10): %f\n', cost);
+fprintf('Expected cost (approx): 3.16\n');
+fprintf('Gradient at test theta - first five values only:\n');
+fprintf(' %f \n', grad(1:5));
+fprintf('Expected gradients (approx) - first five values only:\n');
+fprintf(' 0.3460\n 0.1614\n 0.1948\n 0.2269\n 0.0922\n');
+
+fprintf('\nProgram paused. Press enter to continue.\n');
+pause;
+
+%% ============= Part 2: Regularization and Accuracies =============
+%  Optional Exercise:
+%  In this part, you will get to try different values of lambda and
+%  see how regularization affects the decision coundart
+%
+%  Try the following values of lambda (0, 1, 10, 100).
+%
+%  How does the decision boundary change when you vary lambda? How does
+%  the training set accuracy vary?
+%
+
+% Initialize fitting parameters
+initial_theta = zeros(size(X, 2), 1);
+
+% Set regularization parameter lambda to 1 (you should vary this)
+lambda = 1;
+
+% Set Options
+options = optimset('GradObj', 'on', 'MaxIter', 400);
+
+% Optimize
+[theta, J, exit_flag] = ...
+	fminunc(@(t)(costFunctionReg(t, X, y, lambda)), initial_theta, options);
+theta
+% Plot Boundary
+plotDecisionBoundary(theta, X, y);
+hold on;
+title(sprintf('lambda = %g', lambda))
+
+% Labels and Legend
+xlabel('Microchip Test 1')
+ylabel('Microchip Test 2')
+
+legend('y = 1', 'y = 0', 'Decision boundary')
+hold off;
+
+% Compute accuracy on our training set
+p = predict(theta, X);
+
+fprintf('Train Accuracy: %f\n', mean(double(p == y)) * 100);
+fprintf('Expected accuracy (with lambda = 1): 83.1 (approx)\n');
+

+ 100 - 0
machine learning/machine-learning-ex2/ex2/ex2data1.txt

@@ -0,0 +1,100 @@
+34.62365962451697,78.0246928153624,0
+30.28671076822607,43.89499752400101,0
+35.84740876993872,72.90219802708364,0
+60.18259938620976,86.30855209546826,1
+79.0327360507101,75.3443764369103,1
+45.08327747668339,56.3163717815305,0
+61.10666453684766,96.51142588489624,1
+75.02474556738889,46.55401354116538,1
+76.09878670226257,87.42056971926803,1
+84.43281996120035,43.53339331072109,1
+95.86155507093572,38.22527805795094,0
+75.01365838958247,30.60326323428011,0
+82.30705337399482,76.48196330235604,1
+69.36458875970939,97.71869196188608,1
+39.53833914367223,76.03681085115882,0
+53.9710521485623,89.20735013750205,1
+69.07014406283025,52.74046973016765,1
+67.94685547711617,46.67857410673128,0
+70.66150955499435,92.92713789364831,1
+76.97878372747498,47.57596364975532,1
+67.37202754570876,42.83843832029179,0
+89.67677575072079,65.79936592745237,1
+50.534788289883,48.85581152764205,0
+34.21206097786789,44.20952859866288,0
+77.9240914545704,68.9723599933059,1
+62.27101367004632,69.95445795447587,1
+80.1901807509566,44.82162893218353,1
+93.114388797442,38.80067033713209,0
+61.83020602312595,50.25610789244621,0
+38.78580379679423,64.99568095539578,0
+61.379289447425,72.80788731317097,1
+85.40451939411645,57.05198397627122,1
+52.10797973193984,63.12762376881715,0
+52.04540476831827,69.43286012045222,1
+40.23689373545111,71.16774802184875,0
+54.63510555424817,52.21388588061123,0
+33.91550010906887,98.86943574220611,0
+64.17698887494485,80.90806058670817,1
+74.78925295941542,41.57341522824434,0
+34.1836400264419,75.2377203360134,0
+83.90239366249155,56.30804621605327,1
+51.54772026906181,46.85629026349976,0
+94.44336776917852,65.56892160559052,1
+82.36875375713919,40.61825515970618,0
+51.04775177128865,45.82270145776001,0
+62.22267576120188,52.06099194836679,0
+77.19303492601364,70.45820000180959,1
+97.77159928000232,86.7278223300282,1
+62.07306379667647,96.76882412413983,1
+91.56497449807442,88.69629254546599,1
+79.94481794066932,74.16311935043758,1
+99.2725269292572,60.99903099844988,1
+90.54671411399852,43.39060180650027,1
+34.52451385320009,60.39634245837173,0
+50.2864961189907,49.80453881323059,0
+49.58667721632031,59.80895099453265,0
+97.64563396007767,68.86157272420604,1
+32.57720016809309,95.59854761387875,0
+74.24869136721598,69.82457122657193,1
+71.79646205863379,78.45356224515052,1
+75.3956114656803,85.75993667331619,1
+35.28611281526193,47.02051394723416,0
+56.25381749711624,39.26147251058019,0
+30.05882244669796,49.59297386723685,0
+44.66826172480893,66.45008614558913,0
+66.56089447242954,41.09209807936973,0
+40.45755098375164,97.53518548909936,1
+49.07256321908844,51.88321182073966,0
+80.27957401466998,92.11606081344084,1
+66.74671856944039,60.99139402740988,1
+32.72283304060323,43.30717306430063,0
+64.0393204150601,78.03168802018232,1
+72.34649422579923,96.22759296761404,1
+60.45788573918959,73.09499809758037,1
+58.84095621726802,75.85844831279042,1
+99.82785779692128,72.36925193383885,1
+47.26426910848174,88.47586499559782,1
+50.45815980285988,75.80985952982456,1
+60.45555629271532,42.50840943572217,0
+82.22666157785568,42.71987853716458,0
+88.9138964166533,69.80378889835472,1
+94.83450672430196,45.69430680250754,1
+67.31925746917527,66.58935317747915,1
+57.23870631569862,59.51428198012956,1
+80.36675600171273,90.96014789746954,1
+68.46852178591112,85.59430710452014,1
+42.0754545384731,78.84478600148043,0
+75.47770200533905,90.42453899753964,1
+78.63542434898018,96.64742716885644,1
+52.34800398794107,60.76950525602592,0
+94.09433112516793,77.15910509073893,1
+90.44855097096364,87.50879176484702,1
+55.48216114069585,35.57070347228866,0
+74.49269241843041,84.84513684930135,1
+89.84580670720979,45.35828361091658,1
+83.48916274498238,48.38028579728175,1
+42.2617008099817,87.10385094025457,1
+99.31500880510394,68.77540947206617,1
+55.34001756003703,64.9319380069486,1
+74.77589300092767,89.52981289513276,1

+ 118 - 0
machine learning/machine-learning-ex2/ex2/ex2data2.txt

@@ -0,0 +1,118 @@
+0.051267,0.69956,1
+-0.092742,0.68494,1
+-0.21371,0.69225,1
+-0.375,0.50219,1
+-0.51325,0.46564,1
+-0.52477,0.2098,1
+-0.39804,0.034357,1
+-0.30588,-0.19225,1
+0.016705,-0.40424,1
+0.13191,-0.51389,1
+0.38537,-0.56506,1
+0.52938,-0.5212,1
+0.63882,-0.24342,1
+0.73675,-0.18494,1
+0.54666,0.48757,1
+0.322,0.5826,1
+0.16647,0.53874,1
+-0.046659,0.81652,1
+-0.17339,0.69956,1
+-0.47869,0.63377,1
+-0.60541,0.59722,1
+-0.62846,0.33406,1
+-0.59389,0.005117,1
+-0.42108,-0.27266,1
+-0.11578,-0.39693,1
+0.20104,-0.60161,1
+0.46601,-0.53582,1
+0.67339,-0.53582,1
+-0.13882,0.54605,1
+-0.29435,0.77997,1
+-0.26555,0.96272,1
+-0.16187,0.8019,1
+-0.17339,0.64839,1
+-0.28283,0.47295,1
+-0.36348,0.31213,1
+-0.30012,0.027047,1
+-0.23675,-0.21418,1
+-0.06394,-0.18494,1
+0.062788,-0.16301,1
+0.22984,-0.41155,1
+0.2932,-0.2288,1
+0.48329,-0.18494,1
+0.64459,-0.14108,1
+0.46025,0.012427,1
+0.6273,0.15863,1
+0.57546,0.26827,1
+0.72523,0.44371,1
+0.22408,0.52412,1
+0.44297,0.67032,1
+0.322,0.69225,1
+0.13767,0.57529,1
+-0.0063364,0.39985,1
+-0.092742,0.55336,1
+-0.20795,0.35599,1
+-0.20795,0.17325,1
+-0.43836,0.21711,1
+-0.21947,-0.016813,1
+-0.13882,-0.27266,1
+0.18376,0.93348,0
+0.22408,0.77997,0
+0.29896,0.61915,0
+0.50634,0.75804,0
+0.61578,0.7288,0
+0.60426,0.59722,0
+0.76555,0.50219,0
+0.92684,0.3633,0
+0.82316,0.27558,0
+0.96141,0.085526,0
+0.93836,0.012427,0
+0.86348,-0.082602,0
+0.89804,-0.20687,0
+0.85196,-0.36769,0
+0.82892,-0.5212,0
+0.79435,-0.55775,0
+0.59274,-0.7405,0
+0.51786,-0.5943,0
+0.46601,-0.41886,0
+0.35081,-0.57968,0
+0.28744,-0.76974,0
+0.085829,-0.75512,0
+0.14919,-0.57968,0
+-0.13306,-0.4481,0
+-0.40956,-0.41155,0
+-0.39228,-0.25804,0
+-0.74366,-0.25804,0
+-0.69758,0.041667,0
+-0.75518,0.2902,0
+-0.69758,0.68494,0
+-0.4038,0.70687,0
+-0.38076,0.91886,0
+-0.50749,0.90424,0
+-0.54781,0.70687,0
+0.10311,0.77997,0
+0.057028,0.91886,0
+-0.10426,0.99196,0
+-0.081221,1.1089,0
+0.28744,1.087,0
+0.39689,0.82383,0
+0.63882,0.88962,0
+0.82316,0.66301,0
+0.67339,0.64108,0
+1.0709,0.10015,0
+-0.046659,-0.57968,0
+-0.23675,-0.63816,0
+-0.15035,-0.36769,0
+-0.49021,-0.3019,0
+-0.46717,-0.13377,0
+-0.28859,-0.060673,0
+-0.61118,-0.067982,0
+-0.66302,-0.21418,0
+-0.59965,-0.41886,0
+-0.72638,-0.082602,0
+-0.83007,0.31213,0
+-0.72062,0.53874,0
+-0.59389,0.49488,0
+-0.48445,0.99927,0
+-0.0063364,0.99927,0
+0.63265,-0.030612,0

+ 41 - 0
machine learning/machine-learning-ex2/ex2/lib/jsonlab/AUTHORS.txt

@@ -0,0 +1,41 @@
+The author of "jsonlab" toolbox is Qianqian Fang. Qianqian
+is currently an Assistant Professor at Massachusetts General Hospital, 
+Harvard Medical School.
+
+Address: Martinos Center for Biomedical Imaging, 
+         Massachusetts General Hospital, 
+         Harvard Medical School
+         Bldg 149, 13th St, Charlestown, MA 02129, USA
+URL: http://nmr.mgh.harvard.edu/~fangq/
+Email: <fangq at nmr.mgh.harvard.edu> or <fangqq at gmail.com>
+
+
+The script loadjson.m was built upon previous works by
+
+- Nedialko Krouchev: http://www.mathworks.com/matlabcentral/fileexchange/25713
+       date: 2009/11/02
+- François Glineur: http://www.mathworks.com/matlabcentral/fileexchange/23393
+       date: 2009/03/22
+- Joel Feenstra: http://www.mathworks.com/matlabcentral/fileexchange/20565
+       date: 2008/07/03
+
+
+This toolbox contains patches submitted by the following contributors:
+
+- Blake Johnson <bjohnso at bbn.com>
+  part of revision 341
+
+- Niclas Borlin <Niclas.Borlin at cs.umu.se>
+  various fixes in revision 394, including
+  - loadjson crashes for all-zero sparse matrix.
+  - loadjson crashes for empty sparse matrix.
+  - Non-zero size of 0-by-N and N-by-0 empty matrices is lost after savejson/loadjson.
+  - loadjson crashes for sparse real column vector.
+  - loadjson crashes for sparse complex column vector.
+  - Data is corrupted by savejson for sparse real row vector.
+  - savejson crashes for sparse complex row vector. 
+
+- Yul Kang <yul.kang.on at gmail.com>
+  patches for svn revision 415.
+  - savejson saves an empty cell array as [] instead of null
+  - loadjson differentiates an empty struct from an empty array

+ 74 - 0
machine learning/machine-learning-ex2/ex2/lib/jsonlab/ChangeLog.txt

@@ -0,0 +1,74 @@
+============================================================================
+
+   JSONlab - a toolbox to encode/decode JSON/UBJSON files in MATLAB/Octave
+
+----------------------------------------------------------------------------
+
+JSONlab ChangeLog (key features marked by *):
+
+== JSONlab 1.0 (codename: Optimus - Final), FangQ <fangq (at) nmr.mgh.harvard.edu> ==
+
+ 2015/01/02 polish help info for all major functions, update examples, finalize 1.0
+ 2014/12/19 fix a bug to strictly respect NoRowBracket in savejson
+
+== JSONlab 1.0.0-RC2 (codename: Optimus - RC2), FangQ <fangq (at) nmr.mgh.harvard.edu> ==
+
+ 2014/11/22 show progress bar in loadjson ('ShowProgress') 
+ 2014/11/17 add Compact option in savejson to output compact JSON format ('Compact')
+ 2014/11/17 add FastArrayParser in loadjson to specify fast parser applicable levels
+ 2014/09/18 start official github mirror: https://github.com/fangq/jsonlab
+
+== JSONlab 1.0.0-RC1 (codename: Optimus - RC1), FangQ <fangq (at) nmr.mgh.harvard.edu> ==
+
+ 2014/09/17  fix several compatibility issues when running on octave versions 3.2-3.8
+ 2014/09/17  support 2D cell and struct arrays in both savejson and saveubjson
+ 2014/08/04  escape special characters in a JSON string
+ 2014/02/16  fix a bug when saving ubjson files
+
+== JSONlab 0.9.9 (codename: Optimus - beta), FangQ <fangq (at) nmr.mgh.harvard.edu> ==
+
+ 2014/01/22  use binary read and write in saveubjson and loadubjson
+
+== JSONlab 0.9.8-1 (codename: Optimus - alpha update 1), FangQ <fangq (at) nmr.mgh.harvard.edu> ==
+
+ 2013/10/07 better round-trip conservation for empty arrays and structs (patch submitted by Yul Kang)
+
+== JSONlab 0.9.8 (codename: Optimus - alpha), FangQ <fangq (at) nmr.mgh.harvard.edu> ==
+ 2013/08/23 *universal Binary JSON (UBJSON) support, including both saveubjson and loadubjson
+
+== JSONlab 0.9.1 (codename: Rodimus, update 1), FangQ <fangq (at) nmr.mgh.harvard.edu> ==
+ 2012/12/18 *handling of various empty and sparse matrices (fixes submitted by Niclas Borlin)
+
+== JSONlab 0.9.0 (codename: Rodimus), FangQ <fangq (at) nmr.mgh.harvard.edu> ==
+
+ 2012/06/17 *new format for an invalid leading char, unpacking hex code in savejson
+ 2012/06/01  support JSONP in savejson
+ 2012/05/25  fix the empty cell bug (reported by Cyril Davin)
+ 2012/04/05  savejson can save to a file (suggested by Patrick Rapin)
+
+== JSONlab 0.8.1 (codename: Sentiel, Update 1), FangQ <fangq (at) nmr.mgh.harvard.edu> ==
+
+ 2012/02/28  loadjson quotation mark escape bug, see http://bit.ly/yyk1nS
+ 2012/01/25  patch to handle root-less objects, contributed by Blake Johnson
+
+== JSONlab 0.8.0 (codename: Sentiel), FangQ <fangq (at) nmr.mgh.harvard.edu> ==
+
+ 2012/01/13 *speed up loadjson by 20 fold when parsing large data arrays in matlab
+ 2012/01/11  remove row bracket if an array has 1 element, suggested by Mykel Kochenderfer
+ 2011/12/22 *accept sequence of 'param',value input in savejson and loadjson
+ 2011/11/18  fix struct array bug reported by Mykel Kochenderfer
+
+== JSONlab 0.5.1 (codename: Nexus Update 1), FangQ <fangq (at) nmr.mgh.harvard.edu> ==
+
+ 2011/10/21  fix a bug in loadjson, previous code does not use any of the acceleration
+ 2011/10/20  loadjson supports JSON collections - concatenated JSON objects
+
+== JSONlab 0.5.0 (codename: Nexus), FangQ <fangq (at) nmr.mgh.harvard.edu> ==
+
+ 2011/10/16  package and release jsonlab 0.5.0
+ 2011/10/15 *add json demo and regression test, support cpx numbers, fix double quote bug
+ 2011/10/11 *speed up readjson dramatically, interpret _Array* tags, show data in root level
+ 2011/10/10  create jsonlab project, start jsonlab website, add online documentation
+ 2011/10/07 *speed up savejson by 25x using sprintf instead of mat2str, add options support
+ 2011/10/06 *savejson works for structs, cells and arrays
+ 2011/09/09  derive loadjson from JSON parser from MATLAB Central, draft savejson.m

+ 25 - 0
machine learning/machine-learning-ex2/ex2/lib/jsonlab/LICENSE_BSD.txt

@@ -0,0 +1,25 @@
+Copyright 2011-2015 Qianqian Fang <fangq at nmr.mgh.harvard.edu>. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are
+permitted provided that the following conditions are met:
+
+   1. Redistributions of source code must retain the above copyright notice, this list of
+      conditions and the following disclaimer.
+
+   2. Redistributions in binary form must reproduce the above copyright notice, this list
+      of conditions and the following disclaimer in the documentation and/or other materials
+      provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS 
+OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+The views and conclusions contained in the software and documentation are those of the
+authors and should not be interpreted as representing official policies, either expressed
+or implied, of the copyright holders.

+ 394 - 0
machine learning/machine-learning-ex2/ex2/lib/jsonlab/README.txt

@@ -0,0 +1,394 @@
+===============================================================================
+=                                 JSONLab                                     =
+=           An open-source MATLAB/Octave JSON encoder and decoder             =
+===============================================================================
+
+*Copyright (C) 2011-2015  Qianqian Fang <fangq at nmr.mgh.harvard.edu>
+*License: BSD License, see License_BSD.txt for details
+*Version: 1.0 (Optimus - Final)
+
+-------------------------------------------------------------------------------
+
+Table of Content:
+
+I.  Introduction
+II. Installation
+III.Using JSONLab
+IV. Known Issues and TODOs
+V.  Contribution and feedback
+
+-------------------------------------------------------------------------------
+
+I.  Introduction
+
+JSON ([http://www.json.org/ JavaScript Object Notation]) is a highly portable, 
+human-readable and "[http://en.wikipedia.org/wiki/JSON fat-free]" text format 
+to represent complex and hierarchical data. It is as powerful as 
+[http://en.wikipedia.org/wiki/XML XML], but less verbose. JSON format is widely 
+used for data-exchange in applications, and is essential for the wild success 
+of [http://en.wikipedia.org/wiki/Ajax_(programming) Ajax] and 
+[http://en.wikipedia.org/wiki/Web_2.0 Web2.0]. 
+
+UBJSON (Universal Binary JSON) is a binary JSON format, specifically 
+optimized for compact file size and better performance while keeping
+the semantics as simple as the text-based JSON format. Using the UBJSON
+format allows to wrap complex binary data in a flexible and extensible
+structure, making it possible to process complex and large dataset 
+without accuracy loss due to text conversions.
+
+We envision that both JSON and its binary version will serve as part of 
+the mainstream data-exchange formats for scientific research in the future. 
+It will provide the flexibility and generality achieved by other popular 
+general-purpose file specifications, such as
+[http://www.hdfgroup.org/HDF5/whatishdf5.html HDF5], with significantly 
+reduced complexity and enhanced performance.
+
+JSONLab is a free and open-source implementation of a JSON/UBJSON encoder 
+and a decoder in the native MATLAB language. It can be used to convert a MATLAB 
+data structure (array, struct, cell, struct array and cell array) into 
+JSON/UBJSON formatted strings, or to decode a JSON/UBJSON file into MATLAB 
+data structure. JSONLab supports both MATLAB and  
+[http://www.gnu.org/software/octave/ GNU Octave] (a free MATLAB clone).
+
+-------------------------------------------------------------------------------
+
+II. Installation
+
+The installation of JSONLab is no different than any other simple
+MATLAB toolbox. You only need to download/unzip the JSONLab package
+to a folder, and add the folder's path to MATLAB/Octave's path list
+by using the following command:
+
+    addpath('/path/to/jsonlab');
+
+If you want to add this path permanently, you need to type "pathtool", 
+browse to the jsonlab root folder and add to the list, then click "Save".
+Then, run "rehash" in MATLAB, and type "which loadjson", if you see an 
+output, that means JSONLab is installed for MATLAB/Octave.
+
+-------------------------------------------------------------------------------
+
+III.Using JSONLab
+
+JSONLab provides two functions, loadjson.m -- a MATLAB->JSON decoder, 
+and savejson.m -- a MATLAB->JSON encoder, for the text-based JSON, and 
+two equivallent functions -- loadubjson and saveubjson for the binary 
+JSON. The detailed help info for the four functions can be found below:
+
+=== loadjson.m ===
+<pre>
+  data=loadjson(fname,opt)
+     or
+  data=loadjson(fname,'param1',value1,'param2',value2,...)
+ 
+  parse a JSON (JavaScript Object Notation) file or string
+ 
+  authors:Qianqian Fang (fangq<at> nmr.mgh.harvard.edu)
+  created on 2011/09/09, including previous works from 
+ 
+          Nedialko Krouchev: http://www.mathworks.com/matlabcentral/fileexchange/25713
+             created on 2009/11/02
+          François Glineur: http://www.mathworks.com/matlabcentral/fileexchange/23393
+             created on  2009/03/22
+          Joel Feenstra:
+          http://www.mathworks.com/matlabcentral/fileexchange/20565
+             created on 2008/07/03
+ 
+  $Id: loadjson.m 452 2014-11-22 16:43:33Z fangq $
+ 
+  input:
+       fname: input file name, if fname contains "{}" or "[]", fname
+              will be interpreted as a JSON string
+       opt: a struct to store parsing options, opt can be replaced by 
+            a list of ('param',value) pairs - the param string is equivallent
+            to a field in opt. opt can have the following 
+            fields (first in [.|.] is the default)
+ 
+            opt.SimplifyCell [0|1]: if set to 1, loadjson will call cell2mat
+                          for each element of the JSON data, and group 
+                          arrays based on the cell2mat rules.
+            opt.FastArrayParser [1|0 or integer]: if set to 1, use a
+                          speed-optimized array parser when loading an 
+                          array object. The fast array parser may 
+                          collapse block arrays into a single large
+                          array similar to rules defined in cell2mat; 0 to 
+                          use a legacy parser; if set to a larger-than-1
+                          value, this option will specify the minimum
+                          dimension to enable the fast array parser. For
+                          example, if the input is a 3D array, setting
+                          FastArrayParser to 1 will return a 3D array;
+                          setting to 2 will return a cell array of 2D
+                          arrays; setting to 3 will return to a 2D cell
+                          array of 1D vectors; setting to 4 will return a
+                          3D cell array.
+            opt.ShowProgress [0|1]: if set to 1, loadjson displays a progress bar.
+ 
+  output:
+       dat: a cell array, where {...} blocks are converted into cell arrays,
+            and [...] are converted to arrays
+ 
+  examples:
+       dat=loadjson('{"obj":{"string":"value","array":[1,2,3]}}')
+       dat=loadjson(['examples' filesep 'example1.json'])
+       dat=loadjson(['examples' filesep 'example1.json'],'SimplifyCell',1)
+</pre>
+
+=== savejson.m ===
+
+<pre>
+  json=savejson(rootname,obj,filename)
+     or
+  json=savejson(rootname,obj,opt)
+  json=savejson(rootname,obj,'param1',value1,'param2',value2,...)
+ 
+  convert a MATLAB object (cell, struct or array) into a JSON (JavaScript
+  Object Notation) string
+ 
+  author: Qianqian Fang (fangq<at> nmr.mgh.harvard.edu)
+  created on 2011/09/09
+ 
+  $Id: savejson.m 458 2014-12-19 22:17:17Z fangq $
+ 
+  input:
+       rootname: the name of the root-object, when set to '', the root name
+         is ignored, however, when opt.ForceRootName is set to 1 (see below),
+         the MATLAB variable name will be used as the root name.
+       obj: a MATLAB object (array, cell, cell array, struct, struct array).
+       filename: a string for the file name to save the output JSON data.
+       opt: a struct for additional options, ignore to use default values.
+         opt can have the following fields (first in [.|.] is the default)
+ 
+         opt.FileName [''|string]: a file name to save the output JSON data
+         opt.FloatFormat ['%.10g'|string]: format to show each numeric element
+                          of a 1D/2D array;
+         opt.ArrayIndent [1|0]: if 1, output explicit data array with
+                          precedent indentation; if 0, no indentation
+         opt.ArrayToStruct[0|1]: when set to 0, savejson outputs 1D/2D
+                          array in JSON array format; if sets to 1, an
+                          array will be shown as a struct with fields
+                          "_ArrayType_", "_ArraySize_" and "_ArrayData_"; for
+                          sparse arrays, the non-zero elements will be
+                          saved to _ArrayData_ field in triplet-format i.e.
+                          (ix,iy,val) and "_ArrayIsSparse_" will be added
+                          with a value of 1; for a complex array, the 
+                          _ArrayData_ array will include two columns 
+                          (4 for sparse) to record the real and imaginary 
+                          parts, and also "_ArrayIsComplex_":1 is added. 
+         opt.ParseLogical [0|1]: if this is set to 1, logical array elem
+                          will use true/false rather than 1/0.
+         opt.NoRowBracket [1|0]: if this is set to 1, arrays with a single
+                          numerical element will be shown without a square
+                          bracket, unless it is the root object; if 0, square
+                          brackets are forced for any numerical arrays.
+         opt.ForceRootName [0|1]: when set to 1 and rootname is empty, savejson
+                          will use the name of the passed obj variable as the 
+                          root object name; if obj is an expression and 
+                          does not have a name, 'root' will be used; if this 
+                          is set to 0 and rootname is empty, the root level 
+                          will be merged down to the lower level.
+         opt.Inf ['"$1_Inf_"'|string]: a customized regular expression pattern
+                          to represent +/-Inf. The matched pattern is '([-+]*)Inf'
+                          and $1 represents the sign. For those who want to use
+                          1e999 to represent Inf, they can set opt.Inf to '$11e999'
+         opt.NaN ['"_NaN_"'|string]: a customized regular expression pattern
+                          to represent NaN
+         opt.JSONP [''|string]: to generate a JSONP output (JSON with padding),
+                          for example, if opt.JSONP='foo', the JSON data is
+                          wrapped inside a function call as 'foo(...);'
+         opt.UnpackHex [1|0]: conver the 0x[hex code] output by loadjson 
+                          back to the string form
+         opt.SaveBinary [0|1]: 1 - save the JSON file in binary mode; 0 - text mode.
+         opt.Compact [0|1]: 1- out compact JSON format (remove all newlines and tabs)
+ 
+         opt can be replaced by a list of ('param',value) pairs. The param 
+         string is equivallent to a field in opt and is case sensitive.
+  output:
+       json: a string in the JSON format (see http://json.org)
+ 
+  examples:
+       jsonmesh=struct('MeshNode',[0 0 0;1 0 0;0 1 0;1 1 0;0 0 1;1 0 1;0 1 1;1 1 1],... 
+                'MeshTetra',[1 2 4 8;1 3 4 8;1 2 6 8;1 5 6 8;1 5 7 8;1 3 7 8],...
+                'MeshTri',[1 2 4;1 2 6;1 3 4;1 3 7;1 5 6;1 5 7;...
+                           2 8 4;2 8 6;3 8 4;3 8 7;5 8 6;5 8 7],...
+                'MeshCreator','FangQ','MeshTitle','T6 Cube',...
+                'SpecialData',[nan, inf, -inf]);
+       savejson('jmesh',jsonmesh)
+       savejson('',jsonmesh,'ArrayIndent',0,'FloatFormat','\t%.5g')
+ </pre>
+
+=== loadubjson.m ===
+
+<pre>
+  data=loadubjson(fname,opt)
+     or
+  data=loadubjson(fname,'param1',value1,'param2',value2,...)
+ 
+  parse a JSON (JavaScript Object Notation) file or string
+ 
+  authors:Qianqian Fang (fangq<at> nmr.mgh.harvard.edu)
+  created on 2013/08/01
+ 
+  $Id: loadubjson.m 436 2014-08-05 20:51:40Z fangq $
+ 
+  input:
+       fname: input file name, if fname contains "{}" or "[]", fname
+              will be interpreted as a UBJSON string
+       opt: a struct to store parsing options, opt can be replaced by 
+            a list of ('param',value) pairs - the param string is equivallent
+            to a field in opt. opt can have the following 
+            fields (first in [.|.] is the default)
+ 
+            opt.SimplifyCell [0|1]: if set to 1, loadubjson will call cell2mat
+                          for each element of the JSON data, and group 
+                          arrays based on the cell2mat rules.
+            opt.IntEndian [B|L]: specify the endianness of the integer fields
+                          in the UBJSON input data. B - Big-Endian format for 
+                          integers (as required in the UBJSON specification); 
+                          L - input integer fields are in Little-Endian order.
+ 
+  output:
+       dat: a cell array, where {...} blocks are converted into cell arrays,
+            and [...] are converted to arrays
+ 
+  examples:
+       obj=struct('string','value','array',[1 2 3]);
+       ubjdata=saveubjson('obj',obj);
+       dat=loadubjson(ubjdata)
+       dat=loadubjson(['examples' filesep 'example1.ubj'])
+       dat=loadubjson(['examples' filesep 'example1.ubj'],'SimplifyCell',1)
+</pre>
+
+=== saveubjson.m ===
+
+<pre>
+  json=saveubjson(rootname,obj,filename)
+     or
+  json=saveubjson(rootname,obj,opt)
+  json=saveubjson(rootname,obj,'param1',value1,'param2',value2,...)
+ 
+  convert a MATLAB object (cell, struct or array) into a Universal 
+  Binary JSON (UBJSON) binary string
+ 
+  author: Qianqian Fang (fangq<at> nmr.mgh.harvard.edu)
+  created on 2013/08/17
+ 
+  $Id: saveubjson.m 440 2014-09-17 19:59:45Z fangq $
+ 
+  input:
+       rootname: the name of the root-object, when set to '', the root name
+         is ignored, however, when opt.ForceRootName is set to 1 (see below),
+         the MATLAB variable name will be used as the root name.
+       obj: a MATLAB object (array, cell, cell array, struct, struct array)
+       filename: a string for the file name to save the output UBJSON data
+       opt: a struct for additional options, ignore to use default values.
+         opt can have the following fields (first in [.|.] is the default)
+ 
+         opt.FileName [''|string]: a file name to save the output JSON data
+         opt.ArrayToStruct[0|1]: when set to 0, saveubjson outputs 1D/2D
+                          array in JSON array format; if sets to 1, an
+                          array will be shown as a struct with fields
+                          "_ArrayType_", "_ArraySize_" and "_ArrayData_"; for
+                          sparse arrays, the non-zero elements will be
+                          saved to _ArrayData_ field in triplet-format i.e.
+                          (ix,iy,val) and "_ArrayIsSparse_" will be added
+                          with a value of 1; for a complex array, the 
+                          _ArrayData_ array will include two columns 
+                          (4 for sparse) to record the real and imaginary 
+                          parts, and also "_ArrayIsComplex_":1 is added. 
+         opt.ParseLogical [1|0]: if this is set to 1, logical array elem
+                          will use true/false rather than 1/0.
+         opt.NoRowBracket [1|0]: if this is set to 1, arrays with a single
+                          numerical element will be shown without a square
+                          bracket, unless it is the root object; if 0, square
+                          brackets are forced for any numerical arrays.
+         opt.ForceRootName [0|1]: when set to 1 and rootname is empty, saveubjson
+                          will use the name of the passed obj variable as the 
+                          root object name; if obj is an expression and 
+                          does not have a name, 'root' will be used; if this 
+                          is set to 0 and rootname is empty, the root level 
+                          will be merged down to the lower level.
+         opt.JSONP [''|string]: to generate a JSONP output (JSON with padding),
+                          for example, if opt.JSON='foo', the JSON data is
+                          wrapped inside a function call as 'foo(...);'
+         opt.UnpackHex [1|0]: conver the 0x[hex code] output by loadjson 
+                          back to the string form
+ 
+         opt can be replaced by a list of ('param',value) pairs. The param 
+         string is equivallent to a field in opt and is case sensitive.
+  output:
+       json: a binary string in the UBJSON format (see http://ubjson.org)
+ 
+  examples:
+       jsonmesh=struct('MeshNode',[0 0 0;1 0 0;0 1 0;1 1 0;0 0 1;1 0 1;0 1 1;1 1 1],... 
+                'MeshTetra',[1 2 4 8;1 3 4 8;1 2 6 8;1 5 6 8;1 5 7 8;1 3 7 8],...
+                'MeshTri',[1 2 4;1 2 6;1 3 4;1 3 7;1 5 6;1 5 7;...
+                           2 8 4;2 8 6;3 8 4;3 8 7;5 8 6;5 8 7],...
+                'MeshCreator','FangQ','MeshTitle','T6 Cube',...
+                'SpecialData',[nan, inf, -inf]);
+       saveubjson('jsonmesh',jsonmesh)
+       saveubjson('jsonmesh',jsonmesh,'meshdata.ubj')
+</pre>
+
+
+=== examples ===
+
+Under the "examples" folder, you can find several scripts to demonstrate the
+basic utilities of JSONLab. Running the "demo_jsonlab_basic.m" script, you 
+will see the conversions from MATLAB data structure to JSON text and backward.
+In "jsonlab_selftest.m", we load complex JSON files downloaded from the Internet
+and validate the loadjson/savejson functions for regression testing purposes.
+Similarly, a "demo_ubjson_basic.m" script is provided to test the saveubjson
+and loadubjson pairs for various matlab data structures.
+
+Please run these examples and understand how JSONLab works before you use
+it to process your data.
+
+-------------------------------------------------------------------------------
+
+IV. Known Issues and TODOs
+
+JSONLab has several known limitations. We are striving to make it more general
+and robust. Hopefully in a few future releases, the limitations become less.
+
+Here are the known issues:
+
+# 3D or higher dimensional cell/struct-arrays will be converted to 2D arrays;
+# When processing names containing multi-byte characters, Octave and MATLAB \
+can give different field-names; you can use feature('DefaultCharacterSet','latin1') \
+in MATLAB to get consistant results
+# savejson can not handle class and dataset.
+# saveubjson converts a logical array into a uint8 ([U]) array
+# an unofficial N-D array count syntax is implemented in saveubjson. We are \
+actively communicating with the UBJSON spec maintainer to investigate the \
+possibility of making it upstream
+# loadubjson can not parse all UBJSON Specification (Draft 9) compliant \
+files, however, it can parse all UBJSON files produced by saveubjson.
+
+-------------------------------------------------------------------------------
+
+V. Contribution and feedback
+
+JSONLab is an open-source project. This means you can not only use it and modify
+it as you wish, but also you can contribute your changes back to JSONLab so
+that everyone else can enjoy the improvement. For anyone who want to contribute,
+please download JSONLab source code from it's subversion repository by using the
+following command:
+
+ svn checkout svn://svn.code.sf.net/p/iso2mesh/code/trunk/jsonlab jsonlab
+
+You can make changes to the files as needed. Once you are satisfied with your
+changes, and ready to share it with others, please cd the root directory of 
+JSONLab, and type
+
+ svn diff > yourname_featurename.patch
+
+You then email the .patch file to JSONLab's maintainer, Qianqian Fang, at
+the email address shown in the beginning of this file. Qianqian will review 
+the changes and commit it to the subversion if they are satisfactory.
+
+We appreciate any suggestions and feedbacks from you. Please use iso2mesh's
+mailing list to report any questions you may have with JSONLab:
+
+http://groups.google.com/group/iso2mesh-users?hl=en&pli=1
+
+(Subscription to the mailing list is needed in order to post messages).

+ 32 - 0
machine learning/machine-learning-ex2/ex2/lib/jsonlab/jsonopt.m

@@ -0,0 +1,32 @@
+function val=jsonopt(key,default,varargin)
+%
+% val=jsonopt(key,default,optstruct)
+%
+% setting options based on a struct. The struct can be produced
+% by varargin2struct from a list of 'param','value' pairs
+%
+% authors:Qianqian Fang (fangq<at> nmr.mgh.harvard.edu)
+%
+% $Id: loadjson.m 371 2012-06-20 12:43:06Z fangq $
+%
+% input:
+%      key: a string with which one look up a value from a struct
+%      default: if the key does not exist, return default
+%      optstruct: a struct where each sub-field is a key 
+%
+% output:
+%      val: if key exists, val=optstruct.key; otherwise val=default
+%
+% license:
+%     BSD, see LICENSE_BSD.txt files for details
+%
+% -- this function is part of jsonlab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)
+% 
+
+val=default;
+if(nargin<=2) return; end
+opt=varargin{1};
+if(isstruct(opt) && isfield(opt,key))
+    val=getfield(opt,key);
+end
+

+ 566 - 0
machine learning/machine-learning-ex2/ex2/lib/jsonlab/loadjson.m

@@ -0,0 +1,566 @@
+function data = loadjson(fname,varargin)
+%
+% data=loadjson(fname,opt)
+%    or
+% data=loadjson(fname,'param1',value1,'param2',value2,...)
+%
+% parse a JSON (JavaScript Object Notation) file or string
+%
+% authors:Qianqian Fang (fangq<at> nmr.mgh.harvard.edu)
+% created on 2011/09/09, including previous works from 
+%
+%         Nedialko Krouchev: http://www.mathworks.com/matlabcentral/fileexchange/25713
+%            created on 2009/11/02
+%         François Glineur: http://www.mathworks.com/matlabcentral/fileexchange/23393
+%            created on  2009/03/22
+%         Joel Feenstra:
+%         http://www.mathworks.com/matlabcentral/fileexchange/20565
+%            created on 2008/07/03
+%
+% $Id: loadjson.m 460 2015-01-03 00:30:45Z fangq $
+%
+% input:
+%      fname: input file name, if fname contains "{}" or "[]", fname
+%             will be interpreted as a JSON string
+%      opt: a struct to store parsing options, opt can be replaced by 
+%           a list of ('param',value) pairs - the param string is equivallent
+%           to a field in opt. opt can have the following 
+%           fields (first in [.|.] is the default)
+%
+%           opt.SimplifyCell [0|1]: if set to 1, loadjson will call cell2mat
+%                         for each element of the JSON data, and group 
+%                         arrays based on the cell2mat rules.
+%           opt.FastArrayParser [1|0 or integer]: if set to 1, use a
+%                         speed-optimized array parser when loading an 
+%                         array object. The fast array parser may 
+%                         collapse block arrays into a single large
+%                         array similar to rules defined in cell2mat; 0 to 
+%                         use a legacy parser; if set to a larger-than-1
+%                         value, this option will specify the minimum
+%                         dimension to enable the fast array parser. For
+%                         example, if the input is a 3D array, setting
+%                         FastArrayParser to 1 will return a 3D array;
+%                         setting to 2 will return a cell array of 2D
+%                         arrays; setting to 3 will return to a 2D cell
+%                         array of 1D vectors; setting to 4 will return a
+%                         3D cell array.
+%           opt.ShowProgress [0|1]: if set to 1, loadjson displays a progress bar.
+%
+% output:
+%      dat: a cell array, where {...} blocks are converted into cell arrays,
+%           and [...] are converted to arrays
+%
+% examples:
+%      dat=loadjson('{"obj":{"string":"value","array":[1,2,3]}}')
+%      dat=loadjson(['examples' filesep 'example1.json'])
+%      dat=loadjson(['examples' filesep 'example1.json'],'SimplifyCell',1)
+%
+% license:
+%     BSD, see LICENSE_BSD.txt files for details 
+%
+% -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)
+%
+
+global pos inStr len  esc index_esc len_esc isoct arraytoken
+
+if(regexp(fname,'[\{\}\]\[]','once'))
+   string=fname;
+elseif(exist(fname,'file'))
+   fid = fopen(fname,'rb');
+   string = fread(fid,inf,'uint8=>char')';
+   fclose(fid);
+else
+   error('input file does not exist');
+end
+
+pos = 1; len = length(string); inStr = string;
+isoct=exist('OCTAVE_VERSION','builtin');
+arraytoken=find(inStr=='[' | inStr==']' | inStr=='"');
+jstr=regexprep(inStr,'\\\\','  ');
+escquote=regexp(jstr,'\\"');
+arraytoken=sort([arraytoken escquote]);
+
+% String delimiters and escape chars identified to improve speed:
+esc = find(inStr=='"' | inStr=='\' ); % comparable to: regexp(inStr, '["\\]');
+index_esc = 1; len_esc = length(esc);
+
+opt=varargin2struct(varargin{:});
+
+if(jsonopt('ShowProgress',0,opt)==1)
+    opt.progressbar_=waitbar(0,'loading ...');
+end
+jsoncount=1;
+while pos <= len
+    switch(next_char)
+        case '{'
+            data{jsoncount} = parse_object(opt);
+        case '['
+            data{jsoncount} = parse_array(opt);
+        otherwise
+            error_pos('Outer level structure must be an object or an array');
+    end
+    jsoncount=jsoncount+1;
+end % while
+
+jsoncount=length(data);
+if(jsoncount==1 && iscell(data))
+    data=data{1};
+end
+
+if(~isempty(data))
+      if(isstruct(data)) % data can be a struct array
+          data=jstruct2array(data);
+      elseif(iscell(data))
+          data=jcell2array(data);
+      end
+end
+if(isfield(opt,'progressbar_'))
+    close(opt.progressbar_);
+end
+
+%%
+function newdata=jcell2array(data)
+len=length(data);
+newdata=data;
+for i=1:len
+      if(isstruct(data{i}))
+          newdata{i}=jstruct2array(data{i});
+      elseif(iscell(data{i}))
+          newdata{i}=jcell2array(data{i});
+      end
+end
+
+%%-------------------------------------------------------------------------
+function newdata=jstruct2array(data)
+fn=fieldnames(data);
+newdata=data;
+len=length(data);
+for i=1:length(fn) % depth-first
+    for j=1:len
+        if(isstruct(getfield(data(j),fn{i})))
+            newdata(j)=setfield(newdata(j),fn{i},jstruct2array(getfield(data(j),fn{i})));
+        end
+    end
+end
+if(~isempty(strmatch('x0x5F_ArrayType_',fn)) && ~isempty(strmatch('x0x5F_ArrayData_',fn)))
+  newdata=cell(len,1);
+  for j=1:len
+    ndata=cast(data(j).x0x5F_ArrayData_,data(j).x0x5F_ArrayType_);
+    iscpx=0;
+    if(~isempty(strmatch('x0x5F_ArrayIsComplex_',fn)))
+        if(data(j).x0x5F_ArrayIsComplex_)
+           iscpx=1;
+        end
+    end
+    if(~isempty(strmatch('x0x5F_ArrayIsSparse_',fn)))
+        if(data(j).x0x5F_ArrayIsSparse_)
+            if(~isempty(strmatch('x0x5F_ArraySize_',fn)))
+                dim=data(j).x0x5F_ArraySize_;
+                if(iscpx && size(ndata,2)==4-any(dim==1))
+                    ndata(:,end-1)=complex(ndata(:,end-1),ndata(:,end));
+                end
+                if isempty(ndata)
+                    % All-zeros sparse
+                    ndata=sparse(dim(1),prod(dim(2:end)));
+                elseif dim(1)==1
+                    % Sparse row vector
+                    ndata=sparse(1,ndata(:,1),ndata(:,2),dim(1),prod(dim(2:end)));
+                elseif dim(2)==1
+                    % Sparse column vector
+                    ndata=sparse(ndata(:,1),1,ndata(:,2),dim(1),prod(dim(2:end)));
+                else
+                    % Generic sparse array.
+                    ndata=sparse(ndata(:,1),ndata(:,2),ndata(:,3),dim(1),prod(dim(2:end)));
+                end
+            else
+                if(iscpx && size(ndata,2)==4)
+                    ndata(:,3)=complex(ndata(:,3),ndata(:,4));
+                end
+                ndata=sparse(ndata(:,1),ndata(:,2),ndata(:,3));
+            end
+        end
+    elseif(~isempty(strmatch('x0x5F_ArraySize_',fn)))
+        if(iscpx && size(ndata,2)==2)
+             ndata=complex(ndata(:,1),ndata(:,2));
+        end
+        ndata=reshape(ndata(:),data(j).x0x5F_ArraySize_);
+    end
+    newdata{j}=ndata;
+  end
+  if(len==1)
+      newdata=newdata{1};
+  end
+end
+
+%%-------------------------------------------------------------------------
+function object = parse_object(varargin)
+    parse_char('{');
+    object = [];
+    if next_char ~= '}'
+        while 1
+            str = parseStr(varargin{:});
+            if isempty(str)
+                error_pos('Name of value at position %d cannot be empty');
+            end
+            parse_char(':');
+            val = parse_value(varargin{:});
+            eval( sprintf( 'object.%s  = val;', valid_field(str) ) );
+            if next_char == '}'
+                break;
+            end
+            parse_char(',');
+        end
+    end
+    parse_char('}');
+
+%%-------------------------------------------------------------------------
+
+function object = parse_array(varargin) % JSON array is written in row-major order
+global pos inStr isoct
+    parse_char('[');
+    object = cell(0, 1);
+    dim2=[];
+    arraydepth=jsonopt('JSONLAB_ArrayDepth_',1,varargin{:});
+    pbar=jsonopt('progressbar_',-1,varargin{:});
+
+    if next_char ~= ']'
+	if(jsonopt('FastArrayParser',1,varargin{:})>=1 && arraydepth>=jsonopt('FastArrayParser',1,varargin{:}))
+            [endpos, e1l, e1r, maxlevel]=matching_bracket(inStr,pos);
+            arraystr=['[' inStr(pos:endpos)];
+            arraystr=regexprep(arraystr,'"_NaN_"','NaN');
+            arraystr=regexprep(arraystr,'"([-+]*)_Inf_"','$1Inf');
+            arraystr(arraystr==sprintf('\n'))=[];
+            arraystr(arraystr==sprintf('\r'))=[];
+            %arraystr=regexprep(arraystr,'\s*,',','); % this is slow,sometimes needed
+            if(~isempty(e1l) && ~isempty(e1r)) % the array is in 2D or higher D
+        	astr=inStr((e1l+1):(e1r-1));
+        	astr=regexprep(astr,'"_NaN_"','NaN');
+        	astr=regexprep(astr,'"([-+]*)_Inf_"','$1Inf');
+        	astr(astr==sprintf('\n'))=[];
+        	astr(astr==sprintf('\r'))=[];
+        	astr(astr==' ')='';
+        	if(isempty(find(astr=='[', 1))) % array is 2D
+                    dim2=length(sscanf(astr,'%f,',[1 inf]));
+        	end
+            else % array is 1D
+        	astr=arraystr(2:end-1);
+        	astr(astr==' ')='';
+        	[obj, count, errmsg, nextidx]=sscanf(astr,'%f,',[1,inf]);
+        	if(nextidx>=length(astr)-1)
+                    object=obj;
+                    pos=endpos;
+                    parse_char(']');
+                    return;
+        	end
+            end
+            if(~isempty(dim2))
+        	astr=arraystr;
+        	astr(astr=='[')='';
+        	astr(astr==']')='';
+        	astr(astr==' ')='';
+        	[obj, count, errmsg, nextidx]=sscanf(astr,'%f,',inf);
+        	if(nextidx>=length(astr)-1)
+                    object=reshape(obj,dim2,numel(obj)/dim2)';
+                    pos=endpos;
+                    parse_char(']');
+                    if(pbar>0)
+                        waitbar(pos/length(inStr),pbar,'loading ...');
+                    end
+                    return;
+        	end
+            end
+            arraystr=regexprep(arraystr,'\]\s*,','];');
+	else
+            arraystr='[';
+	end
+        try
+           if(isoct && regexp(arraystr,'"','once'))
+                error('Octave eval can produce empty cells for JSON-like input');
+           end
+           object=eval(arraystr);
+           pos=endpos;
+        catch
+         while 1
+            newopt=varargin2struct(varargin{:},'JSONLAB_ArrayDepth_',arraydepth+1);
+            val = parse_value(newopt);
+            object{end+1} = val;
+            if next_char == ']'
+                break;
+            end
+            parse_char(',');
+         end
+        end
+    end
+    if(jsonopt('SimplifyCell',0,varargin{:})==1)
+      try
+        oldobj=object;
+        object=cell2mat(object')';
+        if(iscell(oldobj) && isstruct(object) && numel(object)>1 && jsonopt('SimplifyCellArray',1,varargin{:})==0)
+            object=oldobj;
+        elseif(size(object,1)>1 && ndims(object)==2)
+            object=object';
+        end
+      catch
+      end
+    end
+    parse_char(']');
+    
+    if(pbar>0)
+        waitbar(pos/length(inStr),pbar,'loading ...');
+    end
+%%-------------------------------------------------------------------------
+
+function parse_char(c)
+    global pos inStr len
+    skip_whitespace;
+    if pos > len || inStr(pos) ~= c
+        error_pos(sprintf('Expected %c at position %%d', c));
+    else
+        pos = pos + 1;
+        skip_whitespace;
+    end
+
+%%-------------------------------------------------------------------------
+
+function c = next_char
+    global pos inStr len
+    skip_whitespace;
+    if pos > len
+        c = [];
+    else
+        c = inStr(pos);
+    end
+
+%%-------------------------------------------------------------------------
+
+function skip_whitespace
+    global pos inStr len
+    while pos <= len && isspace(inStr(pos))
+        pos = pos + 1;
+    end
+
+%%-------------------------------------------------------------------------
+function str = parseStr(varargin)
+    global pos inStr len  esc index_esc len_esc
+ % len, ns = length(inStr), keyboard
+    if inStr(pos) ~= '"'
+        error_pos('String starting with " expected at position %d');
+    else
+        pos = pos + 1;
+    end
+    str = '';
+    while pos <= len
+        while index_esc <= len_esc && esc(index_esc) < pos
+            index_esc = index_esc + 1;
+        end
+        if index_esc > len_esc
+            str = [str inStr(pos:len)];
+            pos = len + 1;
+            break;
+        else
+            str = [str inStr(pos:esc(index_esc)-1)];
+            pos = esc(index_esc);
+        end
+        nstr = length(str); switch inStr(pos)
+            case '"'
+                pos = pos + 1;
+                if(~isempty(str))
+                    if(strcmp(str,'_Inf_'))
+                        str=Inf;
+                    elseif(strcmp(str,'-_Inf_'))
+                        str=-Inf;
+                    elseif(strcmp(str,'_NaN_'))
+                        str=NaN;
+                    end
+                end
+                return;
+            case '\'
+                if pos+1 > len
+                    error_pos('End of file reached right after escape character');
+                end
+                pos = pos + 1;
+                switch inStr(pos)
+                    case {'"' '\' '/'}
+                        str(nstr+1) = inStr(pos);
+                        pos = pos + 1;
+                    case {'b' 'f' 'n' 'r' 't'}
+                        str(nstr+1) = sprintf(['\' inStr(pos)]);
+                        pos = pos + 1;
+                    case 'u'
+                        if pos+4 > len
+                            error_pos('End of file reached in escaped unicode character');
+                        end
+                        str(nstr+(1:6)) = inStr(pos-1:pos+4);
+                        pos = pos + 5;
+                end
+            otherwise % should never happen
+                str(nstr+1) = inStr(pos), keyboard
+                pos = pos + 1;
+        end
+    end
+    error_pos('End of file while expecting end of inStr');
+
+%%-------------------------------------------------------------------------
+
+function num = parse_number(varargin)
+    global pos inStr len isoct
+    currstr=inStr(pos:end);
+    numstr=0;
+    if(isoct~=0)
+        numstr=regexp(currstr,'^\s*-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+\-]?\d+)?','end');
+        [num, one] = sscanf(currstr, '%f', 1);
+        delta=numstr+1;
+    else
+        [num, one, err, delta] = sscanf(currstr, '%f', 1);
+        if ~isempty(err)
+            error_pos('Error reading number at position %d');
+        end
+    end
+    pos = pos + delta-1;
+
+%%-------------------------------------------------------------------------
+
+function val = parse_value(varargin)
+    global pos inStr len
+    true = 1; false = 0;
+    
+    pbar=jsonopt('progressbar_',-1,varargin{:});
+    if(pbar>0)
+        waitbar(pos/len,pbar,'loading ...');
+    end
+    
+    switch(inStr(pos))
+        case '"'
+            val = parseStr(varargin{:});
+            return;
+        case '['
+            val = parse_array(varargin{:});
+            return;
+        case '{'
+            val = parse_object(varargin{:});
+            if isstruct(val)
+                if(~isempty(strmatch('x0x5F_ArrayType_',fieldnames(val), 'exact')))
+                    val=jstruct2array(val);
+                end
+            elseif isempty(val)
+                val = struct;
+            end
+            return;
+        case {'-','0','1','2','3','4','5','6','7','8','9'}
+            val = parse_number(varargin{:});
+            return;
+        case 't'
+            if pos+3 <= len && strcmpi(inStr(pos:pos+3), 'true')
+                val = true;
+                pos = pos + 4;
+                return;
+            end
+        case 'f'
+            if pos+4 <= len && strcmpi(inStr(pos:pos+4), 'false')
+                val = false;
+                pos = pos + 5;
+                return;
+            end
+        case 'n'
+            if pos+3 <= len && strcmpi(inStr(pos:pos+3), 'null')
+                val = [];
+                pos = pos + 4;
+                return;
+            end
+    end
+    error_pos('Value expected at position %d');
+%%-------------------------------------------------------------------------
+
+function error_pos(msg)
+    global pos inStr len
+    poShow = max(min([pos-15 pos-1 pos pos+20],len),1);
+    if poShow(3) == poShow(2)
+        poShow(3:4) = poShow(2)+[0 -1];  % display nothing after
+    end
+    msg = [sprintf(msg, pos) ': ' ...
+    inStr(poShow(1):poShow(2)) '<error>' inStr(poShow(3):poShow(4)) ];
+    error( ['JSONparser:invalidFormat: ' msg] );
+
+%%-------------------------------------------------------------------------
+
+function str = valid_field(str)
+global isoct
+% From MATLAB doc: field names must begin with a letter, which may be
+% followed by any combination of letters, digits, and underscores.
+% Invalid characters will be converted to underscores, and the prefix
+% "x0x[Hex code]_" will be added if the first character is not a letter.
+    pos=regexp(str,'^[^A-Za-z]','once');
+    if(~isempty(pos))
+        if(~isoct)
+            str=regexprep(str,'^([^A-Za-z])','x0x${sprintf(''%X'',unicode2native($1))}_','once');
+        else
+            str=sprintf('x0x%X_%s',char(str(1)),str(2:end));
+        end
+    end
+    if(isempty(regexp(str,'[^0-9A-Za-z_]', 'once' ))) return;  end
+    if(~isoct)
+        str=regexprep(str,'([^0-9A-Za-z_])','_0x${sprintf(''%X'',unicode2native($1))}_');
+    else
+        pos=regexp(str,'[^0-9A-Za-z_]');
+        if(isempty(pos)) return; end
+        str0=str;
+        pos0=[0 pos(:)' length(str)];
+        str='';
+        for i=1:length(pos)
+            str=[str str0(pos0(i)+1:pos(i)-1) sprintf('_0x%X_',str0(pos(i)))];
+        end
+        if(pos(end)~=length(str))
+            str=[str str0(pos0(end-1)+1:pos0(end))];
+        end
+    end
+    %str(~isletter(str) & ~('0' <= str & str <= '9')) = '_';
+
+%%-------------------------------------------------------------------------
+function endpos = matching_quote(str,pos)
+len=length(str);
+while(pos<len)
+    if(str(pos)=='"')
+        if(~(pos>1 && str(pos-1)=='\'))
+            endpos=pos;
+            return;
+        end        
+    end
+    pos=pos+1;
+end
+error('unmatched quotation mark');
+%%-------------------------------------------------------------------------
+function [endpos, e1l, e1r, maxlevel] = matching_bracket(str,pos)
+global arraytoken
+level=1;
+maxlevel=level;
+endpos=0;
+bpos=arraytoken(arraytoken>=pos);
+tokens=str(bpos);
+len=length(tokens);
+pos=1;
+e1l=[];
+e1r=[];
+while(pos<=len)
+    c=tokens(pos);
+    if(c==']')
+        level=level-1;
+        if(isempty(e1r)) e1r=bpos(pos); end
+        if(level==0)
+            endpos=bpos(pos);
+            return
+        end
+    end
+    if(c=='[')
+        if(isempty(e1l)) e1l=bpos(pos); end
+        level=level+1;
+        maxlevel=max(maxlevel,level);
+    end
+    if(c=='"')
+        pos=matching_quote(tokens,pos+1);
+    end
+    pos=pos+1;
+end
+if(endpos==0) 
+    error('unmatched "]"');
+end
+

+ 528 - 0
machine learning/machine-learning-ex2/ex2/lib/jsonlab/loadubjson.m

@@ -0,0 +1,528 @@
+function data = loadubjson(fname,varargin)
+%
+% data=loadubjson(fname,opt)
+%    or
+% data=loadubjson(fname,'param1',value1,'param2',value2,...)
+%
+% parse a JSON (JavaScript Object Notation) file or string
+%
+% authors:Qianqian Fang (fangq<at> nmr.mgh.harvard.edu)
+% created on 2013/08/01
+%
+% $Id: loadubjson.m 460 2015-01-03 00:30:45Z fangq $
+%
+% input:
+%      fname: input file name, if fname contains "{}" or "[]", fname
+%             will be interpreted as a UBJSON string
+%      opt: a struct to store parsing options, opt can be replaced by 
+%           a list of ('param',value) pairs - the param string is equivallent
+%           to a field in opt. opt can have the following 
+%           fields (first in [.|.] is the default)
+%
+%           opt.SimplifyCell [0|1]: if set to 1, loadubjson will call cell2mat
+%                         for each element of the JSON data, and group 
+%                         arrays based on the cell2mat rules.
+%           opt.IntEndian [B|L]: specify the endianness of the integer fields
+%                         in the UBJSON input data. B - Big-Endian format for 
+%                         integers (as required in the UBJSON specification); 
+%                         L - input integer fields are in Little-Endian order.
+%
+% output:
+%      dat: a cell array, where {...} blocks are converted into cell arrays,
+%           and [...] are converted to arrays
+%
+% examples:
+%      obj=struct('string','value','array',[1 2 3]);
+%      ubjdata=saveubjson('obj',obj);
+%      dat=loadubjson(ubjdata)
+%      dat=loadubjson(['examples' filesep 'example1.ubj'])
+%      dat=loadubjson(['examples' filesep 'example1.ubj'],'SimplifyCell',1)
+%
+% license:
+%     BSD, see LICENSE_BSD.txt files for details 
+%
+% -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)
+%
+
+global pos inStr len  esc index_esc len_esc isoct arraytoken fileendian systemendian
+
+if(regexp(fname,'[\{\}\]\[]','once'))
+   string=fname;
+elseif(exist(fname,'file'))
+   fid = fopen(fname,'rb');
+   string = fread(fid,inf,'uint8=>char')';
+   fclose(fid);
+else
+   error('input file does not exist');
+end
+
+pos = 1; len = length(string); inStr = string;
+isoct=exist('OCTAVE_VERSION','builtin');
+arraytoken=find(inStr=='[' | inStr==']' | inStr=='"');
+jstr=regexprep(inStr,'\\\\','  ');
+escquote=regexp(jstr,'\\"');
+arraytoken=sort([arraytoken escquote]);
+
+% String delimiters and escape chars identified to improve speed:
+esc = find(inStr=='"' | inStr=='\' ); % comparable to: regexp(inStr, '["\\]');
+index_esc = 1; len_esc = length(esc);
+
+opt=varargin2struct(varargin{:});
+fileendian=upper(jsonopt('IntEndian','B',opt));
+[os,maxelem,systemendian]=computer;
+
+jsoncount=1;
+while pos <= len
+    switch(next_char)
+        case '{'
+            data{jsoncount} = parse_object(opt);
+        case '['
+            data{jsoncount} = parse_array(opt);
+        otherwise
+            error_pos('Outer level structure must be an object or an array');
+    end
+    jsoncount=jsoncount+1;
+end % while
+
+jsoncount=length(data);
+if(jsoncount==1 && iscell(data))
+    data=data{1};
+end
+
+if(~isempty(data))
+      if(isstruct(data)) % data can be a struct array
+          data=jstruct2array(data);
+      elseif(iscell(data))
+          data=jcell2array(data);
+      end
+end
+
+
+%%
+function newdata=parse_collection(id,data,obj)
+
+if(jsoncount>0 && exist('data','var')) 
+    if(~iscell(data))
+       newdata=cell(1);
+       newdata{1}=data;
+       data=newdata;
+    end
+end
+
+%%
+function newdata=jcell2array(data)
+len=length(data);
+newdata=data;
+for i=1:len
+      if(isstruct(data{i}))
+          newdata{i}=jstruct2array(data{i});
+      elseif(iscell(data{i}))
+          newdata{i}=jcell2array(data{i});
+      end
+end
+
+%%-------------------------------------------------------------------------
+function newdata=jstruct2array(data)
+fn=fieldnames(data);
+newdata=data;
+len=length(data);
+for i=1:length(fn) % depth-first
+    for j=1:len
+        if(isstruct(getfield(data(j),fn{i})))
+            newdata(j)=setfield(newdata(j),fn{i},jstruct2array(getfield(data(j),fn{i})));
+        end
+    end
+end
+if(~isempty(strmatch('x0x5F_ArrayType_',fn)) && ~isempty(strmatch('x0x5F_ArrayData_',fn)))
+  newdata=cell(len,1);
+  for j=1:len
+    ndata=cast(data(j).x0x5F_ArrayData_,data(j).x0x5F_ArrayType_);
+    iscpx=0;
+    if(~isempty(strmatch('x0x5F_ArrayIsComplex_',fn)))
+        if(data(j).x0x5F_ArrayIsComplex_)
+           iscpx=1;
+        end
+    end
+    if(~isempty(strmatch('x0x5F_ArrayIsSparse_',fn)))
+        if(data(j).x0x5F_ArrayIsSparse_)
+            if(~isempty(strmatch('x0x5F_ArraySize_',fn)))
+                dim=double(data(j).x0x5F_ArraySize_);
+                if(iscpx && size(ndata,2)==4-any(dim==1))
+                    ndata(:,end-1)=complex(ndata(:,end-1),ndata(:,end));
+                end
+                if isempty(ndata)
+                    % All-zeros sparse
+                    ndata=sparse(dim(1),prod(dim(2:end)));
+                elseif dim(1)==1
+                    % Sparse row vector
+                    ndata=sparse(1,ndata(:,1),ndata(:,2),dim(1),prod(dim(2:end)));
+                elseif dim(2)==1
+                    % Sparse column vector
+                    ndata=sparse(ndata(:,1),1,ndata(:,2),dim(1),prod(dim(2:end)));
+                else
+                    % Generic sparse array.
+                    ndata=sparse(ndata(:,1),ndata(:,2),ndata(:,3),dim(1),prod(dim(2:end)));
+                end
+            else
+                if(iscpx && size(ndata,2)==4)
+                    ndata(:,3)=complex(ndata(:,3),ndata(:,4));
+                end
+                ndata=sparse(ndata(:,1),ndata(:,2),ndata(:,3));
+            end
+        end
+    elseif(~isempty(strmatch('x0x5F_ArraySize_',fn)))
+        if(iscpx && size(ndata,2)==2)
+             ndata=complex(ndata(:,1),ndata(:,2));
+        end
+        ndata=reshape(ndata(:),data(j).x0x5F_ArraySize_);
+    end
+    newdata{j}=ndata;
+  end
+  if(len==1)
+      newdata=newdata{1};
+  end
+end
+
+%%-------------------------------------------------------------------------
+function object = parse_object(varargin)
+    parse_char('{');
+    object = [];
+    type='';
+    count=-1;
+    if(next_char == '$')
+        type=inStr(pos+1); % TODO
+        pos=pos+2;
+    end
+    if(next_char == '#')
+        pos=pos+1;
+        count=double(parse_number());
+    end
+    if next_char ~= '}'
+        num=0;
+        while 1
+            str = parseStr(varargin{:});
+            if isempty(str)
+                error_pos('Name of value at position %d cannot be empty');
+            end
+            %parse_char(':');
+            val = parse_value(varargin{:});
+            num=num+1;
+            eval( sprintf( 'object.%s  = val;', valid_field(str) ) );
+            if next_char == '}' || (count>=0 && num>=count)
+                break;
+            end
+            %parse_char(',');
+        end
+    end
+    if(count==-1)
+        parse_char('}');
+    end
+
+%%-------------------------------------------------------------------------
+function [cid,len]=elem_info(type)
+id=strfind('iUIlLdD',type);
+dataclass={'int8','uint8','int16','int32','int64','single','double'};
+bytelen=[1,1,2,4,8,4,8];
+if(id>0)
+    cid=dataclass{id};
+    len=bytelen(id);
+else
+    error_pos('unsupported type at position %d');
+end
+%%-------------------------------------------------------------------------
+
+
+function [data adv]=parse_block(type,count,varargin)
+global pos inStr isoct fileendian systemendian
+[cid,len]=elem_info(type);
+datastr=inStr(pos:pos+len*count-1);
+if(isoct)
+    newdata=int8(datastr);
+else
+    newdata=uint8(datastr);
+end
+id=strfind('iUIlLdD',type);
+if(id<=5 && fileendian~=systemendian)
+    newdata=swapbytes(typecast(newdata,cid));
+end
+data=typecast(newdata,cid);
+adv=double(len*count);
+
+%%-------------------------------------------------------------------------
+
+
+function object = parse_array(varargin) % JSON array is written in row-major order
+global pos inStr isoct
+    parse_char('[');
+    object = cell(0, 1);
+    dim=[];
+    type='';
+    count=-1;
+    if(next_char == '$')
+        type=inStr(pos+1);
+        pos=pos+2;
+    end
+    if(next_char == '#')
+        pos=pos+1;
+        if(next_char=='[')
+            dim=parse_array(varargin{:});
+            count=prod(double(dim));
+        else
+            count=double(parse_number());
+        end
+    end
+    if(~isempty(type))
+        if(count>=0)
+            [object adv]=parse_block(type,count,varargin{:});
+            if(~isempty(dim))
+                object=reshape(object,dim);
+            end
+            pos=pos+adv;
+            return;
+        else
+            endpos=matching_bracket(inStr,pos);
+            [cid,len]=elem_info(type);
+            count=(endpos-pos)/len;
+            [object adv]=parse_block(type,count,varargin{:});
+            pos=pos+adv;
+            parse_char(']');
+            return;
+        end
+    end
+    if next_char ~= ']'
+         while 1
+            val = parse_value(varargin{:});
+            object{end+1} = val;
+            if next_char == ']'
+                break;
+            end
+            %parse_char(',');
+         end
+    end
+    if(jsonopt('SimplifyCell',0,varargin{:})==1)
+      try
+        oldobj=object;
+        object=cell2mat(object')';
+        if(iscell(oldobj) && isstruct(object) && numel(object)>1 && jsonopt('SimplifyCellArray',1,varargin{:})==0)
+            object=oldobj;
+        elseif(size(object,1)>1 && ndims(object)==2)
+            object=object';
+        end
+      catch
+      end
+    end
+    if(count==-1)
+        parse_char(']');
+    end
+
+%%-------------------------------------------------------------------------
+
+function parse_char(c)
+    global pos inStr len
+    skip_whitespace;
+    if pos > len || inStr(pos) ~= c
+        error_pos(sprintf('Expected %c at position %%d', c));
+    else
+        pos = pos + 1;
+        skip_whitespace;
+    end
+
+%%-------------------------------------------------------------------------
+
+function c = next_char
+    global pos inStr len
+    skip_whitespace;
+    if pos > len
+        c = [];
+    else
+        c = inStr(pos);
+    end
+
+%%-------------------------------------------------------------------------
+
+function skip_whitespace
+    global pos inStr len
+    while pos <= len && isspace(inStr(pos))
+        pos = pos + 1;
+    end
+
+%%-------------------------------------------------------------------------
+function str = parseStr(varargin)
+    global pos inStr esc index_esc len_esc
+ % len, ns = length(inStr), keyboard
+    type=inStr(pos);
+    if type ~= 'S' && type ~= 'C' && type ~= 'H'
+        error_pos('String starting with S expected at position %d');
+    else
+        pos = pos + 1;
+    end
+    if(type == 'C')
+        str=inStr(pos);
+        pos=pos+1;
+        return;
+    end
+    bytelen=double(parse_number());
+    if(length(inStr)>=pos+bytelen-1)
+        str=inStr(pos:pos+bytelen-1);
+        pos=pos+bytelen;
+    else
+        error_pos('End of file while expecting end of inStr');
+    end
+
+%%-------------------------------------------------------------------------
+
+function num = parse_number(varargin)
+    global pos inStr len isoct fileendian systemendian
+    id=strfind('iUIlLdD',inStr(pos));
+    if(isempty(id))
+        error_pos('expecting a number at position %d');
+    end
+    type={'int8','uint8','int16','int32','int64','single','double'};
+    bytelen=[1,1,2,4,8,4,8];
+    datastr=inStr(pos+1:pos+bytelen(id));
+    if(isoct)
+        newdata=int8(datastr);
+    else
+        newdata=uint8(datastr);
+    end
+    if(id<=5 && fileendian~=systemendian)
+        newdata=swapbytes(typecast(newdata,type{id}));
+    end
+    num=typecast(newdata,type{id});
+    pos = pos + bytelen(id)+1;
+
+%%-------------------------------------------------------------------------
+
+function val = parse_value(varargin)
+    global pos inStr len
+    true = 1; false = 0;
+
+    switch(inStr(pos))
+        case {'S','C','H'}
+            val = parseStr(varargin{:});
+            return;
+        case '['
+            val = parse_array(varargin{:});
+            return;
+        case '{'
+            val = parse_object(varargin{:});
+            if isstruct(val)
+                if(~isempty(strmatch('x0x5F_ArrayType_',fieldnames(val), 'exact')))
+                    val=jstruct2array(val);
+                end
+            elseif isempty(val)
+                val = struct;
+            end
+            return;
+        case {'i','U','I','l','L','d','D'}
+            val = parse_number(varargin{:});
+            return;
+        case 'T'
+            val = true;
+            pos = pos + 1;
+            return;
+        case 'F'
+            val = false;
+            pos = pos + 1;
+            return;
+        case {'Z','N'}
+            val = [];
+            pos = pos + 1;
+            return;
+    end
+    error_pos('Value expected at position %d');
+%%-------------------------------------------------------------------------
+
+function error_pos(msg)
+    global pos inStr len
+    poShow = max(min([pos-15 pos-1 pos pos+20],len),1);
+    if poShow(3) == poShow(2)
+        poShow(3:4) = poShow(2)+[0 -1];  % display nothing after
+    end
+    msg = [sprintf(msg, pos) ': ' ...
+    inStr(poShow(1):poShow(2)) '<error>' inStr(poShow(3):poShow(4)) ];
+    error( ['JSONparser:invalidFormat: ' msg] );
+
+%%-------------------------------------------------------------------------
+
+function str = valid_field(str)
+global isoct
+% From MATLAB doc: field names must begin with a letter, which may be
+% followed by any combination of letters, digits, and underscores.
+% Invalid characters will be converted to underscores, and the prefix
+% "x0x[Hex code]_" will be added if the first character is not a letter.
+    pos=regexp(str,'^[^A-Za-z]','once');
+    if(~isempty(pos))
+        if(~isoct)
+            str=regexprep(str,'^([^A-Za-z])','x0x${sprintf(''%X'',unicode2native($1))}_','once');
+        else
+            str=sprintf('x0x%X_%s',char(str(1)),str(2:end));
+        end
+    end
+    if(isempty(regexp(str,'[^0-9A-Za-z_]', 'once' ))) return;  end
+    if(~isoct)
+        str=regexprep(str,'([^0-9A-Za-z_])','_0x${sprintf(''%X'',unicode2native($1))}_');
+    else
+        pos=regexp(str,'[^0-9A-Za-z_]');
+        if(isempty(pos)) return; end
+        str0=str;
+        pos0=[0 pos(:)' length(str)];
+        str='';
+        for i=1:length(pos)
+            str=[str str0(pos0(i)+1:pos(i)-1) sprintf('_0x%X_',str0(pos(i)))];
+        end
+        if(pos(end)~=length(str))
+            str=[str str0(pos0(end-1)+1:pos0(end))];
+        end
+    end
+    %str(~isletter(str) & ~('0' <= str & str <= '9')) = '_';
+
+%%-------------------------------------------------------------------------
+function endpos = matching_quote(str,pos)
+len=length(str);
+while(pos<len)
+    if(str(pos)=='"')
+        if(~(pos>1 && str(pos-1)=='\'))
+            endpos=pos;
+            return;
+        end        
+    end
+    pos=pos+1;
+end
+error('unmatched quotation mark');
+%%-------------------------------------------------------------------------
+function [endpos e1l e1r maxlevel] = matching_bracket(str,pos)
+global arraytoken
+level=1;
+maxlevel=level;
+endpos=0;
+bpos=arraytoken(arraytoken>=pos);
+tokens=str(bpos);
+len=length(tokens);
+pos=1;
+e1l=[];
+e1r=[];
+while(pos<=len)
+    c=tokens(pos);
+    if(c==']')
+        level=level-1;
+        if(isempty(e1r)) e1r=bpos(pos); end
+        if(level==0)
+            endpos=bpos(pos);
+            return
+        end
+    end
+    if(c=='[')
+        if(isempty(e1l)) e1l=bpos(pos); end
+        level=level+1;
+        maxlevel=max(maxlevel,level);
+    end
+    if(c=='"')
+        pos=matching_quote(tokens,pos+1);
+    end
+    pos=pos+1;
+end
+if(endpos==0) 
+    error('unmatched "]"');
+end
+

+ 33 - 0
machine learning/machine-learning-ex2/ex2/lib/jsonlab/mergestruct.m

@@ -0,0 +1,33 @@
+function s=mergestruct(s1,s2)
+%
+% s=mergestruct(s1,s2)
+%
+% merge two struct objects into one
+%
+% authors:Qianqian Fang (fangq<at> nmr.mgh.harvard.edu)
+% date: 2012/12/22
+%
+% input:
+%      s1,s2: a struct object, s1 and s2 can not be arrays
+%
+% output:
+%      s: the merged struct object. fields in s1 and s2 will be combined in s.
+%
+% license:
+%     BSD, see LICENSE_BSD.txt files for details 
+%
+% -- this function is part of jsonlab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)
+%
+
+if(~isstruct(s1) || ~isstruct(s2))
+    error('input parameters contain non-struct');
+end
+if(length(s1)>1 || length(s2)>1)
+    error('can not merge struct arrays');
+end
+fn=fieldnames(s2);
+s=s1;
+for i=1:length(fn)              
+    s=setfield(s,fn{i},getfield(s2,fn{i}));
+end
+

+ 475 - 0
machine learning/machine-learning-ex2/ex2/lib/jsonlab/savejson.m

@@ -0,0 +1,475 @@
+function json=savejson(rootname,obj,varargin)
+%
+% json=savejson(rootname,obj,filename)
+%    or
+% json=savejson(rootname,obj,opt)
+% json=savejson(rootname,obj,'param1',value1,'param2',value2,...)
+%
+% convert a MATLAB object (cell, struct or array) into a JSON (JavaScript
+% Object Notation) string
+%
+% author: Qianqian Fang (fangq<at> nmr.mgh.harvard.edu)
+% created on 2011/09/09
+%
+% $Id: savejson.m 460 2015-01-03 00:30:45Z fangq $
+%
+% input:
+%      rootname: the name of the root-object, when set to '', the root name
+%        is ignored, however, when opt.ForceRootName is set to 1 (see below),
+%        the MATLAB variable name will be used as the root name.
+%      obj: a MATLAB object (array, cell, cell array, struct, struct array).
+%      filename: a string for the file name to save the output JSON data.
+%      opt: a struct for additional options, ignore to use default values.
+%        opt can have the following fields (first in [.|.] is the default)
+%
+%        opt.FileName [''|string]: a file name to save the output JSON data
+%        opt.FloatFormat ['%.10g'|string]: format to show each numeric element
+%                         of a 1D/2D array;
+%        opt.ArrayIndent [1|0]: if 1, output explicit data array with
+%                         precedent indentation; if 0, no indentation
+%        opt.ArrayToStruct[0|1]: when set to 0, savejson outputs 1D/2D
+%                         array in JSON array format; if sets to 1, an
+%                         array will be shown as a struct with fields
+%                         "_ArrayType_", "_ArraySize_" and "_ArrayData_"; for
+%                         sparse arrays, the non-zero elements will be
+%                         saved to _ArrayData_ field in triplet-format i.e.
+%                         (ix,iy,val) and "_ArrayIsSparse_" will be added
+%                         with a value of 1; for a complex array, the 
+%                         _ArrayData_ array will include two columns 
+%                         (4 for sparse) to record the real and imaginary 
+%                         parts, and also "_ArrayIsComplex_":1 is added. 
+%        opt.ParseLogical [0|1]: if this is set to 1, logical array elem
+%                         will use true/false rather than 1/0.
+%        opt.NoRowBracket [1|0]: if this is set to 1, arrays with a single
+%                         numerical element will be shown without a square
+%                         bracket, unless it is the root object; if 0, square
+%                         brackets are forced for any numerical arrays.
+%        opt.ForceRootName [0|1]: when set to 1 and rootname is empty, savejson
+%                         will use the name of the passed obj variable as the 
+%                         root object name; if obj is an expression and 
+%                         does not have a name, 'root' will be used; if this 
+%                         is set to 0 and rootname is empty, the root level 
+%                         will be merged down to the lower level.
+%        opt.Inf ['"$1_Inf_"'|string]: a customized regular expression pattern
+%                         to represent +/-Inf. The matched pattern is '([-+]*)Inf'
+%                         and $1 represents the sign. For those who want to use
+%                         1e999 to represent Inf, they can set opt.Inf to '$11e999'
+%        opt.NaN ['"_NaN_"'|string]: a customized regular expression pattern
+%                         to represent NaN
+%        opt.JSONP [''|string]: to generate a JSONP output (JSON with padding),
+%                         for example, if opt.JSONP='foo', the JSON data is
+%                         wrapped inside a function call as 'foo(...);'
+%        opt.UnpackHex [1|0]: conver the 0x[hex code] output by loadjson 
+%                         back to the string form
+%        opt.SaveBinary [0|1]: 1 - save the JSON file in binary mode; 0 - text mode.
+%        opt.Compact [0|1]: 1- out compact JSON format (remove all newlines and tabs)
+%
+%        opt can be replaced by a list of ('param',value) pairs. The param 
+%        string is equivallent to a field in opt and is case sensitive.
+% output:
+%      json: a string in the JSON format (see http://json.org)
+%
+% examples:
+%      jsonmesh=struct('MeshNode',[0 0 0;1 0 0;0 1 0;1 1 0;0 0 1;1 0 1;0 1 1;1 1 1],... 
+%               'MeshTetra',[1 2 4 8;1 3 4 8;1 2 6 8;1 5 6 8;1 5 7 8;1 3 7 8],...
+%               'MeshTri',[1 2 4;1 2 6;1 3 4;1 3 7;1 5 6;1 5 7;...
+%                          2 8 4;2 8 6;3 8 4;3 8 7;5 8 6;5 8 7],...
+%               'MeshCreator','FangQ','MeshTitle','T6 Cube',...
+%               'SpecialData',[nan, inf, -inf]);
+%      savejson('jmesh',jsonmesh)
+%      savejson('',jsonmesh,'ArrayIndent',0,'FloatFormat','\t%.5g')
+%
+% license:
+%     BSD, see LICENSE_BSD.txt files for details
+%
+% -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)
+%
+
+if(nargin==1)
+   varname=inputname(1);
+   obj=rootname;
+   if(isempty(varname)) 
+      varname='root';
+   end
+   rootname=varname;
+else
+   varname=inputname(2);
+end
+if(length(varargin)==1 && ischar(varargin{1}))
+   opt=struct('FileName',varargin{1});
+else
+   opt=varargin2struct(varargin{:});
+end
+opt.IsOctave=exist('OCTAVE_VERSION','builtin');
+rootisarray=0;
+rootlevel=1;
+forceroot=jsonopt('ForceRootName',0,opt);
+if((isnumeric(obj) || islogical(obj) || ischar(obj) || isstruct(obj) || iscell(obj)) && isempty(rootname) && forceroot==0)
+    rootisarray=1;
+    rootlevel=0;
+else
+    if(isempty(rootname))
+        rootname=varname;
+    end
+end
+if((isstruct(obj) || iscell(obj))&& isempty(rootname) && forceroot)
+    rootname='root';
+end
+
+whitespaces=struct('tab',sprintf('\t'),'newline',sprintf('\n'),'sep',sprintf(',\n'));
+if(jsonopt('Compact',0,opt)==1)
+    whitespaces=struct('tab','','newline','','sep',',');
+end
+if(~isfield(opt,'whitespaces_'))
+    opt.whitespaces_=whitespaces;
+end
+
+nl=whitespaces.newline;
+
+json=obj2json(rootname,obj,rootlevel,opt);
+if(rootisarray)
+    json=sprintf('%s%s',json,nl);
+else
+    json=sprintf('{%s%s%s}\n',nl,json,nl);
+end
+
+jsonp=jsonopt('JSONP','',opt);
+if(~isempty(jsonp))
+    json=sprintf('%s(%s);%s',jsonp,json,nl);
+end
+
+% save to a file if FileName is set, suggested by Patrick Rapin
+if(~isempty(jsonopt('FileName','',opt)))
+    if(jsonopt('SaveBinary',0,opt)==1)
+	    fid = fopen(opt.FileName, 'wb');
+	    fwrite(fid,json);
+    else
+	    fid = fopen(opt.FileName, 'wt');
+	    fwrite(fid,json,'char');
+    end
+    fclose(fid);
+end
+
+%%-------------------------------------------------------------------------
+function txt=obj2json(name,item,level,varargin)
+
+if(iscell(item))
+    txt=cell2json(name,item,level,varargin{:});
+elseif(isstruct(item))
+    txt=struct2json(name,item,level,varargin{:});
+elseif(ischar(item))
+    txt=str2json(name,item,level,varargin{:});
+else
+    txt=mat2json(name,item,level,varargin{:});
+end
+
+%%-------------------------------------------------------------------------
+function txt=cell2json(name,item,level,varargin)
+txt='';
+if(~iscell(item))
+        error('input is not a cell');
+end
+
+dim=size(item);
+if(ndims(squeeze(item))>2) % for 3D or higher dimensions, flatten to 2D for now
+    item=reshape(item,dim(1),numel(item)/dim(1));
+    dim=size(item);
+end
+len=numel(item);
+ws=jsonopt('whitespaces_',struct('tab',sprintf('\t'),'newline',sprintf('\n'),'sep',sprintf(',\n')),varargin{:});
+padding0=repmat(ws.tab,1,level);
+padding2=repmat(ws.tab,1,level+1);
+nl=ws.newline;
+if(len>1)
+    if(~isempty(name))
+        txt=sprintf('%s"%s": [%s',padding0, checkname(name,varargin{:}),nl); name=''; 
+    else
+        txt=sprintf('%s[%s',padding0,nl); 
+    end
+elseif(len==0)
+    if(~isempty(name))
+        txt=sprintf('%s"%s": []',padding0, checkname(name,varargin{:})); name=''; 
+    else
+        txt=sprintf('%s[]',padding0); 
+    end
+end
+for j=1:dim(2)
+    if(dim(1)>1) txt=sprintf('%s%s[%s',txt,padding2,nl); end
+    for i=1:dim(1)
+       txt=sprintf('%s%s',txt,obj2json(name,item{i,j},level+(dim(1)>1)+1,varargin{:}));
+       if(i<dim(1)) txt=sprintf('%s%s',txt,sprintf(',%s',nl)); end
+    end
+    if(dim(1)>1) txt=sprintf('%s%s%s]',txt,nl,padding2); end
+    if(j<dim(2)) txt=sprintf('%s%s',txt,sprintf(',%s',nl)); end
+    %if(j==dim(2)) txt=sprintf('%s%s',txt,sprintf(',%s',nl)); end
+end
+if(len>1) txt=sprintf('%s%s%s]',txt,nl,padding0); end
+
+%%-------------------------------------------------------------------------
+function txt=struct2json(name,item,level,varargin)
+txt='';
+if(~isstruct(item))
+	error('input is not a struct');
+end
+dim=size(item);
+if(ndims(squeeze(item))>2) % for 3D or higher dimensions, flatten to 2D for now
+    item=reshape(item,dim(1),numel(item)/dim(1));
+    dim=size(item);
+end
+len=numel(item);
+ws=struct('tab',sprintf('\t'),'newline',sprintf('\n'));
+ws=jsonopt('whitespaces_',ws,varargin{:});
+padding0=repmat(ws.tab,1,level);
+padding2=repmat(ws.tab,1,level+1);
+padding1=repmat(ws.tab,1,level+(dim(1)>1)+(len>1));
+nl=ws.newline;
+
+if(~isempty(name)) 
+    if(len>1) txt=sprintf('%s"%s": [%s',padding0,checkname(name,varargin{:}),nl); end
+else
+    if(len>1) txt=sprintf('%s[%s',padding0,nl); end
+end
+for j=1:dim(2)
+  if(dim(1)>1) txt=sprintf('%s%s[%s',txt,padding2,nl); end
+  for i=1:dim(1)
+    names = fieldnames(item(i,j));
+    if(~isempty(name) && len==1)
+        txt=sprintf('%s%s"%s": {%s',txt,padding1, checkname(name,varargin{:}),nl); 
+    else
+        txt=sprintf('%s%s{%s',txt,padding1,nl); 
+    end
+    if(~isempty(names))
+      for e=1:length(names)
+	    txt=sprintf('%s%s',txt,obj2json(names{e},getfield(item(i,j),...
+             names{e}),level+(dim(1)>1)+1+(len>1),varargin{:}));
+        if(e<length(names)) txt=sprintf('%s%s',txt,','); end
+        txt=sprintf('%s%s',txt,nl);
+      end
+    end
+    txt=sprintf('%s%s}',txt,padding1);
+    if(i<dim(1)) txt=sprintf('%s%s',txt,sprintf(',%s',nl)); end
+  end
+  if(dim(1)>1) txt=sprintf('%s%s%s]',txt,nl,padding2); end
+  if(j<dim(2)) txt=sprintf('%s%s',txt,sprintf(',%s',nl)); end
+end
+if(len>1) txt=sprintf('%s%s%s]',txt,nl,padding0); end
+
+%%-------------------------------------------------------------------------
+function txt=str2json(name,item,level,varargin)
+txt='';
+if(~ischar(item))
+        error('input is not a string');
+end
+item=reshape(item, max(size(item),[1 0]));
+len=size(item,1);
+ws=struct('tab',sprintf('\t'),'newline',sprintf('\n'),'sep',sprintf(',\n'));
+ws=jsonopt('whitespaces_',ws,varargin{:});
+padding1=repmat(ws.tab,1,level);
+padding0=repmat(ws.tab,1,level+1);
+nl=ws.newline;
+sep=ws.sep;
+
+if(~isempty(name)) 
+    if(len>1) txt=sprintf('%s"%s": [%s',padding1,checkname(name,varargin{:}),nl); end
+else
+    if(len>1) txt=sprintf('%s[%s',padding1,nl); end
+end
+isoct=jsonopt('IsOctave',0,varargin{:});
+for e=1:len
+    if(isoct)
+        val=regexprep(item(e,:),'\\','\\');
+        val=regexprep(val,'"','\"');
+        val=regexprep(val,'^"','\"');
+    else
+        val=regexprep(item(e,:),'\\','\\\\');
+        val=regexprep(val,'"','\\"');
+        val=regexprep(val,'^"','\\"');
+    end
+    val=escapejsonstring(val);
+    if(len==1)
+        obj=['"' checkname(name,varargin{:}) '": ' '"',val,'"'];
+	if(isempty(name)) obj=['"',val,'"']; end
+        txt=sprintf('%s%s%s%s',txt,padding1,obj);
+    else
+        txt=sprintf('%s%s%s%s',txt,padding0,['"',val,'"']);
+    end
+    if(e==len) sep=''; end
+    txt=sprintf('%s%s',txt,sep);
+end
+if(len>1) txt=sprintf('%s%s%s%s',txt,nl,padding1,']'); end
+
+%%-------------------------------------------------------------------------
+function txt=mat2json(name,item,level,varargin)
+if(~isnumeric(item) && ~islogical(item))
+        error('input is not an array');
+end
+ws=struct('tab',sprintf('\t'),'newline',sprintf('\n'),'sep',sprintf(',\n'));
+ws=jsonopt('whitespaces_',ws,varargin{:});
+padding1=repmat(ws.tab,1,level);
+padding0=repmat(ws.tab,1,level+1);
+nl=ws.newline;
+sep=ws.sep;
+
+if(length(size(item))>2 || issparse(item) || ~isreal(item) || ...
+   isempty(item) ||jsonopt('ArrayToStruct',0,varargin{:}))
+    if(isempty(name))
+    	txt=sprintf('%s{%s%s"_ArrayType_": "%s",%s%s"_ArraySize_": %s,%s',...
+              padding1,nl,padding0,class(item),nl,padding0,regexprep(mat2str(size(item)),'\s+',','),nl);
+    else
+    	txt=sprintf('%s"%s": {%s%s"_ArrayType_": "%s",%s%s"_ArraySize_": %s,%s',...
+              padding1,checkname(name,varargin{:}),nl,padding0,class(item),nl,padding0,regexprep(mat2str(size(item)),'\s+',','),nl);
+    end
+else
+    if(numel(item)==1 && jsonopt('NoRowBracket',1,varargin{:})==1 && level>0)
+        numtxt=regexprep(regexprep(matdata2json(item,level+1,varargin{:}),'^\[',''),']','');
+    else
+        numtxt=matdata2json(item,level+1,varargin{:});
+    end
+    if(isempty(name))
+    	txt=sprintf('%s%s',padding1,numtxt);
+    else
+        if(numel(item)==1 && jsonopt('NoRowBracket',1,varargin{:})==1)
+           	txt=sprintf('%s"%s": %s',padding1,checkname(name,varargin{:}),numtxt);
+        else
+    	    txt=sprintf('%s"%s": %s',padding1,checkname(name,varargin{:}),numtxt);
+        end
+    end
+    return;
+end
+dataformat='%s%s%s%s%s';
+
+if(issparse(item))
+    [ix,iy]=find(item);
+    data=full(item(find(item)));
+    if(~isreal(item))
+       data=[real(data(:)),imag(data(:))];
+       if(size(item,1)==1)
+           % Kludge to have data's 'transposedness' match item's.
+           % (Necessary for complex row vector handling below.)
+           data=data';
+       end
+       txt=sprintf(dataformat,txt,padding0,'"_ArrayIsComplex_": ','1', sep);
+    end
+    txt=sprintf(dataformat,txt,padding0,'"_ArrayIsSparse_": ','1', sep);
+    if(size(item,1)==1)
+        % Row vector, store only column indices.
+        txt=sprintf(dataformat,txt,padding0,'"_ArrayData_": ',...
+           matdata2json([iy(:),data'],level+2,varargin{:}), nl);
+    elseif(size(item,2)==1)
+        % Column vector, store only row indices.
+        txt=sprintf(dataformat,txt,padding0,'"_ArrayData_": ',...
+           matdata2json([ix,data],level+2,varargin{:}), nl);
+    else
+        % General case, store row and column indices.
+        txt=sprintf(dataformat,txt,padding0,'"_ArrayData_": ',...
+           matdata2json([ix,iy,data],level+2,varargin{:}), nl);
+    end
+else
+    if(isreal(item))
+        txt=sprintf(dataformat,txt,padding0,'"_ArrayData_": ',...
+            matdata2json(item(:)',level+2,varargin{:}), nl);
+    else
+        txt=sprintf(dataformat,txt,padding0,'"_ArrayIsComplex_": ','1', sep);
+        txt=sprintf(dataformat,txt,padding0,'"_ArrayData_": ',...
+            matdata2json([real(item(:)) imag(item(:))],level+2,varargin{:}), nl);
+    end
+end
+txt=sprintf('%s%s%s',txt,padding1,'}');
+
+%%-------------------------------------------------------------------------
+function txt=matdata2json(mat,level,varargin)
+
+ws=struct('tab',sprintf('\t'),'newline',sprintf('\n'),'sep',sprintf(',\n'));
+ws=jsonopt('whitespaces_',ws,varargin{:});
+tab=ws.tab;
+nl=ws.newline;
+
+if(size(mat,1)==1)
+    pre='';
+    post='';
+    level=level-1;
+else
+    pre=sprintf('[%s',nl);
+    post=sprintf('%s%s]',nl,repmat(tab,1,level-1));
+end
+
+if(isempty(mat))
+    txt='null';
+    return;
+end
+floatformat=jsonopt('FloatFormat','%.10g',varargin{:});
+%if(numel(mat)>1)
+    formatstr=['[' repmat([floatformat ','],1,size(mat,2)-1) [floatformat sprintf('],%s',nl)]];
+%else
+%    formatstr=[repmat([floatformat ','],1,size(mat,2)-1) [floatformat sprintf(',\n')]];
+%end
+
+if(nargin>=2 && size(mat,1)>1 && jsonopt('ArrayIndent',1,varargin{:})==1)
+    formatstr=[repmat(tab,1,level) formatstr];
+end
+
+txt=sprintf(formatstr,mat');
+txt(end-length(nl):end)=[];
+if(islogical(mat) && jsonopt('ParseLogical',0,varargin{:})==1)
+   txt=regexprep(txt,'1','true');
+   txt=regexprep(txt,'0','false');
+end
+%txt=regexprep(mat2str(mat),'\s+',',');
+%txt=regexprep(txt,';',sprintf('],\n['));
+% if(nargin>=2 && size(mat,1)>1)
+%     txt=regexprep(txt,'\[',[repmat(sprintf('\t'),1,level) '[']);
+% end
+txt=[pre txt post];
+if(any(isinf(mat(:))))
+    txt=regexprep(txt,'([-+]*)Inf',jsonopt('Inf','"$1_Inf_"',varargin{:}));
+end
+if(any(isnan(mat(:))))
+    txt=regexprep(txt,'NaN',jsonopt('NaN','"_NaN_"',varargin{:}));
+end
+
+%%-------------------------------------------------------------------------
+function newname=checkname(name,varargin)
+isunpack=jsonopt('UnpackHex',1,varargin{:});
+newname=name;
+if(isempty(regexp(name,'0x([0-9a-fA-F]+)_','once')))
+    return
+end
+if(isunpack)
+    isoct=jsonopt('IsOctave',0,varargin{:});
+    if(~isoct)
+        newname=regexprep(name,'(^x|_){1}0x([0-9a-fA-F]+)_','${native2unicode(hex2dec($2))}');
+    else
+        pos=regexp(name,'(^x|_){1}0x([0-9a-fA-F]+)_','start');
+        pend=regexp(name,'(^x|_){1}0x([0-9a-fA-F]+)_','end');
+        if(isempty(pos)) return; end
+        str0=name;
+        pos0=[0 pend(:)' length(name)];
+        newname='';
+        for i=1:length(pos)
+            newname=[newname str0(pos0(i)+1:pos(i)-1) char(hex2dec(str0(pos(i)+3:pend(i)-1)))];
+        end
+        if(pos(end)~=length(name))
+            newname=[newname str0(pos0(end-1)+1:pos0(end))];
+        end
+    end
+end
+
+%%-------------------------------------------------------------------------
+function newstr=escapejsonstring(str)
+newstr=str;
+isoct=exist('OCTAVE_VERSION','builtin');
+if(isoct)
+   vv=sscanf(OCTAVE_VERSION,'%f');
+   if(vv(1)>=3.8) isoct=0; end
+end
+if(isoct)
+  escapechars={'\a','\f','\n','\r','\t','\v'};
+  for i=1:length(escapechars);
+    newstr=regexprep(newstr,escapechars{i},escapechars{i});
+  end
+else
+  escapechars={'\a','\b','\f','\n','\r','\t','\v'};
+  for i=1:length(escapechars);
+    newstr=regexprep(newstr,escapechars{i},regexprep(escapechars{i},'\\','\\\\'));
+  end
+end

+ 504 - 0
machine learning/machine-learning-ex2/ex2/lib/jsonlab/saveubjson.m

@@ -0,0 +1,504 @@
+function json=saveubjson(rootname,obj,varargin)
+%
+% json=saveubjson(rootname,obj,filename)
+%    or
+% json=saveubjson(rootname,obj,opt)
+% json=saveubjson(rootname,obj,'param1',value1,'param2',value2,...)
+%
+% convert a MATLAB object (cell, struct or array) into a Universal 
+% Binary JSON (UBJSON) binary string
+%
+% author: Qianqian Fang (fangq<at> nmr.mgh.harvard.edu)
+% created on 2013/08/17
+%
+% $Id: saveubjson.m 460 2015-01-03 00:30:45Z fangq $
+%
+% input:
+%      rootname: the name of the root-object, when set to '', the root name
+%        is ignored, however, when opt.ForceRootName is set to 1 (see below),
+%        the MATLAB variable name will be used as the root name.
+%      obj: a MATLAB object (array, cell, cell array, struct, struct array)
+%      filename: a string for the file name to save the output UBJSON data
+%      opt: a struct for additional options, ignore to use default values.
+%        opt can have the following fields (first in [.|.] is the default)
+%
+%        opt.FileName [''|string]: a file name to save the output JSON data
+%        opt.ArrayToStruct[0|1]: when set to 0, saveubjson outputs 1D/2D
+%                         array in JSON array format; if sets to 1, an
+%                         array will be shown as a struct with fields
+%                         "_ArrayType_", "_ArraySize_" and "_ArrayData_"; for
+%                         sparse arrays, the non-zero elements will be
+%                         saved to _ArrayData_ field in triplet-format i.e.
+%                         (ix,iy,val) and "_ArrayIsSparse_" will be added
+%                         with a value of 1; for a complex array, the 
+%                         _ArrayData_ array will include two columns 
+%                         (4 for sparse) to record the real and imaginary 
+%                         parts, and also "_ArrayIsComplex_":1 is added. 
+%        opt.ParseLogical [1|0]: if this is set to 1, logical array elem
+%                         will use true/false rather than 1/0.
+%        opt.NoRowBracket [1|0]: if this is set to 1, arrays with a single
+%                         numerical element will be shown without a square
+%                         bracket, unless it is the root object; if 0, square
+%                         brackets are forced for any numerical arrays.
+%        opt.ForceRootName [0|1]: when set to 1 and rootname is empty, saveubjson
+%                         will use the name of the passed obj variable as the 
+%                         root object name; if obj is an expression and 
+%                         does not have a name, 'root' will be used; if this 
+%                         is set to 0 and rootname is empty, the root level 
+%                         will be merged down to the lower level.
+%        opt.JSONP [''|string]: to generate a JSONP output (JSON with padding),
+%                         for example, if opt.JSON='foo', the JSON data is
+%                         wrapped inside a function call as 'foo(...);'
+%        opt.UnpackHex [1|0]: conver the 0x[hex code] output by loadjson 
+%                         back to the string form
+%
+%        opt can be replaced by a list of ('param',value) pairs. The param 
+%        string is equivallent to a field in opt and is case sensitive.
+% output:
+%      json: a binary string in the UBJSON format (see http://ubjson.org)
+%
+% examples:
+%      jsonmesh=struct('MeshNode',[0 0 0;1 0 0;0 1 0;1 1 0;0 0 1;1 0 1;0 1 1;1 1 1],... 
+%               'MeshTetra',[1 2 4 8;1 3 4 8;1 2 6 8;1 5 6 8;1 5 7 8;1 3 7 8],...
+%               'MeshTri',[1 2 4;1 2 6;1 3 4;1 3 7;1 5 6;1 5 7;...
+%                          2 8 4;2 8 6;3 8 4;3 8 7;5 8 6;5 8 7],...
+%               'MeshCreator','FangQ','MeshTitle','T6 Cube',...
+%               'SpecialData',[nan, inf, -inf]);
+%      saveubjson('jsonmesh',jsonmesh)
+%      saveubjson('jsonmesh',jsonmesh,'meshdata.ubj')
+%
+% license:
+%     BSD, see LICENSE_BSD.txt files for details
+%
+% -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)
+%
+
+if(nargin==1)
+   varname=inputname(1);
+   obj=rootname;
+   if(isempty(varname)) 
+      varname='root';
+   end
+   rootname=varname;
+else
+   varname=inputname(2);
+end
+if(length(varargin)==1 && ischar(varargin{1}))
+   opt=struct('FileName',varargin{1});
+else
+   opt=varargin2struct(varargin{:});
+end
+opt.IsOctave=exist('OCTAVE_VERSION','builtin');
+rootisarray=0;
+rootlevel=1;
+forceroot=jsonopt('ForceRootName',0,opt);
+if((isnumeric(obj) || islogical(obj) || ischar(obj) || isstruct(obj) || iscell(obj)) && isempty(rootname) && forceroot==0)
+    rootisarray=1;
+    rootlevel=0;
+else
+    if(isempty(rootname))
+        rootname=varname;
+    end
+end
+if((isstruct(obj) || iscell(obj))&& isempty(rootname) && forceroot)
+    rootname='root';
+end
+json=obj2ubjson(rootname,obj,rootlevel,opt);
+if(~rootisarray)
+    json=['{' json '}'];
+end
+
+jsonp=jsonopt('JSONP','',opt);
+if(~isempty(jsonp))
+    json=[jsonp '(' json ')'];
+end
+
+% save to a file if FileName is set, suggested by Patrick Rapin
+if(~isempty(jsonopt('FileName','',opt)))
+    fid = fopen(opt.FileName, 'wb');
+    fwrite(fid,json);
+    fclose(fid);
+end
+
+%%-------------------------------------------------------------------------
+function txt=obj2ubjson(name,item,level,varargin)
+
+if(iscell(item))
+    txt=cell2ubjson(name,item,level,varargin{:});
+elseif(isstruct(item))
+    txt=struct2ubjson(name,item,level,varargin{:});
+elseif(ischar(item))
+    txt=str2ubjson(name,item,level,varargin{:});
+else
+    txt=mat2ubjson(name,item,level,varargin{:});
+end
+
+%%-------------------------------------------------------------------------
+function txt=cell2ubjson(name,item,level,varargin)
+txt='';
+if(~iscell(item))
+        error('input is not a cell');
+end
+
+dim=size(item);
+if(ndims(squeeze(item))>2) % for 3D or higher dimensions, flatten to 2D for now
+    item=reshape(item,dim(1),numel(item)/dim(1));
+    dim=size(item);
+end
+len=numel(item); % let's handle 1D cell first
+if(len>1) 
+    if(~isempty(name))
+        txt=[S_(checkname(name,varargin{:})) '[']; name=''; 
+    else
+        txt='['; 
+    end
+elseif(len==0)
+    if(~isempty(name))
+        txt=[S_(checkname(name,varargin{:})) 'Z']; name=''; 
+    else
+        txt='Z'; 
+    end
+end
+for j=1:dim(2)
+    if(dim(1)>1) txt=[txt '[']; end
+    for i=1:dim(1)
+       txt=[txt obj2ubjson(name,item{i,j},level+(len>1),varargin{:})];
+    end
+    if(dim(1)>1) txt=[txt ']']; end
+end
+if(len>1) txt=[txt ']']; end
+
+%%-------------------------------------------------------------------------
+function txt=struct2ubjson(name,item,level,varargin)
+txt='';
+if(~isstruct(item))
+	error('input is not a struct');
+end
+dim=size(item);
+if(ndims(squeeze(item))>2) % for 3D or higher dimensions, flatten to 2D for now
+    item=reshape(item,dim(1),numel(item)/dim(1));
+    dim=size(item);
+end
+len=numel(item);
+
+if(~isempty(name)) 
+    if(len>1) txt=[S_(checkname(name,varargin{:})) '[']; end
+else
+    if(len>1) txt='['; end
+end
+for j=1:dim(2)
+  if(dim(1)>1) txt=[txt '[']; end
+  for i=1:dim(1)
+     names = fieldnames(item(i,j));
+     if(~isempty(name) && len==1)
+        txt=[txt S_(checkname(name,varargin{:})) '{']; 
+     else
+        txt=[txt '{']; 
+     end
+     if(~isempty(names))
+       for e=1:length(names)
+	     txt=[txt obj2ubjson(names{e},getfield(item(i,j),...
+             names{e}),level+(dim(1)>1)+1+(len>1),varargin{:})];
+       end
+     end
+     txt=[txt '}'];
+  end
+  if(dim(1)>1) txt=[txt ']']; end
+end
+if(len>1) txt=[txt ']']; end
+
+%%-------------------------------------------------------------------------
+function txt=str2ubjson(name,item,level,varargin)
+txt='';
+if(~ischar(item))
+        error('input is not a string');
+end
+item=reshape(item, max(size(item),[1 0]));
+len=size(item,1);
+
+if(~isempty(name)) 
+    if(len>1) txt=[S_(checkname(name,varargin{:})) '[']; end
+else
+    if(len>1) txt='['; end
+end
+isoct=jsonopt('IsOctave',0,varargin{:});
+for e=1:len
+    val=item(e,:);
+    if(len==1)
+        obj=['' S_(checkname(name,varargin{:})) '' '',S_(val),''];
+	if(isempty(name)) obj=['',S_(val),'']; end
+        txt=[txt,'',obj];
+    else
+        txt=[txt,'',['',S_(val),'']];
+    end
+end
+if(len>1) txt=[txt ']']; end
+
+%%-------------------------------------------------------------------------
+function txt=mat2ubjson(name,item,level,varargin)
+if(~isnumeric(item) && ~islogical(item))
+        error('input is not an array');
+end
+
+if(length(size(item))>2 || issparse(item) || ~isreal(item) || ...
+   isempty(item) || jsonopt('ArrayToStruct',0,varargin{:}))
+      cid=I_(uint32(max(size(item))));
+      if(isempty(name))
+    	txt=['{' S_('_ArrayType_'),S_(class(item)),S_('_ArraySize_'),I_a(size(item),cid(1)) ];
+      else
+          if(isempty(item))
+              txt=[S_(checkname(name,varargin{:})),'Z'];
+              return;
+          else
+    	      txt=[S_(checkname(name,varargin{:})),'{',S_('_ArrayType_'),S_(class(item)),S_('_ArraySize_'),I_a(size(item),cid(1))];
+          end
+      end
+else
+    if(isempty(name))
+    	txt=matdata2ubjson(item,level+1,varargin{:});
+    else
+        if(numel(item)==1 && jsonopt('NoRowBracket',1,varargin{:})==1)
+            numtxt=regexprep(regexprep(matdata2ubjson(item,level+1,varargin{:}),'^\[',''),']','');
+           	txt=[S_(checkname(name,varargin{:})) numtxt];
+        else
+    	    txt=[S_(checkname(name,varargin{:})),matdata2ubjson(item,level+1,varargin{:})];
+        end
+    end
+    return;
+end
+if(issparse(item))
+    [ix,iy]=find(item);
+    data=full(item(find(item)));
+    if(~isreal(item))
+       data=[real(data(:)),imag(data(:))];
+       if(size(item,1)==1)
+           % Kludge to have data's 'transposedness' match item's.
+           % (Necessary for complex row vector handling below.)
+           data=data';
+       end
+       txt=[txt,S_('_ArrayIsComplex_'),'T'];
+    end
+    txt=[txt,S_('_ArrayIsSparse_'),'T'];
+    if(size(item,1)==1)
+        % Row vector, store only column indices.
+        txt=[txt,S_('_ArrayData_'),...
+           matdata2ubjson([iy(:),data'],level+2,varargin{:})];
+    elseif(size(item,2)==1)
+        % Column vector, store only row indices.
+        txt=[txt,S_('_ArrayData_'),...
+           matdata2ubjson([ix,data],level+2,varargin{:})];
+    else
+        % General case, store row and column indices.
+        txt=[txt,S_('_ArrayData_'),...
+           matdata2ubjson([ix,iy,data],level+2,varargin{:})];
+    end
+else
+    if(isreal(item))
+        txt=[txt,S_('_ArrayData_'),...
+            matdata2ubjson(item(:)',level+2,varargin{:})];
+    else
+        txt=[txt,S_('_ArrayIsComplex_'),'T'];
+        txt=[txt,S_('_ArrayData_'),...
+            matdata2ubjson([real(item(:)) imag(item(:))],level+2,varargin{:})];
+    end
+end
+txt=[txt,'}'];
+
+%%-------------------------------------------------------------------------
+function txt=matdata2ubjson(mat,level,varargin)
+if(isempty(mat))
+    txt='Z';
+    return;
+end
+if(size(mat,1)==1)
+    level=level-1;
+end
+type='';
+hasnegtive=(mat<0);
+if(isa(mat,'integer') || isinteger(mat) || (isfloat(mat) && all(mod(mat(:),1) == 0)))
+    if(isempty(hasnegtive))
+       if(max(mat(:))<=2^8)
+           type='U';
+       end
+    end
+    if(isempty(type))
+        % todo - need to consider negative ones separately
+        id= histc(abs(max(mat(:))),[0 2^7 2^15 2^31 2^63]);
+        if(isempty(find(id)))
+            error('high-precision data is not yet supported');
+        end
+        key='iIlL';
+	type=key(find(id));
+    end
+    txt=[I_a(mat(:),type,size(mat))];
+elseif(islogical(mat))
+    logicalval='FT';
+    if(numel(mat)==1)
+        txt=logicalval(mat+1);
+    else
+        txt=['[$U#' I_a(size(mat),'l') typecast(swapbytes(uint8(mat(:)')),'uint8')];
+    end
+else
+    if(numel(mat)==1)
+        txt=['[' D_(mat) ']'];
+    else
+        txt=D_a(mat(:),'D',size(mat));
+    end
+end
+
+%txt=regexprep(mat2str(mat),'\s+',',');
+%txt=regexprep(txt,';',sprintf('],['));
+% if(nargin>=2 && size(mat,1)>1)
+%     txt=regexprep(txt,'\[',[repmat(sprintf('\t'),1,level) '[']);
+% end
+if(any(isinf(mat(:))))
+    txt=regexprep(txt,'([-+]*)Inf',jsonopt('Inf','"$1_Inf_"',varargin{:}));
+end
+if(any(isnan(mat(:))))
+    txt=regexprep(txt,'NaN',jsonopt('NaN','"_NaN_"',varargin{:}));
+end
+
+%%-------------------------------------------------------------------------
+function newname=checkname(name,varargin)
+isunpack=jsonopt('UnpackHex',1,varargin{:});
+newname=name;
+if(isempty(regexp(name,'0x([0-9a-fA-F]+)_','once')))
+    return
+end
+if(isunpack)
+    isoct=jsonopt('IsOctave',0,varargin{:});
+    if(~isoct)
+        newname=regexprep(name,'(^x|_){1}0x([0-9a-fA-F]+)_','${native2unicode(hex2dec($2))}');
+    else
+        pos=regexp(name,'(^x|_){1}0x([0-9a-fA-F]+)_','start');
+        pend=regexp(name,'(^x|_){1}0x([0-9a-fA-F]+)_','end');
+        if(isempty(pos)) return; end
+        str0=name;
+        pos0=[0 pend(:)' length(name)];
+        newname='';
+        for i=1:length(pos)
+            newname=[newname str0(pos0(i)+1:pos(i)-1) char(hex2dec(str0(pos(i)+3:pend(i)-1)))];
+        end
+        if(pos(end)~=length(name))
+            newname=[newname str0(pos0(end-1)+1:pos0(end))];
+        end
+    end
+end
+%%-------------------------------------------------------------------------
+function val=S_(str)
+if(length(str)==1)
+  val=['C' str];
+else
+  val=['S' I_(int32(length(str))) str];
+end
+%%-------------------------------------------------------------------------
+function val=I_(num)
+if(~isinteger(num))
+    error('input is not an integer');
+end
+if(num>=0 && num<255)
+   val=['U' data2byte(swapbytes(cast(num,'uint8')),'uint8')];
+   return;
+end
+key='iIlL';
+cid={'int8','int16','int32','int64'};
+for i=1:4
+  if((num>0 && num<2^(i*8-1)) || (num<0 && num>=-2^(i*8-1)))
+    val=[key(i) data2byte(swapbytes(cast(num,cid{i})),'uint8')];
+    return;
+  end
+end
+error('unsupported integer');
+
+%%-------------------------------------------------------------------------
+function val=D_(num)
+if(~isfloat(num))
+    error('input is not a float');
+end
+
+if(isa(num,'single'))
+  val=['d' data2byte(num,'uint8')];
+else
+  val=['D' data2byte(num,'uint8')];
+end
+%%-------------------------------------------------------------------------
+function data=I_a(num,type,dim,format)
+id=find(ismember('iUIlL',type));
+
+if(id==0)
+  error('unsupported integer array');
+end
+
+% based on UBJSON specs, all integer types are stored in big endian format
+
+if(id==1)
+  data=data2byte(swapbytes(int8(num)),'uint8');
+  blen=1;
+elseif(id==2)
+  data=data2byte(swapbytes(uint8(num)),'uint8');
+  blen=1;
+elseif(id==3)
+  data=data2byte(swapbytes(int16(num)),'uint8');
+  blen=2;
+elseif(id==4)
+  data=data2byte(swapbytes(int32(num)),'uint8');
+  blen=4;
+elseif(id==5)
+  data=data2byte(swapbytes(int64(num)),'uint8');
+  blen=8;
+end
+
+if(nargin>=3 && length(dim)>=2 && prod(dim)~=dim(2))
+  format='opt';
+end
+if((nargin<4 || strcmp(format,'opt')) && numel(num)>1)
+  if(nargin>=3 && (length(dim)==1 || (length(dim)>=2 && prod(dim)~=dim(2))))
+      cid=I_(uint32(max(dim)));
+      data=['$' type '#' I_a(dim,cid(1)) data(:)'];
+  else
+      data=['$' type '#' I_(int32(numel(data)/blen)) data(:)'];
+  end
+  data=['[' data(:)'];
+else
+  data=reshape(data,blen,numel(data)/blen);
+  data(2:blen+1,:)=data;
+  data(1,:)=type;
+  data=data(:)';
+  data=['[' data(:)' ']'];
+end
+%%-------------------------------------------------------------------------
+function data=D_a(num,type,dim,format)
+id=find(ismember('dD',type));
+
+if(id==0)
+  error('unsupported float array');
+end
+
+if(id==1)
+  data=data2byte(single(num),'uint8');
+elseif(id==2)
+  data=data2byte(double(num),'uint8');
+end
+
+if(nargin>=3 && length(dim)>=2 && prod(dim)~=dim(2))
+  format='opt';
+end
+if((nargin<4 || strcmp(format,'opt')) && numel(num)>1)
+  if(nargin>=3 && (length(dim)==1 || (length(dim)>=2 && prod(dim)~=dim(2))))
+      cid=I_(uint32(max(dim)));
+      data=['$' type '#' I_a(dim,cid(1)) data(:)'];
+  else
+      data=['$' type '#' I_(int32(numel(data)/(id*4))) data(:)'];
+  end
+  data=['[' data];
+else
+  data=reshape(data,(id*4),length(data)/(id*4));
+  data(2:(id*4+1),:)=data;
+  data(1,:)=type;
+  data=data(:)';
+  data=['[' data(:)' ']'];
+end
+%%-------------------------------------------------------------------------
+function bytes=data2byte(varargin)
+bytes=typecast(varargin{:});
+bytes=bytes(:)';

+ 40 - 0
machine learning/machine-learning-ex2/ex2/lib/jsonlab/varargin2struct.m

@@ -0,0 +1,40 @@
+function opt=varargin2struct(varargin)
+%
+% opt=varargin2struct('param1',value1,'param2',value2,...)
+%   or
+% opt=varargin2struct(...,optstruct,...)
+%
+% convert a series of input parameters into a structure
+%
+% authors:Qianqian Fang (fangq<at> nmr.mgh.harvard.edu)
+% date: 2012/12/22
+%
+% input:
+%      'param', value: the input parameters should be pairs of a string and a value
+%       optstruct: if a parameter is a struct, the fields will be merged to the output struct
+%
+% output:
+%      opt: a struct where opt.param1=value1, opt.param2=value2 ...
+%
+% license:
+%     BSD, see LICENSE_BSD.txt files for details 
+%
+% -- this function is part of jsonlab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)
+%
+
+len=length(varargin);
+opt=struct;
+if(len==0) return; end
+i=1;
+while(i<=len)
+    if(isstruct(varargin{i}))
+        opt=mergestruct(opt,varargin{i});
+    elseif(ischar(varargin{i}) && i<len)
+        opt=setfield(opt,varargin{i},varargin{i+1});
+        i=i+1;
+    else
+        error('input must be in the form of ...,''name'',value,... pairs or structs');
+    end
+    i=i+1;
+end
+

+ 30 - 0
machine learning/machine-learning-ex2/ex2/lib/makeValidFieldName.m

@@ -0,0 +1,30 @@
+function str = makeValidFieldName(str)
+% From MATLAB doc: field names must begin with a letter, which may be
+% followed by any combination of letters, digits, and underscores.
+% Invalid characters will be converted to underscores, and the prefix
+% "x0x[Hex code]_" will be added if the first character is not a letter.
+    isoct=exist('OCTAVE_VERSION','builtin');
+    pos=regexp(str,'^[^A-Za-z]','once');
+    if(~isempty(pos))
+        if(~isoct)
+            str=regexprep(str,'^([^A-Za-z])','x0x${sprintf(''%X'',unicode2native($1))}_','once');
+        else
+            str=sprintf('x0x%X_%s',char(str(1)),str(2:end));
+        end
+    end
+    if(isempty(regexp(str,'[^0-9A-Za-z_]', 'once' ))) return;  end
+    if(~isoct)
+        str=regexprep(str,'([^0-9A-Za-z_])','_0x${sprintf(''%X'',unicode2native($1))}_');
+    else
+        pos=regexp(str,'[^0-9A-Za-z_]');
+        if(isempty(pos)) return; end
+        str0=str;
+        pos0=[0 pos(:)' length(str)];
+        str='';
+        for i=1:length(pos)
+            str=[str str0(pos0(i)+1:pos(i)-1) sprintf('_0x%X_',str0(pos(i)))];
+        end
+        if(pos(end)~=length(str))
+            str=[str str0(pos0(end-1)+1:pos0(end))];
+        end
+    end

+ 179 - 0
machine learning/machine-learning-ex2/ex2/lib/submitWithConfiguration.m

@@ -0,0 +1,179 @@
+function submitWithConfiguration(conf)
+  addpath('./lib/jsonlab');
+
+  parts = parts(conf);
+
+  fprintf('== Submitting solutions | %s...\n', conf.itemName);
+
+  tokenFile = 'token.mat';
+  if exist(tokenFile, 'file')
+    load(tokenFile);
+    [email token] = promptToken(email, token, tokenFile);
+  else
+    [email token] = promptToken('', '', tokenFile);
+  end
+
+  if isempty(token)
+    fprintf('!! Submission Cancelled\n');
+    return
+  end
+
+  try
+    response = submitParts(conf, email, token, parts);
+  catch
+    e = lasterror();
+    fprintf('\n!! Submission failed: %s\n', e.message);
+    fprintf('\n\nFunction: %s\nFileName: %s\nLineNumber: %d\n', ...
+      e.stack(1,1).name, e.stack(1,1).file, e.stack(1,1).line);
+    fprintf('\nPlease correct your code and resubmit.\n');
+    return
+  end
+
+  if isfield(response, 'errorMessage')
+    fprintf('!! Submission failed: %s\n', response.errorMessage);
+  elseif isfield(response, 'errorCode')
+    fprintf('!! Submission failed: %s\n', response.message);
+  else
+    showFeedback(parts, response);
+    save(tokenFile, 'email', 'token');
+  end
+end
+
+function [email token] = promptToken(email, existingToken, tokenFile)
+  if (~isempty(email) && ~isempty(existingToken))
+    prompt = sprintf( ...
+      'Use token from last successful submission (%s)? (Y/n): ', ...
+      email);
+    reenter = input(prompt, 's');
+
+    if (isempty(reenter) || reenter(1) == 'Y' || reenter(1) == 'y')
+      token = existingToken;
+      return;
+    else
+      delete(tokenFile);
+    end
+  end
+  email = input('Login (email address): ', 's');
+  token = input('Token: ', 's');
+end
+
+function isValid = isValidPartOptionIndex(partOptions, i)
+  isValid = (~isempty(i)) && (1 <= i) && (i <= numel(partOptions));
+end
+
+function response = submitParts(conf, email, token, parts)
+  body = makePostBody(conf, email, token, parts);
+  submissionUrl = submissionUrl();
+
+  responseBody = getResponse(submissionUrl, body);
+  jsonResponse = validateResponse(responseBody);
+  response = loadjson(jsonResponse);
+end
+
+function body = makePostBody(conf, email, token, parts)
+  bodyStruct.assignmentSlug = conf.assignmentSlug;
+  bodyStruct.submitterEmail = email;
+  bodyStruct.secret = token;
+  bodyStruct.parts = makePartsStruct(conf, parts);
+
+  opt.Compact = 1;
+  body = savejson('', bodyStruct, opt);
+end
+
+function partsStruct = makePartsStruct(conf, parts)
+  for part = parts
+    partId = part{:}.id;
+    fieldName = makeValidFieldName(partId);
+    outputStruct.output = conf.output(partId);
+    partsStruct.(fieldName) = outputStruct;
+  end
+end
+
+function [parts] = parts(conf)
+  parts = {};
+  for partArray = conf.partArrays
+    part.id = partArray{:}{1};
+    part.sourceFiles = partArray{:}{2};
+    part.name = partArray{:}{3};
+    parts{end + 1} = part;
+  end
+end
+
+function showFeedback(parts, response)
+  fprintf('== \n');
+  fprintf('== %43s | %9s | %-s\n', 'Part Name', 'Score', 'Feedback');
+  fprintf('== %43s | %9s | %-s\n', '---------', '-----', '--------');
+  for part = parts
+    score = '';
+    partFeedback = '';
+    partFeedback = response.partFeedbacks.(makeValidFieldName(part{:}.id));
+    partEvaluation = response.partEvaluations.(makeValidFieldName(part{:}.id));
+    score = sprintf('%d / %3d', partEvaluation.score, partEvaluation.maxScore);
+    fprintf('== %43s | %9s | %-s\n', part{:}.name, score, partFeedback);
+  end
+  evaluation = response.evaluation;
+  totalScore = sprintf('%d / %d', evaluation.score, evaluation.maxScore);
+  fprintf('==                                   --------------------------------\n');
+  fprintf('== %43s | %9s | %-s\n', '', totalScore, '');
+  fprintf('== \n');
+end
+
+% use urlread or curl to send submit results to the grader and get a response
+function response = getResponse(url, body)
+% try using urlread() and a secure connection
+  params = {'jsonBody', body};
+  [response, success] = urlread(url, 'post', params);
+
+  if (success == 0)
+    % urlread didn't work, try curl & the peer certificate patch
+    if ispc
+      % testing note: use 'jsonBody =' for a test case
+      json_command = sprintf('echo jsonBody=%s | curl -k -X POST -d @- %s', body, url);
+    else
+      % it's linux/OS X, so use the other form
+      json_command = sprintf('echo ''jsonBody=%s'' | curl -k -X POST -d @- %s', body, url);
+    end
+    % get the response body for the peer certificate patch method
+    [code, response] = system(json_command);
+    % test the success code
+    if (code ~= 0)
+      fprintf('[error] submission with curl() was not successful\n');
+    end
+  end
+end
+
+% validate the grader's response
+function response = validateResponse(resp)
+  % test if the response is json or an HTML page
+  isJson = length(resp) > 0 && resp(1) == '{';
+  isHtml = findstr(lower(resp), '<html');
+
+  if (isJson)
+    response = resp;
+  elseif (isHtml)
+    % the response is html, so it's probably an error message
+    printHTMLContents(resp);
+    error('Grader response is an HTML message');
+  else
+    error('Grader sent no response');
+  end
+end
+
+% parse a HTML response and print it's contents
+function printHTMLContents(response)
+  strippedResponse = regexprep(response, '<[^>]+>', ' ');
+  strippedResponse = regexprep(strippedResponse, '[\t ]+', ' ');
+  fprintf(strippedResponse);
+end
+
+
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% Service configuration
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+function submissionUrl = submissionUrl()
+  submissionUrl = 'https://www-origin.coursera.org/api/onDemandProgrammingImmediateFormSubmissions.v1';
+end

+ 21 - 0
machine learning/machine-learning-ex2/ex2/mapFeature.m

@@ -0,0 +1,21 @@
+function out = mapFeature(X1, X2)
+% MAPFEATURE Feature mapping function to polynomial features
+%
+%   MAPFEATURE(X1, X2) maps the two input features
+%   to quadratic features used in the regularization exercise.
+%
+%   Returns a new feature array with more features, comprising of 
+%   X1, X2, X1.^2, X2.^2, X1*X2, X1*X2.^2, etc..
+%
+%   Inputs X1, X2 must be the same size
+%
+
+degree = 6;
+out = ones(size(X1(:,1)));
+for i = 1:degree
+    for j = 0:i
+        out(:, end+1) = (X1.^(i-j)).*(X2.^j);
+    end
+end
+
+end

+ 91 - 0
machine learning/machine-learning-ex2/ex2/myex2.m

@@ -0,0 +1,91 @@
+%% Machine Learning Online Class - Exercise 2: Logistic Regression
+%
+%  Instructions
+%  ------------
+%
+%  This file contains code that helps you get started on the second part
+%  of the exercise which covers regularization with logistic regression.
+%
+%  You will need to complete the following functions in this exericse:
+%
+%     sigmoid.m
+%     costFunction.m
+%     predict.m
+%     costFunctionReg.m
+%
+%  For this exercise, you will not need to change any code in this file,
+%  or any other files other than those mentioned above.
+%
+
+%% Initialization
+clear ; close all; clc
+
+%% Load Data
+%  The first two columns contains the X values and the third column
+%  contains the label (y).
+
+data = load('ex2data2.txt');
+X = data(:, [1, 2]); y = data(:, 3);
+
+plotData(X, y);
+
+% Put some labels
+hold on;
+
+% Labels and Legend
+xlabel('Microchip Test 1')
+ylabel('Microchip Test 2')
+
+% Specified in plot order
+legend('y = 1', 'y = 0')
+hold off;
+
+
+%% =========== Part 1: Regularized Logistic Regression ============
+%  In this part, you are given a dataset with data points that are not
+%  linearly separable. However, you would still like to use logistic
+%  regression to classify the data points.
+%
+%  To do so, you introduce more features to use -- in particular, you add
+%  polynomial features to our data matrix (similar to polynomial
+%  regression).
+%
+
+% Add Polynomial Features
+
+% Note that mapFeature also adds a column of ones for us, so the intercept
+% term is handled
+X = mapFeature(X(:,1), X(:,2));
+
+% Initialize fitting parameters
+initial_theta = zeros(size(X, 2), 1);
+
+% Set regularization parameter lambda to 1
+lambda = 1;
+
+% Compute and display initial cost and gradient for regularized logistic
+% regression
+[cost, grad] = costFunctionReg(initial_theta, X, y, lambda);
+
+fprintf('Cost at initial theta (zeros): %f\n', cost);
+fprintf('Expected cost (approx): 0.693\n');
+fprintf('Gradient at initial theta (zeros) - first five values only:\n');
+fprintf(' %f \n', grad(1:5));
+fprintf('Expected gradients (approx) - first five values only:\n');
+fprintf(' 0.0085\n 0.0188\n 0.0001\n 0.0503\n 0.0115\n');
+
+fprintf('\nProgram paused. Press enter to continue.\n');
+
+% Compute and display cost and gradient
+% with all-ones theta and lambda = 10
+test_theta = ones(size(X,2),1);
+[cost, grad] = costFunctionReg(test_theta, X, y, 10);
+
+fprintf('\nCost at test theta (with lambda = 10): %f\n', cost);
+fprintf('Expected cost (approx): 3.16\n');
+fprintf('Gradient at test theta - first five values only:\n');
+fprintf(' %f \n', grad(1:5));
+fprintf('Expected gradients (approx) - first five values only:\n');
+fprintf(' 0.3460\n 0.1614\n 0.1948\n 0.2269\n 0.0922\n');
+
+fprintf('\nProgram paused. Press enter to continue.\n');

+ 39 - 0
machine learning/machine-learning-ex2/ex2/myex22.m

@@ -0,0 +1,39 @@
+
+
+clear ; close all; clc
+
+%% Load Data
+%  The first two columns contains the X values and the third column
+%  contains the label (y).
+
+data = load('ex2data2.txt');
+
+X = data(:, [1, 2]); y = data(:, 3);
+
+
+X = mapFeature(X(:,1), X(:,2));
+
+% Initialize fitting parameters
+
+% Compute and display initial cost and gradient for regularized logistic
+% regression
+
+%test_theta = ones(size(X,2),1);
+%[cost, grad] = costFunctionReg(test_theta, X, y, 10);
+
+
+a = randi(10,5,5)
+b = randi(9,5,1)
+a*b
+
+[zeros(rows(a), 1) a(:, 2:end)];
+
+c = [a(:,1) [zeros(rows(a), columns(a) -1)]] 
+c * b
+
+d = [zeros(rows(a), 1) [a(:,2:end)]]
+d * b
+
+e = (c*b) + (d*b) - (a*b)
+
+

BIN
machine learning/machine-learning-ex2/ex2/octave-workspace


+ 33 - 0
machine learning/machine-learning-ex2/ex2/plotData.m

@@ -0,0 +1,33 @@
+function plotData(X, y)
+%PLOTDATA Plots the data points X and y into a new figure 
+%   PLOTDATA(x,y) plots the data points with + for the positive examples
+%   and o for the negative examples. X is assumed to be a Mx2 matrix.
+
+% Create New Figure
+figure; hold on;
+
+% ====================== YOUR CODE HERE ======================
+% Instructions: Plot the positive and negative examples on a
+%               2D plot, using the option 'k+' for the positive
+%               examples and 'ko' for the negative examples.
+%
+
+one = find(y == 1);
+zero = find(y == 0);
+scatter(X(one,1), X(one,2), 'b', '+', 'filled');
+scatter(X(zero,1), X(zero,2), 'r', 'o', 'filled');
+
+
+
+
+
+
+
+
+% =========================================================================
+
+
+
+hold off;
+
+end

+ 48 - 0
machine learning/machine-learning-ex2/ex2/plotDecisionBoundary.m

@@ -0,0 +1,48 @@
+function plotDecisionBoundary(theta, X, y)
+%PLOTDECISIONBOUNDARY Plots the data points X and y into a new figure with
+%the decision boundary defined by theta
+%   PLOTDECISIONBOUNDARY(theta, X,y) plots the data points with + for the 
+%   positive examples and o for the negative examples. X is assumed to be 
+%   a either 
+%   1) Mx3 matrix, where the first column is an all-ones column for the 
+%      intercept.
+%   2) MxN, N>3 matrix, where the first column is all-ones
+
+% Plot Data
+plotData(X(:,2:3), y);
+hold on
+
+if size(X, 2) <= 3
+    % Only need 2 points to define a line, so choose two endpoints
+    plot_x = [min(X(:,2))-2,  max(X(:,2))+2];
+
+    % Calculate the decision boundary line
+    plot_y = (-1./theta(3)).*(theta(2).*plot_x + theta(1));
+
+    % Plot, and adjust axes for better viewing
+    plot(plot_x, plot_y)
+    
+    % Legend, specific for the exercise
+    legend('Admitted', 'Not admitted', 'Decision Boundary')
+    axis([30, 100, 30, 100])
+else
+    % Here is the grid range
+    u = linspace(-1, 1.5, 50);
+    v = linspace(-1, 1.5, 50);
+
+    z = zeros(length(u), length(v));
+    % Evaluate z = theta*x over the grid
+    for i = 1:length(u)
+        for j = 1:length(v)
+            z(i,j) = mapFeature(u(i), v(j))*theta;
+        end
+    end
+    z = z'; % important to transpose z before calling contour
+
+    % Plot z = 0
+    % Notice you need to specify the range [0, 0]
+    contour(u, v, z, [0, 0], 'LineWidth', 2)
+end
+hold off
+
+end

+ 27 - 0
machine learning/machine-learning-ex2/ex2/predict.m

@@ -0,0 +1,27 @@
+function p = predict(theta, X)
+%PREDICT Predict whether the label is 0 or 1 using learned logistic 
+%regression parameters theta
+%   p = PREDICT(theta, X) computes the predictions for X using a 
+%   threshold at 0.5 (i.e., if sigmoid(theta'*x) >= 0.5, predict 1)
+
+m = size(X, 1); % Number of training examples
+
+% You need to return the following variables correctly
+p = zeros(m, 1);
+
+% ====================== YOUR CODE HERE ======================
+% Instructions: Complete the following code to make predictions using
+%               your learned logistic regression parameters. 
+%               You should set p to a vector of 0's and 1's
+%
+p = ifelse (sigmoid(X * theta) >= 0.5, 1, 0);
+
+
+
+
+
+
+% =========================================================================
+
+
+end

+ 18 - 0
machine learning/machine-learning-ex2/ex2/sigmoid.m

@@ -0,0 +1,18 @@
+function g = sigmoid(z)
+%SIGMOID Compute sigmoid function
+%   g = SIGMOID(z) computes the sigmoid of z.
+
+% You need to return the following variables correctly 
+g = zeros(size(z));
+
+% ====================== YOUR CODE HERE ======================
+% Instructions: Compute the sigmoid of each value of z (z can be a matrix,
+%               vector or scalar).
+g = 1 ./ (1 + exp(-z));
+
+
+
+
+% =============================================================
+
+end

+ 62 - 0
machine learning/machine-learning-ex2/ex2/submit.m

@@ -0,0 +1,62 @@
+function submit()
+  addpath('./lib');
+
+  conf.assignmentSlug = 'logistic-regression';
+  conf.itemName = 'Logistic Regression';
+  conf.partArrays = { ...
+    { ...
+      '1', ...
+      { 'sigmoid.m' }, ...
+      'Sigmoid Function', ...
+    }, ...
+    { ...
+      '2', ...
+      { 'costFunction.m' }, ...
+      'Logistic Regression Cost', ...
+    }, ...
+    { ...
+      '3', ...
+      { 'costFunction.m' }, ...
+      'Logistic Regression Gradient', ...
+    }, ...
+    { ...
+      '4', ...
+      { 'predict.m' }, ...
+      'Predict', ...
+    }, ...
+    { ...
+      '5', ...
+      { 'costFunctionReg.m' }, ...
+      'Regularized Logistic Regression Cost', ...
+    }, ...
+    { ...
+      '6', ...
+      { 'costFunctionReg.m' }, ...
+      'Regularized Logistic Regression Gradient', ...
+    }, ...
+  };
+  conf.output = @output;
+
+  submitWithConfiguration(conf);
+end
+
+function out = output(partId, auxstring)
+  % Random Test Cases
+  X = [ones(20,1) (exp(1) * sin(1:1:20))' (exp(0.5) * cos(1:1:20))'];
+  y = sin(X(:,1) + X(:,2)) > 0;
+  if partId == '1'
+    out = sprintf('%0.5f ', sigmoid(X));
+  elseif partId == '2'
+    out = sprintf('%0.5f ', costFunction([0.25 0.5 -0.5]', X, y));
+  elseif partId == '3'
+    [cost, grad] = costFunction([0.25 0.5 -0.5]', X, y);
+    out = sprintf('%0.5f ', grad);
+  elseif partId == '4'
+    out = sprintf('%0.5f ', predict([0.25 0.5 -0.5]', X));
+  elseif partId == '5'
+    out = sprintf('%0.5f ', costFunctionReg([0.25 0.5 -0.5]', X, y, 0.1));
+  elseif partId == '6'
+    [cost, grad] = costFunctionReg([0.25 0.5 -0.5]', X, y, 0.1);
+    out = sprintf('%0.5f ', grad);
+  end 
+end

+ 15 - 0
machine learning/machine-learning-ex2/ex2/token.mat

@@ -0,0 +1,15 @@
+# Created by Octave 4.2.2, Sat Nov 10 15:05:19 2018 HKT <astron@astron>
+# name: email
+# type: sq_string
+# elements: 1
+# length: 20
+larry1chan@gmail.com
+
+
+# name: token
+# type: sq_string
+# elements: 1
+# length: 16
+RYnvZ9qKu0jb7CJ2
+
+

BIN
machine learning/machine-learning-ex3/ex3.pdf


+ 59 - 0
machine learning/machine-learning-ex3/ex3/displayData.m

@@ -0,0 +1,59 @@
+function [h, display_array] = displayData(X, example_width)
+%DISPLAYDATA Display 2D data in a nice grid
+%   [h, display_array] = DISPLAYDATA(X, example_width) displays 2D data
+%   stored in X in a nice grid. It returns the figure handle h and the 
+%   displayed array if requested.
+
+% Set example_width automatically if not passed in
+if ~exist('example_width', 'var') || isempty(example_width) 
+	example_width = round(sqrt(size(X, 2)));
+end
+
+% Gray Image
+colormap(gray);
+
+% Compute rows, cols
+[m n] = size(X);
+example_height = (n / example_width);
+
+% Compute number of items to display
+display_rows = floor(sqrt(m));
+display_cols = ceil(m / display_rows);
+
+% Between images padding
+pad = 1;
+
+% Setup blank display
+display_array = - ones(pad + display_rows * (example_height + pad), ...
+                       pad + display_cols * (example_width + pad));
+
+% Copy each example into a patch on the display array
+curr_ex = 1;
+for j = 1:display_rows
+	for i = 1:display_cols
+		if curr_ex > m, 
+			break; 
+		end
+		% Copy the patch
+		
+		% Get the max value of the patch
+		max_val = max(abs(X(curr_ex, :)));
+		display_array(pad + (j - 1) * (example_height + pad) + (1:example_height), ...
+		              pad + (i - 1) * (example_width + pad) + (1:example_width)) = ...
+						reshape(X(curr_ex, :), example_height, example_width) / max_val;
+		curr_ex = curr_ex + 1;
+	end
+	if curr_ex > m, 
+		break; 
+	end
+end
+
+% Display Image
+h = imagesc(display_array, [-1 1]);
+
+% Do not show axis
+axis image off
+
+drawnow;
+
+end

+ 88 - 0
machine learning/machine-learning-ex3/ex3/ex3.m

@@ -0,0 +1,88 @@
+%% Machine Learning Online Class - Exercise 3 | Part 1: One-vs-all
+
+%  Instructions
+%  ------------
+%
+%  This file contains code that helps you get started on the
+%  linear exercise. You will need to complete the following functions
+%  in this exericse:
+%
+%     lrCostFunction.m (logistic regression cost function)
+%     oneVsAll.m
+%     predictOneVsAll.m
+%     predict.m
+%
+%  For this exercise, you will not need to change any code in this file,
+%  or any other files other than those mentioned above.
+%
+
+%% Initialization
+clear ; close all; clc
+
+%% Setup the parameters you will use for this part of the exercise
+input_layer_size  = 400;  % 20x20 Input Images of Digits
+num_labels = 10;          % 10 labels, from 1 to 10
+                          % (note that we have mapped "0" to label 10)
+
+%% =========== Part 1: Loading and Visualizing Data =============
+%  We start the exercise by first loading and visualizing the dataset.
+%  You will be working with a dataset that contains handwritten digits.
+%
+
+% Load Training Data
+fprintf('Loading and Visualizing Data ...\n')
+
+load('ex3data1.mat'); % training data stored in arrays X, y
+m = size(X, 1);
+
+% Randomly select 100 data points to display
+rand_indices = randperm(m);
+sel = X(rand_indices(1:100), :);
+
+displayData(sel);
+
+fprintf('Program paused. Press enter to continue.\n');
+pause;
+
+%% ============ Part 2a: Vectorize Logistic Regression ============
+%  In this part of the exercise, you will reuse your logistic regression
+%  code from the last exercise. You task here is to make sure that your
+%  regularized logistic regression implementation is vectorized. After
+%  that, you will implement one-vs-all classification for the handwritten
+%  digit dataset.
+%
+
+% Test case for lrCostFunction
+fprintf('\nTesting lrCostFunction() with regularization');
+
+theta_t = [-2; -1; 1; 2];
+X_t = [ones(5,1) reshape(1:15,5,3)/10];
+y_t = ([1;0;1;0;1] >= 0.5);
+lambda_t = 3;
+[J grad] = lrCostFunction(theta_t, X_t, y_t, lambda_t);
+
+fprintf('\nCost: %f\n', J);
+fprintf('Expected cost: 2.534819\n');
+fprintf('Gradients:\n');
+fprintf(' %f \n', grad);
+fprintf('Expected gradients:\n');
+fprintf(' 0.146561\n -0.548558\n 0.724722\n 1.398003\n');
+
+fprintf('Program paused. Press enter to continue.\n');
+pause;
+%% ============ Part 2b: One-vs-All Training ============
+fprintf('\nTraining One-vs-All Logistic Regression...\n')
+
+lambda = 0.1;
+[all_theta] = oneVsAll(X, y, num_labels, lambda);
+
+fprintf('Program paused. Press enter to continue.\n');
+pause;
+
+
+%% ================ Part 3: Predict for One-Vs-All ================
+
+pred = predictOneVsAll(all_theta, X);
+
+fprintf('\nTraining Set Accuracy: %f\n', mean(double(pred == y)) * 100);
+

+ 90 - 0
machine learning/machine-learning-ex3/ex3/ex3_nn.m

@@ -0,0 +1,90 @@
+%% Machine Learning Online Class - Exercise 3 | Part 2: Neural Networks
+
+%  Instructions
+%  ------------
+% 
+%  This file contains code that helps you get started on the
+%  linear exercise. You will need to complete the following functions 
+%  in this exericse:
+%
+%     lrCostFunction.m (logistic regression cost function)
+%     oneVsAll.m
+%     predictOneVsAll.m
+%     predict.m
+%
+%  For this exercise, you will not need to change any code in this file,
+%  or any other files other than those mentioned above.
+%
+
+%% Initialization
+clear ; close all; clc
+
+%% Setup the parameters you will use for this exercise
+input_layer_size  = 400;  % 20x20 Input Images of Digits
+hidden_layer_size = 25;   % 25 hidden units
+num_labels = 10;          % 10 labels, from 1 to 10   
+                          % (note that we have mapped "0" to label 10)
+
+%% =========== Part 1: Loading and Visualizing Data =============
+%  We start the exercise by first loading and visualizing the dataset. 
+%  You will be working with a dataset that contains handwritten digits.
+%
+
+% Load Training Data
+fprintf('Loading and Visualizing Data ...\n')
+
+load('ex3data1.mat');
+m = size(X, 1);
+
+% Randomly select 100 data points to display
+sel = randperm(size(X, 1));
+sel = sel(1:100);
+
+displayData(X(sel, :));
+
+fprintf('Program paused. Press enter to continue.\n');
+pause;
+
+%% ================ Part 2: Loading Pameters ================
+% In this part of the exercise, we load some pre-initialized 
+% neural network parameters.
+
+fprintf('\nLoading Saved Neural Network Parameters ...\n')
+
+% Load the weights into variables Theta1 and Theta2
+load('ex3weights.mat');
+
+%% ================= Part 3: Implement Predict =================
+%  After training the neural network, we would like to use it to predict
+%  the labels. You will now implement the "predict" function to use the
+%  neural network to predict the labels of the training set. This lets
+%  you compute the training set accuracy.
+
+pred = predict(Theta1, Theta2, X);
+
+fprintf('\nTraining Set Accuracy: %f\n', mean(double(pred == y)) * 100);
+
+fprintf('Program paused. Press enter to continue.\n');
+pause;
+
+%  To give you an idea of the network's output, you can also run
+%  through the examples one at the a time to see what it is predicting.
+
+%  Randomly permute examples
+rp = randperm(m);
+
+for i = 1:m
+    % Display 
+    fprintf('\nDisplaying Example Image\n');
+    displayData(X(rp(i), :));
+
+    pred = predict(Theta1, Theta2, X(rp(i),:));
+    fprintf('\nNeural Network Prediction: %d (digit %d)\n', pred, mod(pred, 10));
+    
+    % Pause with quit option
+    s = input('Paused - press enter to continue, q to exit:','s');
+    if s == 'q'
+      break
+    end
+end
+

BIN
machine learning/machine-learning-ex3/ex3/ex3data1.mat


BIN
machine learning/machine-learning-ex3/ex3/ex3weights.mat


+ 175 - 0
machine learning/machine-learning-ex3/ex3/fmincg.m

@@ -0,0 +1,175 @@
+function [X, fX, i] = fmincg(f, X, options, P1, P2, P3, P4, P5)
+% Minimize a continuous differentialble multivariate function. Starting point
+% is given by "X" (D by 1), and the function named in the string "f", must
+% return a function value and a vector of partial derivatives. The Polack-
+% Ribiere flavour of conjugate gradients is used to compute search directions,
+% and a line search using quadratic and cubic polynomial approximations and the
+% Wolfe-Powell stopping criteria is used together with the slope ratio method
+% for guessing initial step sizes. Additionally a bunch of checks are made to
+% make sure that exploration is taking place and that extrapolation will not
+% be unboundedly large. The "length" gives the length of the run: if it is
+% positive, it gives the maximum number of line searches, if negative its
+% absolute gives the maximum allowed number of function evaluations. You can
+% (optionally) give "length" a second component, which will indicate the
+% reduction in function value to be expected in the first line-search (defaults
+% to 1.0). The function returns when either its length is up, or if no further
+% progress can be made (ie, we are at a minimum, or so close that due to
+% numerical problems, we cannot get any closer). If the function terminates
+% within a few iterations, it could be an indication that the function value
+% and derivatives are not consistent (ie, there may be a bug in the
+% implementation of your "f" function). The function returns the found
+% solution "X", a vector of function values "fX" indicating the progress made
+% and "i" the number of iterations (line searches or function evaluations,
+% depending on the sign of "length") used.
+%
+% Usage: [X, fX, i] = fmincg(f, X, options, P1, P2, P3, P4, P5)
+%
+% See also: checkgrad 
+%
+% Copyright (C) 2001 and 2002 by Carl Edward Rasmussen. Date 2002-02-13
+%
+%
+% (C) Copyright 1999, 2000 & 2001, Carl Edward Rasmussen
+% 
+% Permission is granted for anyone to copy, use, or modify these
+% programs and accompanying documents for purposes of research or
+% education, provided this copyright notice is retained, and note is
+% made of any changes that have been made.
+% 
+% These programs and documents are distributed without any warranty,
+% express or implied.  As the programs were written for research
+% purposes only, they have not been tested to the degree that would be
+% advisable in any important application.  All use of these programs is
+% entirely at the user's own risk.
+%
+% [ml-class] Changes Made:
+% 1) Function name and argument specifications
+% 2) Output display
+%
+
+% Read options
+if exist('options', 'var') && ~isempty(options) && isfield(options, 'MaxIter')
+    length = options.MaxIter;
+else
+    length = 100;
+end
+
+
+RHO = 0.01;                            % a bunch of constants for line searches
+SIG = 0.5;       % RHO and SIG are the constants in the Wolfe-Powell conditions
+INT = 0.1;    % don't reevaluate within 0.1 of the limit of the current bracket
+EXT = 3.0;                    % extrapolate maximum 3 times the current bracket
+MAX = 20;                         % max 20 function evaluations per line search
+RATIO = 100;                                      % maximum allowed slope ratio
+
+argstr = ['feval(f, X'];                      % compose string used to call function
+for i = 1:(nargin - 3)
+  argstr = [argstr, ',P', int2str(i)];
+end
+argstr = [argstr, ')'];
+
+if max(size(length)) == 2, red=length(2); length=length(1); else red=1; end
+S=['Iteration '];
+
+i = 0;                                            % zero the run length counter
+ls_failed = 0;                             % no previous line search has failed
+fX = [];
+[f1 df1] = eval(argstr);                      % get function value and gradient
+i = i + (length<0);                                            % count epochs?!
+s = -df1;                                        % search direction is steepest
+d1 = -s'*s;                                                 % this is the slope
+z1 = red/(1-d1);                                  % initial step is red/(|s|+1)
+
+while i < abs(length)                                      % while not finished
+  i = i + (length>0);                                      % count iterations?!
+
+  X0 = X; f0 = f1; df0 = df1;                   % make a copy of current values
+  X = X + z1*s;                                             % begin line search
+  [f2 df2] = eval(argstr);
+  i = i + (length<0);                                          % count epochs?!
+  d2 = df2'*s;
+  f3 = f1; d3 = d1; z3 = -z1;             % initialize point 3 equal to point 1
+  if length>0, M = MAX; else M = min(MAX, -length-i); end
+  success = 0; limit = -1;                     % initialize quanteties
+  while 1
+    while ((f2 > f1+z1*RHO*d1) || (d2 > -SIG*d1)) && (M > 0) 
+      limit = z1;                                         % tighten the bracket
+      if f2 > f1
+        z2 = z3 - (0.5*d3*z3*z3)/(d3*z3+f2-f3);                 % quadratic fit
+      else
+        A = 6*(f2-f3)/z3+3*(d2+d3);                                 % cubic fit
+        B = 3*(f3-f2)-z3*(d3+2*d2);
+        z2 = (sqrt(B*B-A*d2*z3*z3)-B)/A;       % numerical error possible - ok!
+      end
+      if isnan(z2) || isinf(z2)
+        z2 = z3/2;                  % if we had a numerical problem then bisect
+      end
+      z2 = max(min(z2, INT*z3),(1-INT)*z3);  % don't accept too close to limits
+      z1 = z1 + z2;                                           % update the step
+      X = X + z2*s;
+      [f2 df2] = eval(argstr);
+      M = M - 1; i = i + (length<0);                           % count epochs?!
+      d2 = df2'*s;
+      z3 = z3-z2;                    % z3 is now relative to the location of z2
+    end
+    if f2 > f1+z1*RHO*d1 || d2 > -SIG*d1
+      break;                                                % this is a failure
+    elseif d2 > SIG*d1
+      success = 1; break;                                             % success
+    elseif M == 0
+      break;                                                          % failure
+    end
+    A = 6*(f2-f3)/z3+3*(d2+d3);                      % make cubic extrapolation
+    B = 3*(f3-f2)-z3*(d3+2*d2);
+    z2 = -d2*z3*z3/(B+sqrt(B*B-A*d2*z3*z3));        % num. error possible - ok!
+    if ~isreal(z2) || isnan(z2) || isinf(z2) || z2 < 0 % num prob or wrong sign?
+      if limit < -0.5                               % if we have no upper limit
+        z2 = z1 * (EXT-1);                 % the extrapolate the maximum amount
+      else
+        z2 = (limit-z1)/2;                                   % otherwise bisect
+      end
+    elseif (limit > -0.5) && (z2+z1 > limit)         % extraplation beyond max?
+      z2 = (limit-z1)/2;                                               % bisect
+    elseif (limit < -0.5) && (z2+z1 > z1*EXT)       % extrapolation beyond limit
+      z2 = z1*(EXT-1.0);                           % set to extrapolation limit
+    elseif z2 < -z3*INT
+      z2 = -z3*INT;
+    elseif (limit > -0.5) && (z2 < (limit-z1)*(1.0-INT))  % too close to limit?
+      z2 = (limit-z1)*(1.0-INT);
+    end
+    f3 = f2; d3 = d2; z3 = -z2;                  % set point 3 equal to point 2
+    z1 = z1 + z2; X = X + z2*s;                      % update current estimates
+    [f2 df2] = eval(argstr);
+    M = M - 1; i = i + (length<0);                             % count epochs?!
+    d2 = df2'*s;
+  end                                                      % end of line search
+
+  if success                                         % if line search succeeded
+    f1 = f2; fX = [fX' f1]';
+    fprintf('%s %4i | Cost: %4.6e\r', S, i, f1);
+    s = (df2'*df2-df1'*df2)/(df1'*df1)*s - df2;      % Polack-Ribiere direction
+    tmp = df1; df1 = df2; df2 = tmp;                         % swap derivatives
+    d2 = df1'*s;
+    if d2 > 0                                      % new slope must be negative
+      s = -df1;                              % otherwise use steepest direction
+      d2 = -s'*s;    
+    end
+    z1 = z1 * min(RATIO, d1/(d2-realmin));          % slope ratio but max RATIO
+    d1 = d2;
+    ls_failed = 0;                              % this line search did not fail
+  else
+    X = X0; f1 = f0; df1 = df0;  % restore point from before failed line search
+    if ls_failed || i > abs(length)          % line search failed twice in a row
+      break;                             % or we ran out of time, so we give up
+    end
+    tmp = df1; df1 = df2; df2 = tmp;                         % swap derivatives
+    s = -df1;                                                    % try steepest
+    d1 = -s'*s;
+    z1 = 1/(1-d1);                     
+    ls_failed = 1;                                    % this line search failed
+  end
+  if exist('OCTAVE_VERSION')
+    fflush(stdout);
+  end
+end
+fprintf('\n');

+ 41 - 0
machine learning/machine-learning-ex3/ex3/lib/jsonlab/AUTHORS.txt

@@ -0,0 +1,41 @@
+The author of "jsonlab" toolbox is Qianqian Fang. Qianqian
+is currently an Assistant Professor at Massachusetts General Hospital, 
+Harvard Medical School.
+
+Address: Martinos Center for Biomedical Imaging, 
+         Massachusetts General Hospital, 
+         Harvard Medical School
+         Bldg 149, 13th St, Charlestown, MA 02129, USA
+URL: http://nmr.mgh.harvard.edu/~fangq/
+Email: <fangq at nmr.mgh.harvard.edu> or <fangqq at gmail.com>
+
+
+The script loadjson.m was built upon previous works by
+
+- Nedialko Krouchev: http://www.mathworks.com/matlabcentral/fileexchange/25713
+       date: 2009/11/02
+- François Glineur: http://www.mathworks.com/matlabcentral/fileexchange/23393
+       date: 2009/03/22
+- Joel Feenstra: http://www.mathworks.com/matlabcentral/fileexchange/20565
+       date: 2008/07/03
+
+
+This toolbox contains patches submitted by the following contributors:
+
+- Blake Johnson <bjohnso at bbn.com>
+  part of revision 341
+
+- Niclas Borlin <Niclas.Borlin at cs.umu.se>
+  various fixes in revision 394, including
+  - loadjson crashes for all-zero sparse matrix.
+  - loadjson crashes for empty sparse matrix.
+  - Non-zero size of 0-by-N and N-by-0 empty matrices is lost after savejson/loadjson.
+  - loadjson crashes for sparse real column vector.
+  - loadjson crashes for sparse complex column vector.
+  - Data is corrupted by savejson for sparse real row vector.
+  - savejson crashes for sparse complex row vector. 
+
+- Yul Kang <yul.kang.on at gmail.com>
+  patches for svn revision 415.
+  - savejson saves an empty cell array as [] instead of null
+  - loadjson differentiates an empty struct from an empty array

+ 74 - 0
machine learning/machine-learning-ex3/ex3/lib/jsonlab/ChangeLog.txt

@@ -0,0 +1,74 @@
+============================================================================
+
+   JSONlab - a toolbox to encode/decode JSON/UBJSON files in MATLAB/Octave
+
+----------------------------------------------------------------------------
+
+JSONlab ChangeLog (key features marked by *):
+
+== JSONlab 1.0 (codename: Optimus - Final), FangQ <fangq (at) nmr.mgh.harvard.edu> ==
+
+ 2015/01/02 polish help info for all major functions, update examples, finalize 1.0
+ 2014/12/19 fix a bug to strictly respect NoRowBracket in savejson
+
+== JSONlab 1.0.0-RC2 (codename: Optimus - RC2), FangQ <fangq (at) nmr.mgh.harvard.edu> ==
+
+ 2014/11/22 show progress bar in loadjson ('ShowProgress') 
+ 2014/11/17 add Compact option in savejson to output compact JSON format ('Compact')
+ 2014/11/17 add FastArrayParser in loadjson to specify fast parser applicable levels
+ 2014/09/18 start official github mirror: https://github.com/fangq/jsonlab
+
+== JSONlab 1.0.0-RC1 (codename: Optimus - RC1), FangQ <fangq (at) nmr.mgh.harvard.edu> ==
+
+ 2014/09/17  fix several compatibility issues when running on octave versions 3.2-3.8
+ 2014/09/17  support 2D cell and struct arrays in both savejson and saveubjson
+ 2014/08/04  escape special characters in a JSON string
+ 2014/02/16  fix a bug when saving ubjson files
+
+== JSONlab 0.9.9 (codename: Optimus - beta), FangQ <fangq (at) nmr.mgh.harvard.edu> ==
+
+ 2014/01/22  use binary read and write in saveubjson and loadubjson
+
+== JSONlab 0.9.8-1 (codename: Optimus - alpha update 1), FangQ <fangq (at) nmr.mgh.harvard.edu> ==
+
+ 2013/10/07 better round-trip conservation for empty arrays and structs (patch submitted by Yul Kang)
+
+== JSONlab 0.9.8 (codename: Optimus - alpha), FangQ <fangq (at) nmr.mgh.harvard.edu> ==
+ 2013/08/23 *universal Binary JSON (UBJSON) support, including both saveubjson and loadubjson
+
+== JSONlab 0.9.1 (codename: Rodimus, update 1), FangQ <fangq (at) nmr.mgh.harvard.edu> ==
+ 2012/12/18 *handling of various empty and sparse matrices (fixes submitted by Niclas Borlin)
+
+== JSONlab 0.9.0 (codename: Rodimus), FangQ <fangq (at) nmr.mgh.harvard.edu> ==
+
+ 2012/06/17 *new format for an invalid leading char, unpacking hex code in savejson
+ 2012/06/01  support JSONP in savejson
+ 2012/05/25  fix the empty cell bug (reported by Cyril Davin)
+ 2012/04/05  savejson can save to a file (suggested by Patrick Rapin)
+
+== JSONlab 0.8.1 (codename: Sentiel, Update 1), FangQ <fangq (at) nmr.mgh.harvard.edu> ==
+
+ 2012/02/28  loadjson quotation mark escape bug, see http://bit.ly/yyk1nS
+ 2012/01/25  patch to handle root-less objects, contributed by Blake Johnson
+
+== JSONlab 0.8.0 (codename: Sentiel), FangQ <fangq (at) nmr.mgh.harvard.edu> ==
+
+ 2012/01/13 *speed up loadjson by 20 fold when parsing large data arrays in matlab
+ 2012/01/11  remove row bracket if an array has 1 element, suggested by Mykel Kochenderfer
+ 2011/12/22 *accept sequence of 'param',value input in savejson and loadjson
+ 2011/11/18  fix struct array bug reported by Mykel Kochenderfer
+
+== JSONlab 0.5.1 (codename: Nexus Update 1), FangQ <fangq (at) nmr.mgh.harvard.edu> ==
+
+ 2011/10/21  fix a bug in loadjson, previous code does not use any of the acceleration
+ 2011/10/20  loadjson supports JSON collections - concatenated JSON objects
+
+== JSONlab 0.5.0 (codename: Nexus), FangQ <fangq (at) nmr.mgh.harvard.edu> ==
+
+ 2011/10/16  package and release jsonlab 0.5.0
+ 2011/10/15 *add json demo and regression test, support cpx numbers, fix double quote bug
+ 2011/10/11 *speed up readjson dramatically, interpret _Array* tags, show data in root level
+ 2011/10/10  create jsonlab project, start jsonlab website, add online documentation
+ 2011/10/07 *speed up savejson by 25x using sprintf instead of mat2str, add options support
+ 2011/10/06 *savejson works for structs, cells and arrays
+ 2011/09/09  derive loadjson from JSON parser from MATLAB Central, draft savejson.m

+ 25 - 0
machine learning/machine-learning-ex3/ex3/lib/jsonlab/LICENSE_BSD.txt

@@ -0,0 +1,25 @@
+Copyright 2011-2015 Qianqian Fang <fangq at nmr.mgh.harvard.edu>. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are
+permitted provided that the following conditions are met:
+
+   1. Redistributions of source code must retain the above copyright notice, this list of
+      conditions and the following disclaimer.
+
+   2. Redistributions in binary form must reproduce the above copyright notice, this list
+      of conditions and the following disclaimer in the documentation and/or other materials
+      provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS 
+OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+The views and conclusions contained in the software and documentation are those of the
+authors and should not be interpreted as representing official policies, either expressed
+or implied, of the copyright holders.

+ 394 - 0
machine learning/machine-learning-ex3/ex3/lib/jsonlab/README.txt

@@ -0,0 +1,394 @@
+===============================================================================
+=                                 JSONLab                                     =
+=           An open-source MATLAB/Octave JSON encoder and decoder             =
+===============================================================================
+
+*Copyright (C) 2011-2015  Qianqian Fang <fangq at nmr.mgh.harvard.edu>
+*License: BSD License, see License_BSD.txt for details
+*Version: 1.0 (Optimus - Final)
+
+-------------------------------------------------------------------------------
+
+Table of Content:
+
+I.  Introduction
+II. Installation
+III.Using JSONLab
+IV. Known Issues and TODOs
+V.  Contribution and feedback
+
+-------------------------------------------------------------------------------
+
+I.  Introduction
+
+JSON ([http://www.json.org/ JavaScript Object Notation]) is a highly portable, 
+human-readable and "[http://en.wikipedia.org/wiki/JSON fat-free]" text format 
+to represent complex and hierarchical data. It is as powerful as 
+[http://en.wikipedia.org/wiki/XML XML], but less verbose. JSON format is widely 
+used for data-exchange in applications, and is essential for the wild success 
+of [http://en.wikipedia.org/wiki/Ajax_(programming) Ajax] and 
+[http://en.wikipedia.org/wiki/Web_2.0 Web2.0]. 
+
+UBJSON (Universal Binary JSON) is a binary JSON format, specifically 
+optimized for compact file size and better performance while keeping
+the semantics as simple as the text-based JSON format. Using the UBJSON
+format allows to wrap complex binary data in a flexible and extensible
+structure, making it possible to process complex and large dataset 
+without accuracy loss due to text conversions.
+
+We envision that both JSON and its binary version will serve as part of 
+the mainstream data-exchange formats for scientific research in the future. 
+It will provide the flexibility and generality achieved by other popular 
+general-purpose file specifications, such as
+[http://www.hdfgroup.org/HDF5/whatishdf5.html HDF5], with significantly 
+reduced complexity and enhanced performance.
+
+JSONLab is a free and open-source implementation of a JSON/UBJSON encoder 
+and a decoder in the native MATLAB language. It can be used to convert a MATLAB 
+data structure (array, struct, cell, struct array and cell array) into 
+JSON/UBJSON formatted strings, or to decode a JSON/UBJSON file into MATLAB 
+data structure. JSONLab supports both MATLAB and  
+[http://www.gnu.org/software/octave/ GNU Octave] (a free MATLAB clone).
+
+-------------------------------------------------------------------------------
+
+II. Installation
+
+The installation of JSONLab is no different than any other simple
+MATLAB toolbox. You only need to download/unzip the JSONLab package
+to a folder, and add the folder's path to MATLAB/Octave's path list
+by using the following command:
+
+    addpath('/path/to/jsonlab');
+
+If you want to add this path permanently, you need to type "pathtool", 
+browse to the jsonlab root folder and add to the list, then click "Save".
+Then, run "rehash" in MATLAB, and type "which loadjson", if you see an 
+output, that means JSONLab is installed for MATLAB/Octave.
+
+-------------------------------------------------------------------------------
+
+III.Using JSONLab
+
+JSONLab provides two functions, loadjson.m -- a MATLAB->JSON decoder, 
+and savejson.m -- a MATLAB->JSON encoder, for the text-based JSON, and 
+two equivallent functions -- loadubjson and saveubjson for the binary 
+JSON. The detailed help info for the four functions can be found below:
+
+=== loadjson.m ===
+<pre>
+  data=loadjson(fname,opt)
+     or
+  data=loadjson(fname,'param1',value1,'param2',value2,...)
+ 
+  parse a JSON (JavaScript Object Notation) file or string
+ 
+  authors:Qianqian Fang (fangq<at> nmr.mgh.harvard.edu)
+  created on 2011/09/09, including previous works from 
+ 
+          Nedialko Krouchev: http://www.mathworks.com/matlabcentral/fileexchange/25713
+             created on 2009/11/02
+          François Glineur: http://www.mathworks.com/matlabcentral/fileexchange/23393
+             created on  2009/03/22
+          Joel Feenstra:
+          http://www.mathworks.com/matlabcentral/fileexchange/20565
+             created on 2008/07/03
+ 
+  $Id: loadjson.m 452 2014-11-22 16:43:33Z fangq $
+ 
+  input:
+       fname: input file name, if fname contains "{}" or "[]", fname
+              will be interpreted as a JSON string
+       opt: a struct to store parsing options, opt can be replaced by 
+            a list of ('param',value) pairs - the param string is equivallent
+            to a field in opt. opt can have the following 
+            fields (first in [.|.] is the default)
+ 
+            opt.SimplifyCell [0|1]: if set to 1, loadjson will call cell2mat
+                          for each element of the JSON data, and group 
+                          arrays based on the cell2mat rules.
+            opt.FastArrayParser [1|0 or integer]: if set to 1, use a
+                          speed-optimized array parser when loading an 
+                          array object. The fast array parser may 
+                          collapse block arrays into a single large
+                          array similar to rules defined in cell2mat; 0 to 
+                          use a legacy parser; if set to a larger-than-1
+                          value, this option will specify the minimum
+                          dimension to enable the fast array parser. For
+                          example, if the input is a 3D array, setting
+                          FastArrayParser to 1 will return a 3D array;
+                          setting to 2 will return a cell array of 2D
+                          arrays; setting to 3 will return to a 2D cell
+                          array of 1D vectors; setting to 4 will return a
+                          3D cell array.
+            opt.ShowProgress [0|1]: if set to 1, loadjson displays a progress bar.
+ 
+  output:
+       dat: a cell array, where {...} blocks are converted into cell arrays,
+            and [...] are converted to arrays
+ 
+  examples:
+       dat=loadjson('{"obj":{"string":"value","array":[1,2,3]}}')
+       dat=loadjson(['examples' filesep 'example1.json'])
+       dat=loadjson(['examples' filesep 'example1.json'],'SimplifyCell',1)
+</pre>
+
+=== savejson.m ===
+
+<pre>
+  json=savejson(rootname,obj,filename)
+     or
+  json=savejson(rootname,obj,opt)
+  json=savejson(rootname,obj,'param1',value1,'param2',value2,...)
+ 
+  convert a MATLAB object (cell, struct or array) into a JSON (JavaScript
+  Object Notation) string
+ 
+  author: Qianqian Fang (fangq<at> nmr.mgh.harvard.edu)
+  created on 2011/09/09
+ 
+  $Id: savejson.m 458 2014-12-19 22:17:17Z fangq $
+ 
+  input:
+       rootname: the name of the root-object, when set to '', the root name
+         is ignored, however, when opt.ForceRootName is set to 1 (see below),
+         the MATLAB variable name will be used as the root name.
+       obj: a MATLAB object (array, cell, cell array, struct, struct array).
+       filename: a string for the file name to save the output JSON data.
+       opt: a struct for additional options, ignore to use default values.
+         opt can have the following fields (first in [.|.] is the default)
+ 
+         opt.FileName [''|string]: a file name to save the output JSON data
+         opt.FloatFormat ['%.10g'|string]: format to show each numeric element
+                          of a 1D/2D array;
+         opt.ArrayIndent [1|0]: if 1, output explicit data array with
+                          precedent indentation; if 0, no indentation
+         opt.ArrayToStruct[0|1]: when set to 0, savejson outputs 1D/2D
+                          array in JSON array format; if sets to 1, an
+                          array will be shown as a struct with fields
+                          "_ArrayType_", "_ArraySize_" and "_ArrayData_"; for
+                          sparse arrays, the non-zero elements will be
+                          saved to _ArrayData_ field in triplet-format i.e.
+                          (ix,iy,val) and "_ArrayIsSparse_" will be added
+                          with a value of 1; for a complex array, the 
+                          _ArrayData_ array will include two columns 
+                          (4 for sparse) to record the real and imaginary 
+                          parts, and also "_ArrayIsComplex_":1 is added. 
+         opt.ParseLogical [0|1]: if this is set to 1, logical array elem
+                          will use true/false rather than 1/0.
+         opt.NoRowBracket [1|0]: if this is set to 1, arrays with a single
+                          numerical element will be shown without a square
+                          bracket, unless it is the root object; if 0, square
+                          brackets are forced for any numerical arrays.
+         opt.ForceRootName [0|1]: when set to 1 and rootname is empty, savejson
+                          will use the name of the passed obj variable as the 
+                          root object name; if obj is an expression and 
+                          does not have a name, 'root' will be used; if this 
+                          is set to 0 and rootname is empty, the root level 
+                          will be merged down to the lower level.
+         opt.Inf ['"$1_Inf_"'|string]: a customized regular expression pattern
+                          to represent +/-Inf. The matched pattern is '([-+]*)Inf'
+                          and $1 represents the sign. For those who want to use
+                          1e999 to represent Inf, they can set opt.Inf to '$11e999'
+         opt.NaN ['"_NaN_"'|string]: a customized regular expression pattern
+                          to represent NaN
+         opt.JSONP [''|string]: to generate a JSONP output (JSON with padding),
+                          for example, if opt.JSONP='foo', the JSON data is
+                          wrapped inside a function call as 'foo(...);'
+         opt.UnpackHex [1|0]: conver the 0x[hex code] output by loadjson 
+                          back to the string form
+         opt.SaveBinary [0|1]: 1 - save the JSON file in binary mode; 0 - text mode.
+         opt.Compact [0|1]: 1- out compact JSON format (remove all newlines and tabs)
+ 
+         opt can be replaced by a list of ('param',value) pairs. The param 
+         string is equivallent to a field in opt and is case sensitive.
+  output:
+       json: a string in the JSON format (see http://json.org)
+ 
+  examples:
+       jsonmesh=struct('MeshNode',[0 0 0;1 0 0;0 1 0;1 1 0;0 0 1;1 0 1;0 1 1;1 1 1],... 
+                'MeshTetra',[1 2 4 8;1 3 4 8;1 2 6 8;1 5 6 8;1 5 7 8;1 3 7 8],...
+                'MeshTri',[1 2 4;1 2 6;1 3 4;1 3 7;1 5 6;1 5 7;...
+                           2 8 4;2 8 6;3 8 4;3 8 7;5 8 6;5 8 7],...
+                'MeshCreator','FangQ','MeshTitle','T6 Cube',...
+                'SpecialData',[nan, inf, -inf]);
+       savejson('jmesh',jsonmesh)
+       savejson('',jsonmesh,'ArrayIndent',0,'FloatFormat','\t%.5g')
+ </pre>
+
+=== loadubjson.m ===
+
+<pre>
+  data=loadubjson(fname,opt)
+     or
+  data=loadubjson(fname,'param1',value1,'param2',value2,...)
+ 
+  parse a JSON (JavaScript Object Notation) file or string
+ 
+  authors:Qianqian Fang (fangq<at> nmr.mgh.harvard.edu)
+  created on 2013/08/01
+ 
+  $Id: loadubjson.m 436 2014-08-05 20:51:40Z fangq $
+ 
+  input:
+       fname: input file name, if fname contains "{}" or "[]", fname
+              will be interpreted as a UBJSON string
+       opt: a struct to store parsing options, opt can be replaced by 
+            a list of ('param',value) pairs - the param string is equivallent
+            to a field in opt. opt can have the following 
+            fields (first in [.|.] is the default)
+ 
+            opt.SimplifyCell [0|1]: if set to 1, loadubjson will call cell2mat
+                          for each element of the JSON data, and group 
+                          arrays based on the cell2mat rules.
+            opt.IntEndian [B|L]: specify the endianness of the integer fields
+                          in the UBJSON input data. B - Big-Endian format for 
+                          integers (as required in the UBJSON specification); 
+                          L - input integer fields are in Little-Endian order.
+ 
+  output:
+       dat: a cell array, where {...} blocks are converted into cell arrays,
+            and [...] are converted to arrays
+ 
+  examples:
+       obj=struct('string','value','array',[1 2 3]);
+       ubjdata=saveubjson('obj',obj);
+       dat=loadubjson(ubjdata)
+       dat=loadubjson(['examples' filesep 'example1.ubj'])
+       dat=loadubjson(['examples' filesep 'example1.ubj'],'SimplifyCell',1)
+</pre>
+
+=== saveubjson.m ===
+
+<pre>
+  json=saveubjson(rootname,obj,filename)
+     or
+  json=saveubjson(rootname,obj,opt)
+  json=saveubjson(rootname,obj,'param1',value1,'param2',value2,...)
+ 
+  convert a MATLAB object (cell, struct or array) into a Universal 
+  Binary JSON (UBJSON) binary string
+ 
+  author: Qianqian Fang (fangq<at> nmr.mgh.harvard.edu)
+  created on 2013/08/17
+ 
+  $Id: saveubjson.m 440 2014-09-17 19:59:45Z fangq $
+ 
+  input:
+       rootname: the name of the root-object, when set to '', the root name
+         is ignored, however, when opt.ForceRootName is set to 1 (see below),
+         the MATLAB variable name will be used as the root name.
+       obj: a MATLAB object (array, cell, cell array, struct, struct array)
+       filename: a string for the file name to save the output UBJSON data
+       opt: a struct for additional options, ignore to use default values.
+         opt can have the following fields (first in [.|.] is the default)
+ 
+         opt.FileName [''|string]: a file name to save the output JSON data
+         opt.ArrayToStruct[0|1]: when set to 0, saveubjson outputs 1D/2D
+                          array in JSON array format; if sets to 1, an
+                          array will be shown as a struct with fields
+                          "_ArrayType_", "_ArraySize_" and "_ArrayData_"; for
+                          sparse arrays, the non-zero elements will be
+                          saved to _ArrayData_ field in triplet-format i.e.
+                          (ix,iy,val) and "_ArrayIsSparse_" will be added
+                          with a value of 1; for a complex array, the 
+                          _ArrayData_ array will include two columns 
+                          (4 for sparse) to record the real and imaginary 
+                          parts, and also "_ArrayIsComplex_":1 is added. 
+         opt.ParseLogical [1|0]: if this is set to 1, logical array elem
+                          will use true/false rather than 1/0.
+         opt.NoRowBracket [1|0]: if this is set to 1, arrays with a single
+                          numerical element will be shown without a square
+                          bracket, unless it is the root object; if 0, square
+                          brackets are forced for any numerical arrays.
+         opt.ForceRootName [0|1]: when set to 1 and rootname is empty, saveubjson
+                          will use the name of the passed obj variable as the 
+                          root object name; if obj is an expression and 
+                          does not have a name, 'root' will be used; if this 
+                          is set to 0 and rootname is empty, the root level 
+                          will be merged down to the lower level.
+         opt.JSONP [''|string]: to generate a JSONP output (JSON with padding),
+                          for example, if opt.JSON='foo', the JSON data is
+                          wrapped inside a function call as 'foo(...);'
+         opt.UnpackHex [1|0]: conver the 0x[hex code] output by loadjson 
+                          back to the string form
+ 
+         opt can be replaced by a list of ('param',value) pairs. The param 
+         string is equivallent to a field in opt and is case sensitive.
+  output:
+       json: a binary string in the UBJSON format (see http://ubjson.org)
+ 
+  examples:
+       jsonmesh=struct('MeshNode',[0 0 0;1 0 0;0 1 0;1 1 0;0 0 1;1 0 1;0 1 1;1 1 1],... 
+                'MeshTetra',[1 2 4 8;1 3 4 8;1 2 6 8;1 5 6 8;1 5 7 8;1 3 7 8],...
+                'MeshTri',[1 2 4;1 2 6;1 3 4;1 3 7;1 5 6;1 5 7;...
+                           2 8 4;2 8 6;3 8 4;3 8 7;5 8 6;5 8 7],...
+                'MeshCreator','FangQ','MeshTitle','T6 Cube',...
+                'SpecialData',[nan, inf, -inf]);
+       saveubjson('jsonmesh',jsonmesh)
+       saveubjson('jsonmesh',jsonmesh,'meshdata.ubj')
+</pre>
+
+
+=== examples ===
+
+Under the "examples" folder, you can find several scripts to demonstrate the
+basic utilities of JSONLab. Running the "demo_jsonlab_basic.m" script, you 
+will see the conversions from MATLAB data structure to JSON text and backward.
+In "jsonlab_selftest.m", we load complex JSON files downloaded from the Internet
+and validate the loadjson/savejson functions for regression testing purposes.
+Similarly, a "demo_ubjson_basic.m" script is provided to test the saveubjson
+and loadubjson pairs for various matlab data structures.
+
+Please run these examples and understand how JSONLab works before you use
+it to process your data.
+
+-------------------------------------------------------------------------------
+
+IV. Known Issues and TODOs
+
+JSONLab has several known limitations. We are striving to make it more general
+and robust. Hopefully in a few future releases, the limitations become less.
+
+Here are the known issues:
+
+# 3D or higher dimensional cell/struct-arrays will be converted to 2D arrays;
+# When processing names containing multi-byte characters, Octave and MATLAB \
+can give different field-names; you can use feature('DefaultCharacterSet','latin1') \
+in MATLAB to get consistant results
+# savejson can not handle class and dataset.
+# saveubjson converts a logical array into a uint8 ([U]) array
+# an unofficial N-D array count syntax is implemented in saveubjson. We are \
+actively communicating with the UBJSON spec maintainer to investigate the \
+possibility of making it upstream
+# loadubjson can not parse all UBJSON Specification (Draft 9) compliant \
+files, however, it can parse all UBJSON files produced by saveubjson.
+
+-------------------------------------------------------------------------------
+
+V. Contribution and feedback
+
+JSONLab is an open-source project. This means you can not only use it and modify
+it as you wish, but also you can contribute your changes back to JSONLab so
+that everyone else can enjoy the improvement. For anyone who want to contribute,
+please download JSONLab source code from it's subversion repository by using the
+following command:
+
+ svn checkout svn://svn.code.sf.net/p/iso2mesh/code/trunk/jsonlab jsonlab
+
+You can make changes to the files as needed. Once you are satisfied with your
+changes, and ready to share it with others, please cd the root directory of 
+JSONLab, and type
+
+ svn diff > yourname_featurename.patch
+
+You then email the .patch file to JSONLab's maintainer, Qianqian Fang, at
+the email address shown in the beginning of this file. Qianqian will review 
+the changes and commit it to the subversion if they are satisfactory.
+
+We appreciate any suggestions and feedbacks from you. Please use iso2mesh's
+mailing list to report any questions you may have with JSONLab:
+
+http://groups.google.com/group/iso2mesh-users?hl=en&pli=1
+
+(Subscription to the mailing list is needed in order to post messages).

+ 32 - 0
machine learning/machine-learning-ex3/ex3/lib/jsonlab/jsonopt.m

@@ -0,0 +1,32 @@
+function val=jsonopt(key,default,varargin)
+%
+% val=jsonopt(key,default,optstruct)
+%
+% setting options based on a struct. The struct can be produced
+% by varargin2struct from a list of 'param','value' pairs
+%
+% authors:Qianqian Fang (fangq<at> nmr.mgh.harvard.edu)
+%
+% $Id: loadjson.m 371 2012-06-20 12:43:06Z fangq $
+%
+% input:
+%      key: a string with which one look up a value from a struct
+%      default: if the key does not exist, return default
+%      optstruct: a struct where each sub-field is a key 
+%
+% output:
+%      val: if key exists, val=optstruct.key; otherwise val=default
+%
+% license:
+%     BSD, see LICENSE_BSD.txt files for details
+%
+% -- this function is part of jsonlab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)
+% 
+
+val=default;
+if(nargin<=2) return; end
+opt=varargin{1};
+if(isstruct(opt) && isfield(opt,key))
+    val=getfield(opt,key);
+end
+

+ 566 - 0
machine learning/machine-learning-ex3/ex3/lib/jsonlab/loadjson.m

@@ -0,0 +1,566 @@
+function data = loadjson(fname,varargin)
+%
+% data=loadjson(fname,opt)
+%    or
+% data=loadjson(fname,'param1',value1,'param2',value2,...)
+%
+% parse a JSON (JavaScript Object Notation) file or string
+%
+% authors:Qianqian Fang (fangq<at> nmr.mgh.harvard.edu)
+% created on 2011/09/09, including previous works from 
+%
+%         Nedialko Krouchev: http://www.mathworks.com/matlabcentral/fileexchange/25713
+%            created on 2009/11/02
+%         François Glineur: http://www.mathworks.com/matlabcentral/fileexchange/23393
+%            created on  2009/03/22
+%         Joel Feenstra:
+%         http://www.mathworks.com/matlabcentral/fileexchange/20565
+%            created on 2008/07/03
+%
+% $Id: loadjson.m 460 2015-01-03 00:30:45Z fangq $
+%
+% input:
+%      fname: input file name, if fname contains "{}" or "[]", fname
+%             will be interpreted as a JSON string
+%      opt: a struct to store parsing options, opt can be replaced by 
+%           a list of ('param',value) pairs - the param string is equivallent
+%           to a field in opt. opt can have the following 
+%           fields (first in [.|.] is the default)
+%
+%           opt.SimplifyCell [0|1]: if set to 1, loadjson will call cell2mat
+%                         for each element of the JSON data, and group 
+%                         arrays based on the cell2mat rules.
+%           opt.FastArrayParser [1|0 or integer]: if set to 1, use a
+%                         speed-optimized array parser when loading an 
+%                         array object. The fast array parser may 
+%                         collapse block arrays into a single large
+%                         array similar to rules defined in cell2mat; 0 to 
+%                         use a legacy parser; if set to a larger-than-1
+%                         value, this option will specify the minimum
+%                         dimension to enable the fast array parser. For
+%                         example, if the input is a 3D array, setting
+%                         FastArrayParser to 1 will return a 3D array;
+%                         setting to 2 will return a cell array of 2D
+%                         arrays; setting to 3 will return to a 2D cell
+%                         array of 1D vectors; setting to 4 will return a
+%                         3D cell array.
+%           opt.ShowProgress [0|1]: if set to 1, loadjson displays a progress bar.
+%
+% output:
+%      dat: a cell array, where {...} blocks are converted into cell arrays,
+%           and [...] are converted to arrays
+%
+% examples:
+%      dat=loadjson('{"obj":{"string":"value","array":[1,2,3]}}')
+%      dat=loadjson(['examples' filesep 'example1.json'])
+%      dat=loadjson(['examples' filesep 'example1.json'],'SimplifyCell',1)
+%
+% license:
+%     BSD, see LICENSE_BSD.txt files for details 
+%
+% -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)
+%
+
+global pos inStr len  esc index_esc len_esc isoct arraytoken
+
+if(regexp(fname,'[\{\}\]\[]','once'))
+   string=fname;
+elseif(exist(fname,'file'))
+   fid = fopen(fname,'rb');
+   string = fread(fid,inf,'uint8=>char')';
+   fclose(fid);
+else
+   error('input file does not exist');
+end
+
+pos = 1; len = length(string); inStr = string;
+isoct=exist('OCTAVE_VERSION','builtin');
+arraytoken=find(inStr=='[' | inStr==']' | inStr=='"');
+jstr=regexprep(inStr,'\\\\','  ');
+escquote=regexp(jstr,'\\"');
+arraytoken=sort([arraytoken escquote]);
+
+% String delimiters and escape chars identified to improve speed:
+esc = find(inStr=='"' | inStr=='\' ); % comparable to: regexp(inStr, '["\\]');
+index_esc = 1; len_esc = length(esc);
+
+opt=varargin2struct(varargin{:});
+
+if(jsonopt('ShowProgress',0,opt)==1)
+    opt.progressbar_=waitbar(0,'loading ...');
+end
+jsoncount=1;
+while pos <= len
+    switch(next_char)
+        case '{'
+            data{jsoncount} = parse_object(opt);
+        case '['
+            data{jsoncount} = parse_array(opt);
+        otherwise
+            error_pos('Outer level structure must be an object or an array');
+    end
+    jsoncount=jsoncount+1;
+end % while
+
+jsoncount=length(data);
+if(jsoncount==1 && iscell(data))
+    data=data{1};
+end
+
+if(~isempty(data))
+      if(isstruct(data)) % data can be a struct array
+          data=jstruct2array(data);
+      elseif(iscell(data))
+          data=jcell2array(data);
+      end
+end
+if(isfield(opt,'progressbar_'))
+    close(opt.progressbar_);
+end
+
+%%
+function newdata=jcell2array(data)
+len=length(data);
+newdata=data;
+for i=1:len
+      if(isstruct(data{i}))
+          newdata{i}=jstruct2array(data{i});
+      elseif(iscell(data{i}))
+          newdata{i}=jcell2array(data{i});
+      end
+end
+
+%%-------------------------------------------------------------------------
+function newdata=jstruct2array(data)
+fn=fieldnames(data);
+newdata=data;
+len=length(data);
+for i=1:length(fn) % depth-first
+    for j=1:len
+        if(isstruct(getfield(data(j),fn{i})))
+            newdata(j)=setfield(newdata(j),fn{i},jstruct2array(getfield(data(j),fn{i})));
+        end
+    end
+end
+if(~isempty(strmatch('x0x5F_ArrayType_',fn)) && ~isempty(strmatch('x0x5F_ArrayData_',fn)))
+  newdata=cell(len,1);
+  for j=1:len
+    ndata=cast(data(j).x0x5F_ArrayData_,data(j).x0x5F_ArrayType_);
+    iscpx=0;
+    if(~isempty(strmatch('x0x5F_ArrayIsComplex_',fn)))
+        if(data(j).x0x5F_ArrayIsComplex_)
+           iscpx=1;
+        end
+    end
+    if(~isempty(strmatch('x0x5F_ArrayIsSparse_',fn)))
+        if(data(j).x0x5F_ArrayIsSparse_)
+            if(~isempty(strmatch('x0x5F_ArraySize_',fn)))
+                dim=data(j).x0x5F_ArraySize_;
+                if(iscpx && size(ndata,2)==4-any(dim==1))
+                    ndata(:,end-1)=complex(ndata(:,end-1),ndata(:,end));
+                end
+                if isempty(ndata)
+                    % All-zeros sparse
+                    ndata=sparse(dim(1),prod(dim(2:end)));
+                elseif dim(1)==1
+                    % Sparse row vector
+                    ndata=sparse(1,ndata(:,1),ndata(:,2),dim(1),prod(dim(2:end)));
+                elseif dim(2)==1
+                    % Sparse column vector
+                    ndata=sparse(ndata(:,1),1,ndata(:,2),dim(1),prod(dim(2:end)));
+                else
+                    % Generic sparse array.
+                    ndata=sparse(ndata(:,1),ndata(:,2),ndata(:,3),dim(1),prod(dim(2:end)));
+                end
+            else
+                if(iscpx && size(ndata,2)==4)
+                    ndata(:,3)=complex(ndata(:,3),ndata(:,4));
+                end
+                ndata=sparse(ndata(:,1),ndata(:,2),ndata(:,3));
+            end
+        end
+    elseif(~isempty(strmatch('x0x5F_ArraySize_',fn)))
+        if(iscpx && size(ndata,2)==2)
+             ndata=complex(ndata(:,1),ndata(:,2));
+        end
+        ndata=reshape(ndata(:),data(j).x0x5F_ArraySize_);
+    end
+    newdata{j}=ndata;
+  end
+  if(len==1)
+      newdata=newdata{1};
+  end
+end
+
+%%-------------------------------------------------------------------------
+function object = parse_object(varargin)
+    parse_char('{');
+    object = [];
+    if next_char ~= '}'
+        while 1
+            str = parseStr(varargin{:});
+            if isempty(str)
+                error_pos('Name of value at position %d cannot be empty');
+            end
+            parse_char(':');
+            val = parse_value(varargin{:});
+            eval( sprintf( 'object.%s  = val;', valid_field(str) ) );
+            if next_char == '}'
+                break;
+            end
+            parse_char(',');
+        end
+    end
+    parse_char('}');
+
+%%-------------------------------------------------------------------------
+
+function object = parse_array(varargin) % JSON array is written in row-major order
+global pos inStr isoct
+    parse_char('[');
+    object = cell(0, 1);
+    dim2=[];
+    arraydepth=jsonopt('JSONLAB_ArrayDepth_',1,varargin{:});
+    pbar=jsonopt('progressbar_',-1,varargin{:});
+
+    if next_char ~= ']'
+	if(jsonopt('FastArrayParser',1,varargin{:})>=1 && arraydepth>=jsonopt('FastArrayParser',1,varargin{:}))
+            [endpos, e1l, e1r, maxlevel]=matching_bracket(inStr,pos);
+            arraystr=['[' inStr(pos:endpos)];
+            arraystr=regexprep(arraystr,'"_NaN_"','NaN');
+            arraystr=regexprep(arraystr,'"([-+]*)_Inf_"','$1Inf');
+            arraystr(arraystr==sprintf('\n'))=[];
+            arraystr(arraystr==sprintf('\r'))=[];
+            %arraystr=regexprep(arraystr,'\s*,',','); % this is slow,sometimes needed
+            if(~isempty(e1l) && ~isempty(e1r)) % the array is in 2D or higher D
+        	astr=inStr((e1l+1):(e1r-1));
+        	astr=regexprep(astr,'"_NaN_"','NaN');
+        	astr=regexprep(astr,'"([-+]*)_Inf_"','$1Inf');
+        	astr(astr==sprintf('\n'))=[];
+        	astr(astr==sprintf('\r'))=[];
+        	astr(astr==' ')='';
+        	if(isempty(find(astr=='[', 1))) % array is 2D
+                    dim2=length(sscanf(astr,'%f,',[1 inf]));
+        	end
+            else % array is 1D
+        	astr=arraystr(2:end-1);
+        	astr(astr==' ')='';
+        	[obj, count, errmsg, nextidx]=sscanf(astr,'%f,',[1,inf]);
+        	if(nextidx>=length(astr)-1)
+                    object=obj;
+                    pos=endpos;
+                    parse_char(']');
+                    return;
+        	end
+            end
+            if(~isempty(dim2))
+        	astr=arraystr;
+        	astr(astr=='[')='';
+        	astr(astr==']')='';
+        	astr(astr==' ')='';
+        	[obj, count, errmsg, nextidx]=sscanf(astr,'%f,',inf);
+        	if(nextidx>=length(astr)-1)
+                    object=reshape(obj,dim2,numel(obj)/dim2)';
+                    pos=endpos;
+                    parse_char(']');
+                    if(pbar>0)
+                        waitbar(pos/length(inStr),pbar,'loading ...');
+                    end
+                    return;
+        	end
+            end
+            arraystr=regexprep(arraystr,'\]\s*,','];');
+	else
+            arraystr='[';
+	end
+        try
+           if(isoct && regexp(arraystr,'"','once'))
+                error('Octave eval can produce empty cells for JSON-like input');
+           end
+           object=eval(arraystr);
+           pos=endpos;
+        catch
+         while 1
+            newopt=varargin2struct(varargin{:},'JSONLAB_ArrayDepth_',arraydepth+1);
+            val = parse_value(newopt);
+            object{end+1} = val;
+            if next_char == ']'
+                break;
+            end
+            parse_char(',');
+         end
+        end
+    end
+    if(jsonopt('SimplifyCell',0,varargin{:})==1)
+      try
+        oldobj=object;
+        object=cell2mat(object')';
+        if(iscell(oldobj) && isstruct(object) && numel(object)>1 && jsonopt('SimplifyCellArray',1,varargin{:})==0)
+            object=oldobj;
+        elseif(size(object,1)>1 && ndims(object)==2)
+            object=object';
+        end
+      catch
+      end
+    end
+    parse_char(']');
+    
+    if(pbar>0)
+        waitbar(pos/length(inStr),pbar,'loading ...');
+    end
+%%-------------------------------------------------------------------------
+
+function parse_char(c)
+    global pos inStr len
+    skip_whitespace;
+    if pos > len || inStr(pos) ~= c
+        error_pos(sprintf('Expected %c at position %%d', c));
+    else
+        pos = pos + 1;
+        skip_whitespace;
+    end
+
+%%-------------------------------------------------------------------------
+
+function c = next_char
+    global pos inStr len
+    skip_whitespace;
+    if pos > len
+        c = [];
+    else
+        c = inStr(pos);
+    end
+
+%%-------------------------------------------------------------------------
+
+function skip_whitespace
+    global pos inStr len
+    while pos <= len && isspace(inStr(pos))
+        pos = pos + 1;
+    end
+
+%%-------------------------------------------------------------------------
+function str = parseStr(varargin)
+    global pos inStr len  esc index_esc len_esc
+ % len, ns = length(inStr), keyboard
+    if inStr(pos) ~= '"'
+        error_pos('String starting with " expected at position %d');
+    else
+        pos = pos + 1;
+    end
+    str = '';
+    while pos <= len
+        while index_esc <= len_esc && esc(index_esc) < pos
+            index_esc = index_esc + 1;
+        end
+        if index_esc > len_esc
+            str = [str inStr(pos:len)];
+            pos = len + 1;
+            break;
+        else
+            str = [str inStr(pos:esc(index_esc)-1)];
+            pos = esc(index_esc);
+        end
+        nstr = length(str); switch inStr(pos)
+            case '"'
+                pos = pos + 1;
+                if(~isempty(str))
+                    if(strcmp(str,'_Inf_'))
+                        str=Inf;
+                    elseif(strcmp(str,'-_Inf_'))
+                        str=-Inf;
+                    elseif(strcmp(str,'_NaN_'))
+                        str=NaN;
+                    end
+                end
+                return;
+            case '\'
+                if pos+1 > len
+                    error_pos('End of file reached right after escape character');
+                end
+                pos = pos + 1;
+                switch inStr(pos)
+                    case {'"' '\' '/'}
+                        str(nstr+1) = inStr(pos);
+                        pos = pos + 1;
+                    case {'b' 'f' 'n' 'r' 't'}
+                        str(nstr+1) = sprintf(['\' inStr(pos)]);
+                        pos = pos + 1;
+                    case 'u'
+                        if pos+4 > len
+                            error_pos('End of file reached in escaped unicode character');
+                        end
+                        str(nstr+(1:6)) = inStr(pos-1:pos+4);
+                        pos = pos + 5;
+                end
+            otherwise % should never happen
+                str(nstr+1) = inStr(pos), keyboard
+                pos = pos + 1;
+        end
+    end
+    error_pos('End of file while expecting end of inStr');
+
+%%-------------------------------------------------------------------------
+
+function num = parse_number(varargin)
+    global pos inStr len isoct
+    currstr=inStr(pos:end);
+    numstr=0;
+    if(isoct~=0)
+        numstr=regexp(currstr,'^\s*-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+\-]?\d+)?','end');
+        [num, one] = sscanf(currstr, '%f', 1);
+        delta=numstr+1;
+    else
+        [num, one, err, delta] = sscanf(currstr, '%f', 1);
+        if ~isempty(err)
+            error_pos('Error reading number at position %d');
+        end
+    end
+    pos = pos + delta-1;
+
+%%-------------------------------------------------------------------------
+
+function val = parse_value(varargin)
+    global pos inStr len
+    true = 1; false = 0;
+    
+    pbar=jsonopt('progressbar_',-1,varargin{:});
+    if(pbar>0)
+        waitbar(pos/len,pbar,'loading ...');
+    end
+    
+    switch(inStr(pos))
+        case '"'
+            val = parseStr(varargin{:});
+            return;
+        case '['
+            val = parse_array(varargin{:});
+            return;
+        case '{'
+            val = parse_object(varargin{:});
+            if isstruct(val)
+                if(~isempty(strmatch('x0x5F_ArrayType_',fieldnames(val), 'exact')))
+                    val=jstruct2array(val);
+                end
+            elseif isempty(val)
+                val = struct;
+            end
+            return;
+        case {'-','0','1','2','3','4','5','6','7','8','9'}
+            val = parse_number(varargin{:});
+            return;
+        case 't'
+            if pos+3 <= len && strcmpi(inStr(pos:pos+3), 'true')
+                val = true;
+                pos = pos + 4;
+                return;
+            end
+        case 'f'
+            if pos+4 <= len && strcmpi(inStr(pos:pos+4), 'false')
+                val = false;
+                pos = pos + 5;
+                return;
+            end
+        case 'n'
+            if pos+3 <= len && strcmpi(inStr(pos:pos+3), 'null')
+                val = [];
+                pos = pos + 4;
+                return;
+            end
+    end
+    error_pos('Value expected at position %d');
+%%-------------------------------------------------------------------------
+
+function error_pos(msg)
+    global pos inStr len
+    poShow = max(min([pos-15 pos-1 pos pos+20],len),1);
+    if poShow(3) == poShow(2)
+        poShow(3:4) = poShow(2)+[0 -1];  % display nothing after
+    end
+    msg = [sprintf(msg, pos) ': ' ...
+    inStr(poShow(1):poShow(2)) '<error>' inStr(poShow(3):poShow(4)) ];
+    error( ['JSONparser:invalidFormat: ' msg] );
+
+%%-------------------------------------------------------------------------
+
+function str = valid_field(str)
+global isoct
+% From MATLAB doc: field names must begin with a letter, which may be
+% followed by any combination of letters, digits, and underscores.
+% Invalid characters will be converted to underscores, and the prefix
+% "x0x[Hex code]_" will be added if the first character is not a letter.
+    pos=regexp(str,'^[^A-Za-z]','once');
+    if(~isempty(pos))
+        if(~isoct)
+            str=regexprep(str,'^([^A-Za-z])','x0x${sprintf(''%X'',unicode2native($1))}_','once');
+        else
+            str=sprintf('x0x%X_%s',char(str(1)),str(2:end));
+        end
+    end
+    if(isempty(regexp(str,'[^0-9A-Za-z_]', 'once' ))) return;  end
+    if(~isoct)
+        str=regexprep(str,'([^0-9A-Za-z_])','_0x${sprintf(''%X'',unicode2native($1))}_');
+    else
+        pos=regexp(str,'[^0-9A-Za-z_]');
+        if(isempty(pos)) return; end
+        str0=str;
+        pos0=[0 pos(:)' length(str)];
+        str='';
+        for i=1:length(pos)
+            str=[str str0(pos0(i)+1:pos(i)-1) sprintf('_0x%X_',str0(pos(i)))];
+        end
+        if(pos(end)~=length(str))
+            str=[str str0(pos0(end-1)+1:pos0(end))];
+        end
+    end
+    %str(~isletter(str) & ~('0' <= str & str <= '9')) = '_';
+
+%%-------------------------------------------------------------------------
+function endpos = matching_quote(str,pos)
+len=length(str);
+while(pos<len)
+    if(str(pos)=='"')
+        if(~(pos>1 && str(pos-1)=='\'))
+            endpos=pos;
+            return;
+        end        
+    end
+    pos=pos+1;
+end
+error('unmatched quotation mark');
+%%-------------------------------------------------------------------------
+function [endpos, e1l, e1r, maxlevel] = matching_bracket(str,pos)
+global arraytoken
+level=1;
+maxlevel=level;
+endpos=0;
+bpos=arraytoken(arraytoken>=pos);
+tokens=str(bpos);
+len=length(tokens);
+pos=1;
+e1l=[];
+e1r=[];
+while(pos<=len)
+    c=tokens(pos);
+    if(c==']')
+        level=level-1;
+        if(isempty(e1r)) e1r=bpos(pos); end
+        if(level==0)
+            endpos=bpos(pos);
+            return
+        end
+    end
+    if(c=='[')
+        if(isempty(e1l)) e1l=bpos(pos); end
+        level=level+1;
+        maxlevel=max(maxlevel,level);
+    end
+    if(c=='"')
+        pos=matching_quote(tokens,pos+1);
+    end
+    pos=pos+1;
+end
+if(endpos==0) 
+    error('unmatched "]"');
+end
+

+ 528 - 0
machine learning/machine-learning-ex3/ex3/lib/jsonlab/loadubjson.m

@@ -0,0 +1,528 @@
+function data = loadubjson(fname,varargin)
+%
+% data=loadubjson(fname,opt)
+%    or
+% data=loadubjson(fname,'param1',value1,'param2',value2,...)
+%
+% parse a JSON (JavaScript Object Notation) file or string
+%
+% authors:Qianqian Fang (fangq<at> nmr.mgh.harvard.edu)
+% created on 2013/08/01
+%
+% $Id: loadubjson.m 460 2015-01-03 00:30:45Z fangq $
+%
+% input:
+%      fname: input file name, if fname contains "{}" or "[]", fname
+%             will be interpreted as a UBJSON string
+%      opt: a struct to store parsing options, opt can be replaced by 
+%           a list of ('param',value) pairs - the param string is equivallent
+%           to a field in opt. opt can have the following 
+%           fields (first in [.|.] is the default)
+%
+%           opt.SimplifyCell [0|1]: if set to 1, loadubjson will call cell2mat
+%                         for each element of the JSON data, and group 
+%                         arrays based on the cell2mat rules.
+%           opt.IntEndian [B|L]: specify the endianness of the integer fields
+%                         in the UBJSON input data. B - Big-Endian format for 
+%                         integers (as required in the UBJSON specification); 
+%                         L - input integer fields are in Little-Endian order.
+%
+% output:
+%      dat: a cell array, where {...} blocks are converted into cell arrays,
+%           and [...] are converted to arrays
+%
+% examples:
+%      obj=struct('string','value','array',[1 2 3]);
+%      ubjdata=saveubjson('obj',obj);
+%      dat=loadubjson(ubjdata)
+%      dat=loadubjson(['examples' filesep 'example1.ubj'])
+%      dat=loadubjson(['examples' filesep 'example1.ubj'],'SimplifyCell',1)
+%
+% license:
+%     BSD, see LICENSE_BSD.txt files for details 
+%
+% -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)
+%
+
+global pos inStr len  esc index_esc len_esc isoct arraytoken fileendian systemendian
+
+if(regexp(fname,'[\{\}\]\[]','once'))
+   string=fname;
+elseif(exist(fname,'file'))
+   fid = fopen(fname,'rb');
+   string = fread(fid,inf,'uint8=>char')';
+   fclose(fid);
+else
+   error('input file does not exist');
+end
+
+pos = 1; len = length(string); inStr = string;
+isoct=exist('OCTAVE_VERSION','builtin');
+arraytoken=find(inStr=='[' | inStr==']' | inStr=='"');
+jstr=regexprep(inStr,'\\\\','  ');
+escquote=regexp(jstr,'\\"');
+arraytoken=sort([arraytoken escquote]);
+
+% String delimiters and escape chars identified to improve speed:
+esc = find(inStr=='"' | inStr=='\' ); % comparable to: regexp(inStr, '["\\]');
+index_esc = 1; len_esc = length(esc);
+
+opt=varargin2struct(varargin{:});
+fileendian=upper(jsonopt('IntEndian','B',opt));
+[os,maxelem,systemendian]=computer;
+
+jsoncount=1;
+while pos <= len
+    switch(next_char)
+        case '{'
+            data{jsoncount} = parse_object(opt);
+        case '['
+            data{jsoncount} = parse_array(opt);
+        otherwise
+            error_pos('Outer level structure must be an object or an array');
+    end
+    jsoncount=jsoncount+1;
+end % while
+
+jsoncount=length(data);
+if(jsoncount==1 && iscell(data))
+    data=data{1};
+end
+
+if(~isempty(data))
+      if(isstruct(data)) % data can be a struct array
+          data=jstruct2array(data);
+      elseif(iscell(data))
+          data=jcell2array(data);
+      end
+end
+
+
+%%
+function newdata=parse_collection(id,data,obj)
+
+if(jsoncount>0 && exist('data','var')) 
+    if(~iscell(data))
+       newdata=cell(1);
+       newdata{1}=data;
+       data=newdata;
+    end
+end
+
+%%
+function newdata=jcell2array(data)
+len=length(data);
+newdata=data;
+for i=1:len
+      if(isstruct(data{i}))
+          newdata{i}=jstruct2array(data{i});
+      elseif(iscell(data{i}))
+          newdata{i}=jcell2array(data{i});
+      end
+end
+
+%%-------------------------------------------------------------------------
+function newdata=jstruct2array(data)
+fn=fieldnames(data);
+newdata=data;
+len=length(data);
+for i=1:length(fn) % depth-first
+    for j=1:len
+        if(isstruct(getfield(data(j),fn{i})))
+            newdata(j)=setfield(newdata(j),fn{i},jstruct2array(getfield(data(j),fn{i})));
+        end
+    end
+end
+if(~isempty(strmatch('x0x5F_ArrayType_',fn)) && ~isempty(strmatch('x0x5F_ArrayData_',fn)))
+  newdata=cell(len,1);
+  for j=1:len
+    ndata=cast(data(j).x0x5F_ArrayData_,data(j).x0x5F_ArrayType_);
+    iscpx=0;
+    if(~isempty(strmatch('x0x5F_ArrayIsComplex_',fn)))
+        if(data(j).x0x5F_ArrayIsComplex_)
+           iscpx=1;
+        end
+    end
+    if(~isempty(strmatch('x0x5F_ArrayIsSparse_',fn)))
+        if(data(j).x0x5F_ArrayIsSparse_)
+            if(~isempty(strmatch('x0x5F_ArraySize_',fn)))
+                dim=double(data(j).x0x5F_ArraySize_);
+                if(iscpx && size(ndata,2)==4-any(dim==1))
+                    ndata(:,end-1)=complex(ndata(:,end-1),ndata(:,end));
+                end
+                if isempty(ndata)
+                    % All-zeros sparse
+                    ndata=sparse(dim(1),prod(dim(2:end)));
+                elseif dim(1)==1
+                    % Sparse row vector
+                    ndata=sparse(1,ndata(:,1),ndata(:,2),dim(1),prod(dim(2:end)));
+                elseif dim(2)==1
+                    % Sparse column vector
+                    ndata=sparse(ndata(:,1),1,ndata(:,2),dim(1),prod(dim(2:end)));
+                else
+                    % Generic sparse array.
+                    ndata=sparse(ndata(:,1),ndata(:,2),ndata(:,3),dim(1),prod(dim(2:end)));
+                end
+            else
+                if(iscpx && size(ndata,2)==4)
+                    ndata(:,3)=complex(ndata(:,3),ndata(:,4));
+                end
+                ndata=sparse(ndata(:,1),ndata(:,2),ndata(:,3));
+            end
+        end
+    elseif(~isempty(strmatch('x0x5F_ArraySize_',fn)))
+        if(iscpx && size(ndata,2)==2)
+             ndata=complex(ndata(:,1),ndata(:,2));
+        end
+        ndata=reshape(ndata(:),data(j).x0x5F_ArraySize_);
+    end
+    newdata{j}=ndata;
+  end
+  if(len==1)
+      newdata=newdata{1};
+  end
+end
+
+%%-------------------------------------------------------------------------
+function object = parse_object(varargin)
+    parse_char('{');
+    object = [];
+    type='';
+    count=-1;
+    if(next_char == '$')
+        type=inStr(pos+1); % TODO
+        pos=pos+2;
+    end
+    if(next_char == '#')
+        pos=pos+1;
+        count=double(parse_number());
+    end
+    if next_char ~= '}'
+        num=0;
+        while 1
+            str = parseStr(varargin{:});
+            if isempty(str)
+                error_pos('Name of value at position %d cannot be empty');
+            end
+            %parse_char(':');
+            val = parse_value(varargin{:});
+            num=num+1;
+            eval( sprintf( 'object.%s  = val;', valid_field(str) ) );
+            if next_char == '}' || (count>=0 && num>=count)
+                break;
+            end
+            %parse_char(',');
+        end
+    end
+    if(count==-1)
+        parse_char('}');
+    end
+
+%%-------------------------------------------------------------------------
+function [cid,len]=elem_info(type)
+id=strfind('iUIlLdD',type);
+dataclass={'int8','uint8','int16','int32','int64','single','double'};
+bytelen=[1,1,2,4,8,4,8];
+if(id>0)
+    cid=dataclass{id};
+    len=bytelen(id);
+else
+    error_pos('unsupported type at position %d');
+end
+%%-------------------------------------------------------------------------
+
+
+function [data adv]=parse_block(type,count,varargin)
+global pos inStr isoct fileendian systemendian
+[cid,len]=elem_info(type);
+datastr=inStr(pos:pos+len*count-1);
+if(isoct)
+    newdata=int8(datastr);
+else
+    newdata=uint8(datastr);
+end
+id=strfind('iUIlLdD',type);
+if(id<=5 && fileendian~=systemendian)
+    newdata=swapbytes(typecast(newdata,cid));
+end
+data=typecast(newdata,cid);
+adv=double(len*count);
+
+%%-------------------------------------------------------------------------
+
+
+function object = parse_array(varargin) % JSON array is written in row-major order
+global pos inStr isoct
+    parse_char('[');
+    object = cell(0, 1);
+    dim=[];
+    type='';
+    count=-1;
+    if(next_char == '$')
+        type=inStr(pos+1);
+        pos=pos+2;
+    end
+    if(next_char == '#')
+        pos=pos+1;
+        if(next_char=='[')
+            dim=parse_array(varargin{:});
+            count=prod(double(dim));
+        else
+            count=double(parse_number());
+        end
+    end
+    if(~isempty(type))
+        if(count>=0)
+            [object adv]=parse_block(type,count,varargin{:});
+            if(~isempty(dim))
+                object=reshape(object,dim);
+            end
+            pos=pos+adv;
+            return;
+        else
+            endpos=matching_bracket(inStr,pos);
+            [cid,len]=elem_info(type);
+            count=(endpos-pos)/len;
+            [object adv]=parse_block(type,count,varargin{:});
+            pos=pos+adv;
+            parse_char(']');
+            return;
+        end
+    end
+    if next_char ~= ']'
+         while 1
+            val = parse_value(varargin{:});
+            object{end+1} = val;
+            if next_char == ']'
+                break;
+            end
+            %parse_char(',');
+         end
+    end
+    if(jsonopt('SimplifyCell',0,varargin{:})==1)
+      try
+        oldobj=object;
+        object=cell2mat(object')';
+        if(iscell(oldobj) && isstruct(object) && numel(object)>1 && jsonopt('SimplifyCellArray',1,varargin{:})==0)
+            object=oldobj;
+        elseif(size(object,1)>1 && ndims(object)==2)
+            object=object';
+        end
+      catch
+      end
+    end
+    if(count==-1)
+        parse_char(']');
+    end
+
+%%-------------------------------------------------------------------------
+
+function parse_char(c)
+    global pos inStr len
+    skip_whitespace;
+    if pos > len || inStr(pos) ~= c
+        error_pos(sprintf('Expected %c at position %%d', c));
+    else
+        pos = pos + 1;
+        skip_whitespace;
+    end
+
+%%-------------------------------------------------------------------------
+
+function c = next_char
+    global pos inStr len
+    skip_whitespace;
+    if pos > len
+        c = [];
+    else
+        c = inStr(pos);
+    end
+
+%%-------------------------------------------------------------------------
+
+function skip_whitespace
+    global pos inStr len
+    while pos <= len && isspace(inStr(pos))
+        pos = pos + 1;
+    end
+
+%%-------------------------------------------------------------------------
+function str = parseStr(varargin)
+    global pos inStr esc index_esc len_esc
+ % len, ns = length(inStr), keyboard
+    type=inStr(pos);
+    if type ~= 'S' && type ~= 'C' && type ~= 'H'
+        error_pos('String starting with S expected at position %d');
+    else
+        pos = pos + 1;
+    end
+    if(type == 'C')
+        str=inStr(pos);
+        pos=pos+1;
+        return;
+    end
+    bytelen=double(parse_number());
+    if(length(inStr)>=pos+bytelen-1)
+        str=inStr(pos:pos+bytelen-1);
+        pos=pos+bytelen;
+    else
+        error_pos('End of file while expecting end of inStr');
+    end
+
+%%-------------------------------------------------------------------------
+
+function num = parse_number(varargin)
+    global pos inStr len isoct fileendian systemendian
+    id=strfind('iUIlLdD',inStr(pos));
+    if(isempty(id))
+        error_pos('expecting a number at position %d');
+    end
+    type={'int8','uint8','int16','int32','int64','single','double'};
+    bytelen=[1,1,2,4,8,4,8];
+    datastr=inStr(pos+1:pos+bytelen(id));
+    if(isoct)
+        newdata=int8(datastr);
+    else
+        newdata=uint8(datastr);
+    end
+    if(id<=5 && fileendian~=systemendian)
+        newdata=swapbytes(typecast(newdata,type{id}));
+    end
+    num=typecast(newdata,type{id});
+    pos = pos + bytelen(id)+1;
+
+%%-------------------------------------------------------------------------
+
+function val = parse_value(varargin)
+    global pos inStr len
+    true = 1; false = 0;
+
+    switch(inStr(pos))
+        case {'S','C','H'}
+            val = parseStr(varargin{:});
+            return;
+        case '['
+            val = parse_array(varargin{:});
+            return;
+        case '{'
+            val = parse_object(varargin{:});
+            if isstruct(val)
+                if(~isempty(strmatch('x0x5F_ArrayType_',fieldnames(val), 'exact')))
+                    val=jstruct2array(val);
+                end
+            elseif isempty(val)
+                val = struct;
+            end
+            return;
+        case {'i','U','I','l','L','d','D'}
+            val = parse_number(varargin{:});
+            return;
+        case 'T'
+            val = true;
+            pos = pos + 1;
+            return;
+        case 'F'
+            val = false;
+            pos = pos + 1;
+            return;
+        case {'Z','N'}
+            val = [];
+            pos = pos + 1;
+            return;
+    end
+    error_pos('Value expected at position %d');
+%%-------------------------------------------------------------------------
+
+function error_pos(msg)
+    global pos inStr len
+    poShow = max(min([pos-15 pos-1 pos pos+20],len),1);
+    if poShow(3) == poShow(2)
+        poShow(3:4) = poShow(2)+[0 -1];  % display nothing after
+    end
+    msg = [sprintf(msg, pos) ': ' ...
+    inStr(poShow(1):poShow(2)) '<error>' inStr(poShow(3):poShow(4)) ];
+    error( ['JSONparser:invalidFormat: ' msg] );
+
+%%-------------------------------------------------------------------------
+
+function str = valid_field(str)
+global isoct
+% From MATLAB doc: field names must begin with a letter, which may be
+% followed by any combination of letters, digits, and underscores.
+% Invalid characters will be converted to underscores, and the prefix
+% "x0x[Hex code]_" will be added if the first character is not a letter.
+    pos=regexp(str,'^[^A-Za-z]','once');
+    if(~isempty(pos))
+        if(~isoct)
+            str=regexprep(str,'^([^A-Za-z])','x0x${sprintf(''%X'',unicode2native($1))}_','once');
+        else
+            str=sprintf('x0x%X_%s',char(str(1)),str(2:end));
+        end
+    end
+    if(isempty(regexp(str,'[^0-9A-Za-z_]', 'once' ))) return;  end
+    if(~isoct)
+        str=regexprep(str,'([^0-9A-Za-z_])','_0x${sprintf(''%X'',unicode2native($1))}_');
+    else
+        pos=regexp(str,'[^0-9A-Za-z_]');
+        if(isempty(pos)) return; end
+        str0=str;
+        pos0=[0 pos(:)' length(str)];
+        str='';
+        for i=1:length(pos)
+            str=[str str0(pos0(i)+1:pos(i)-1) sprintf('_0x%X_',str0(pos(i)))];
+        end
+        if(pos(end)~=length(str))
+            str=[str str0(pos0(end-1)+1:pos0(end))];
+        end
+    end
+    %str(~isletter(str) & ~('0' <= str & str <= '9')) = '_';
+
+%%-------------------------------------------------------------------------
+function endpos = matching_quote(str,pos)
+len=length(str);
+while(pos<len)
+    if(str(pos)=='"')
+        if(~(pos>1 && str(pos-1)=='\'))
+            endpos=pos;
+            return;
+        end        
+    end
+    pos=pos+1;
+end
+error('unmatched quotation mark');
+%%-------------------------------------------------------------------------
+function [endpos e1l e1r maxlevel] = matching_bracket(str,pos)
+global arraytoken
+level=1;
+maxlevel=level;
+endpos=0;
+bpos=arraytoken(arraytoken>=pos);
+tokens=str(bpos);
+len=length(tokens);
+pos=1;
+e1l=[];
+e1r=[];
+while(pos<=len)
+    c=tokens(pos);
+    if(c==']')
+        level=level-1;
+        if(isempty(e1r)) e1r=bpos(pos); end
+        if(level==0)
+            endpos=bpos(pos);
+            return
+        end
+    end
+    if(c=='[')
+        if(isempty(e1l)) e1l=bpos(pos); end
+        level=level+1;
+        maxlevel=max(maxlevel,level);
+    end
+    if(c=='"')
+        pos=matching_quote(tokens,pos+1);
+    end
+    pos=pos+1;
+end
+if(endpos==0) 
+    error('unmatched "]"');
+end
+

+ 33 - 0
machine learning/machine-learning-ex3/ex3/lib/jsonlab/mergestruct.m

@@ -0,0 +1,33 @@
+function s=mergestruct(s1,s2)
+%
+% s=mergestruct(s1,s2)
+%
+% merge two struct objects into one
+%
+% authors:Qianqian Fang (fangq<at> nmr.mgh.harvard.edu)
+% date: 2012/12/22
+%
+% input:
+%      s1,s2: a struct object, s1 and s2 can not be arrays
+%
+% output:
+%      s: the merged struct object. fields in s1 and s2 will be combined in s.
+%
+% license:
+%     BSD, see LICENSE_BSD.txt files for details 
+%
+% -- this function is part of jsonlab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)
+%
+
+if(~isstruct(s1) || ~isstruct(s2))
+    error('input parameters contain non-struct');
+end
+if(length(s1)>1 || length(s2)>1)
+    error('can not merge struct arrays');
+end
+fn=fieldnames(s2);
+s=s1;
+for i=1:length(fn)              
+    s=setfield(s,fn{i},getfield(s2,fn{i}));
+end
+

+ 475 - 0
machine learning/machine-learning-ex3/ex3/lib/jsonlab/savejson.m

@@ -0,0 +1,475 @@
+function json=savejson(rootname,obj,varargin)
+%
+% json=savejson(rootname,obj,filename)
+%    or
+% json=savejson(rootname,obj,opt)
+% json=savejson(rootname,obj,'param1',value1,'param2',value2,...)
+%
+% convert a MATLAB object (cell, struct or array) into a JSON (JavaScript
+% Object Notation) string
+%
+% author: Qianqian Fang (fangq<at> nmr.mgh.harvard.edu)
+% created on 2011/09/09
+%
+% $Id: savejson.m 460 2015-01-03 00:30:45Z fangq $
+%
+% input:
+%      rootname: the name of the root-object, when set to '', the root name
+%        is ignored, however, when opt.ForceRootName is set to 1 (see below),
+%        the MATLAB variable name will be used as the root name.
+%      obj: a MATLAB object (array, cell, cell array, struct, struct array).
+%      filename: a string for the file name to save the output JSON data.
+%      opt: a struct for additional options, ignore to use default values.
+%        opt can have the following fields (first in [.|.] is the default)
+%
+%        opt.FileName [''|string]: a file name to save the output JSON data
+%        opt.FloatFormat ['%.10g'|string]: format to show each numeric element
+%                         of a 1D/2D array;
+%        opt.ArrayIndent [1|0]: if 1, output explicit data array with
+%                         precedent indentation; if 0, no indentation
+%        opt.ArrayToStruct[0|1]: when set to 0, savejson outputs 1D/2D
+%                         array in JSON array format; if sets to 1, an
+%                         array will be shown as a struct with fields
+%                         "_ArrayType_", "_ArraySize_" and "_ArrayData_"; for
+%                         sparse arrays, the non-zero elements will be
+%                         saved to _ArrayData_ field in triplet-format i.e.
+%                         (ix,iy,val) and "_ArrayIsSparse_" will be added
+%                         with a value of 1; for a complex array, the 
+%                         _ArrayData_ array will include two columns 
+%                         (4 for sparse) to record the real and imaginary 
+%                         parts, and also "_ArrayIsComplex_":1 is added. 
+%        opt.ParseLogical [0|1]: if this is set to 1, logical array elem
+%                         will use true/false rather than 1/0.
+%        opt.NoRowBracket [1|0]: if this is set to 1, arrays with a single
+%                         numerical element will be shown without a square
+%                         bracket, unless it is the root object; if 0, square
+%                         brackets are forced for any numerical arrays.
+%        opt.ForceRootName [0|1]: when set to 1 and rootname is empty, savejson
+%                         will use the name of the passed obj variable as the 
+%                         root object name; if obj is an expression and 
+%                         does not have a name, 'root' will be used; if this 
+%                         is set to 0 and rootname is empty, the root level 
+%                         will be merged down to the lower level.
+%        opt.Inf ['"$1_Inf_"'|string]: a customized regular expression pattern
+%                         to represent +/-Inf. The matched pattern is '([-+]*)Inf'
+%                         and $1 represents the sign. For those who want to use
+%                         1e999 to represent Inf, they can set opt.Inf to '$11e999'
+%        opt.NaN ['"_NaN_"'|string]: a customized regular expression pattern
+%                         to represent NaN
+%        opt.JSONP [''|string]: to generate a JSONP output (JSON with padding),
+%                         for example, if opt.JSONP='foo', the JSON data is
+%                         wrapped inside a function call as 'foo(...);'
+%        opt.UnpackHex [1|0]: conver the 0x[hex code] output by loadjson 
+%                         back to the string form
+%        opt.SaveBinary [0|1]: 1 - save the JSON file in binary mode; 0 - text mode.
+%        opt.Compact [0|1]: 1- out compact JSON format (remove all newlines and tabs)
+%
+%        opt can be replaced by a list of ('param',value) pairs. The param 
+%        string is equivallent to a field in opt and is case sensitive.
+% output:
+%      json: a string in the JSON format (see http://json.org)
+%
+% examples:
+%      jsonmesh=struct('MeshNode',[0 0 0;1 0 0;0 1 0;1 1 0;0 0 1;1 0 1;0 1 1;1 1 1],... 
+%               'MeshTetra',[1 2 4 8;1 3 4 8;1 2 6 8;1 5 6 8;1 5 7 8;1 3 7 8],...
+%               'MeshTri',[1 2 4;1 2 6;1 3 4;1 3 7;1 5 6;1 5 7;...
+%                          2 8 4;2 8 6;3 8 4;3 8 7;5 8 6;5 8 7],...
+%               'MeshCreator','FangQ','MeshTitle','T6 Cube',...
+%               'SpecialData',[nan, inf, -inf]);
+%      savejson('jmesh',jsonmesh)
+%      savejson('',jsonmesh,'ArrayIndent',0,'FloatFormat','\t%.5g')
+%
+% license:
+%     BSD, see LICENSE_BSD.txt files for details
+%
+% -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)
+%
+
+if(nargin==1)
+   varname=inputname(1);
+   obj=rootname;
+   if(isempty(varname)) 
+      varname='root';
+   end
+   rootname=varname;
+else
+   varname=inputname(2);
+end
+if(length(varargin)==1 && ischar(varargin{1}))
+   opt=struct('FileName',varargin{1});
+else
+   opt=varargin2struct(varargin{:});
+end
+opt.IsOctave=exist('OCTAVE_VERSION','builtin');
+rootisarray=0;
+rootlevel=1;
+forceroot=jsonopt('ForceRootName',0,opt);
+if((isnumeric(obj) || islogical(obj) || ischar(obj) || isstruct(obj) || iscell(obj)) && isempty(rootname) && forceroot==0)
+    rootisarray=1;
+    rootlevel=0;
+else
+    if(isempty(rootname))
+        rootname=varname;
+    end
+end
+if((isstruct(obj) || iscell(obj))&& isempty(rootname) && forceroot)
+    rootname='root';
+end
+
+whitespaces=struct('tab',sprintf('\t'),'newline',sprintf('\n'),'sep',sprintf(',\n'));
+if(jsonopt('Compact',0,opt)==1)
+    whitespaces=struct('tab','','newline','','sep',',');
+end
+if(~isfield(opt,'whitespaces_'))
+    opt.whitespaces_=whitespaces;
+end
+
+nl=whitespaces.newline;
+
+json=obj2json(rootname,obj,rootlevel,opt);
+if(rootisarray)
+    json=sprintf('%s%s',json,nl);
+else
+    json=sprintf('{%s%s%s}\n',nl,json,nl);
+end
+
+jsonp=jsonopt('JSONP','',opt);
+if(~isempty(jsonp))
+    json=sprintf('%s(%s);%s',jsonp,json,nl);
+end
+
+% save to a file if FileName is set, suggested by Patrick Rapin
+if(~isempty(jsonopt('FileName','',opt)))
+    if(jsonopt('SaveBinary',0,opt)==1)
+	    fid = fopen(opt.FileName, 'wb');
+	    fwrite(fid,json);
+    else
+	    fid = fopen(opt.FileName, 'wt');
+	    fwrite(fid,json,'char');
+    end
+    fclose(fid);
+end
+
+%%-------------------------------------------------------------------------
+function txt=obj2json(name,item,level,varargin)
+
+if(iscell(item))
+    txt=cell2json(name,item,level,varargin{:});
+elseif(isstruct(item))
+    txt=struct2json(name,item,level,varargin{:});
+elseif(ischar(item))
+    txt=str2json(name,item,level,varargin{:});
+else
+    txt=mat2json(name,item,level,varargin{:});
+end
+
+%%-------------------------------------------------------------------------
+function txt=cell2json(name,item,level,varargin)
+txt='';
+if(~iscell(item))
+        error('input is not a cell');
+end
+
+dim=size(item);
+if(ndims(squeeze(item))>2) % for 3D or higher dimensions, flatten to 2D for now
+    item=reshape(item,dim(1),numel(item)/dim(1));
+    dim=size(item);
+end
+len=numel(item);
+ws=jsonopt('whitespaces_',struct('tab',sprintf('\t'),'newline',sprintf('\n'),'sep',sprintf(',\n')),varargin{:});
+padding0=repmat(ws.tab,1,level);
+padding2=repmat(ws.tab,1,level+1);
+nl=ws.newline;
+if(len>1)
+    if(~isempty(name))
+        txt=sprintf('%s"%s": [%s',padding0, checkname(name,varargin{:}),nl); name=''; 
+    else
+        txt=sprintf('%s[%s',padding0,nl); 
+    end
+elseif(len==0)
+    if(~isempty(name))
+        txt=sprintf('%s"%s": []',padding0, checkname(name,varargin{:})); name=''; 
+    else
+        txt=sprintf('%s[]',padding0); 
+    end
+end
+for j=1:dim(2)
+    if(dim(1)>1) txt=sprintf('%s%s[%s',txt,padding2,nl); end
+    for i=1:dim(1)
+       txt=sprintf('%s%s',txt,obj2json(name,item{i,j},level+(dim(1)>1)+1,varargin{:}));
+       if(i<dim(1)) txt=sprintf('%s%s',txt,sprintf(',%s',nl)); end
+    end
+    if(dim(1)>1) txt=sprintf('%s%s%s]',txt,nl,padding2); end
+    if(j<dim(2)) txt=sprintf('%s%s',txt,sprintf(',%s',nl)); end
+    %if(j==dim(2)) txt=sprintf('%s%s',txt,sprintf(',%s',nl)); end
+end
+if(len>1) txt=sprintf('%s%s%s]',txt,nl,padding0); end
+
+%%-------------------------------------------------------------------------
+function txt=struct2json(name,item,level,varargin)
+txt='';
+if(~isstruct(item))
+	error('input is not a struct');
+end
+dim=size(item);
+if(ndims(squeeze(item))>2) % for 3D or higher dimensions, flatten to 2D for now
+    item=reshape(item,dim(1),numel(item)/dim(1));
+    dim=size(item);
+end
+len=numel(item);
+ws=struct('tab',sprintf('\t'),'newline',sprintf('\n'));
+ws=jsonopt('whitespaces_',ws,varargin{:});
+padding0=repmat(ws.tab,1,level);
+padding2=repmat(ws.tab,1,level+1);
+padding1=repmat(ws.tab,1,level+(dim(1)>1)+(len>1));
+nl=ws.newline;
+
+if(~isempty(name)) 
+    if(len>1) txt=sprintf('%s"%s": [%s',padding0,checkname(name,varargin{:}),nl); end
+else
+    if(len>1) txt=sprintf('%s[%s',padding0,nl); end
+end
+for j=1:dim(2)
+  if(dim(1)>1) txt=sprintf('%s%s[%s',txt,padding2,nl); end
+  for i=1:dim(1)
+    names = fieldnames(item(i,j));
+    if(~isempty(name) && len==1)
+        txt=sprintf('%s%s"%s": {%s',txt,padding1, checkname(name,varargin{:}),nl); 
+    else
+        txt=sprintf('%s%s{%s',txt,padding1,nl); 
+    end
+    if(~isempty(names))
+      for e=1:length(names)
+	    txt=sprintf('%s%s',txt,obj2json(names{e},getfield(item(i,j),...
+             names{e}),level+(dim(1)>1)+1+(len>1),varargin{:}));
+        if(e<length(names)) txt=sprintf('%s%s',txt,','); end
+        txt=sprintf('%s%s',txt,nl);
+      end
+    end
+    txt=sprintf('%s%s}',txt,padding1);
+    if(i<dim(1)) txt=sprintf('%s%s',txt,sprintf(',%s',nl)); end
+  end
+  if(dim(1)>1) txt=sprintf('%s%s%s]',txt,nl,padding2); end
+  if(j<dim(2)) txt=sprintf('%s%s',txt,sprintf(',%s',nl)); end
+end
+if(len>1) txt=sprintf('%s%s%s]',txt,nl,padding0); end
+
+%%-------------------------------------------------------------------------
+function txt=str2json(name,item,level,varargin)
+txt='';
+if(~ischar(item))
+        error('input is not a string');
+end
+item=reshape(item, max(size(item),[1 0]));
+len=size(item,1);
+ws=struct('tab',sprintf('\t'),'newline',sprintf('\n'),'sep',sprintf(',\n'));
+ws=jsonopt('whitespaces_',ws,varargin{:});
+padding1=repmat(ws.tab,1,level);
+padding0=repmat(ws.tab,1,level+1);
+nl=ws.newline;
+sep=ws.sep;
+
+if(~isempty(name)) 
+    if(len>1) txt=sprintf('%s"%s": [%s',padding1,checkname(name,varargin{:}),nl); end
+else
+    if(len>1) txt=sprintf('%s[%s',padding1,nl); end
+end
+isoct=jsonopt('IsOctave',0,varargin{:});
+for e=1:len
+    if(isoct)
+        val=regexprep(item(e,:),'\\','\\');
+        val=regexprep(val,'"','\"');
+        val=regexprep(val,'^"','\"');
+    else
+        val=regexprep(item(e,:),'\\','\\\\');
+        val=regexprep(val,'"','\\"');
+        val=regexprep(val,'^"','\\"');
+    end
+    val=escapejsonstring(val);
+    if(len==1)
+        obj=['"' checkname(name,varargin{:}) '": ' '"',val,'"'];
+	if(isempty(name)) obj=['"',val,'"']; end
+        txt=sprintf('%s%s%s%s',txt,padding1,obj);
+    else
+        txt=sprintf('%s%s%s%s',txt,padding0,['"',val,'"']);
+    end
+    if(e==len) sep=''; end
+    txt=sprintf('%s%s',txt,sep);
+end
+if(len>1) txt=sprintf('%s%s%s%s',txt,nl,padding1,']'); end
+
+%%-------------------------------------------------------------------------
+function txt=mat2json(name,item,level,varargin)
+if(~isnumeric(item) && ~islogical(item))
+        error('input is not an array');
+end
+ws=struct('tab',sprintf('\t'),'newline',sprintf('\n'),'sep',sprintf(',\n'));
+ws=jsonopt('whitespaces_',ws,varargin{:});
+padding1=repmat(ws.tab,1,level);
+padding0=repmat(ws.tab,1,level+1);
+nl=ws.newline;
+sep=ws.sep;
+
+if(length(size(item))>2 || issparse(item) || ~isreal(item) || ...
+   isempty(item) ||jsonopt('ArrayToStruct',0,varargin{:}))
+    if(isempty(name))
+    	txt=sprintf('%s{%s%s"_ArrayType_": "%s",%s%s"_ArraySize_": %s,%s',...
+              padding1,nl,padding0,class(item),nl,padding0,regexprep(mat2str(size(item)),'\s+',','),nl);
+    else
+    	txt=sprintf('%s"%s": {%s%s"_ArrayType_": "%s",%s%s"_ArraySize_": %s,%s',...
+              padding1,checkname(name,varargin{:}),nl,padding0,class(item),nl,padding0,regexprep(mat2str(size(item)),'\s+',','),nl);
+    end
+else
+    if(numel(item)==1 && jsonopt('NoRowBracket',1,varargin{:})==1 && level>0)
+        numtxt=regexprep(regexprep(matdata2json(item,level+1,varargin{:}),'^\[',''),']','');
+    else
+        numtxt=matdata2json(item,level+1,varargin{:});
+    end
+    if(isempty(name))
+    	txt=sprintf('%s%s',padding1,numtxt);
+    else
+        if(numel(item)==1 && jsonopt('NoRowBracket',1,varargin{:})==1)
+           	txt=sprintf('%s"%s": %s',padding1,checkname(name,varargin{:}),numtxt);
+        else
+    	    txt=sprintf('%s"%s": %s',padding1,checkname(name,varargin{:}),numtxt);
+        end
+    end
+    return;
+end
+dataformat='%s%s%s%s%s';
+
+if(issparse(item))
+    [ix,iy]=find(item);
+    data=full(item(find(item)));
+    if(~isreal(item))
+       data=[real(data(:)),imag(data(:))];
+       if(size(item,1)==1)
+           % Kludge to have data's 'transposedness' match item's.
+           % (Necessary for complex row vector handling below.)
+           data=data';
+       end
+       txt=sprintf(dataformat,txt,padding0,'"_ArrayIsComplex_": ','1', sep);
+    end
+    txt=sprintf(dataformat,txt,padding0,'"_ArrayIsSparse_": ','1', sep);
+    if(size(item,1)==1)
+        % Row vector, store only column indices.
+        txt=sprintf(dataformat,txt,padding0,'"_ArrayData_": ',...
+           matdata2json([iy(:),data'],level+2,varargin{:}), nl);
+    elseif(size(item,2)==1)
+        % Column vector, store only row indices.
+        txt=sprintf(dataformat,txt,padding0,'"_ArrayData_": ',...
+           matdata2json([ix,data],level+2,varargin{:}), nl);
+    else
+        % General case, store row and column indices.
+        txt=sprintf(dataformat,txt,padding0,'"_ArrayData_": ',...
+           matdata2json([ix,iy,data],level+2,varargin{:}), nl);
+    end
+else
+    if(isreal(item))
+        txt=sprintf(dataformat,txt,padding0,'"_ArrayData_": ',...
+            matdata2json(item(:)',level+2,varargin{:}), nl);
+    else
+        txt=sprintf(dataformat,txt,padding0,'"_ArrayIsComplex_": ','1', sep);
+        txt=sprintf(dataformat,txt,padding0,'"_ArrayData_": ',...
+            matdata2json([real(item(:)) imag(item(:))],level+2,varargin{:}), nl);
+    end
+end
+txt=sprintf('%s%s%s',txt,padding1,'}');
+
+%%-------------------------------------------------------------------------
+function txt=matdata2json(mat,level,varargin)
+
+ws=struct('tab',sprintf('\t'),'newline',sprintf('\n'),'sep',sprintf(',\n'));
+ws=jsonopt('whitespaces_',ws,varargin{:});
+tab=ws.tab;
+nl=ws.newline;
+
+if(size(mat,1)==1)
+    pre='';
+    post='';
+    level=level-1;
+else
+    pre=sprintf('[%s',nl);
+    post=sprintf('%s%s]',nl,repmat(tab,1,level-1));
+end
+
+if(isempty(mat))
+    txt='null';
+    return;
+end
+floatformat=jsonopt('FloatFormat','%.10g',varargin{:});
+%if(numel(mat)>1)
+    formatstr=['[' repmat([floatformat ','],1,size(mat,2)-1) [floatformat sprintf('],%s',nl)]];
+%else
+%    formatstr=[repmat([floatformat ','],1,size(mat,2)-1) [floatformat sprintf(',\n')]];
+%end
+
+if(nargin>=2 && size(mat,1)>1 && jsonopt('ArrayIndent',1,varargin{:})==1)
+    formatstr=[repmat(tab,1,level) formatstr];
+end
+
+txt=sprintf(formatstr,mat');
+txt(end-length(nl):end)=[];
+if(islogical(mat) && jsonopt('ParseLogical',0,varargin{:})==1)
+   txt=regexprep(txt,'1','true');
+   txt=regexprep(txt,'0','false');
+end
+%txt=regexprep(mat2str(mat),'\s+',',');
+%txt=regexprep(txt,';',sprintf('],\n['));
+% if(nargin>=2 && size(mat,1)>1)
+%     txt=regexprep(txt,'\[',[repmat(sprintf('\t'),1,level) '[']);
+% end
+txt=[pre txt post];
+if(any(isinf(mat(:))))
+    txt=regexprep(txt,'([-+]*)Inf',jsonopt('Inf','"$1_Inf_"',varargin{:}));
+end
+if(any(isnan(mat(:))))
+    txt=regexprep(txt,'NaN',jsonopt('NaN','"_NaN_"',varargin{:}));
+end
+
+%%-------------------------------------------------------------------------
+function newname=checkname(name,varargin)
+isunpack=jsonopt('UnpackHex',1,varargin{:});
+newname=name;
+if(isempty(regexp(name,'0x([0-9a-fA-F]+)_','once')))
+    return
+end
+if(isunpack)
+    isoct=jsonopt('IsOctave',0,varargin{:});
+    if(~isoct)
+        newname=regexprep(name,'(^x|_){1}0x([0-9a-fA-F]+)_','${native2unicode(hex2dec($2))}');
+    else
+        pos=regexp(name,'(^x|_){1}0x([0-9a-fA-F]+)_','start');
+        pend=regexp(name,'(^x|_){1}0x([0-9a-fA-F]+)_','end');
+        if(isempty(pos)) return; end
+        str0=name;
+        pos0=[0 pend(:)' length(name)];
+        newname='';
+        for i=1:length(pos)
+            newname=[newname str0(pos0(i)+1:pos(i)-1) char(hex2dec(str0(pos(i)+3:pend(i)-1)))];
+        end
+        if(pos(end)~=length(name))
+            newname=[newname str0(pos0(end-1)+1:pos0(end))];
+        end
+    end
+end
+
+%%-------------------------------------------------------------------------
+function newstr=escapejsonstring(str)
+newstr=str;
+isoct=exist('OCTAVE_VERSION','builtin');
+if(isoct)
+   vv=sscanf(OCTAVE_VERSION,'%f');
+   if(vv(1)>=3.8) isoct=0; end
+end
+if(isoct)
+  escapechars={'\a','\f','\n','\r','\t','\v'};
+  for i=1:length(escapechars);
+    newstr=regexprep(newstr,escapechars{i},escapechars{i});
+  end
+else
+  escapechars={'\a','\b','\f','\n','\r','\t','\v'};
+  for i=1:length(escapechars);
+    newstr=regexprep(newstr,escapechars{i},regexprep(escapechars{i},'\\','\\\\'));
+  end
+end

+ 504 - 0
machine learning/machine-learning-ex3/ex3/lib/jsonlab/saveubjson.m

@@ -0,0 +1,504 @@
+function json=saveubjson(rootname,obj,varargin)
+%
+% json=saveubjson(rootname,obj,filename)
+%    or
+% json=saveubjson(rootname,obj,opt)
+% json=saveubjson(rootname,obj,'param1',value1,'param2',value2,...)
+%
+% convert a MATLAB object (cell, struct or array) into a Universal 
+% Binary JSON (UBJSON) binary string
+%
+% author: Qianqian Fang (fangq<at> nmr.mgh.harvard.edu)
+% created on 2013/08/17
+%
+% $Id: saveubjson.m 460 2015-01-03 00:30:45Z fangq $
+%
+% input:
+%      rootname: the name of the root-object, when set to '', the root name
+%        is ignored, however, when opt.ForceRootName is set to 1 (see below),
+%        the MATLAB variable name will be used as the root name.
+%      obj: a MATLAB object (array, cell, cell array, struct, struct array)
+%      filename: a string for the file name to save the output UBJSON data
+%      opt: a struct for additional options, ignore to use default values.
+%        opt can have the following fields (first in [.|.] is the default)
+%
+%        opt.FileName [''|string]: a file name to save the output JSON data
+%        opt.ArrayToStruct[0|1]: when set to 0, saveubjson outputs 1D/2D
+%                         array in JSON array format; if sets to 1, an
+%                         array will be shown as a struct with fields
+%                         "_ArrayType_", "_ArraySize_" and "_ArrayData_"; for
+%                         sparse arrays, the non-zero elements will be
+%                         saved to _ArrayData_ field in triplet-format i.e.
+%                         (ix,iy,val) and "_ArrayIsSparse_" will be added
+%                         with a value of 1; for a complex array, the 
+%                         _ArrayData_ array will include two columns 
+%                         (4 for sparse) to record the real and imaginary 
+%                         parts, and also "_ArrayIsComplex_":1 is added. 
+%        opt.ParseLogical [1|0]: if this is set to 1, logical array elem
+%                         will use true/false rather than 1/0.
+%        opt.NoRowBracket [1|0]: if this is set to 1, arrays with a single
+%                         numerical element will be shown without a square
+%                         bracket, unless it is the root object; if 0, square
+%                         brackets are forced for any numerical arrays.
+%        opt.ForceRootName [0|1]: when set to 1 and rootname is empty, saveubjson
+%                         will use the name of the passed obj variable as the 
+%                         root object name; if obj is an expression and 
+%                         does not have a name, 'root' will be used; if this 
+%                         is set to 0 and rootname is empty, the root level 
+%                         will be merged down to the lower level.
+%        opt.JSONP [''|string]: to generate a JSONP output (JSON with padding),
+%                         for example, if opt.JSON='foo', the JSON data is
+%                         wrapped inside a function call as 'foo(...);'
+%        opt.UnpackHex [1|0]: conver the 0x[hex code] output by loadjson 
+%                         back to the string form
+%
+%        opt can be replaced by a list of ('param',value) pairs. The param 
+%        string is equivallent to a field in opt and is case sensitive.
+% output:
+%      json: a binary string in the UBJSON format (see http://ubjson.org)
+%
+% examples:
+%      jsonmesh=struct('MeshNode',[0 0 0;1 0 0;0 1 0;1 1 0;0 0 1;1 0 1;0 1 1;1 1 1],... 
+%               'MeshTetra',[1 2 4 8;1 3 4 8;1 2 6 8;1 5 6 8;1 5 7 8;1 3 7 8],...
+%               'MeshTri',[1 2 4;1 2 6;1 3 4;1 3 7;1 5 6;1 5 7;...
+%                          2 8 4;2 8 6;3 8 4;3 8 7;5 8 6;5 8 7],...
+%               'MeshCreator','FangQ','MeshTitle','T6 Cube',...
+%               'SpecialData',[nan, inf, -inf]);
+%      saveubjson('jsonmesh',jsonmesh)
+%      saveubjson('jsonmesh',jsonmesh,'meshdata.ubj')
+%
+% license:
+%     BSD, see LICENSE_BSD.txt files for details
+%
+% -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)
+%
+
+if(nargin==1)
+   varname=inputname(1);
+   obj=rootname;
+   if(isempty(varname)) 
+      varname='root';
+   end
+   rootname=varname;
+else
+   varname=inputname(2);
+end
+if(length(varargin)==1 && ischar(varargin{1}))
+   opt=struct('FileName',varargin{1});
+else
+   opt=varargin2struct(varargin{:});
+end
+opt.IsOctave=exist('OCTAVE_VERSION','builtin');
+rootisarray=0;
+rootlevel=1;
+forceroot=jsonopt('ForceRootName',0,opt);
+if((isnumeric(obj) || islogical(obj) || ischar(obj) || isstruct(obj) || iscell(obj)) && isempty(rootname) && forceroot==0)
+    rootisarray=1;
+    rootlevel=0;
+else
+    if(isempty(rootname))
+        rootname=varname;
+    end
+end
+if((isstruct(obj) || iscell(obj))&& isempty(rootname) && forceroot)
+    rootname='root';
+end
+json=obj2ubjson(rootname,obj,rootlevel,opt);
+if(~rootisarray)
+    json=['{' json '}'];
+end
+
+jsonp=jsonopt('JSONP','',opt);
+if(~isempty(jsonp))
+    json=[jsonp '(' json ')'];
+end
+
+% save to a file if FileName is set, suggested by Patrick Rapin
+if(~isempty(jsonopt('FileName','',opt)))
+    fid = fopen(opt.FileName, 'wb');
+    fwrite(fid,json);
+    fclose(fid);
+end
+
+%%-------------------------------------------------------------------------
+function txt=obj2ubjson(name,item,level,varargin)
+
+if(iscell(item))
+    txt=cell2ubjson(name,item,level,varargin{:});
+elseif(isstruct(item))
+    txt=struct2ubjson(name,item,level,varargin{:});
+elseif(ischar(item))
+    txt=str2ubjson(name,item,level,varargin{:});
+else
+    txt=mat2ubjson(name,item,level,varargin{:});
+end
+
+%%-------------------------------------------------------------------------
+function txt=cell2ubjson(name,item,level,varargin)
+txt='';
+if(~iscell(item))
+        error('input is not a cell');
+end
+
+dim=size(item);
+if(ndims(squeeze(item))>2) % for 3D or higher dimensions, flatten to 2D for now
+    item=reshape(item,dim(1),numel(item)/dim(1));
+    dim=size(item);
+end
+len=numel(item); % let's handle 1D cell first
+if(len>1) 
+    if(~isempty(name))
+        txt=[S_(checkname(name,varargin{:})) '[']; name=''; 
+    else
+        txt='['; 
+    end
+elseif(len==0)
+    if(~isempty(name))
+        txt=[S_(checkname(name,varargin{:})) 'Z']; name=''; 
+    else
+        txt='Z'; 
+    end
+end
+for j=1:dim(2)
+    if(dim(1)>1) txt=[txt '[']; end
+    for i=1:dim(1)
+       txt=[txt obj2ubjson(name,item{i,j},level+(len>1),varargin{:})];
+    end
+    if(dim(1)>1) txt=[txt ']']; end
+end
+if(len>1) txt=[txt ']']; end
+
+%%-------------------------------------------------------------------------
+function txt=struct2ubjson(name,item,level,varargin)
+txt='';
+if(~isstruct(item))
+	error('input is not a struct');
+end
+dim=size(item);
+if(ndims(squeeze(item))>2) % for 3D or higher dimensions, flatten to 2D for now
+    item=reshape(item,dim(1),numel(item)/dim(1));
+    dim=size(item);
+end
+len=numel(item);
+
+if(~isempty(name)) 
+    if(len>1) txt=[S_(checkname(name,varargin{:})) '[']; end
+else
+    if(len>1) txt='['; end
+end
+for j=1:dim(2)
+  if(dim(1)>1) txt=[txt '[']; end
+  for i=1:dim(1)
+     names = fieldnames(item(i,j));
+     if(~isempty(name) && len==1)
+        txt=[txt S_(checkname(name,varargin{:})) '{']; 
+     else
+        txt=[txt '{']; 
+     end
+     if(~isempty(names))
+       for e=1:length(names)
+	     txt=[txt obj2ubjson(names{e},getfield(item(i,j),...
+             names{e}),level+(dim(1)>1)+1+(len>1),varargin{:})];
+       end
+     end
+     txt=[txt '}'];
+  end
+  if(dim(1)>1) txt=[txt ']']; end
+end
+if(len>1) txt=[txt ']']; end
+
+%%-------------------------------------------------------------------------
+function txt=str2ubjson(name,item,level,varargin)
+txt='';
+if(~ischar(item))
+        error('input is not a string');
+end
+item=reshape(item, max(size(item),[1 0]));
+len=size(item,1);
+
+if(~isempty(name)) 
+    if(len>1) txt=[S_(checkname(name,varargin{:})) '[']; end
+else
+    if(len>1) txt='['; end
+end
+isoct=jsonopt('IsOctave',0,varargin{:});
+for e=1:len
+    val=item(e,:);
+    if(len==1)
+        obj=['' S_(checkname(name,varargin{:})) '' '',S_(val),''];
+	if(isempty(name)) obj=['',S_(val),'']; end
+        txt=[txt,'',obj];
+    else
+        txt=[txt,'',['',S_(val),'']];
+    end
+end
+if(len>1) txt=[txt ']']; end
+
+%%-------------------------------------------------------------------------
+function txt=mat2ubjson(name,item,level,varargin)
+if(~isnumeric(item) && ~islogical(item))
+        error('input is not an array');
+end
+
+if(length(size(item))>2 || issparse(item) || ~isreal(item) || ...
+   isempty(item) || jsonopt('ArrayToStruct',0,varargin{:}))
+      cid=I_(uint32(max(size(item))));
+      if(isempty(name))
+    	txt=['{' S_('_ArrayType_'),S_(class(item)),S_('_ArraySize_'),I_a(size(item),cid(1)) ];
+      else
+          if(isempty(item))
+              txt=[S_(checkname(name,varargin{:})),'Z'];
+              return;
+          else
+    	      txt=[S_(checkname(name,varargin{:})),'{',S_('_ArrayType_'),S_(class(item)),S_('_ArraySize_'),I_a(size(item),cid(1))];
+          end
+      end
+else
+    if(isempty(name))
+    	txt=matdata2ubjson(item,level+1,varargin{:});
+    else
+        if(numel(item)==1 && jsonopt('NoRowBracket',1,varargin{:})==1)
+            numtxt=regexprep(regexprep(matdata2ubjson(item,level+1,varargin{:}),'^\[',''),']','');
+           	txt=[S_(checkname(name,varargin{:})) numtxt];
+        else
+    	    txt=[S_(checkname(name,varargin{:})),matdata2ubjson(item,level+1,varargin{:})];
+        end
+    end
+    return;
+end
+if(issparse(item))
+    [ix,iy]=find(item);
+    data=full(item(find(item)));
+    if(~isreal(item))
+       data=[real(data(:)),imag(data(:))];
+       if(size(item,1)==1)
+           % Kludge to have data's 'transposedness' match item's.
+           % (Necessary for complex row vector handling below.)
+           data=data';
+       end
+       txt=[txt,S_('_ArrayIsComplex_'),'T'];
+    end
+    txt=[txt,S_('_ArrayIsSparse_'),'T'];
+    if(size(item,1)==1)
+        % Row vector, store only column indices.
+        txt=[txt,S_('_ArrayData_'),...
+           matdata2ubjson([iy(:),data'],level+2,varargin{:})];
+    elseif(size(item,2)==1)
+        % Column vector, store only row indices.
+        txt=[txt,S_('_ArrayData_'),...
+           matdata2ubjson([ix,data],level+2,varargin{:})];
+    else
+        % General case, store row and column indices.
+        txt=[txt,S_('_ArrayData_'),...
+           matdata2ubjson([ix,iy,data],level+2,varargin{:})];
+    end
+else
+    if(isreal(item))
+        txt=[txt,S_('_ArrayData_'),...
+            matdata2ubjson(item(:)',level+2,varargin{:})];
+    else
+        txt=[txt,S_('_ArrayIsComplex_'),'T'];
+        txt=[txt,S_('_ArrayData_'),...
+            matdata2ubjson([real(item(:)) imag(item(:))],level+2,varargin{:})];
+    end
+end
+txt=[txt,'}'];
+
+%%-------------------------------------------------------------------------
+function txt=matdata2ubjson(mat,level,varargin)
+if(isempty(mat))
+    txt='Z';
+    return;
+end
+if(size(mat,1)==1)
+    level=level-1;
+end
+type='';
+hasnegtive=(mat<0);
+if(isa(mat,'integer') || isinteger(mat) || (isfloat(mat) && all(mod(mat(:),1) == 0)))
+    if(isempty(hasnegtive))
+       if(max(mat(:))<=2^8)
+           type='U';
+       end
+    end
+    if(isempty(type))
+        % todo - need to consider negative ones separately
+        id= histc(abs(max(mat(:))),[0 2^7 2^15 2^31 2^63]);
+        if(isempty(find(id)))
+            error('high-precision data is not yet supported');
+        end
+        key='iIlL';
+	type=key(find(id));
+    end
+    txt=[I_a(mat(:),type,size(mat))];
+elseif(islogical(mat))
+    logicalval='FT';
+    if(numel(mat)==1)
+        txt=logicalval(mat+1);
+    else
+        txt=['[$U#' I_a(size(mat),'l') typecast(swapbytes(uint8(mat(:)')),'uint8')];
+    end
+else
+    if(numel(mat)==1)
+        txt=['[' D_(mat) ']'];
+    else
+        txt=D_a(mat(:),'D',size(mat));
+    end
+end
+
+%txt=regexprep(mat2str(mat),'\s+',',');
+%txt=regexprep(txt,';',sprintf('],['));
+% if(nargin>=2 && size(mat,1)>1)
+%     txt=regexprep(txt,'\[',[repmat(sprintf('\t'),1,level) '[']);
+% end
+if(any(isinf(mat(:))))
+    txt=regexprep(txt,'([-+]*)Inf',jsonopt('Inf','"$1_Inf_"',varargin{:}));
+end
+if(any(isnan(mat(:))))
+    txt=regexprep(txt,'NaN',jsonopt('NaN','"_NaN_"',varargin{:}));
+end
+
+%%-------------------------------------------------------------------------
+function newname=checkname(name,varargin)
+isunpack=jsonopt('UnpackHex',1,varargin{:});
+newname=name;
+if(isempty(regexp(name,'0x([0-9a-fA-F]+)_','once')))
+    return
+end
+if(isunpack)
+    isoct=jsonopt('IsOctave',0,varargin{:});
+    if(~isoct)
+        newname=regexprep(name,'(^x|_){1}0x([0-9a-fA-F]+)_','${native2unicode(hex2dec($2))}');
+    else
+        pos=regexp(name,'(^x|_){1}0x([0-9a-fA-F]+)_','start');
+        pend=regexp(name,'(^x|_){1}0x([0-9a-fA-F]+)_','end');
+        if(isempty(pos)) return; end
+        str0=name;
+        pos0=[0 pend(:)' length(name)];
+        newname='';
+        for i=1:length(pos)
+            newname=[newname str0(pos0(i)+1:pos(i)-1) char(hex2dec(str0(pos(i)+3:pend(i)-1)))];
+        end
+        if(pos(end)~=length(name))
+            newname=[newname str0(pos0(end-1)+1:pos0(end))];
+        end
+    end
+end
+%%-------------------------------------------------------------------------
+function val=S_(str)
+if(length(str)==1)
+  val=['C' str];
+else
+  val=['S' I_(int32(length(str))) str];
+end
+%%-------------------------------------------------------------------------
+function val=I_(num)
+if(~isinteger(num))
+    error('input is not an integer');
+end
+if(num>=0 && num<255)
+   val=['U' data2byte(swapbytes(cast(num,'uint8')),'uint8')];
+   return;
+end
+key='iIlL';
+cid={'int8','int16','int32','int64'};
+for i=1:4
+  if((num>0 && num<2^(i*8-1)) || (num<0 && num>=-2^(i*8-1)))
+    val=[key(i) data2byte(swapbytes(cast(num,cid{i})),'uint8')];
+    return;
+  end
+end
+error('unsupported integer');
+
+%%-------------------------------------------------------------------------
+function val=D_(num)
+if(~isfloat(num))
+    error('input is not a float');
+end
+
+if(isa(num,'single'))
+  val=['d' data2byte(num,'uint8')];
+else
+  val=['D' data2byte(num,'uint8')];
+end
+%%-------------------------------------------------------------------------
+function data=I_a(num,type,dim,format)
+id=find(ismember('iUIlL',type));
+
+if(id==0)
+  error('unsupported integer array');
+end
+
+% based on UBJSON specs, all integer types are stored in big endian format
+
+if(id==1)
+  data=data2byte(swapbytes(int8(num)),'uint8');
+  blen=1;
+elseif(id==2)
+  data=data2byte(swapbytes(uint8(num)),'uint8');
+  blen=1;
+elseif(id==3)
+  data=data2byte(swapbytes(int16(num)),'uint8');
+  blen=2;
+elseif(id==4)
+  data=data2byte(swapbytes(int32(num)),'uint8');
+  blen=4;
+elseif(id==5)
+  data=data2byte(swapbytes(int64(num)),'uint8');
+  blen=8;
+end
+
+if(nargin>=3 && length(dim)>=2 && prod(dim)~=dim(2))
+  format='opt';
+end
+if((nargin<4 || strcmp(format,'opt')) && numel(num)>1)
+  if(nargin>=3 && (length(dim)==1 || (length(dim)>=2 && prod(dim)~=dim(2))))
+      cid=I_(uint32(max(dim)));
+      data=['$' type '#' I_a(dim,cid(1)) data(:)'];
+  else
+      data=['$' type '#' I_(int32(numel(data)/blen)) data(:)'];
+  end
+  data=['[' data(:)'];
+else
+  data=reshape(data,blen,numel(data)/blen);
+  data(2:blen+1,:)=data;
+  data(1,:)=type;
+  data=data(:)';
+  data=['[' data(:)' ']'];
+end
+%%-------------------------------------------------------------------------
+function data=D_a(num,type,dim,format)
+id=find(ismember('dD',type));
+
+if(id==0)
+  error('unsupported float array');
+end
+
+if(id==1)
+  data=data2byte(single(num),'uint8');
+elseif(id==2)
+  data=data2byte(double(num),'uint8');
+end
+
+if(nargin>=3 && length(dim)>=2 && prod(dim)~=dim(2))
+  format='opt';
+end
+if((nargin<4 || strcmp(format,'opt')) && numel(num)>1)
+  if(nargin>=3 && (length(dim)==1 || (length(dim)>=2 && prod(dim)~=dim(2))))
+      cid=I_(uint32(max(dim)));
+      data=['$' type '#' I_a(dim,cid(1)) data(:)'];
+  else
+      data=['$' type '#' I_(int32(numel(data)/(id*4))) data(:)'];
+  end
+  data=['[' data];
+else
+  data=reshape(data,(id*4),length(data)/(id*4));
+  data(2:(id*4+1),:)=data;
+  data(1,:)=type;
+  data=data(:)';
+  data=['[' data(:)' ']'];
+end
+%%-------------------------------------------------------------------------
+function bytes=data2byte(varargin)
+bytes=typecast(varargin{:});
+bytes=bytes(:)';

+ 40 - 0
machine learning/machine-learning-ex3/ex3/lib/jsonlab/varargin2struct.m

@@ -0,0 +1,40 @@
+function opt=varargin2struct(varargin)
+%
+% opt=varargin2struct('param1',value1,'param2',value2,...)
+%   or
+% opt=varargin2struct(...,optstruct,...)
+%
+% convert a series of input parameters into a structure
+%
+% authors:Qianqian Fang (fangq<at> nmr.mgh.harvard.edu)
+% date: 2012/12/22
+%
+% input:
+%      'param', value: the input parameters should be pairs of a string and a value
+%       optstruct: if a parameter is a struct, the fields will be merged to the output struct
+%
+% output:
+%      opt: a struct where opt.param1=value1, opt.param2=value2 ...
+%
+% license:
+%     BSD, see LICENSE_BSD.txt files for details 
+%
+% -- this function is part of jsonlab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)
+%
+
+len=length(varargin);
+opt=struct;
+if(len==0) return; end
+i=1;
+while(i<=len)
+    if(isstruct(varargin{i}))
+        opt=mergestruct(opt,varargin{i});
+    elseif(ischar(varargin{i}) && i<len)
+        opt=setfield(opt,varargin{i},varargin{i+1});
+        i=i+1;
+    else
+        error('input must be in the form of ...,''name'',value,... pairs or structs');
+    end
+    i=i+1;
+end
+

+ 30 - 0
machine learning/machine-learning-ex3/ex3/lib/makeValidFieldName.m

@@ -0,0 +1,30 @@
+function str = makeValidFieldName(str)
+% From MATLAB doc: field names must begin with a letter, which may be
+% followed by any combination of letters, digits, and underscores.
+% Invalid characters will be converted to underscores, and the prefix
+% "x0x[Hex code]_" will be added if the first character is not a letter.
+    isoct=exist('OCTAVE_VERSION','builtin');
+    pos=regexp(str,'^[^A-Za-z]','once');
+    if(~isempty(pos))
+        if(~isoct)
+            str=regexprep(str,'^([^A-Za-z])','x0x${sprintf(''%X'',unicode2native($1))}_','once');
+        else
+            str=sprintf('x0x%X_%s',char(str(1)),str(2:end));
+        end
+    end
+    if(isempty(regexp(str,'[^0-9A-Za-z_]', 'once' ))) return;  end
+    if(~isoct)
+        str=regexprep(str,'([^0-9A-Za-z_])','_0x${sprintf(''%X'',unicode2native($1))}_');
+    else
+        pos=regexp(str,'[^0-9A-Za-z_]');
+        if(isempty(pos)) return; end
+        str0=str;
+        pos0=[0 pos(:)' length(str)];
+        str='';
+        for i=1:length(pos)
+            str=[str str0(pos0(i)+1:pos(i)-1) sprintf('_0x%X_',str0(pos(i)))];
+        end
+        if(pos(end)~=length(str))
+            str=[str str0(pos0(end-1)+1:pos0(end))];
+        end
+    end

+ 179 - 0
machine learning/machine-learning-ex3/ex3/lib/submitWithConfiguration.m

@@ -0,0 +1,179 @@
+function submitWithConfiguration(conf)
+  addpath('./lib/jsonlab');
+
+  parts = parts(conf);
+
+  fprintf('== Submitting solutions | %s...\n', conf.itemName);
+
+  tokenFile = 'token.mat';
+  if exist(tokenFile, 'file')
+    load(tokenFile);
+    [email token] = promptToken(email, token, tokenFile);
+  else
+    [email token] = promptToken('', '', tokenFile);
+  end
+
+  if isempty(token)
+    fprintf('!! Submission Cancelled\n');
+    return
+  end
+
+  try
+    response = submitParts(conf, email, token, parts);
+  catch
+    e = lasterror();
+    fprintf('\n!! Submission failed: %s\n', e.message);
+    fprintf('\n\nFunction: %s\nFileName: %s\nLineNumber: %d\n', ...
+      e.stack(1,1).name, e.stack(1,1).file, e.stack(1,1).line);
+    fprintf('\nPlease correct your code and resubmit.\n');
+    return
+  end
+
+  if isfield(response, 'errorMessage')
+    fprintf('!! Submission failed: %s\n', response.errorMessage);
+  elseif isfield(response, 'errorCode')
+    fprintf('!! Submission failed: %s\n', response.message);
+  else
+    showFeedback(parts, response);
+    save(tokenFile, 'email', 'token');
+  end
+end
+
+function [email token] = promptToken(email, existingToken, tokenFile)
+  if (~isempty(email) && ~isempty(existingToken))
+    prompt = sprintf( ...
+      'Use token from last successful submission (%s)? (Y/n): ', ...
+      email);
+    reenter = input(prompt, 's');
+
+    if (isempty(reenter) || reenter(1) == 'Y' || reenter(1) == 'y')
+      token = existingToken;
+      return;
+    else
+      delete(tokenFile);
+    end
+  end
+  email = input('Login (email address): ', 's');
+  token = input('Token: ', 's');
+end
+
+function isValid = isValidPartOptionIndex(partOptions, i)
+  isValid = (~isempty(i)) && (1 <= i) && (i <= numel(partOptions));
+end
+
+function response = submitParts(conf, email, token, parts)
+  body = makePostBody(conf, email, token, parts);
+  submissionUrl = submissionUrl();
+
+  responseBody = getResponse(submissionUrl, body);
+  jsonResponse = validateResponse(responseBody);
+  response = loadjson(jsonResponse);
+end
+
+function body = makePostBody(conf, email, token, parts)
+  bodyStruct.assignmentSlug = conf.assignmentSlug;
+  bodyStruct.submitterEmail = email;
+  bodyStruct.secret = token;
+  bodyStruct.parts = makePartsStruct(conf, parts);
+
+  opt.Compact = 1;
+  body = savejson('', bodyStruct, opt);
+end
+
+function partsStruct = makePartsStruct(conf, parts)
+  for part = parts
+    partId = part{:}.id;
+    fieldName = makeValidFieldName(partId);
+    outputStruct.output = conf.output(partId);
+    partsStruct.(fieldName) = outputStruct;
+  end
+end
+
+function [parts] = parts(conf)
+  parts = {};
+  for partArray = conf.partArrays
+    part.id = partArray{:}{1};
+    part.sourceFiles = partArray{:}{2};
+    part.name = partArray{:}{3};
+    parts{end + 1} = part;
+  end
+end
+
+function showFeedback(parts, response)
+  fprintf('== \n');
+  fprintf('== %43s | %9s | %-s\n', 'Part Name', 'Score', 'Feedback');
+  fprintf('== %43s | %9s | %-s\n', '---------', '-----', '--------');
+  for part = parts
+    score = '';
+    partFeedback = '';
+    partFeedback = response.partFeedbacks.(makeValidFieldName(part{:}.id));
+    partEvaluation = response.partEvaluations.(makeValidFieldName(part{:}.id));
+    score = sprintf('%d / %3d', partEvaluation.score, partEvaluation.maxScore);
+    fprintf('== %43s | %9s | %-s\n', part{:}.name, score, partFeedback);
+  end
+  evaluation = response.evaluation;
+  totalScore = sprintf('%d / %d', evaluation.score, evaluation.maxScore);
+  fprintf('==                                   --------------------------------\n');
+  fprintf('== %43s | %9s | %-s\n', '', totalScore, '');
+  fprintf('== \n');
+end
+
+% use urlread or curl to send submit results to the grader and get a response
+function response = getResponse(url, body)
+% try using urlread() and a secure connection
+  params = {'jsonBody', body};
+  [response, success] = urlread(url, 'post', params);
+
+  if (success == 0)
+    % urlread didn't work, try curl & the peer certificate patch
+    if ispc
+      % testing note: use 'jsonBody =' for a test case
+      json_command = sprintf('echo jsonBody=%s | curl -k -X POST -d @- %s', body, url);
+    else
+      % it's linux/OS X, so use the other form
+      json_command = sprintf('echo ''jsonBody=%s'' | curl -k -X POST -d @- %s', body, url);
+    end
+    % get the response body for the peer certificate patch method
+    [code, response] = system(json_command);
+    % test the success code
+    if (code ~= 0)
+      fprintf('[error] submission with curl() was not successful\n');
+    end
+  end
+end
+
+% validate the grader's response
+function response = validateResponse(resp)
+  % test if the response is json or an HTML page
+  isJson = length(resp) > 0 && resp(1) == '{';
+  isHtml = findstr(lower(resp), '<html');
+
+  if (isJson)
+    response = resp;
+  elseif (isHtml)
+    % the response is html, so it's probably an error message
+    printHTMLContents(resp);
+    error('Grader response is an HTML message');
+  else
+    error('Grader sent no response');
+  end
+end
+
+% parse a HTML response and print it's contents
+function printHTMLContents(response)
+  strippedResponse = regexprep(response, '<[^>]+>', ' ');
+  strippedResponse = regexprep(strippedResponse, '[\t ]+', ' ');
+  fprintf(strippedResponse);
+end
+
+
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% Service configuration
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+function submissionUrl = submissionUrl()
+  submissionUrl = 'https://www-origin.coursera.org/api/onDemandProgrammingImmediateFormSubmissions.v1';
+end

+ 60 - 0
machine learning/machine-learning-ex3/ex3/lrCostFunction.m

@@ -0,0 +1,60 @@
+function [J, grad] = lrCostFunction(theta, X, y, lambda)
+%LRCOSTFUNCTION Compute cost and gradient for logistic regression with 
+%regularization
+%   J = LRCOSTFUNCTION(theta, X, y, lambda) computes the cost of using
+%   theta as the parameter for regularized logistic regression and the
+%   gradient of the cost w.r.t. to the parameters. 
+
+% Initialize some useful values
+m = length(y); % number of training examples
+
+% You need to return the following variables correctly 
+J = 0;
+grad = zeros(size(theta));
+
+% ====================== YOUR CODE HERE ======================
+% Instructions: Compute the cost of a particular choice of theta.
+%               You should set J to the cost.
+%               Compute the partial derivatives and set grad to the partial
+%               derivatives of the cost w.r.t. each parameter in theta
+%
+% Hint: The computation of the cost function and gradients can be
+%       efficiently vectorized. For example, consider the computation
+%
+%           sigmoid(X * theta)
+%
+%       Each row of the resulting matrix will contain the value of the
+%       prediction for that example. You can make use of this to vectorize
+%       the cost function and gradient computations. 
+%
+% Hint: When computing the gradient of the regularized cost function, 
+%       there're many possible vectorized solutions, but one solution
+%       looks like:
+%           grad = (unregularized gradient for logistic regression)
+%           temp = theta; 
+%           temp(1) = 0;   % because we don't add anything for j = 0  
+%           grad = grad + YOUR_CODE_HERE (using the temp variable)
+%
+% exclude the first term
+rt = lambda / (2 * m) * sum((theta(2:end) .^ 2));
+J = 1/m * sum(-y .* log(sigmoid(X * theta)) - (1 .- y) .* log(1 .- sigmoid(X * theta))) ...
+    + rt;
+
+% regularized mask
+rm = [zeros(1,1); theta(2:end)];
+grad = 1/m * X' * (sigmoid(X * theta) .- y) + lambda/m .* rm;
+
+    
+
+
+
+
+
+
+
+
+% =============================================================
+
+grad = grad(:);
+
+end

+ 83 - 0
machine learning/machine-learning-ex3/ex3/myex3.m

@@ -0,0 +1,83 @@
+%% Machine Learning Online Class - Exercise 3 | Part 1: One-vs-all
+
+%  Instructions
+%  ------------
+%
+%  This file contains code that helps you get started on the
+%  linear exercise. You will need to complete the following functions
+%  in this exericse:
+%
+%     lrCostFunction.m (logistic regression cost function)
+%     oneVsAll.m
+%     predictOneVsAll.m
+%     predict.m
+%
+%  For this exercise, you will not need to change any code in this file,
+%  or any other files other than those mentioned above.
+%
+
+%% Initialization
+clear ; close all; clc
+
+%% Setup the parameters you will use for this part of the exercise
+input_layer_size  = 400;  % 20x20 Input Images of Digits
+num_labels = 10;          % 10 labels, from 1 to 10
+                          % (note that we have mapped "0" to label 10)
+
+%% =========== Part 1: Loading and Visualizing Data =============
+%  We start the exercise by first loading and visualizing the dataset.
+%  You will be working with a dataset that contains handwritten digits.
+%
+
+% Load Training Data
+fprintf('Loading and Visualizing Data ...\n')
+
+load('ex3data1.mat'); % training data stored in arrays X, y
+m = size(X, 1);
+
+% Randomly select 100 data points to display
+rand_indices = randperm(m);
+sel = X(rand_indices(1:100), :);
+
+displayData(sel);
+
+fprintf('Program paused. Press enter to continue.\n');
+%pause;
+
+%% ============ Part 2a: Vectorize Logistic Regression ============
+%  In this part of the exercise, you will reuse your logistic regression
+%  code from the last exercise. You task here is to make sure that your
+%  regularized logistic regression implementation is vectorized. After
+%  that, you will implement one-vs-all classification for the handwritten
+%  digit dataset.
+%
+
+% Test case for lrCostFunction
+##fprintf('\nTesting lrCostFunction() with regularization');
+##
+theta_t = [-2; -1; 1; 2];
+X_t = [ones(5,1) reshape(1:15,5,3)/10];
+y_t = ([1;0;1;0;1] >= 0.5);
+lambda_t = 3;
+[J grad] = lrCostFunction(theta_t, X_t, y_t, lambda_t);
+
+fprintf('\nCost: %f\n', J);
+fprintf('Expected cost: 2.534819\n');
+fprintf('Gradients:\n');
+fprintf(' %f \n', grad);
+fprintf('Expected gradients:\n');
+fprintf(' 0.146561\n -0.548558\n 0.724722\n 1.398003\n');
+
+##fprintf('Program paused. Press enter to continue.\n');
+##pause;
+fprintf('\nTraining One-vs-All Logistic Regression...\n')
+
+lambda = 0.1;
+[all_theta] = oneVsAll(X, y, num_labels, lambda);
+
+fprintf('Program paused. Press enter to continue.\n');
+%% ================ Part 3: Predict for One-Vs-All ================
+
+pred = predictOneVsAll(all_theta, X);
+
+fprintf('\nTraining Set Accuracy: %f\n', mean(double(pred == y)) * 100);

+ 72 - 0
machine learning/machine-learning-ex3/ex3/myex3nn.m

@@ -0,0 +1,72 @@
+%% Machine Learning Online Class - Exercise 3 | Part 2: Neural Networks
+
+%  Instructions
+%  ------------
+% 
+%  This file contains code that helps you get started on the
+%  linear exercise. You will need to complete the following functions 
+%  in this exericse:
+%
+%     lrCostFunction.m (logistic regression cost function)
+%     oneVsAll.m
+%     predictOneVsAll.m
+%     predict.m
+%
+%  For this exercise, you will not need to change any code in this file,
+%  or any other files other than those mentioned above.
+%
+
+%% Initialization
+clear ; close all; clc
+
+%% Setup the parameters you will use for this exercise
+input_layer_size  = 400;  % 20x20 Input Images of Digits
+hidden_layer_size = 25;   % 25 hidden units
+num_labels = 10;          % 10 labels, from 1 to 10   
+                          % (note that we have mapped "0" to label 10)
+
+%% =========== Part 1: Loading and Visualizing Data =============
+%  We start the exercise by first loading and visualizing the dataset. 
+%  You will be working with a dataset that contains handwritten digits.
+%
+
+% Load Training Data
+fprintf('Loading and Visualizing Data ...\n')
+
+load('ex3data1.mat');
+m = size(X, 1);
+
+% Randomly select 100 data points to display
+sel = randperm(size(X, 1));
+sel = sel(1:100);
+
+displayData(X(sel, :));
+
+fprintf('Program paused. Press enter to continue.\n');
+
+%% ================ Part 2: Loading Pameters ================
+% In this part of the exercise, we load some pre-initialized 
+% neural network parameters.
+
+fprintf('\nLoading Saved Neural Network Parameters ...\n')
+
+% Load the weights into variables Theta1 and Theta2
+load('ex3weights.mat');
+
+%% ================= Part 3: Implement Predict =================
+%  After training the neural network, we would like to use it to predict
+%  the labels. You will now implement the "predict" function to use the
+%  neural network to predict the labels of the training set. This lets
+%  you compute the training set accuracy.
+
+pred = predict(Theta1, Theta2, X);
+
+fprintf('\nTraining Set Accuracy: %f\n', mean(double(pred == y)) * 100);
+
+fprintf('Program paused. Press enter to continue.\n');
+
+%  To give you an idea of the network's output, you can also run
+%  through the examples one at the a time to see what it is predicting.
+
+%  Randomly permute examples
+

+ 0 - 0
machine learning/machine-learning-ex3/ex3/octave-workspace


+ 77 - 0
machine learning/machine-learning-ex3/ex3/oneVsAll.m

@@ -0,0 +1,77 @@
+function [all_theta] = oneVsAll(X, y, num_labels, lambda)
+%ONEVSALL trains multiple logistic regression classifiers and returns all
+%the classifiers in a matrix all_theta, where the i-th row of all_theta 
+%corresponds to the classifier for label i
+%   [all_theta] = ONEVSALL(X, y, num_labels, lambda) trains num_labels
+%   logistic regression classifiers and returns each of these classifiers
+%   in a matrix all_theta, where the i-th row of all_theta corresponds 
+%   to the classifier for label i
+
+% Some useful variables
+m = size(X, 1);
+n = size(X, 2);
+
+% You need to return the following variables correctly 
+all_theta = zeros(num_labels, n + 1);
+
+% Add ones to the X data matrix
+X = [ones(m, 1) X];
+
+% ====================== YOUR CODE HERE ======================
+% Instructions: You should complete the following code to train num_labels
+%               logistic regression classifiers with regularization
+%               parameter lambda. 
+%
+% Hint: theta(:) will return a column vector.
+%
+% Hint: You can use y == c to obtain a vector of 1's and 0's that tell you
+%       whether the ground truth is true/false for this class.
+%
+% Note: For this assignment, we recommend using fmincg to optimize the cost
+%       function. It is okay to use a for-loop (for c = 1:num_labels) to
+%       loop over the different classes.
+%
+%       fmincg works similarly to fminunc, but is more efficient when we
+%       are dealing with large number of parameters.
+%
+% Example Code for fmincg:
+%
+%     % Set Initial theta
+%     initial_theta = zeros(n + 1, 1);
+%     
+%     % Set options for fminunc
+%     options = optimset('GradObj', 'on', 'MaxIter', 50);
+% 
+%     % Run fmincg to obtain the optimal theta
+%     % This function will return theta and the cost 
+%     [theta] = ...
+%         fmincg (@(t)(lrCostFunction(t, X, (y == c), lambda)), ...
+%                 initial_theta, options);
+%
+initial_theta = zeros(n + 1, 1);
+options = optimset('GradObj', 'on', 'MaxIter', 50);
+
+%fprintf ('unique y %f\n', unique(y))
+for i = 1:num_labels
+  %mask = mod(i, 10);  % map to => 1,2,3..8,9,0
+  %mask = i;
+  c =  i % zeros(rows(y), 1) + mask;
+  %size(c)
+  %size(y ==c)
+  [theta] = fmincg (@(t)(lrCostFunction(t, X, (y == c), lambda)), initial_theta, options);
+  %size(theta)
+  % copy the theta values for each classifier into the corresponding row of all_theta matrix
+  all_theta(i,:) = theta';
+endfor
+
+
+
+
+
+
+
+
+% =========================================================================
+
+
+end

+ 45 - 0
machine learning/machine-learning-ex3/ex3/predict.m

@@ -0,0 +1,45 @@
+function p = predict(Theta1, Theta2, X)
+%PREDICT Predict the label of an input given a trained neural network
+%   p = PREDICT(Theta1, Theta2, X) outputs the predicted label of X given the
+%   trained weights of a neural network (Theta1, Theta2)
+
+% Useful values
+m = size(X, 1);
+num_labels = size(Theta2, 1);
+
+% You need to return the following variables correctly 
+p = zeros(size(X, 1), 1);
+
+% ====================== YOUR CODE HERE ======================
+% Instructions: Complete the following code to make predictions using
+%               your learned neural network. You should set p to a 
+%               vector containing labels between 1 to num_labels.
+%
+% Hint: The max function might come in useful. In particular, the max
+%       function can also return the index of the max element, for more
+%       information see 'help max'. If your examples are in rows, then, you
+%       can use max(A, [], 2) to obtain the max for each row.
+%
+X1 = [ones(rows(X), 1) X];
+a2 = sigmoid(X1 * Theta1');
+a2_1 = [ones(rows(a2), 1) a2];
+% size = 5000 * 26
+%size(a2_1)
+a3 = sigmoid(a2_1 * Theta2');
+% size = 5000 * 10
+%size(a3)
+# pick the max value at each row
+[v,p] = max(a3, [], 2);
+
+# check to see that the array contain values that are mapped to the 10 classes
+#unique(p)
+
+
+
+
+
+
+% =========================================================================
+
+
+end

+ 51 - 0
machine learning/machine-learning-ex3/ex3/predictOneVsAll.m

@@ -0,0 +1,51 @@
+function p = predictOneVsAll(all_theta, X)
+%PREDICT Predict the label for a trained one-vs-all classifier. The labels 
+%are in the range 1..K, where K = size(all_theta, 1). 
+%  p = PREDICTONEVSALL(all_theta, X) will return a vector of predictions
+%  for each example in the matrix X. Note that X contains the examples in
+%  rows. all_theta is a matrix where the i-th row is a trained logistic
+%  regression theta vector for the i-th class. You should set p to a vector
+%  of values from 1..K (e.g., p = [1; 3; 1; 2] predicts classes 1, 3, 1, 2
+%  for 4 examples) 
+
+m = size(X, 1);
+num_labels = size(all_theta, 1);
+
+% You need to return the following variables correctly 
+p = zeros(size(X, 1), 1);
+v = zeros(size(X, 1), 1);
+
+% Add ones to the X data matrix
+X = [ones(m, 1) X];
+
+% ====================== YOUR CODE HERE ======================
+% Instructions: Complete the following code to make predictions using
+%               your learned logistic regression parameters (one-vs-all).
+%               You should set p to a vector of predictions (from 1 to
+%               num_labels).
+%
+% Hint: This code can be done all vectorized using the max function.
+%       In particular, the max function can also return the index of the 
+%       max element, for more information see 'help max'. If your examples 
+%       are in rows, then, you can use max(A, [], 2) to obtain the max 
+%       for each row.
+%       
+
+% refer to week 3 reading: multiclass classification: 1 vs all
+% at the last line it mentions picking the class that maximize h function
+
+XT = X * all_theta';
+[v,p] = max(XT, [], 2);
+%size(p)
+r = [v,p];
+unique(p);
+
+
+
+
+
+
+% =========================================================================
+
+
+end

+ 6 - 0
machine learning/machine-learning-ex3/ex3/sigmoid.m

@@ -0,0 +1,6 @@
+function g = sigmoid(z)
+%SIGMOID Compute sigmoid functoon
+%   J = SIGMOID(z) computes the sigmoid of z.
+
+g = 1.0 ./ (1.0 + exp(-z));
+end

+ 56 - 0
machine learning/machine-learning-ex3/ex3/submit.m

@@ -0,0 +1,56 @@
+function submit()
+  addpath('./lib');
+
+  conf.assignmentSlug = 'multi-class-classification-and-neural-networks';
+  conf.itemName = 'Multi-class Classification and Neural Networks';
+  conf.partArrays = { ...
+    { ...
+      '1', ...
+      { 'lrCostFunction.m' }, ...
+      'Regularized Logistic Regression', ...
+    }, ...
+    { ...
+      '2', ...
+      { 'oneVsAll.m' }, ...
+      'One-vs-All Classifier Training', ...
+    }, ...
+    { ...
+      '3', ...
+      { 'predictOneVsAll.m' }, ...
+      'One-vs-All Classifier Prediction', ...
+    }, ...
+    { ...
+      '4', ...
+      { 'predict.m' }, ...
+      'Neural Network Prediction Function' ...
+    }, ...
+  };
+  conf.output = @output;
+
+  submitWithConfiguration(conf);
+end
+
+function out = output(partId, auxdata)
+  % Random Test Cases
+  X = [ones(20,1) (exp(1) * sin(1:1:20))' (exp(0.5) * cos(1:1:20))'];
+  y = sin(X(:,1) + X(:,2)) > 0;
+  Xm = [ -1 -1 ; -1 -2 ; -2 -1 ; -2 -2 ; ...
+          1 1 ;  1 2 ;  2 1 ; 2 2 ; ...
+         -1 1 ;  -1 2 ;  -2 1 ; -2 2 ; ...
+          1 -1 ; 1 -2 ;  -2 -1 ; -2 -2 ];
+  ym = [ 1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4 ]';
+  t1 = sin(reshape(1:2:24, 4, 3));
+  t2 = cos(reshape(1:2:40, 4, 5));
+
+  if partId == '1'
+    [J, grad] = lrCostFunction([0.25 0.5 -0.5]', X, y, 0.1);
+    out = sprintf('%0.5f ', J);
+    out = [out sprintf('%0.5f ', grad)];
+  elseif partId == '2'
+    out = sprintf('%0.5f ', oneVsAll(Xm, ym, 4, 0.1));
+  elseif partId == '3'
+    out = sprintf('%0.5f ', predictOneVsAll(t1, Xm));
+  elseif partId == '4'
+    out = sprintf('%0.5f ', predict(t1, t2, Xm));
+  end 
+end

+ 15 - 0
machine learning/machine-learning-ex3/ex3/token.mat

@@ -0,0 +1,15 @@
+# Created by Octave 4.2.2, Mon Nov 12 21:17:38 2018 HKT <astron@astron>
+# name: email
+# type: sq_string
+# elements: 1
+# length: 20
+larry1chan@gmail.com
+
+
+# name: token
+# type: sq_string
+# elements: 1
+# length: 16
+04T709CVzMcBJ2Xj
+
+

BIN
machine learning/machine-learning-week4/Machine Learning - Home _ Coursera-quiz2.pdf


+ 18 - 0
machine learning/machine-learning-week4/sigmoid.m

@@ -0,0 +1,18 @@
+function g = sigmoid(z)
+%SIGMOID Compute sigmoid function
+%   g = SIGMOID(z) computes the sigmoid of z.
+
+% You need to return the following variables correctly 
+g = zeros(size(z));
+
+% ====================== YOUR CODE HERE ======================
+% Instructions: Compute the sigmoid of each value of z (z can be a matrix,
+%               vector or scalar).
+g = 1 ./ (1 + exp(-z));
+
+
+
+
+% =============================================================
+
+end

+ 7 - 0
machine learning/machine-learning-week4/xnor.m

@@ -0,0 +1,7 @@
+X= [1 0 0; 1 0 1; 1 1 0;1 1 1];
+t1 = [-30 20 20 ; 10 -20 -20];
+t2 = [-10 20 20]
+
+a2 = [ones(rows(X), 1) sigmoid(X * t1')]
+a3 = round(sigmoid(a2 * t2'))
+ 

+ 496 - 0
machine learning/ml workspace

@@ -0,0 +1,496 @@
+# Created by Octave 4.2.2, Sun Nov 04 00:27:40 2018 HKT <astron@astron>
+# name: J
+# type: scalar
+54.24245508201238
+
+
+# name: J_vals
+# type: matrix
+# rows: 100
+# columns: 100
+ 328.0929055495073 323.2650419231362 318.4779904587896 313.7317511564671 309.026324016169 304.3617090378953 299.7379062216457 295.1549155674203 290.6127370752193 286.1113707450427 281.6508165768903 277.2310745707622 272.8521447266583 268.5140270445787 264.2167215245235 259.9602281664926 255.7445469704859 251.5696779365034 247.4356210645451 243.3423763546114 239.2899438067018 235.2783234208163 231.3075151969553 227.3775191351186 223.4883352353062 219.6399634975181 215.8324039217542 212.0656565080145 208.3397212562992 204.6545981666081 201.0102872389415 197.4067884732988 193.8441018696808 190.3222274280867 186.8411651485172 183.4009150309719 180.0014770754509 176.6428512819541 173.3250376504816 170.0480361810334 166.8118468736094 163.6164697282098 160.4619047448344 157.3481519234834 154.2752112641566 151.2430827668541 148.2517664315758 145.3012622583219 142.3915702470922 139.5226903978869 136.6946227107058 133.907367185549 131.1609238224164 128.4552926213082 125.7904735822243 123.1664667051646 120.5832719901292 118.0408894371181 115.5393190461313 113.0785608171687 110.6586147502305 108.2794808453165 105.9411591024269 103.6436495215615 101.3869521027203 99.1710668459035 96.99599375111082 94.86173281834256 92.7682840475986 90.7156474388789 88.7038229921835 86.73281070751236 84.80261058486546 82.91322262424292 81.06464682564463 79.25688318907063 77.48993171452089 75.76379240199547 74.07846525149428 72.43395026301741 70.83024743656483 69.26735677213649 67.74527826973251 66.26401192935272 64.82355775099731 63.42391573466608 62.06508588035916 60.74706818807661 59.46986265781826 58.23346928958423 57.03788808337448 55.883119039189 54.76916215702784 53.69601743689092 52.66368487877827 51.67216448268994 50.72145624862585 49.81156017658609 48.9424762665706 48.11420451857943
+ 316.6648683047675 311.920259448318 307.2164627538925 302.5534782214914 297.9313058511149 293.3499456427625 288.8093975964344 284.3096617121306 279.850737989851 275.4326264295958 271.0553270313647 266.7188397951581 262.4231647209756 258.1683018088174 253.9542510586837 249.7810124705741 245.6485860444889 241.5569717804279 237.5061696783911 233.4961797383787 229.5270019603905 225.5986363444267 221.711082890487 217.8643415985718 214.0584124686808 210.293295500814 206.5689906949717 202.8854980511534 199.2428175693595 195.64094924959 192.0798930918446 188.5596490961237 185.0802172624269 181.6415975907544 178.2437900811061 174.8867947334822 171.5706115478827 168.2952405243073 165.0606816627562 161.8669349632295 158.714000425727 155.6018780502489 152.5305678367949 149.5000697853652 146.51038389596 143.5615101685789 140.653448603222 137.7861991998896 134.9597619585813 132.1741368792974 129.4293239620378 126.7253232068024 124.0621346135913 121.4397581824045 118.8581939132419 116.3174418061038 113.8175018609898 111.3583740779001 108.9400584568347 106.5625549977936 104.2258637007768 101.9299845657842 99.67491759281607 97.46066278187202 95.28722013295238 93.15458964605693 91.06277132118582 89.01176515833896 87.00157115751644 85.03218931871815 83.10361964194418 81.2158621271945 79.36891677446908 77.56278358376788 75.79746255509102 74.0729536884385 72.38925698381021 70.74637244120622 69.14430006062648 67.58303984207103 66.06259178553987 64.58295589103301 63.14413215855046 61.7461205880921 60.38892117965808 59.07253393324834 57.79695884886294 56.56219592650172 55.36824516616483 54.2151065678522 53.10278013156388 52.03126585729986 51.0005637450601 50.01067379484468 49.06159600665346 48.15333038048656 47.2858769163439 46.45923561422556 45.67340647413148 44.92838949606175
+ 305.4444729915193 300.7831189049911 296.1625769804875 291.5828472180079 287.0439296175526 282.5458241791216 278.0885309027149 273.6720497883326 269.2963808359746 264.9615240456406 260.6674794173311 256.4142469510458 252.2018266467848 248.0302185045481 243.8994225243357 239.8094387061476 235.7602670499838 231.7519075558442 227.784360223729 223.857625053638 219.9717020455712 216.1265911995288 212.3222925155107 208.5588059935168 204.8361316335472 201.1542694356019 197.513219399681 193.9129815257842 190.3535558139118 186.8349422640636 183.3571408762398 179.9201516504401 176.5239745866648 173.1686096849138 169.854056945187 166.5803163674846 163.3473879518064 160.1552716981525 157.0039676065229 153.8934756769176 150.8237959093364 147.7949283037798 144.8068728602473 141.859629578739 138.9531984592551 136.0875795017955 133.2627727063602 130.4787780729491 127.7355956015623 125.0332252921998 122.3716671448616 119.7509211595476 117.170987336258 114.6318656749926 112.1335561757515 109.6760588385347 107.2593736633422 104.8835006501739 102.54843979903 100.2541911099103 98.00075458281496 95.78813021774388 93.61631801469707 91.48531797367457 89.39513009467632 87.34575437770226 85.33719082275263 83.36943942982722 81.44250019892611 79.55637313004928 77.71105822319674 75.90655547836846 74.1428648955645 72.41998647478475 70.73792021602932 69.09666611929822 67.49622418459137 65.93659441190881 64.41777680125048 62.93977135261647 61.50257806600678 60.10619694142136 58.75062797886024 57.4358711783233 56.16192653981075 54.92879406332241 53.73647374885843 52.58496559641868 51.4742696060032 50.40438577761205 49.3753141112452 48.38705460690255 47.43960726458423 46.53297208429019 45.66714906602044 44.842138209775 44.05793951555382 43.31455298335694 42.61197861318428 41.95021640503595
+ 294.4317196097631 289.8536202931565 285.3163331385741 280.819858146016 276.3641953154823 271.9493446469728 267.5753061404875 263.2420797960266 258.9496656135898 254.6980635931774 250.4872737347893 246.3172960384256 242.1881305040859 238.0997771317705 234.0522359214797 230.0455068732129 226.0795899869706 222.1544852627524 218.2701927005587 214.4267123003891 210.6240440622436 206.862187986123 203.1411440720261 199.4609123199536 195.8214927299055 192.2228853018817 188.6650900358821 185.1481069319069 181.6719359899558 178.236577210029 174.8420305921266 171.4882961362486 168.1753738423945 164.9032637105649 161.6719657407596 158.4814799329786 155.3318062872218 152.2229448034895 149.1548954817812 146.1276583220974 143.1412333244378 140.1956204888024 137.2908198151913 134.4268313036046 131.6036549540421 128.8212907665039 126.0797387409901 123.3789988775004 120.7190711760351 118.099955636594 115.5216522591772 112.9841610437847 110.4874819904165 108.0316150990726 105.6165603697529 103.2423178024575 100.9088873971864 98.61626915393965 96.36446307271721 94.15346915351901 91.98328739634498 89.85391780119534 87.76536036806993 85.71761509696888 83.71068198789204 81.74456104083954 79.81925225581124 77.9347556328073 76.09107117182759 74.28819887287221 72.5261387359411 70.80489076103426 69.12445494815169 67.48483129729344 65.88601980845948 64.32802048164979 62.8108333168644 61.33445831410321 59.89889547336635 58.50414479465381 57.15020627796552 55.83707992330152 54.56476573066184 53.33326370004635 52.14257383145519 50.99269612488836 49.88363058034579 48.81537719782747 47.7879359773335 46.80130691886374 45.85549002241831 44.95048528799711 44.08629271560026 43.26291230522764 42.4803440568793 41.73858797055529 41.03764404625553 40.37751228398006 39.75819268372886 39.17968524550199
+ 283.6266081594989 279.1317636128136 274.6777312281527 270.2645110055161 265.8921029449036 261.5605070463155 257.2697233097518 253.0197517352121 248.8105923226971 244.642245072206 240.5147099837394 236.4279870572969 232.3820762928789 228.3769776904849 224.4126912501154 220.4892169717701 216.6065548554493 212.7647049011525 208.9636671088801 205.203441478632 201.4840280104083 197.8054267042086 194.1676375600333 190.5706605778823 187.0144957577557 183.4991430996532 180.0246026035751 176.5908742695213 173.1979580974917 169.8458540874864 166.5345622395054 163.2640825535486 160.0344150296162 156.8455596677081 153.6975164678241 150.5902854299645 147.5238665541293 144.4982598403183 141.5134652885315 138.5694828987691 135.6663126710308 132.803954605317 129.9824087016273 127.2016749599621 124.461753380321 121.7626439627043 119.1043467071118 116.4868616135437 113.9101886819997 111.37432791248 108.8792793049847 106.4250428595137 104.0116185760669 101.6390064546444 99.30720649524618 97.01621869787222 94.7660430625226 92.5566795891972 90.38812827789623 88.26038912861938 86.17346214136684 84.12734731613864 82.12204465293466 80.15755415175504 78.23387581259965 76.35100963546854 74.5089556203617 72.7077137672792 70.94728407622098 69.22766654718704 67.54886118017734 65.91086797519193 64.31368693223084 62.75731805129398 61.24176133238144 59.76701677549322 58.33308438062922 56.93996414778952 55.58765607697411 54.276160168183 53.00547642141612 51.77560483667356 50.58654541395528 49.43829815326127 48.33086305459158 47.26424011794614 46.23842934332501 45.25343073072815 44.30924428015554 43.40586999160725 42.54330786508326 41.72155790058351 40.94062009810808 40.20049445765689 39.50118097923003 38.84267966282742 38.22499050844912 37.64811351609507 37.11204868576533 36.61679601745987
+ 273.0291386407263 268.6175488639627 264.2467712492229 259.9168057965078 255.6276525058169 251.3793113771501 247.1717824105078 243.0050656058899 238.879160963296 234.7940684827264 230.7497881641811 226.7463200076603 222.7836640131638 218.8618201806912 214.9807885102431 211.1405690018192 207.3411616554197 203.5825664710446 199.8647834486934 196.1878125883668 192.5516538900644 188.9563073537862 185.4017729795325 181.8880507673029 178.4151407170976 174.9830428289166 171.5917571027599 168.2412835386275 164.9316221365194 161.6627728964356 158.4347358183759 155.2475109023407 152.1010981483297 148.9954975563429 145.9307091263805 142.9067328584423 139.9235687525284 136.9812168086389 134.0796770267736 131.2189494069326 128.3990339491158 125.6199306533234 122.8816395195552 120.1841605478113 117.5274937380917 114.9116390903964 112.3365966047254 109.8023662810786 107.3089481194561 104.856342119858 102.444548282284 100.0735666067344 97.7433970932091 95.45403974170804 93.20549455223126 90.99776152477877 88.83084065935051 86.70473195594664 84.61943541456698 82.57495103521161 80.57127881788057 78.60841876257379 76.68637086929125 74.80513513803307 72.96471156879909 71.16510016158944 69.40630091640402 67.68831383324292 66.01113891210613 64.37477615299362 62.77922555590539 61.22448712084143 59.71056084780177 58.23744673678636 56.80514478779521 55.41365500082843 54.06297737588589 52.75311191296758 51.48405861207362 50.25581747320396 49.06838849635849 47.92177168153743 46.81596702874058 45.75097453796802 44.72679420921974 43.74342604249576 42.80087003779602 41.89912619512062 41.03819451446946 40.2180749958426 39.43876763924004 38.70027244466172 38.00258941210772 37.34571854157799 36.72965983307254 36.1544132865914 35.61997890213452 35.12635667970194 34.67354661929362 34.26154872090958
+ 262.6393110534456 258.3109760466034 254.0234532017852 249.7767425189915 245.570843998222 241.4057576394768 237.2814834427558 233.1980214080591 229.1553715353869 225.1535338247387 221.1925082761151 217.2722948895153 213.3928936649402 209.5543046023893 205.7565277018625 201.9995629633601 198.2834103868822 194.6080699724283 190.9735417199988 187.3798256295934 183.8269217012125 180.3148299348558 176.8435503305235 173.4130828882154 170.0234276079315 166.674584489672 163.3665535334366 160.0993347392257 156.872928107039 153.6873336368765 150.5425513287385 147.4385811826246 144.375423198535 141.3530773764697 138.3715437164287 135.430822218412 132.5309128824196 129.6718157084514 126.8535306965075 124.0760578465879 121.3393971586927 118.6435486328216 115.9885122689749 113.3742880671524 110.8008760273543 108.2682761495804 105.7764884338308 103.3255128801055 100.9153494884044 98.54599825872769 96.21745919107531 93.929732285447 91.68281754184314 89.47671496026351 87.31142454070829 85.18694628317711 83.10328018767038 81.06042625418786 79.05838448272966 77.09715487329574 75.17673742588607 73.29713214050076 71.45833901713968 69.66035805580289 67.90318925649039 66.18683261920212 64.51128814393824 62.87655583069861 61.28263567948321 59.72952769029207 58.2172318631253 56.74574819798278 55.31507669486455 53.92521735377059 52.57617017470096 51.26793515765553 50.00051230263439 48.7739016096376 47.58810307866506 46.44311670971682 45.33894250279282 44.27558045789313 43.25303057501775 42.2712928541666 41.33036729533979 40.43025389853721 39.57095266375894 38.75246359100495 37.97478668027524 37.23792193156982 36.54186934488867 35.88662892023182 35.27220065759923 34.69858455699095 34.16578061840695 33.67378884184724 33.22260922731178 32.81224177480063 32.44268648431373 32.11394335585117
+ 252.4571253976568 248.2120451607358 244.0077770858393 239.8443211729672 235.721677422119 231.6398458332951 227.5988264064956 223.5986191417205 219.6392240389694 215.7206410982427 211.8428703195404 208.0059117028624 204.2097652482086 200.4544309555791 196.7399088249738 193.0661988563929 189.4333010498362 185.8412154053039 182.2899419227958 178.7794806023119 175.3098314438524 171.8809944474172 168.4929696130062 165.1457569406195 161.8393564302572 158.5737680819191 155.3489918956052 152.1650278713157 149.0218760090504 145.9195363088094 142.8580087705928 139.8372933944003 136.8573901802322 133.9182991280884 131.0200202379687 128.1625535098734 125.3458989438025 122.5700565397558 119.8350262977333 117.1408082177351 114.4874022997613 111.8748085438117 109.3030269498864 106.7720575179854 104.2819002481087 101.8325551402563 99.42402219442813 97.05630141062413 94.72939278884459 92.44329632908922 90.1980120313582 87.99353989565151 85.82987992196897 83.70703211031081 81.62499646067694 79.58377297306733 77.58336164748194 75.62376248392088 73.70497548238416 71.82700064287167 69.98983796538347 68.19348744991954 66.43794909647995 64.72322290506457 63.04930887567353 61.41620700830675 59.8239173029642 58.27243975964598 56.76177437835207 55.2919211590824 53.86288010183701 52.474651206616 51.12723447341916 49.82062990224663 48.55483749309836 47.3298572459745 46.1456891608748 45.0023332377994 43.89978947674829 42.83805787772147 41.81713844071893 40.83703116574067 39.89773605278672 38.99925310185703 38.14158231295164 37.32472368607051 36.54867722121367 35.81344291838113 35.11902077757284 34.46541079878885 33.85261298202916 33.28062732729374 32.7494538345826 32.25909250389575 31.80954333523319 31.4008063285949 31.03288148398089 30.70576880139118 30.41946828082571 30.17397992228456
+ 242.4825816733599 238.3207562063605 234.1997429013852 230.1195417584343 226.0801527775077 222.0815759586053 218.1238113017272 214.2068588068736 210.330718474044 206.4953903032388 202.7008742944579 198.9471704477012 195.2342787629688 191.5621992402609 187.9309318795769 184.3404766809174 180.7908336442823 177.2820027696714 173.8139840570847 170.3867775065223 167.0003831179842 163.6548008914706 160.3500308269809 157.0860729245158 153.8629271840747 150.6805936056579 147.5390721892656 144.4383629348975 141.3784658425537 138.3593809122341 135.3811081439388 132.4436475376679 129.5469990934212 126.6911628111987 123.8761386910006 121.1019267328268 118.3685269366772 115.6759393025519 113.024163830451 110.4132005203742 107.8430493723218 105.3137103862937 102.8251835622898 100.3774689003103 97.97056640035491 95.60447606242397 93.27919788651718 90.99473187263473 88.7510780207766 86.54823633094271 84.38620680313311 82.26498943734777 80.18458423358678 78.14499119185001 76.1462103121376 74.18824159444935 72.27108503878547 70.39474064514586 68.55920841353056 66.76448834393946 65.01058043637271 63.29748469083022 61.62520110731209 59.99372968581812 58.40307042634847 56.85322332890313 55.34418839348204 53.87596562008533 52.44855500871281 51.06195655936458 49.71617027204062 48.41119614674101 47.14703418346564 45.92368438221457 44.74114674298774 43.59942126578522 42.49850795060701 41.43840679745303 40.41911780632339 39.44064097721799 38.50297631013689 37.60612380508008 36.75008346204758 35.93485528103931 35.16043926205533 34.42683540509564 33.73404371016026 33.08206417724914 32.47089680636228 31.90054159749974 31.37099855066149 30.88226766584751 30.4343489430578 30.02724238229239 29.66094798355126 29.3354657468344 29.05079567214182 28.80693775947355 28.60389200882955 28.44165842020982
+ 232.7156798805546 228.6371091834768 224.599350648423 220.6024042753936 216.6462700643882 212.7309480154073 208.8564381284507 205.0227404035184 201.2298548406104 197.4777814397265 193.7665202008671 190.0960711240318 186.466434209221 182.8776094564343 179.329596865672 175.822396436934 172.35600817022 168.9304320655306 165.5456681228653 162.2017163422244 158.8985767236078 155.6362492670153 152.4147339724473 149.2340308399035 146.094139869384 142.9950610608888 139.9367944144178 136.9193399299711 133.9426976075487 131.0068674471506 128.1118494487768 125.2576436124273 122.444249938102 119.671668425801 116.9398990755244 114.2489418872719 111.5987968610438 108.9894639968399 106.4209432946604 103.8932347545052 101.4063383763741 98.96025416026734 96.55498210618502 94.19052221412689 91.86687448409299 89.58403891608347 87.34201551009811 85.14080426613715 82.98040518420038 80.86081826428793 78.78204350639977 76.74408091053591 74.74693047669631 72.79059220488101 70.87506609508999 69.00035214732324 67.16645036158077 65.37336073786257 63.62108327616871 61.90961797649911 60.23896483885376 58.60912386323273 57.020095049636 55.4718783980635 53.96447390851529 52.49788158099135 51.07210141549178 49.6871334120164 48.34297757056535 47.03963389113855 45.77710237373606 44.5553830183579 43.37447582500391 42.23438079367429 41.13509792436891 40.07662721708785 39.05896867183105 38.08212228859855 37.14608806739034 36.25086600820637 35.3964561110467 34.58285837591131 33.81007280280023 33.07809939171341 32.3869381426509 31.73658905561264 31.12705213059868 30.558327367609 30.0304147666436 29.54331432770248 29.09702605078564 28.6915499358931 28.32688598302484 28.00303419218086 27.71999456336115 27.47776709656576 27.27635179179461 27.11574864904777 26.99595766832521 26.91697884962691
+ 223.1564200192415 219.1611040920849 215.2066003269525 211.2929087238446 207.4200292827609 203.5879620037012 199.7967068866661 196.0462639316552 192.3366331386686 188.6678145077063 185.0398080387683 181.4526137318543 177.9062315869649 174.4006616040997 170.9359037832588 167.5119581244422 164.1288246276498 160.7865032928818 157.4849941201379 154.2242971094185 151.0044122607232 147.8253395740524 144.6870790494056 141.5896306867832 138.5329944861851 135.5171704476113 132.5421585710619 129.6079588565367 126.7145713040356 123.861995913559 121.0502326851067 118.2792816186785 115.5491427142747 112.8598159718951 110.2113013915398 107.6035989732089 105.0367087169022 102.5106306226199 100.0253646903618 97.58091092012788 95.17726931191829 92.81443986573309 90.49242258157203 88.21121745943537 85.97082449932296 83.77124370123482 81.61247506517091 79.49451859113134 77.41737427911606 75.38104212912506 73.38552214115832 71.43081431521593 69.51691865129774 67.64383514940386 65.81156380953426 64.02010463168895 62.26945761586796 60.55962276207121 58.89060007029877 57.2623895405506 55.67499117282669 54.12840496712705 52.62263092345177 51.15766904180069 49.73351932217397 48.35018176457145 47.00765636899328 45.70594313543937 44.44504206390977 43.22495315440443 42.04567640692333 40.90721182146658 39.80955939803408 38.75271913662588 37.73669103724195 36.7614750998823 35.82707132454697 34.93347971123585 34.08070025994907 33.26873297068659 32.49757784344834 31.7672348782344 31.07770407504475 30.42898543387936 29.82107895473825 29.25398463762145 28.72770248252895 28.24223248946069 27.79757465841675 27.39372898939705 27.03069548240165 26.70847413743055 26.42706495448373 26.18646793356118 25.9866830746629 25.82771037778895 25.70954984293925 25.63220147011383 25.5956652593127 25.59994121053586
+ 213.80480208942 209.8927409321847 206.021491936974 202.1910551037874 198.401430432625 194.652617923487 190.9446175763732 187.2774293912838 183.6510533682188 180.0654895071776 176.520737808161 173.0167982711688 169.5536708962008 166.131355683257 162.7498526323374 159.4091617434422 156.1092830165714 152.8502164517248 149.6319620489024 146.4545198081044 143.3178897293306 140.222071812581 137.1670660578558 134.1528724651549 131.1794910344782 128.2469217658259 125.3551646591978 122.504219714594 119.6940869320144 116.9247663114591 114.1962578529283 111.5085615564216 108.8616774219392 106.2556054494811 103.6903456390473 101.1658979906378 98.68226250425258 96.23943917989153 93.83742801755491 91.47622901724247 89.15584217895432 86.87626750269047 84.63750498845097 82.43955463623566 80.28241644604473 78.16609041787801 76.09057655173558 74.05587484761743 72.06198530552356 70.10890792545401 68.19664270740874 66.3251896513877 64.49454875739097 62.70472002541855 60.95570345547042 59.24749904754652 57.58010680164696 55.95352671777163 54.36775879592064 52.8228030360939 51.31865943829145 49.85532800251325 48.4328087287594 47.05110161702977 45.71020666732446 44.41012387964342 43.15085325398665 41.93239479035418 40.754748488746 39.61791434916208 38.52189237160248 37.46668255606714 36.45228490255608 35.47869941106931 34.54592608160682 33.65396491416862 32.80281590875468 31.99247906536506 31.2229543839997 30.49424186465863 29.80634150734183 29.15925331204931 28.55297727878112 27.98751340753716 27.4628616983175 26.97902215112212 26.53599476595104 26.13377954280423 25.7723764816817 25.45178558258347 25.17200684550953 24.93304027045982 24.73488585743446 24.57754360643334 24.46101351745652 24.38529559050397 24.35038982557573 24.35629622267173 24.40301478179205 24.49054550293664
+ 204.6608260910905 200.8320197037768 197.0440254784872 193.2968434152221 189.5904735139812 185.9249157747646 182.3001701975723 178.7162367824043 175.1731155292605 171.6708064381411 168.2093095090459 164.788624741975 161.4087521369284 158.069691693906 154.771443412908 151.5140072939343 148.2973833369848 145.1215715420596 141.9865719091587 138.892384438282 135.8390091294297 132.8264459826017 129.8546949977978 126.9237561750183 124.0336295142631 121.1843150155322 118.3758126788255 115.6081225041432 112.8812444914851 110.1951786408513 107.5499249522418 104.9454834256565 102.3818540610956 99.85903685855895 97.37703181804652 94.93583893955845 92.53545822309466 90.1758896686551 87.85713327623984 85.57918904584891 83.34205697748222 81.14573707113982 78.99022932682166 76.87553374452789 74.8016503242583 72.76857906601302 70.77631996979206 68.82487303559537 66.91423826342294 65.0444156532748 63.21540520515097 61.42720691905139 59.6798207949761 57.97324683292511 56.30748503289839 54.68253539489601 53.09839791891781 51.55507260496395 50.05255945303434 48.59085846312906 47.16996963524802 45.7898929693913 44.45062846555888 43.15217612375069 41.89453594396681 40.6777079262072 39.50169207047188 38.36648837676084 37.2720968450741 36.21851747541158 35.20575026777342 34.23379522215953 33.30265233856991 32.4123216170046 31.56280305746353 30.75409665994675 29.98620242445427 29.25912035098606 28.57285043954214 27.92739269012252 27.32274710272716 26.75891367735607 26.2358924140093 25.7536833126868 25.31228637338858 24.91170159611464 24.55192898086499 24.23296852763961 23.95482023643854 23.71748410726173 23.52096014010922 23.36524833498097 23.25034869187703 23.17626121079734 23.14298589174196 23.15052273471085 23.19887173970403 23.28803290672149 23.41800623576322 23.58879172682926
+ 195.7244920242528 191.9789404068603 188.2742009514922 184.6102736581487 180.9871585268291 177.404855557534 173.8633647502631 170.3626861050166 166.9028196217943 163.4837653005963 160.1055231414225 156.768093144273 153.4714753091479 150.215669636047 147.0006761249704 143.826494775918 140.69312558889 137.6005685638862 134.5488237009067 131.5378909999516 128.5677704610207 125.638462084114 122.7499658692317 119.9022818163736 117.0954099255398 114.3293501967304 111.6041026299451 108.9196672251842 106.2760439824476 103.6732329017352 101.1112339830471 98.59004722638332 96.10967263174373 93.6701101991286 91.27135992853766 88.91342181997098 86.59629587342859 84.31998208891049 82.08448046641669 79.88979100594713 77.73591370750191 75.62284857108095 73.5505955966843 71.51915478431188 69.52852613396372 67.57870964563999 65.66970531934038 63.80151315506512 61.9741331528141 60.18756531258744 58.44180963438504 56.73686611820689 55.07273476405305 53.44941557192347 51.86690854181823 50.32521367373722 48.82433096768051 47.36426042364808 45.94500204163991 44.56655582165607 43.22892176369647 41.93209986776119 40.67609013385016 39.46089256196344 38.28650715210099 37.15293390426281 36.06017281844894 35.00822389465933 33.99708713289403 33.02676253315298 32.09725009543623 31.20854981974378 30.36066170607558 29.55358575443169 28.78732196481208 28.06187033721677 27.3772308716457 26.73340356809893 26.13038842657644 25.56818544707824 25.04679462960432 24.56621597415469 24.12644948072933 23.72749514932829 23.3693529799515 23.05202297259898 22.77550512727078 22.53979944396685 22.34490592268719 22.19082456343182 22.07755536620075 22.00509833099395 21.97345345781143 21.98262074665319 22.03260019751924 22.12339181040957 22.2549955853242 22.42741152226308 22.64063962122627 22.89467988221373
+ 186.9957998889068 183.3335030414358 179.7120183559893 176.131345832567 172.5914854711691 169.0924372717952 165.6342012344458 162.2167773591208 158.8401656458198 155.5043660945432 152.209378705291 148.9552034780629 145.7418404128592 142.5692895096798 139.4375507685245 136.3466241893937 133.2965097722871 130.2872075172048 127.3187174241467 124.3910394931129 121.5041737241034 118.6581201171182 115.8528786721574 113.0884493892207 110.3648322683084 107.6820273094203 105.0400345125565 102.4388538777171 99.87848540490185 97.35892909411095 94.88018494534428 92.44225295860193 90.04513313388388 87.68882547119007 85.37332997052053 83.09864663187531 80.8647754552544 78.67171644065778 76.51946958808533 74.40803489753725 72.33741236901348 70.30760200251393 68.31860379803871 66.37041775558774 64.46304387516103 62.59648215675865 60.77073260038053 58.98579520602673 57.24166997369714 55.53835690339193 53.87585599511095 52.25416724885423 50.67329066462183 49.13322624241371 47.63397398222987 46.17553388407033 44.75790594793501 43.38109017382401 42.04508656173735 40.74989511167489 39.49551582363674 38.28194869762288 37.10919373363332 35.97725093166802 34.88612029172701 33.83580181381029 32.82629549791784 31.85760134404968 30.92971935220578 30.0426495223862 29.19639185459088 28.39094634881985 27.62631300507312 26.90249182335064 26.21948280365248 25.57728594597859 24.97590125032897 24.41532871670364 23.89556834510259 23.41662013552583 22.97848408797334 22.58116020244515 22.22464847894123 21.9089489174616 21.63406151800627 21.39998628057519 21.2067232051684 21.05427229178591 20.9426335404277 20.87180695109375 20.84179252378413 20.85259025849876 20.90420015523768 20.99662221400087 21.12985643478836 21.30390281760012 21.51876136243618 21.77443206929651 22.07091493818114 22.40820996909004
+ 178.4747496850527 174.8957076075032 171.3574776919781 167.8600599384773 164.4034543470007 160.9876609175483 157.6126796501204 154.2785105447167 150.9851536013372 147.7326088199821 144.5208762006512 141.3499557433447 138.2198474480623 135.1305513148044 132.0820673435706 129.0743955343611 126.107535887176 123.1814884020151 120.2962530788785 117.4518299177661 114.6482189186781 111.8854200816143 109.1634334065749 106.4822588935598 103.8418965425688 101.2423463536022 98.68360832665977 96.16568246174178 93.68856875884805 91.25226721797853 88.85677783913333 86.50210062231247 84.18823556751576 81.91518267474339 79.68294194399533 77.49151337527158 75.34089696857208 73.23109272389679 71.1621006412459 69.13392072061924 67.14655296201684 65.19999736543878 63.29425393088496 61.42932265835542 59.60520354785019 57.82189659936922 56.07940181291259 54.37771918848018 52.71684872607207 51.09679042568825 49.5175442873287 47.97911031099345 46.48148849668247 45.02467884439577 43.60868135413335 42.23349602589526 40.89912285968142 39.60556185549186 38.35281301332661 37.1408763331856 35.96975181506888 34.83943945897644 33.74993926490833 32.70125123286445 31.69337536284489 30.7263116548496 29.80006010887858 28.91462072493185 28.06999350300942 27.26617844311127 26.50317554523738 25.78098480938779 25.09960623556249 24.45903982376144 23.8592855739847 23.30034348623225 22.78221356050408 22.30489579680016 21.86839019512057 21.47269675546524 21.1178154778342 20.80374636222744 20.53048940864497 20.29804461708676 20.10641198755286 19.95559152004322 19.84558321455788 19.77638707109682 19.74800308966005 19.76043127024754 19.81367161285934 19.90772411749542 20.04258878415577 20.21826561284041 20.43475460354934 20.69205575628254 20.99016907104003 21.32909454782179 21.70883218662785 22.12938198745819
+ 170.1613414126904 166.6655541050625 163.2105789594588 159.7964159758794 156.4230651543242 153.0905264947934 149.7987999972868 146.5478856618046 143.3377834883465 140.1684934769128 137.0400156275034 133.9523499401182 130.9054964147574 127.8994550514208 124.9342258501084 122.0098088108204 119.1262039335568 116.2834112183172 113.481430665102 110.7202622739113 107.9999060447447 105.3203619776023 102.6816300724843 100.0837103293905 97.52660274832103 95.01030732927589 92.53482407225496 90.10015297725835 87.70629404428601 85.35324727333798 83.0410126644142 80.76959021751469 78.53897993263951 76.3491818097886 74.20019584896194 72.09202205015961 70.02466041338154 67.99811093862775 66.01237362589826 64.06744847519302 62.16333548651208 60.30003465985546 58.47754599522306 56.69586949261496 54.95500515203114 53.25495297347163 51.59571295693642 49.97728510242545 48.39966940993881 46.86286587947639 45.36687451103829 43.91169530462448 42.49732826023496 41.12377337786969 39.79103065752874 38.49910009921204 37.24798170291961 36.03767546865151 34.86818139640766 33.73949948618812 32.65162973799284 31.60457215182184 30.59832672767515 29.63289346555273 28.70827236545459 27.82446342738074 26.98146665133116 26.17928203730588 25.41790958530487 24.69734929532816 24.01760116737572 23.37866520144756 22.78054139754368 22.22322975566409 21.70673027580878 21.23104295797776 20.79616780217102 20.40210480838856 20.04885397663039 19.73641530689651 19.4647887991869 19.23397445350157 19.04397226984052 18.89478224820378 18.7864043885913 18.71883869100311 18.69208515543919 18.70614378189958 18.76101457038423 18.85669752089317 18.9931926334264 19.17049990798391 19.38861934456571 19.64755094317179 19.94729470380214 20.28785062645678 20.6692187111357 21.09139895783892 21.5543913665664 22.05819593731818
+ 162.0555750718201 158.6430425341135 155.2713221584312 151.9404139447734 148.6503178931397 145.4010340035301 142.192562275945 139.0249027103843 135.8980553068476 132.8120200653353 129.7667969858473 126.7623860683836 123.7987873129442 120.876000719529 117.9940262881382 115.1528640187716 112.3525139114294 109.5929759661113 106.8742501828175 104.1963365615482 101.5592351023029 98.96294580508213 96.4074686698855 93.89280369671317 91.4189508855652 88.9859102364414 86.59368174934188 84.24226542426676 81.93166126121588 79.66186926018923 77.4328894211869 75.2447217442089 73.09736622925506 70.99082287632564 68.92509168542038 66.90017265653947 64.91606578968286 62.97277108485051 61.07028854204243 59.20861816125871 57.38775994249917 55.60771388576394 53.86847999105299 52.17005825836637 50.51244868770397 48.89565127906597 47.31966603245212 45.7844929478626 44.29013202529734 42.83658326475639 41.42384666623973 40.05192222974738 38.72080995527924 37.43050984283546 36.18102189241592 34.97234610402067 33.8044824776497 32.67743101330299 31.59119171098061 30.5457645706825 29.54114959240864 28.57734677615911 27.65435612193382 26.77217762973285 25.93081129955614 25.13025713140373 24.3705151252756 23.65158528117173 22.97346759909218 22.33616207903688 21.73966872100588 21.18398752499916 20.66911849101673 20.19506161905857 19.7618169091247 19.36938436121513 19.01776397532982 18.70695575146879 18.43695968963206 18.2077757898196 18.01940405203144 17.87184447626755 17.76509706252794 17.69916181081262 17.67403872112157 17.68972779345483 17.74622902781237 17.84354242419416 17.98166798260027 18.16060570303065 18.3803555854853 18.64091762996426 18.94229183646749 19.284478204995 19.6674767355468 20.09128742812286 20.55591028272323 21.06134529934787 21.60759247799681 22.19465181867001
+ 154.1574506624416 150.8281728946564 147.5397072888956 144.292053845159 141.0852125634468 137.9191834437587 134.7939664860951 131.7095616904557 128.6659690568406 125.6631885852497 122.7012202756832 119.7800641281409 116.8997201426229 114.0601883191293 111.2614686576598 108.5035611582146 105.7864658207938 103.1101826453972 100.4747116320249 97.88005278067688 95.3262060913532 92.81317156405373 90.34094919877857 87.90953899552768 85.51894095430104 83.16915507509873 80.86018135792079 78.59201980276701 76.3646704096375 74.17813317853233 72.03240810945145 69.92749520239482 67.8633944573625 65.84010587435449 63.8576294533707 61.91596519441124 60.01511309747601 58.1550731625651 56.33584538967848 54.55742977881613 52.81982632997806 51.1230350431643 49.46705591837484 47.85188895560955 46.27753415486863 44.74399151615202 43.25126103945965 41.79934272479156 40.38823657214778 39.01794258152825 37.68846075293304 36.39979108636211 35.15193358181543 33.94488823929305 32.77865505879495 31.65323404032112 30.56862518387161 29.52482848944635 28.52184395704538 27.5596715866687 26.6383113783163 25.75776333198821 24.91802744768437 24.11910372540481 23.36099216514954 22.64369276691856 21.96720553071185 21.33153045652945 20.73666754437132 20.18261679423746 19.66937820612789 19.19695178004261 18.76533751598161 18.37453541394489 18.02454547393247 17.71536769594432 17.44700207998045 17.21944862604087 17.03270733412556 16.88677820423453 16.78166123636781 16.71735643052536 16.69386378670719 16.71118330491331 16.76931498514371 16.8682588273984 17.00801483167736 17.18858299798061 17.40996332630815 17.67215581665996 17.97516046903606 18.31897728343644 18.7036062598611 19.12904739831005 19.59530069878329 20.10236616128079 20.6502437858026 21.23893357234867 21.86843552091905 22.53874963151369
+ 146.4669681845548 143.2209451866912 140.0157343508517 136.8513356770367 133.7277491652459 130.6449748154792 127.603012627737 124.6018626020191 121.6415247383253 118.7219990366559 115.8432854970109 113.00538411939 110.2082949037934 107.4520178502212 104.7365529586732 102.0619002291495 99.42805966165008 96.83503125617484 94.28281501272401 91.77141093129751 89.30081901189514 86.87103925451719 84.48207165916349 82.13391622583401 79.82657295452884 77.56004184524797 75.33432289799136 73.14941611275911 71.00532148955106 68.90203902836731 66.83956872920785 64.81791059207266 62.8370646169618 60.89703080387512 58.99780915281285 57.13939966377482 55.32180233676106 53.5450171717716 51.80904416880636 50.11388332786547 48.45953464894883 46.84599813205651 45.27327377718843 43.74136158434468 42.25026155352516 40.79997368472993 39.39049797795902 38.02183443321237 36.69398305049003 35.40694382979195 34.16071677111817 32.95530187446866 31.79069913984342 30.66690856724248 29.58393015666582 28.54176390811344 27.54040982158533 26.57986789708152 25.66013813460201 24.78122053414676 23.94311509571578 23.14582181930911 22.38934070492671 21.67367175256861 20.99881496223477 20.36477033392523 19.77153786763998 19.219117563379 18.7075094211423 18.23671344092989 17.80672962274175 17.41755796657789 17.06919847243834 16.76165114032307 16.49491597023207 16.26899296216536 16.08388211612292 15.93958343210478 15.83609691011092 15.77342255014134 15.75156035219604 15.77051031627501 15.83027244237828 15.93084673050585 16.07223318065769 16.25443179283381 16.47744256703421 16.74126550325888 17.04590060150786 17.39134786178111 17.77760728407864 18.20467886840046 18.67256261474656 19.18125852311696 19.73076659351162 20.32108682593056 20.95221922037381 21.62416377684132 22.33692049533312 23.0904893758492
+ 138.98412763816 135.8213594102176 132.6994033442998 129.6182594404061 126.5779276985366 123.5784081186915 120.6197007008708 117.7018054450743 114.824722351302 111.988451419554 109.1929926498303 106.4383460421309 103.7245115964558 101.0514893128051 98.41927919117842 95.82788123157616 93.27729543399819 90.76752179844448 88.29856032491507 85.87041101340994 83.48307386392902 81.13654887647249 78.83083605104019 76.56593538763217 74.34184688624848 72.15857054688902 70.01610636955388 67.91445435424299 65.85361450095644 63.8335868096941 61.85437128045611 59.91596791324232 58.01837670805291 56.16159766488772 54.34563078374683 52.57047606463019 50.83613350753792 49.14260311246985 47.48988487942613 45.87797880840662 44.30688489941144 42.77660315244055 41.28713356749392 39.83847614457157 38.43063088367351 37.06359778479975 35.73737684795024 34.45196807312504 33.20737146032411 32.00358700954747 30.84061472079513 29.71845459406703 28.63710662936325 27.59657082668376 26.59684718602854 25.63793570739758 24.71983639079093 23.84254923620853 23.00607424365045 22.21041141311664 21.45556074460713 20.74152223812189 20.06829589366092 19.43588171122426 18.84427969081185 18.29348983242375 17.78351213605994 17.31434660172038 16.88599322940512 16.49845201911414 16.15172297084745 15.84580608460504 15.58070136038691 15.35640879819307 15.17292839802352 15.03026015987824 14.92840408375724 14.86736016966054 14.84712841758811 14.86770882753996 14.9291013995161 15.03130613351653 15.17432302954123 15.35815208759022 15.58279330766349 15.84824668976105 16.15451223388288 16.50158994002902 16.88947980819943 17.3181818383941 17.78769603061307 18.29802238485633 18.84916090112387 19.44111157941569 20.0738744197318 20.74744942207218 21.46183658643686 22.21703591282581 23.01304740123906 23.84987105167657
+ 131.7089290232569 128.6294155652361 125.5907142692396 122.5928251352675 119.6357481633194 116.7194833533958 113.8440307054965 111.0093902196213 108.2155618957705 105.4625457339439 102.7503417341417 100.0789498963637 97.44837022061003 94.85860270688062 92.3096473551755 89.80150416549469 87.33417313783818 84.90765427220587 82.52194756859787 80.17705302701422 77.87297064745476 75.60970042991964 73.38724237440881 71.20559648092221 69.06476274945994 66.96474118002192 64.90553177260823 62.88713452721878 60.90954944385363 58.97277652251278 57.07681576319619 55.22166716590386 53.40733073063585 51.6338064573921 49.90109434617266 48.20919439697748 46.55810660980662 44.94783098465999 43.3783675215377 41.84971622043965 40.36187708136588 38.91485010431642 37.50863528929123 36.14323263629031 34.81864214531372 33.53486381636137 32.29189764943332 31.08974364452954 29.92840180165005 28.80787212079483 27.72815460196394 26.6892492451573 25.69115605037496 24.73387501761686 23.81740614688309 22.94174943817358 22.10690489148835 21.31287250682742 20.55965228419077 19.8472442235784 19.17564832499029 18.5448645884265 17.95489301388698 17.40573360137174 16.89738635088079 16.42985126241411 16.00312833597173 15.61721757155362 15.27211896915979 14.96783252879026 14.704358250445 14.48169613412402 14.29984617982733 14.15880838755493 14.0585827573068 13.99916928908296 13.98056798288341 14.00277883870814 14.06580185655715 14.16963703643044 14.31428437832801 14.49974388224987 14.72601554819601 14.99309937616644 15.30099536616115 15.64970351818015 16.03922383222341 16.46955630829098 16.94070094638282 17.45265774649894 18.00542670863934 18.59900783280404 19.23340111899301 19.90860656720629 20.62462417744381 21.38145394970563 22.17909588399175 23.01754998030214 23.89681623863682 24.81689465899577
+ 124.6413723398458 121.6451136517463 118.6896671256713 115.7750327616205 112.901210559594 110.0682005195918 107.2760026416138 104.5246169256602 101.8140433717307 99.14428197982565 96.51533274994489 93.92719568208837 91.37987077625608 88.87335803244811 86.40765745066447 83.98276903090508 81.59869277316999 79.25542867745912 76.9529767437726 74.69133697211028 72.47050936247231 70.29049391485862 68.15129062926918 66.05289950570405 63.99532054416321 61.97855374464665 60.00259910715437 58.06745663168638 56.17312631824266 54.31960816682327 52.50690217742805 50.73500835005724 49.00392668471062 47.31365718138832 45.66419984009031 44.05555466081659 42.48772164356714 40.96070078834199 39.47449209514107 38.02909556396447 36.62451119481217 35.26073898768414 33.93777894258039 32.65563105950093 31.41429533844573 30.21377177941485 29.05406038240823 27.93516114742589 26.85707407446784 25.81979916353406 24.82333641462458 23.86768582773939 22.95284740287847 22.07882114004183 21.24560703922948 20.45320510044142 19.70161532367764 18.99083770893811 18.32087225622292 17.69171896553197 17.10337783686532 16.55584887022296 16.04913206560488 15.58322742301107 15.15813494244154 14.77385462389631 14.43038646737536 14.12773047287869 13.8658866404063 13.6448549699582 13.46463546153438 13.32522811513484 13.2266329307596 13.16884990840863 13.15187904808194 13.17572034977953 13.24037381350142 13.34583943924758 13.49211722701802 13.67920717681275 13.90710928863177 14.17582356247507 14.48534999834264 14.8356885962345 15.22683935615065 15.65880227809108 16.13157736205579 16.64516460804478 17.19956401605806 17.79477558609562 18.43079931815746 19.1076352122436 19.82528326835401 20.58374348648871 21.38301586664767 22.22310040883093 23.1039971130385 24.02570597927032 24.98822700752643 25.99156019780682
+ 117.7814575879264 114.8684536697485 111.9962619135949 109.1648823194655 106.3743148873604 103.6245596172796 100.9156165092231 98.24748556319093 95.62016677918292 93.03366015719931 90.48796569723991 87.98308339930483 85.519013263394 83.09575528950751 80.71330947764527 78.37167582780731 76.07085433999364 73.81084501420422 71.59164785043913 69.41326284869828 67.2756900089817 65.17892933128948 63.12298081562147 61.10784446197778 59.13352027035838 57.20000824076328 55.30730837319242 53.45542066764587 51.64434512412358 49.87408174262557 48.1446305231519 46.45599146570244 44.80816457027728 43.20114983687642 41.63494726549984 40.10955685614753 38.62497860881953 37.18121252351581 35.77825860023636 34.41611683898118 33.0947872397503 31.8142698025437 30.57456452736142 29.37567141420336 28.21759046306963 27.10032167396019 26.02386504687496 24.98822058181408 23.99338827877745 23.03936813776513 22.12616015877708 21.25376434181332 20.42218068687384 19.63140919395864 18.88144986306774 18.17230269420109 17.50396768735875 16.87644484254068 16.28973415974691 15.74383563897741 15.23874928023219 14.77447508351126 14.3510130488146 13.96836317614225 13.62652546549416 13.32549991687035 13.06528653027084 12.8458853056956 12.66729624314466 12.52951934261799 12.43255460411561 12.37640202763751 12.3610616131837 12.38653336075416 12.45281727034891 12.55991334196794 12.70782157561126 12.89654197127886 13.12607452897075 13.39641924868691 13.70757613042736 14.05954517419208 14.4523263799811 14.8859197477944 15.36032527763198 15.87554296949387 16.43157282338 17.02841483929043 17.66606901722515 18.34453535718414 19.06381385916742 19.82390452317499 20.62480734920684 21.46652233726298 22.34904948734339 23.27238879944808 24.23654027357706 25.24150390973033 26.28727970790788 27.37386766810971
+ 111.1291847674989 108.2994356192424 105.5104986330102 102.7623738088023 100.0550611466187 97.38856064645935 94.76287230832416 92.17799613221344 89.63393211812698 87.13068026606473 84.66824057602673 82.24661304801312 79.86579768202378 77.52579447805861 75.22660343611784 72.96822455620132 70.75065783830912 68.57390328244109 66.4379608885974 64.34283065677809 62.28851258698293 60.27500667921214 58.30231293346563 56.37043134974333 54.47936192804536 52.62910466837166 50.81965957072225 49.05102663509714 47.32320586149631 45.63619724991975 43.99000080036745 42.38461651283949 40.82004438733576 39.29628442385631 37.8133366224012 36.37120098297032 34.96987750556374 33.60936619018145 32.28966703682347 31.01078004548971 29.77270521618027 28.57544254889513 27.41899204363425 26.30335370039765 25.22852751918532 24.19451349999731 23.20131164283357 22.2489219476941 21.33734441457893 20.46657904348803 19.63662583442142 18.8474847873791 18.09915590236105 17.39163917936729 16.72493461839781 16.09904221945261 15.5139619825317 14.96969390763507 14.46623799476273 14.00359424391466 13.58176265509089 13.20074322829139 12.86053596351618 12.56114086076525 12.3025579200386 12.08478714133624 11.90782852465816 11.77168207000437 11.67634777737486 11.62182564676963 11.60811567818868 11.63521787163201 11.70313222709964 11.81185874459154 11.96139742410772 12.1517482656482 12.38291126921295 12.65488643480199 12.9676737624153 13.32127325205291 13.71568490371479 14.15090871740096 14.62694469311141 15.14379283084616 15.70145313060517 16.29992559238848 16.93921021619605 17.61930700202792 18.34021594988408 19.10193705976451 19.90447033166923 20.74781576559822 21.63197336155152 22.55694311952909 23.52272503953093 24.52931912155707 25.57672536560749 26.66494377168217 27.79397433978117 28.96381706990444
+ 104.6845538785633 101.9380595002282 99.2323772839174 96.56750722963102 93.94344933736875 91.36020360713087 88.81777003891723 86.31614863272789 83.8553393885628 81.43534230642202 79.05615738630549 76.71778462821328 74.42022403214536 72.16347559810173 69.94753932608231 67.7724152160872 65.6381032681164 63.5446034821699 61.4919158582477 59.48004039634975 57.50897709647604 55.57872595862666 53.68928698280157 51.84066016900074 50.0328455172242 48.26584302747192 46.53965269974398 44.85427453404029 43.20970853036086 41.60595468870576 40.04301300907491 38.52088349146836 37.03956613588608 35.59906094232809 34.19936791079436 32.84048704128497 31.52241833379983 30.24516178833896 29.00871740490238 27.81308518349011 26.6582651241021 25.54425722673838 24.47106149139894 23.43867791808378 22.44710650679291 21.49634725752631 20.586400170284 19.71726524506597 18.88894248187223 18.10143188070279 17.35473344155761 16.64884716443672 15.98377304934011 15.35951109626777 14.77606130521974 14.23342367619598 13.7315982091965 13.27058490422131 12.85038376127042 12.47099478034378 12.13241796144144 11.83465330456338 11.5777008097096 11.36156047688011 11.18623230607491 11.05171629729398 10.95801245053733 10.90512076580497 10.89304124309689 10.9217738824131 10.99131868375359 11.10167564711836 11.25284477250742 11.44482605992076 11.67761950935838 11.95122512082029 12.26564289430648 12.62087282981695 13.01691492735171 13.45376918691075 13.93143560849407 14.44991419210167 15.00920493773355 15.60930784538974 16.25022291507019 16.93195014677493 17.65448954050395 18.41784109625726 19.22200481403484 20.06698069383672 20.95276873566286 21.87936893951331 22.84678130538802 23.85500583328704 24.90404252321032 25.99389137515788 27.12455238912975 28.29602556512589 29.50831090314633 30.76140840319101
+ 98.44756492111946 95.78432531270585 93.16189786631654 90.58028258195148 88.03947945961069 85.53948849929428 83.08030970100205 80.66194306473413 78.28438859049052 75.94764627827114 73.65171612807606 71.39659813990531 69.18229231375877 67.00879864963656 64.87611714753859 62.78424780746499 60.7331906294156 58.72294561339054 56.75351275938973 54.8248920674132 52.93708353746095 51.09008716953297 49.28390296362933 47.51853091974996 45.79397103789486 44.11022331806404 42.4672877602575 40.86516436447527 39.30385313071726 37.7833540589836 36.30366714927419 34.86479240158911 33.46672981592824 32.10947939229168 30.79304113067942 29.51741503109142 28.28260109352773 27.08859931798832 25.93540970447318 24.8230322529823 23.75146696351574 22.72071383607346 21.73077287065546 20.78164406726173 19.8733274258923 19.00582294654715 18.17913062922626 17.39325047392968 16.64818248065738 15.94392664940936 15.28048298018562 14.65785147298617 14.076032127811 13.53502494466012 13.0348299235335 12.57544706443119 12.15687636735314 11.7791178322994 11.44217145926992 11.14603724826473 10.89071519928382 10.6762053123272 10.50250758739486 10.36962202448681 10.27754862360304 10.22628738474355 10.21583830790833 10.24620139309741 10.31737664031077 10.42936404954842 10.58216362081034 10.77577535409655 11.01019924940705 11.28543530674183 11.60148352610089 11.95834390748422 12.35601645089185 12.79450115632377 13.27379802377995 13.79390705326044 14.35482824476519 14.95656159829423 15.59910711384755 16.28246479142517 17.00663463102706 17.77161663265324 18.57741079630368 19.42401712197843 20.31143560967746 21.23966625940077 22.20870907114835 23.21856404492023 24.26923118071639 25.36071047853684 26.49300193838156 27.66610556025056 28.88002134414387 30.13474929006142 31.43028939800331 32.76664166796942
+ 92.41821789516756 89.83823305667535 87.29906038020746 84.80069986576383 82.34315151334451 79.92641532294945 77.55049129457872 75.21537942823227 72.92107972391003 70.66759218161211 68.45491680133848 66.28305358308914 64.15200252686405 62.06176363266325 60.01233690048678 58.00372233033458 56.03591992220667 54.10892967610296 52.2227515920236 50.37738566996855 48.57283190993774 46.80909031193123 45.086160875949 43.40404360199106 41.76273849005739 40.16224554014799 38.60256475226289 37.08369612640208 35.60563966256554 34.16839536075329 32.77196322096535 31.41634324320166 30.10153542746225 28.82753977374714 27.59435628205631 26.40198495238976 25.25042578474751 24.1396787791295 23.06974393553581 22.04062125396637 21.05231073442125 20.1048123769004 19.19812618140384 18.33225214793155 17.50719027648355 16.72294056705984 15.9795030196604 15.27687763428524 14.61506441093437 13.99406334960779 13.4138744503055 12.87449771302748 12.37593313777374 11.91818072454428 11.50124047333913 11.12511238415823 10.78979645700163 10.49529269186931 10.24160108876128 10.02872164767753 9.856654368618054 9.72539925158287 9.634956296571966 9.585325503585347 9.576506872623014 9.608500403684955 9.681306096771189 9.794923951881698 9.949353969016501 10.14459614817558 10.38065048935894 10.65751699256658 10.97519565779852 11.33368648505473 11.73298947433523 12.17310462564 12.65403193896907 13.17577141432241 13.73832305170005 14.34168685110195 14.98586281252815 15.67085093597863 16.39665122145338 17.16326366895244 17.97068827847576 18.81892505002338 19.70797398359528 20.63783507919144 21.60850833681192 22.61999375645666 23.67229133812567 24.765401081819 25.8993229875366 27.07405705527849 28.28960328504462 29.54596167683505 30.8431322306498 32.18111494648883 33.55990982435212 34.97951686423968
+ 86.59651280070742 84.09978273213665 81.64386482559019 79.22875908106802 76.85446549857011 74.52098407809649 72.22831481964715 69.97645772322214 67.76541278882141 65.59518001644494 63.46575940609269 61.37715095776475 59.32935467146118 57.3223705471818 55.35619858492678 53.43083878469598 51.54629114648949 49.70255567030733 47.89963235614935 46.13752120401572 44.41622221390635 42.73573538582129 41.09606071976049 39.49719821572396 37.93914787371172 36.42190969372379 34.94548367576012 33.50986981982075 32.11506812590566 30.76107859401483 29.4479012241483 28.17553601630607 26.94398297048809 25.7532420866944 24.60331336492503 23.49419680517991 22.42589240745907 21.39840017176253 20.41172009809026 19.46585218644228 18.56079643681858 17.69655284921918 16.87312142364404 16.09050216009319 15.34869505856663 14.64770011906435 13.98751734158635 13.36814672613264 12.7895882727032 12.25184198129806 11.7549078519172 11.29878588456062 10.88347607922831 10.5089784359203 10.17529295463657 9.882419635377119 9.63035847814195 9.419109482931074 9.248672649744478 9.119047978582159 9.030235469444124 8.982235122330371 8.97504693724091 9.008670914175724 9.083107053134825 9.19835535411821 9.354415817125878 9.55128844215783 9.788973229214063 10.06747017829458 10.38677928939938 10.74690056252846 11.14783399768183 11.58957959485948 12.07213735406141 12.59550727528763 13.15968935853813 13.76468360381291 14.41049001111197 15.09710858043532 15.82453931178295 16.59278220515487 17.40183726055107 18.25170447797156 19.14238385741632 20.07387539888537 21.0461791023787 22.05929496789631 23.11322299543822 24.20796318500439 25.34351553659484 26.5198800502096 27.73705672584862 28.99504556351195 30.29384656319954 31.63345972491142 33.01388504864759 34.43512253440803 35.89717218219278 37.4000339920018
+ 80.98244963773914 78.56897433908981 76.19631120246478 73.86446022786409 71.5734214152876 69.32319476473539 67.11378027620752 64.94517794970395 62.81738778522458 60.7304097827696 58.68424394233884 56.67889026393236 54.71434874755013 52.79061939319226 50.90770220085857 49.06559717054927 47.26430430226423 45.50382359600342 43.78415505176697 42.10529866955473 40.4672544493668 38.87002239120316 37.3136024950638 35.79799476094873 34.32319918885794 32.88921577879144 31.4960445307492 30.14368544473125 28.83213852073759 27.56140375876823 26.33148115882313 25.14237072090231 23.99407244500579 22.88658633113354 21.81991237928559 20.79405058946192 19.80900096166252 18.86476349588741 17.96133819213659 17.09872505041004 16.27692407070777 15.49593525302981 14.7557585973761 14.0563941037467 13.39784177214157 12.78010160256074 12.20317359500417 11.66705774947189 11.17175406596388 10.71726254448018 10.30358318502075 9.930715987585597 9.598660952174736 9.307418078788158 9.056987367425869 8.847368818087851 8.678562430774127 8.55056820548468 8.463386142219518 8.417016240978638 8.411458501762041 8.446712924569731 8.522779509401701 8.639658256257954 8.79734916513849 8.995852236043309 9.235167468972413 9.515294863925799 9.836234420903466 10.19798613990542 10.60055002093166 11.04392606398217 11.52811426905698 12.05311463615607 12.61892716527944 13.22555185642708 13.87298870959903 14.56123772479525 15.29029890201575 16.06017224126052 16.87085774252962 17.72235540582295 18.61466523114058 19.54778721848251 20.5217213678487 21.5364676792392 22.59202615265396 23.68839678809301 24.82557958555635 26.00357454504397 27.22238166655585 28.48200095009204 29.7824323956525 31.12367600323729 32.50573177284631 33.92859970447962 35.39227979813723 36.89677205381909 38.44207647152528 40.02819305125573
+ 75.57602840626271 73.24580787753482 70.95639951083119 68.70780330615194 66.50001926349692 64.33304738286613 62.20688766425972 60.12154010767757 58.07700471311966 56.07328148058603 54.1103704100767 52.18827150159168 50.30698475513093 48.46651017069444 46.66684774828228 44.90799748789438 43.18995938953076 41.5127334531914 39.87631967887635 38.28071806658556 36.72592861631909 35.21195132807691 33.73878620185894 32.30643323766533 30.91489243549596 29.5641637953509 28.25424731723009 26.98514300113361 25.75685084706138 24.56937085501345 23.42270302498979 22.31684735699041 21.25180385101531 20.22757250706452 19.24415332513799 18.30154630523575 17.3997514473578 16.53876875150413 15.71859821767473 14.93923984586962 14.2006936360888 13.50295958833227 12.84603770260001 12.22992797889203 11.65463041720834 11.12014501754893 10.6264717799138 10.17361070430296 9.761561790716398 9.390325039154128 9.059900449616137 8.770288022102427 8.521487756613002 8.313499653147856 8.146323711707007 8.019959932290428 7.934408314898135 7.889668859530128 7.885741566186397 7.922626434866956 8.000323465571796 8.118832658300928 8.27815401305433 8.47828752983202 8.719233208633991 9.000991049460252 9.323561052310794 9.686943217185609 10.09113754408472 10.53614403300811 11.02196268395578 11.54859349692773 12.11603647192398 12.72429160894451 13.37335890798931 14.06323836905839 14.79392999215177 15.56543377726942 16.37774972441136 17.23087783357759 18.1248181047681 19.05957053798288 20.03513513322195 21.05151189048532 22.10870080977295 23.20670189108488 24.34551513442107 25.52514053978156 26.74557810716634 28.00682783657538 29.3088897280087 30.65176378146635 32.03544999694824 33.45994837445445 34.92525891398489 36.43138161553964 37.9783164791187 39.56606350472202 41.19462269234963 42.86399404200152
+ 70.37724910627809 68.13028334747167 65.9241297506895 63.75878831593165 61.63425904319807 59.55054193248874 57.50763698380375 55.50554419714304 53.54426357250653 51.62379510989441 49.74413880930649 47.9052946707429 46.10726269420359 44.35004287968854 42.63363522719779 40.95803973673134 39.32325640828915 37.72928524187123 36.17612623747763 34.66377939510829 33.19224471476323 31.76152219644248 30.37161184014598 29.02251364587377 27.71422761362587 26.44675374340222 25.22009203520286 24.0342424890278 22.88920510487701 21.78497988275052 20.72156682264828 19.69896592457035 18.7171771885167 17.77620061448733 16.87603620248224 16.01668395250144 15.19814386454492 14.42041593861269 13.68350017470473 12.98739657282105 12.33210513296167 11.71762585512657 11.14395873931575 10.61110378552921 10.11906099376695 9.667830364028978 9.25741189631529 8.887805590625886 8.559011446960763 8.271029465319929 8.023859645703372 7.817501988111102 7.651956492543112 7.527223158999403 7.443301987479988 7.400192977984841 7.397896130513988 7.436411445067418 7.515738921645124 7.635878560247117 7.796830360873397 7.99859432352396 8.241170448198801 8.52455873489793 8.848759183621338 9.213771794369027 9.619596567141004 10.06623350193727 10.55368259875781 11.08194385760264 11.65101727847175 12.26090286136514 12.91160060628281 13.60311051322477 14.33543258219103 15.10856681318154 15.92251320619635 16.77727176123544 17.67284247829882 18.60922535738647 19.58642039849842 20.60442760163463 21.66324696679515 22.76287849397995 23.90332218318902 25.08457803442239 26.30664604768001 27.56952622296194 28.87321856026816 30.21772305959864 31.60303972095342 33.02916854433246 34.49610952973581 36.00386267716344 37.55242798661534 39.1418054580915 40.77199509159201 42.44299688711676 44.15481084466582 45.90743696423914
+ 65.38611173778536 63.22240074890031 61.09950192203961 59.01741525720319 56.97614075439108 54.97567841360318 53.01602823483957 51.09719021810029 49.21916436338531 47.38195067069456 45.58554914002811 43.82995977138595 42.11518256476807 40.44121752017446 38.80806463760518 37.21572391706012 35.66419535853938 34.15347896204291 32.68357472757072 31.25448265512283 29.86620274469919 28.51873499629988 27.21207940992482 25.94623598557406 24.72120472324758 23.53698562294538 22.39357868466746 21.29098390841383 20.22920129418447 19.20823084197941 18.22807255179863 17.28872642364214 16.39019245750992 15.53247065340199 14.71556101131833 13.93946353125896 13.20417821322388 12.50970505721308 11.85604406322656 11.24319523126432 10.67115856132637 10.13993405341271 9.649521707523323 9.199921523658226 8.7911335018174 8.423157642000874 8.095993944208622 7.809642408440656 7.564103034696969 7.359375822977562 7.195460773282447 7.07235788561161 6.990067159965055 6.948588596342788 6.947922194744806 6.988067955171103 7.069025877621683 7.190795962096548 7.353378208595694 7.556772617119126 7.800979187666838 8.085997920238835 8.411828814835115 8.778471871455679 9.185927090100529 9.634194470769659 10.12327401346307 10.65316571818077 11.22386958492275 11.835385613689 12.48771380447956 13.18085415729438 13.9148066721335 14.68957134899689 15.50514818788458 16.36153718879653 17.25873835173278 18.1967516766933 19.17557716367812 20.19521481268722 21.2556646237206 22.35692659677825 23.49900073186019 24.68188702896644 25.90558548809692 27.17009610925175 28.47541889243083 29.82155383763418 31.20850094486183 32.63626021411374 34.10483164538994 35.61421523869046 37.16441099401523 38.75541891136429 40.38723899073764 42.05987123213523 43.77331563555718 45.52757220100335 47.32264092847384 49.15852181796862
+ 60.6026163007844 58.52216008182081 56.48251602488159 54.48368412996657 52.52566439707586 50.60845682620944 48.73206141736729 46.89647817054946 45.10170708575586 43.34774816298655 41.63460140224155 39.96226680352084 38.3307443668244 36.74003409215221 35.19013597950434 33.68105002888074 32.21277624028144 30.78531461370641 29.39866514915565 28.05282784662922 26.74780270612703 25.48358972764913 24.26018891119551 23.07760025676619 21.93582376436114 20.83485943398038 19.77470726562389 18.75536725929171 17.77683941498379 16.83912373270016 15.94222021244082 15.08612885420575 14.27084965799496 13.49638262380846 12.76272775164626 12.06988504150833 11.41785449339469 10.80663610730531 10.23622988324024 9.706635821199443 9.217853921182924 8.769884183190694 8.362726607222751 7.996381193279086 7.670847941359705 7.386126851464603 7.142217923593792 6.939121157747261 6.776836553925008 6.655364112127044 6.574703832353364 6.534855714603966 6.53581975887885 6.57759596517802 6.660184333501471 6.783584863849202 6.947797556221221 7.152822410617524 7.398659427038107 7.685308605482973 8.012769945952126 8.381043448445554 8.790129112963275 9.240026939505274 9.730736928071558 10.26225907866213 10.83459339127698 11.44773986591611 12.10169850257953 12.79646930126723 13.53205226197922 14.30844738471547 15.12565466947603 15.98367411626086 16.88250572506998 17.82214949590336 18.80260542876105 19.82387352364302 20.88595378054926 21.9888461994798 23.13255078043463 24.31706752341372 25.54239642841709 26.80853749544476 28.11549072449671 29.46325611557296 30.85183366867346 32.28122338379826 33.75142526094734 35.26243930012069 36.81426550131835 38.40690386454028 40.04035438978649 41.71461707705701 43.42969192635177 45.18557893767082 46.9822781110142 48.81978944638181 50.69811294377374 52.6172486031899
+ 56.02676279527537 54.02956134623322 52.0731720592154 50.15759493422185 48.28282997125255 46.44887717030758 44.65573653138684 42.90340805449043 41.19189173961831 39.52118758677041 37.89129559594687 36.30221576714758 34.75394810037257 33.24649259562184 31.7798492528954 30.35401807219325 28.96899905351536 27.62479219686176 26.32139750223245 25.05881496962743 23.8370445990467 22.65608639049023 21.51594034395805 20.41660645945016 19.35808473696655 18.34037517650723 17.36347777807218 16.42739254166143 15.53211946727494 14.67765855491276 13.86400980457484 13.09117321626123 12.35914878997187 11.66793652570682 11.01753642346604 10.40794848324954 9.839172705057337 9.311209088889409 8.824057634745763 8.377718342626402 7.97219121253132 7.607476244460534 7.283573438414017 7.00048279439179 6.75820431239385 6.556737992420183 6.396083834470809 6.276241838545711 6.197212004644896 6.158994332768372 6.161588822916126 6.204995475088166 6.289214289284487 6.414245265505091 6.580088403749978 6.786743704019149 7.034211166312602 7.322490790630339 7.651582576972356 8.021486525338661 8.432202635729249 8.883730908144122 9.37607134258327 9.90922393904671 10.48318869753443 11.09796561804643 11.75355470058272 12.44995594514329 13.18716935172814 13.96519492033728 14.7840326509707 15.6436825436284 16.54414459831039 17.48541881501666 18.46750519374721 19.49040373450204 20.55411443728116 21.65863730208457 22.80397232891226 23.99011951776422 25.21707886864047 26.48485038154101 27.79343405646581 29.14282989341493 30.53303789238831 31.96405805338599 33.43589037640793 34.94853486145416 36.50199150852468 38.0962603176195 39.73134128873853 41.40723442188195 43.12393971704959 44.88145717424152 46.67978679345774 48.51892857469822 50.39888251796302 52.31964862325206 54.28122689056549 56.28361731990303
+ 51.65855122125812 49.74460454213746 47.871470025041 46.03914766996892 44.24763747692106 42.49693944589751 40.78705357689824 39.11797986992326 37.48971832497255 35.90226894204615 34.35563172114399 32.84980666226615 31.38479376541256 29.96059303058327 28.57720445777828 27.23462804699755 25.93286379824111 24.67191171150897 23.45177178680109 22.27244402411749 21.13392842345819 20.03622498482317 18.97933370821242 17.96325459362598 16.98798764106381 16.05353285052592 15.15989022201231 14.30705975552298 13.49504145105795 12.72383530861719 11.99344132820072 11.30385950980853 10.65508985344062 10.047132359097 9.47998702677766 8.953653856482592 8.468132848211823 8.023424001965331 7.619527317743124 7.256442795545207 6.934170435371562 6.652710237222204 6.412062201097129 6.212226326996338 6.053202614919829 5.934991064867607 5.85759167683966 5.821004450836002 5.825229386856632 5.870266484901538 5.956115744970729 6.082777167064204 6.250250751181963 6.458536497324003 6.707634405490329 6.997544475680933 7.328266707895824 7.699801102135 8.112147658398458 8.565306376686195 9.059277256998218 9.594060299334528 10.16965550369512 10.78606287007999 11.44328239848915 12.14131408892259 12.88015794138032 13.65981395586231 14.48028213236861 15.34156247089918 16.24365497145405 17.18655963403317 18.1702764586366 19.1948054452643 20.2601465939163 21.36629990459256 22.51326537729313 23.70104301201794 24.92963280876709 26.19903476754048 27.50924888833818 28.86027517116015 30.25211361600639 31.68476422287694 33.15822699177176 34.67250192269088 36.22758901563427 37.82348827060192 39.46019968759389 41.13772326661012 42.85605900765061 44.61520691071544 46.41516697580452 48.25593920291789 50.13752359205556 52.05992014321745 54.02312885640373 56.02714973161421 58.07198276884901 60.15762796810809
+ 47.49798157873274 45.6672896695335 43.87740992235852 42.12834233720785 40.42008691408144 38.75264365297933 37.1260125539015 35.54019361684795 33.99518684181867 32.49099222881368 31.02760977783299 29.60503948887657 28.22328136194445 26.88233539703659 25.58220159415299 24.32287995329373 23.10437047445873 21.926673157648 20.78978800286157 19.69371501009942 18.63845417936155 17.62400551064796 16.65036900395865 15.71754465929364 14.8255324766529 13.97433245603646 13.16394459744428 12.3943689008764 11.66560536633279 10.97765399381347 10.33051478331843 9.724187734847678 9.158672848401208 8.633970123979019 8.150079561581114 7.707001161207498 7.304734922858158 6.943280846533104 6.622638932232335 6.342809179955848 6.103791589703638 5.905586161475725 5.748192895272084 5.631611791092726 5.555842848937653 5.520886068806868 5.52674145070036 5.573408994618141 5.660888700560202 5.789180568526546 5.958284598517173 6.168200790532083 6.418929144571277 6.710469660634757 7.042822338722514 7.415987178834559 7.829964180970888 8.284753345131501 8.78035467131639 9.316768159525569 9.893993809759028 10.51203162201677 11.17088159629879 11.87054373260511 12.6110180309357 13.39230449129057 14.21440311366974 15.07731389807318 15.9810368445009 16.92557195295292 17.91091922342921 18.93707865592977 20.00405025045464 21.11183400700379 22.26042992557722 23.44983800617491 24.68005824879689 25.9510906534432 27.26293522011374 28.61559194880858 30.00906083952772 31.44334189227112 32.91843510703879 34.43434048383078 35.99105802264704 37.58858772348758 39.22692958635239 40.90608361124151 42.6260497981549 44.38682814709259 46.18841865805453 48.03082133104076 49.91403616605129 51.83806316308613 53.8029023221452 55.80855364322856 57.85501712633624 59.94229277146816 62.0703805786244 64.23928054780488
+ 43.54505386769917 41.79761672842137 40.09099175116785 38.4251789359386 36.80017828273365 35.21598979155296 33.67261346239654 32.17004929526446 30.70829729015662 29.28735744707308 27.9072297660138 26.5679142469788 25.26941088996812 24.01171969498172 22.79484066201957 21.61877379108172 20.48351908216816 19.38907653527888 18.33544615041389 17.32262792757317 16.35062186675674 15.41942796796458 14.52904623119671 13.67947665645313 12.87071924373383 12.10277399303882 11.37564090436808 10.68931997772164 10.04381121309947 9.439114610501587 8.875230169927983 8.352157891378667 7.869897774853636 7.428449820352879 7.027814027876421 6.66799039742423 6.348978928996337 6.07077962259272 5.833392478213384 5.636817495858334 5.481054675527565 5.36610401722108 5.291965520938877 5.258639186680958 5.266125014447324 5.314423004237971 5.403533156052903 5.53345546989212 5.704189945755616 5.915736583643398 6.168095383555459 6.461266345491809 6.795249469452443 7.170044755437358 7.585652203446551 8.042071813480032 8.5393035855378 9.077347519619845 9.656203615726175 10.27587187385679 10.93635229401169 11.63764487619086 12.37974962039432 13.16266652662207 13.98639559487409 14.85093682515042 15.75629021745101 16.70245577177589 17.68943348812505 18.7172233664985 19.78582540689623 20.89523960931824 22.04546597376453 23.23650450023512 24.46835518872998 25.74101803924912 27.05449305179255 28.40878022636025 29.80387956295227 31.23979106156853 32.71651472220911 34.23405054487395 35.79239852956306 37.39155867627649 39.03153098501416 40.71231545577616 42.43391208856243 44.19632088337296 45.99954184020778 47.84357495906688 49.72842023995028 51.65407768285795 53.62054728778993 55.62782905474619 57.6759229837267 59.76482907473151 61.89454732776059 64.06507774281398 66.27642031989167 68.5285750589936
+ 39.7997680881575 38.13558571880112 36.51221551146903 34.92965746616124 33.3879115828777 31.88697786161845 30.42685630238349 29.00754690517282 27.62904966998641 26.29136459682431 24.99449168568647 23.73843093657293 22.52318234948367 21.34874592441869 20.21512166137799 19.12230956036157 18.07030962136946 17.05912184440161 16.08874622945804 15.15918277653877 14.27043148564376 13.42249235677305 12.61536538992664 11.84905058510448 11.12354794230662 10.43885746153304 9.794979142783742 9.191912986058728 8.629658991358003 8.108217158681549 7.627587488029387 7.187769979401507 6.788764632797909 6.430571448218593 6.113190425663563 5.836621565132818 5.600864866626353 5.405920330144168 5.251787955686273 5.13846774325266 5.065959692843326 5.034263804458278 5.043380078097511 5.093308513761031 5.184049111448834 5.315601871160919 5.487966792897286 5.701143876657939 5.955133122442872 6.249934530252092 6.585548100085589 6.961973831943372 7.379211725825441 7.837261781731795 8.336123999662425 8.875798379617342 9.456284921596547 10.07758362560003 10.73969449162779 11.44261751967984 12.18635270975617 12.97090006185679 13.79625957598169 14.66243125213088 15.56941509030434 16.51721109050209 17.50581925272413 18.53523957697044 19.60547206324104 20.71651671153593 21.86837352185509 23.06104249419852 24.29452362856626 25.5688169249583 26.88392238337459 28.23984000381515 29.63656978628003 31.07411173076918 32.55246583728261 34.07163210582031 35.63161053638233 37.23240112896859 38.87400388357916 40.55641880021401 42.27964587887314 44.04368511955659 45.84853652226427 47.69420008699624 49.58067581375253 51.50796370253305 53.47606375333785 55.484975966167 57.5347003410204 59.62523687789808 61.75658557680007 63.92874643772625 66.14171946067681 68.39550464565161 70.69010199265075 73.02551150167413
+ 36.26212424010765 34.6811966406727 33.14108120326205 31.64177792787567 30.18328681451356 28.76560786317577 27.38874107386224 26.052686446573 24.75744398130804 23.50301367806736 22.28939553685098 21.11658955765887 19.98459574049105 18.8934140853475 17.84304459222825 16.83348726113326 15.86474209206259 14.93680908501617 14.04968823999404 13.2033795569962 12.39788303602264 11.63319867707337 10.90932648014837 10.22626644524767 9.584018572371241 8.982582861519091 8.421959312691234 7.902147925887658 7.423148701108363 6.984961638353355 6.587586737622624 6.231023998916182 5.915273422234025 5.640335007576142 5.40620875494255 5.21289466433324 5.060392735748212 4.948702969187466 4.877825364651003 4.84775992213883 4.858506641650934 4.91006552318732 5.002436566747994 5.135619772332948 5.309615139942188 5.524422669575706 5.780042361233514 6.076474214915602 6.413718230621969 6.791774408352628 7.210642748107563 7.670323249886782 8.170815913690292 8.712120739518074 9.294237727370144 9.917166877246498 10.58090818914714 11.28546166307206 12.03082729902126 12.81700509699475 13.64399505699252 14.51179717901458 15.4204114630609 16.36983790913152 17.36007651722643 18.39112728734561 19.46299021948909 20.57566531365684 21.72915256984886 22.92345198806519 24.1585635683058 25.43448731057069 26.75122321485986 28.10877128117331 29.50713150951105 30.94630389987304 32.42628845225935 33.94708516666994 35.50869404310482 37.11111508156396 38.75434828204742 40.43839364455513 42.1632511690871 43.92892085564343 45.73540270422394 47.58269671482883 49.47080288745797 51.39972122211136 53.36945171878909 55.37999437749104 57.4313491982173 59.52351618096789 61.6564953257427 63.83028663254184 66.04489010136524 68.30030573221289 70.59653352508491 72.93357347998112 75.31142559690169 77.7300898758465
+ 32.93212232354963 31.43444949403612 29.97758882654687 28.56154032108197 27.18630397764129 25.85187979622491 24.55826777683285 23.30546791946505 22.09348022412152 20.92230469080228 19.79194131950732 18.70239011023665 17.65365106299026 16.64572417776815 15.67860945457034 14.7523068933968 13.86681649424755 13.02213825712258 12.21827218202188 11.45521826894548 10.73297651789335 10.05154692886551 9.410929501861961 8.811124236882687 8.252131133927692 7.733950192996986 7.25658141409057 6.820024797208432 6.424280342350571 6.069348049516998 5.755227918707702 5.481919949922699 5.249424143161976 5.057740498425534 4.906869015713377 4.796809695025503 4.727562536361912 4.699127539722607 4.71150470510758 4.76469403251684 4.858695521950382 4.993509173408207 5.169134986890317 5.385572962396708 5.642823099927382 5.940885399482339 6.279759861061581 6.65944648466511 7.079945270292917 7.541256217945005 8.043379327621377 8.586314599322039 9.170062033046978 9.794621628796206 10.45999338656971 11.1661773063675 11.91317338818957 12.70098163203594 13.52960203790657 14.39903460580149 15.30927933572071 16.2603362276642 17.25220528163196 18.28488649762403 19.35837987564036 20.472685415681 21.6278031177459 22.82373298183508 24.06047500794855 25.33802919608631 26.65639554624836 28.01557405843467 29.41556473264527 30.85636756888017 32.33798256713933 33.86040972742278 35.42364904973052 37.02770053406255 38.67256418041885 40.35823998879943 42.08472795920432 43.85202809163348 45.66014038608689 47.50906484256463 49.39880146106663 51.32935024159294 53.30071118414351 55.31288428871835 57.36586955531749 59.45966698394089 61.59427657458859 63.76969832726061 65.98593224195682 68.24297831867744 70.54083655742224 72.87950695819139 75.25898952098477 77.67928424580246 80.14039113264442 82.64231018151071
+ 29.80976233848347 28.39534427889139 27.02173838132362 25.68894464578012 24.3969630722609 23.14579366076596 21.93543641129531 20.76589132384895 19.63715839842686 18.54923763502905 17.50212903365554 16.49583259430629 15.53034831698134 14.60567620168067 13.72181624840429 12.87876845715219 12.07653282792437 11.31510936072083 10.59449805554158 9.914698912386608 9.27571193125592 8.677537112149526 8.120174455067398 7.60362396000956 7.127885626976014 6.692959455966738 6.298845446981754 5.94554360002105 5.633053915084624 5.361376392172492 5.130511031284635 4.940457832421062 4.791216795581779 4.682787920766772 4.615171207976052 4.588366657209614 4.602374268467457 4.657194041749587 4.752825977055998 4.889270074386691 5.066526333741673 5.28459475512093 5.543475338524478 5.843168083952304 6.183672991404417 6.564990060880805 6.987119292381485 7.450060685906448 7.953814241455697 8.498379959029224 9.083757838627033 9.709947880249123 10.3769500838955 11.08476444956617 11.8333909772611 12.62282966698033 13.45308051872385 14.32414353249163 15.23601870828371 16.18870604610007 17.18220554594071 18.21651720780564 19.29164103169485 20.40757701760834 21.56432516554612 22.76188547550818 24.00025794749453 25.27944258150513 26.59943937754004 27.96024833559925 29.36186945568274 30.80430273779049 32.28754818192252 33.81160578807884 35.37647555625945 36.98215748646433 38.62865157869351 40.31595783294697 42.04407624922472 43.81300682752673 45.62274956785306 47.47330447020364 49.36467153457851 51.29685076097768 53.2698421494011 55.28364569984885 57.3382614123208 59.43368928681711 61.5699293233377 63.74698152188253 65.96484588245167 68.22352240504513 70.52301108966284 72.86331193630484 75.2444249449711 77.66635011566167 80.1290874483765 82.63263694311559 85.17699859987904 87.76217241866671
+ 26.89504428490914 25.56388099523851 24.27352986759215 23.02399090197008 21.8152640983723 20.64734945679881 19.52024697724959 18.43395665972467 17.38847850422402 16.38381251074765 15.41995867929556 14.49691700986776 13.61468750246426 12.77327015708502 11.97266497373007 11.21287195239941 10.49389109309302 9.815722395810919 9.178365860553104 8.581821487319573 8.026089276110325 7.511169226925357 7.037061339764668 6.60376561462827 6.211282051516156 5.859610650428321 5.548751411364774 5.278704334325505 5.04946941931052 4.861046666319821 4.713436075353403 4.606637646411267 4.540651379493417 4.515477274599848 4.531115331730564 4.587565550885564 4.684827932064845 4.82290247526841 5.001789180496257 5.221488047748389 5.481999077024805 5.7833222683255 6.125457621650486 6.508405136999746 6.932164814373296 7.396736653771124 7.902120655193241 8.44831681863964 9.03532514411032 9.663145631605289 10.33177828112453 11.04122309266806 11.79148006623587 12.58254920182798 13.41443049944435 14.28712395908502 15.20062958074996 16.15494736443919 17.1500773101527 18.1860194178905 19.26277368765258 20.38034011943895 21.53871871324958 22.73790946908452 23.97791238694374 25.25872746682723 26.58035470873502 27.94279411266708 29.3460456786234 30.79010940660404 32.27498529660895 33.80067334863814 35.3671735626916 36.97448593876939 38.62261047687145 40.31154717699776 42.04129603914838 43.81185706332328 45.62323024952244 47.47541559774589 49.36841310799366 51.30222278026568 53.27684461456195 55.29227861088258 57.34852476922745 59.44558308959665 61.58345357199006 63.76213621640777 65.98163102284978 68.24193799131612 70.54305712180665 72.88498841432154 75.26773186886066 77.69128748542411 80.15565526401183 82.66083520462375 85.20682730726008 87.79363157192064 90.42124799860547 93.08967658731463
+ 24.18796816282666 22.94005964307745 21.73296328535253 20.5666790896519 19.44120705597557 18.3565471843235 17.31269947469572 16.30966392709223 15.34744054151303 14.42602931795809 13.54543025642744 12.70564335692108 11.906668619439 11.14850604398119 10.43115563054769 9.754617379138461 9.118891289753517 8.52397736239285 7.969875597056473 7.456585993744376 6.984108552456562 6.552443273193036 6.161590155953788 5.811549200738825 5.502320407548144 5.233903776381748 5.006299307239631 4.819507000121805 4.673526855028255 4.568358871958994 4.504003050914012 4.480459391893312 4.497727894896898 4.555808559924769 4.654701386976921 4.794406376053357 4.974923527154076 5.196252840279077 5.458394315428362 5.761347952601931 6.105113751799781 6.489691713021917 6.915081836268334 7.381284121539037 7.888298568834026 8.436125178153286 9.024763949496842 9.654214882864673 10.32447797825679 11.0355532356732 11.78744065511387 12.58014023657885 13.41365198006809 14.28797588558163 15.20311195311944 16.15906018268154 17.15582057426792 18.1933931278786 19.27177784351354 20.39097472117277 21.55098376085629 22.7518049625641 23.99343832629617 25.27588385205254 26.59914153983319 27.96321138963811 29.36809340146735 30.81378757532082 32.3002939111986 33.82761240910069 35.39574306902703 37.00468589097766 38.65444087495258 40.34500802095177 42.07638732897527 43.84857879902302 45.66158243109506 47.51539822519141 49.41002618131203 51.34546629945691 53.32171857962611 55.33878302181957 57.39665962603728 59.49534839227935 61.63484932054565 63.81516241083627 66.03628766315114 68.29822507749026 70.60097465385374 72.94453639224147 75.32891029265345 77.75409635508977 80.22009457955035 82.72690496603521 85.2745275145444 87.86296222507775 90.49220909763554 93.16226813221752 95.87313932882381 98.62482268745435
+ 21.68853397223598 20.52388022240822 19.40003863460475 18.31700920882557 17.27479194507066 16.27338684334003 15.31279390363368 14.39301312595164 13.51404451029385 12.67588805666037 11.87854376505116 11.12201163546623 10.40629166790558 9.731383862369228 9.097288218857155 8.504004737369366 7.951533417905852 7.439874260466628 6.969027265051683 6.538992431661024 6.149769760294645 5.801359250952553 5.493760903634746 5.226974718341218 5.001000695071974 4.815838833827014 4.671489134606338 4.567951597409944 4.505226222237833 4.483313009090007 4.502211957966462 4.561923068867203 4.662446341792223 4.803781776741531 4.985929373715117 5.20888913271299 5.472661053735147 5.777245136781586 6.12264138185231 6.508849788947313 6.935870358066603 7.403703089210173 7.912347982378029 8.461805037570169 9.052074254786591 9.683155634027287 10.35504917529228 11.06775487858155 11.82127274389511 12.61560277123295 13.45074496059506 14.32669931198147 15.24346582539215 16.20104450082712 17.19943533828638 18.23863833776991 19.31865349927773 20.43948082280984 21.60112030836622 22.80357195594689 24.04683576555185 25.33091173718109 26.65579987083458 28.0215001665124 29.42801262421449 30.87533724394086 32.36347402569152 33.89242296946646 35.46218407526566 37.07275734308917 38.72414277293694 40.41634036480903 42.14935011870538 43.92317203462602 45.73780611257094 47.59325235254011 49.48951075453363 51.42658131855138 53.40446404459345 55.42315893265977 57.4826659827504 59.58298519486529 61.72411656900447 63.90606010516792 66.12881580335569 68.39238366356777 70.69676368580403 73.04195587006464 75.42796021634955 77.85477672465866 80.32240539499215 82.83084622734989 85.3800992217319 87.97016437813819 90.60104169656877 93.27273117702364 95.9852328195028 98.7385466240062 101.532672590534 104.3676107190859
+ 19.3967417131372 18.31534273323088 17.27475591534883 16.27498125949109 15.31601876565762 14.39786843384842 13.52053026406352 12.6840042563029 11.88829041056656 11.13338872685451 10.41929920516673 9.746021845503238 9.113556647864034 8.521903612249112 7.971062738658467 7.461034027092116 6.991817477550042 6.563413090032251 6.175820864538743 5.829040801069518 5.523072899624579 5.257917160203924 5.03357358280755 4.850042167435459 4.707322914087653 4.605415822764127 4.544320893464885 4.524038126189927 4.544567520939254 4.605909077712864 4.708062796510757 4.851028677332931 5.034806720179388 5.259396925050133 5.524799291945156 5.831013820864465 6.178040511808057 6.565879364775932 6.994530379768087 7.463993556784529 7.974268895825257 8.525356396890258 9.11725605997955 9.749967885093126 10.42349187223098 11.13782802139312 11.89297633257956 12.68893680579026 13.52570944102525 14.40329423828452 15.32169119756808 16.28090031887591 17.28092160220805 18.32175504756446 19.40340065494513 20.52585842435012 21.68912835577936 22.89321044923291 24.13810470471072 25.42381112221284 26.75032970173923 28.1176604432899 29.52580334686483 30.97475841246408 32.4645256400876 33.99510502973542 35.56649658140751 37.17870029510387 38.83171617082451 40.52554420856948 42.26018440833867 44.0356367701322 45.85190129395 47.70897797979207 49.60686682765841 51.54556783754904 53.52508100946397 55.54540634340316 57.60654383936665 59.70849349735443 61.85125531736649 64.03482929940283 66.25921544346343 68.52441374954834 70.83042421765752 73.17724684779104 75.56488163994875 77.99332859413077 80.4625877103371 82.97265898856773 85.52354242882254 88.11523803110175 90.74774579540522 93.42106572173299 96.13519781008495 98.89014206046126 101.6858984728619 104.5224670472867 107.3998477837359 110.3180406822094
+ 17.31259138553023 16.31444717554534 15.35711512758474 14.44059524164844 13.56488751773639 12.72999195584864 11.93590855598516 11.18263731814599 10.47017824233109 9.798531328540465 9.167696576774121 8.57767398703208 8.028463559314314 7.520065293620819 7.052479189951617 6.625705248306696 6.239743468686062 5.89459385108971 5.590256395517639 5.326731101969851 5.10401797044635 4.922117000947124 4.781028193472192 4.680751548021542 4.621287064595166 4.60263474319308 4.624794583815278 4.687766586461753 4.791550751132519 4.936147077827566 5.121555566546893 5.347776217290505 5.6148090300584 5.922654004850579 6.27131114166704 6.660780440507787 7.091061901372814 7.562155524262124 8.074061309175722 8.626779256113597 9.220309365075758 9.854651636062204 10.52980606907293 11.24577266410794 12.00255142116723 12.8001423402508 13.63854542135868 14.51776066449082 15.43778806964725 16.39862763682796 17.40027936603294 18.44274325726222 19.52601931051578 20.65010752579364 21.81500790309575 23.02072044242216 24.26724514377287 25.55458200714783 26.88273103254709 28.25169221997063 29.66146556941847 31.11205108089058 32.60344875438695 34.13565858990764 35.70868058745259 37.32251474702184 38.97716106861537 40.67261955223316 42.40889019787526 44.18597300554165 46.0038679752323 47.86257510694725 49.76209440068645 51.70242585644998 53.68356947423781 55.70552525404982 57.7682931958862 59.87187329974684 62.01626556563176 64.20146999354097 66.42748658347445 68.69431533543225 71.00195624941425 73.35040932542063 75.73967456345123 78.16975196350622 80.64064152558535 83.1523432496888 85.70485713581664 88.29818318396859 90.93232139414491 93.60727176634558 96.32303430057046 99.07960899681964 101.8769958550931 104.7151948753908 107.5942060577129 110.5140294020591 113.4746649084297 116.4761125768245
+ 15.43608298941511 14.52119354935165 13.64711627131249 12.81385115529762 12.02139820130702 11.2697574093407 10.55892877939866 9.888912311480919 9.259708005587456 8.671315861718268 8.123735879873381 7.616968060052758 7.15101240225643 6.725868906484379 6.341537572736604 5.998018401013127 5.69531139131393 5.433416543639011 5.212333857988379 5.03206333436203 4.892604972759964 4.79395877318218 4.73612473562868 4.719102860099461 4.742893146594525 4.807495595113875 4.91291020565751 5.059136978225427 5.246175912817625 5.474027009434107 5.742690268074872 6.052165688739923 6.402453271429254 6.793553016142869 7.225464922880766 7.698188991642948 8.211725222429417 8.766073615240161 9.361234170075193 9.997206886934508 10.6739917658181 11.39158880672598 12.14999800965815 12.9492193746146 13.78925290159533 14.67009859060034 15.59175644162963 16.55422645468322 17.55750862976109 18.60160296686324 19.68650946598966 20.81222812714038 21.97875895031537 23.18610193551466 24.43425708273821 25.72322439198606 27.05300386325819 28.4235954965546 29.83499929187529 31.28721524922028 32.78024336858955 34.31408364998309 35.88873609340092 37.50420069884301 39.16047746630944 40.85756639580011 42.59546748731508 44.3741807408543 46.19370615641785 48.05404373400566 49.95519347361776 51.89715537525412 53.87992943891477 55.90351566459973 57.96791405230896 60.07312460204245 62.21914731380026 64.40598218758232 66.63362922338872 68.90208842121932 71.21135978107429 73.56144330295348 75.95233898685696 78.38404683278478 80.85656684073679 83.3698990107132 85.92404334271383 88.5189998367387 91.15476849278791 93.83134931086131 96.54874229095908 99.30694743308121 102.1059647372275 104.9457942033981 107.8264358315929 110.7478896218122 113.7101555740556 116.7132336883234 119.7571239646154 122.8418264029317
+ 13.76721652479182 12.93558185464982 12.14475934653209 11.39474900043865 10.68555081636949 10.01716479432461 9.389590934304012 8.802829236307703 8.25687970033567 7.751742326387924 7.28741711446446 6.863904064565279 6.481203176690387 6.139314450839771 5.838237887013443 5.5779734852114 5.358521245433636 5.179881167680152 5.042053251950961 4.945037498246045 4.888833906565416 4.873442476909068 4.898863209277006 4.965096103669228 5.072141160085728 5.219998378526514 5.408667758991584 5.638149301480935 5.908443005994577 6.219548872532491 6.571466901094692 6.964197091681182 7.397739444291948 7.872093958927002 8.387260635586337 8.943239474269955 9.540030474977858 10.17763363771004 10.85604896246651 11.57527644924726 12.3353160980523 13.13616790888161 13.97783188173522 14.8603080166131 15.78359631351526 16.74769677244171 17.75260939339245 18.79833417636748 19.88487112136677 21.01222022839035 22.18038149743821 23.38935492851036 24.63914052160682 25.92973827672753 27.26114819387253 28.63337027304181 30.04640451423537 31.50025091745323 32.99490948269536 34.53038020996176 36.10666309925247 37.72375815056744 39.38166536390671 41.08038473927028 42.81991627665811 44.60025997607023 46.42141583750661 48.28338386096728 50.18616404645225 52.12975639396149 54.11416090349505 56.13937757505287 58.20540640863495 60.31224740424131 62.45990056187199 64.64836588152693 66.87764336320618 69.14773300690968 71.45863481263746 73.81034878038952 76.20287491016595 78.63621320196658 81.11036365579147 83.62532627164073 86.18110104951424 88.77768798941202 91.41508709133409 94.0932983552804 96.81232178125106 99.57215736924599 102.3728051192651 105.2142650313087 108.0965371053764 111.0196213414685 113.9835177395848 116.9882262997253 120.0337470218903 123.1200799060795 126.247224952293 129.4151821605307
+ 12.3059919916604 11.55761209143981 10.85004435324353 10.18328877707153 9.557345362923797 8.972214110800351 8.427895020701191 7.924388092626319 7.46169332657573 7.039810722549419 6.658740280547397 6.318482000569648 6.019035882616194 5.760401926687013 5.542580132782118 5.365570500901513 5.229373031045188 5.133987723213145 5.079414577405386 5.065653593621907 5.092704771862715 5.160568112127806 5.269243614417181 5.418731278730833 5.609031105068773 5.840143093430998 6.112067243817506 6.424803556228294 6.778352030663366 7.172712667122719 7.607885465606359 8.083870426114281 8.600667548646488 9.158276833202978 9.756698279783746 10.39593188838881 11.07597765901814 11.79683559167177 12.55850568634967 13.36098794305186 14.20428236177833 15.08838894252909 16.01330768530412 16.97903859010345 17.98558165692705 19.03293688577493 20.12110427664711 21.25008382954356 22.4198755444643 23.63047942140932 24.88189546037862 26.17412366137222 27.50716402439008 28.88101654943223 30.29568123649867 31.75115808558937 33.2474470967044 34.7845482698437 36.36246160500724 37.98118710219509 39.64072476140724 41.34107458264366 43.08223656590435 44.86421071118934 46.6869970184986 48.55059548783218 50.45500611919002 52.40022891257212 54.38626386797851 56.4131109854092 58.48077026486417 60.5892417063434 62.73852530984698 64.92862107537478 67.15952900292694 69.43124909250324 71.74378134410392 74.09712575772888 76.49128233337811 78.92625107105164 81.40203197074946 83.91862503247152 86.47603025621785 89.07424764198856 91.7132771897835 94.39311889960273 97.11377277144624 99.87523880531391 102.6775170012061 105.5206073591224 108.404509879063 111.3292245610279 114.2947514050171 117.3010904110307 120.3482415790684 123.4362049091304 126.5649804012168 129.7345680553275 132.9449678714623 136.1961798496214
+ 11.05240939002081 10.38728425972167 9.762971291446812 9.179470485196248 8.636781840969956 8.134905358767952 7.673841038590225 7.253588880436787 6.874148884307632 6.535521050202761 6.237705378122167 5.980701868065866 5.764510520033847 5.589131334026101 5.454564310042645 5.360809448083474 5.307866748148583 5.295736210237974 5.32441783435165 5.39391162048961 5.504217568651853 5.655335678838375 5.847265951049188 6.080008385284281 6.353562981543655 6.667929739827316 7.023108660135255 7.419099742467483 7.85590298682399 8.333518393204782 8.851945961609859 9.411185692039217 10.01123758449286 10.65210163897078 11.33377785547299 12.05626623399949 12.81956677455026 13.62367947712532 14.46860434172465 15.35434136834828 16.28089055699618 17.24825190766838 18.25642542036486 19.30541109508561 20.39520893183064 21.52581893059997 22.69724109139358 23.90947541421147 25.16252189905364 26.4563805459201 27.79105135481083 29.16653432572587 30.58282945866517 32.03993675362876 33.53785621061662 35.07658782962879 36.65613161066523 38.27648755372596 39.93765565881095 41.63963592592024 43.3824283550538 45.16603294621167 46.99044969939379 48.85567861460024 50.76171969183093 52.70857293108595 54.6962383323652 56.72471589566872 58.79400562099659 60.90410750834871 63.05502155772513 65.24674776912579 67.47928614255076 69.75263667800002 72.06679937547358 74.42177423497139 76.81756125649349 79.25416044003987 81.73157178561056 84.24979529320545 86.80883096282479 89.40867879446824 92.04933878813604 94.73081094382819 97.4530952615445 100.2161917412852 103.0201003830501 105.8648211868393 108.7503541526529 111.6766992804907 114.6438565703527 117.6518260222391 120.7006076361496 123.7902014120847 126.9206073500438 130.0918254500273 133.3038557120351 136.5566981360671 139.8503527221235 143.1848194702041
+ 10.00646871987306 9.424598359495361 8.883540161141935 8.383294124812807 7.923860250507954 7.50523853822738 7.127428987971093 6.790431599739093 6.494246373531372 6.238873309347936 6.024312407188785 5.850563667053917 5.717627088943327 5.625502672857028 5.574190418795011 5.56369032675727 5.594002396743818 5.665126628754644 5.777063022789762 5.929811578849153 6.123372296932835 6.357745177040798 6.632930219173047 6.948927423329573 7.305736789510386 7.703358317715484 8.141792007944858 8.621037860198522 9.14109587447647 9.701966050778694 10.30364838910521 10.946142889456 11.62944955183108 12.35356837623044 13.11849936265409 13.92424251110202 14.77079782157423 15.65816529407072 16.58634492859149 17.55533672513656 18.56514068370591 19.61575680429954 20.70718508691743 21.83942553155964 23.01247813822612 24.22634290691688 25.48101983763193 26.77650893037124 28.11281018513486 29.48992360192275 30.90784918073492 32.36658692157139 33.86613682443213 35.40649888931716 36.98767311622646 38.60965950516005 40.27245805611793 41.9760687691001 43.72049164410653 45.50572668113725 47.33177388019226 49.19863324127156 51.10630476437513 53.05478844950301 55.04408429665516 57.07419230583158 59.1451124770323 61.25684481025724 63.40938930550654 65.60274596278012 67.83691478207794 70.11189576340004 72.42768890674648 74.78429421211716 77.18171167951212 79.61994130893139 82.09898310037491 84.61883705384277 87.17950316933482 89.78098144685123 92.42327188639196 95.10637448795687 97.83028925154608 100.5950161771596 103.4005552647974 106.2469065144595 109.1340699261459 112.0620454998565 115.0308332355915 118.0404331333507 121.0908451931342 124.1820694149421 127.3141057987741 130.4869543446304 133.7006150525111 136.955087922416 140.2503729543452 143.5864701482987 146.9633795042765 150.3811010222785
+ 9.168169981217149 8.669554390760883 8.211750962328901 7.794759695921208 7.418580591537791 7.083213649178659 6.788658868843807 6.534916250533245 6.321985794246962 6.149867499984956 6.018561367747243 5.928067397533812 5.878385589344662 5.869515943179794 5.901458459039213 5.974213136922915 6.087779976830895 6.24215897876316 6.437350142719715 6.673353468700541 6.950168956705665 7.267796606735061 7.626236418788746 8.025488392866711 8.46555252896896 8.946428827095495 9.468117287246308 10.0306179094214 10.63393069362079 11.27805563984445 11.96299274809241 12.68874201836463 13.45530345066115 14.26267704498195 15.11086280132703 15.9998607196964 16.92967080009005 17.90029304250798 18.91172744695018 19.96397401341669 21.05703274190747 22.19090363242253 23.36558668496188 24.58108189952551 25.83738927611342 27.13450881472561 28.47244051536209 29.85118437802286 31.27074040270792 32.73110858941724 34.23228893815083 35.77428144890873 37.35708612169093 38.9807029564974 40.64513195332814 42.35037311218316 44.09642643306248 45.88329191596607 47.71096956089394 49.5794593678461 51.48876133682256 53.43887546782329 55.42980176084829 57.4615402158976 59.53409083297121 61.64745361206904 63.8016285531912 65.9966156563376 68.23241492150828 70.50902634870334 72.82644993792265 75.18468568916616 77.58373360243399 80.02359367772611 82.50426591504255 85.02575031438323 87.58804687574818 90.19115559913743 92.83507648455102 95.51980953198883 98.24535474145102 101.0117121129374 103.818881646448 106.666863341983 109.5556571995422 112.4852632191258 115.4556814007336 118.4669117443656 121.518954250022 124.6118089177027 127.7454757474076 130.9199547391368 134.1352458928904 137.3913492086682 140.6882646864703 144.0259923262966 147.4045321281473 150.8238840920222 154.2840482179215 157.7850245058448
+ 8.537513174053084 8.122152353518254 7.747603695007713 7.41386719852145 7.120942864059474 6.868830691621775 6.657530681208362 6.487042832819234 6.357367146454389 6.26850362211383 6.220452259797549 6.213213059505549 6.246786021237833 6.321171144994405 6.436368430775262 6.592377878580396 6.789199488409817 7.026833260263516 7.305279194141507 7.624537290043779 7.984607547970332 8.385489967921165 8.827184549896288 9.309691293895689 9.833010199919377 10.39714126796734 11.0020844980396 11.64783989013613 12.33440744425696 13.06178716040205 13.82997903857144 14.63898307876511 15.48879928098306 16.3794276452253 17.31086817149182 18.28312085978262 19.2961857100977 20.35006272243707 21.44475189680071 22.58025323318866 23.75656673160088 24.97369239203738 26.23163021449815 27.53038019898322 28.8699423454926 30.25031665402621 31.67150312458413 33.13350175716634 34.63631255177282 36.17993550840358 37.76437062705863 39.38961790773797 41.05567735044158 42.76254895516948 44.51023272192165 46.29872865069813 48.12803674149886 49.99815699432391 51.9090894091732 53.86083398604681 55.85339072494472 57.88675962586686 59.96094068881332 62.07593391378404 64.23173930077905 66.42835684979839 68.66578656084195 70.94402843390979 73.26308246900193 75.62294866611838 78.0236270252591 80.4651175464241 82.94742022961336 85.47053507482694 88.03446208206479 90.6392012513269 93.28475258261332 95.97111607592403 98.69829173125906 101.4662795486183 104.2750795280019 107.1246916694097 110.0151159728418 112.9463524382981 115.9184010657788 118.9312618552839 121.984934806813 125.0794199203665 128.2147171959444 131.3908266335466 134.6077482331729 137.8654819948235 141.1640279184985 144.5033860041978 147.8835562519212 151.304538661669 154.766333233441 158.2689399672375 161.8123588630581 165.396589920903
+ 8.114498298380855 7.782392247767476 7.491098359178364 7.240616632613538 7.030947068072992 6.862089665556734 6.734044425064759 6.646811346597064 6.600390430153657 6.59478167573453 6.629985083339688 6.706000652969125 6.822828384622851 6.98046827830085 7.178920334003147 7.418184551729719 7.698260931480574 8.019149473255714 8.380850177055141 8.783363042878843 9.226688070726832 9.710825260599107 10.23577461249566 10.8015361264165 11.40810980236162 12.05549564033102 12.74369364032472 13.47270380234268 14.24252612638495 15.05316061245148 15.9046072605423 16.79686607065741 17.7299370427968 18.70382017696047 19.71851547314842 20.77402293136065 21.87034255159717 23.00747433385799 24.18541827814308 25.40417438445244 26.66374265278609 27.96412308314403 29.30531567552624 30.68732042993274 32.11013734636354 33.57376642481861 35.07820766529795 36.62346106780159 38.20952663232952 39.83640435888172 41.5040942474582 43.21259629805898 44.96191051068404 46.75203688533337 48.58297542200696 50.4547261207049 52.36728898142709 54.32066400417355 56.31485118894425 58.34985053573934 60.42566204455868 62.54228571540227 64.69972154827011 66.89796954316232 69.13702970007877 71.41690201901947 73.73758649998452 76.09908314297377 78.50139194798739 80.94451291502526 83.42844604408741 85.95319133517383 88.51874878828458 91.12511840341956 93.77230018057882 96.46029411976241 99.18910022097027 101.9587184842024 104.7691489094588 107.6203914967395 110.5124462460445 113.4453131573738 116.4189922307273 119.4334834661052 122.4887868635072 125.5849024229336 128.7218301443844 131.8995700278594 135.1181220733586 138.3774862808821 141.6776626504299 145.018651182002 148.4004518755983 151.8230647312191 155.286489748864 158.7907269285333 162.3357762702268 165.9216377739446 169.5483114396867 173.215797267453
+ 7.899125354200483 7.650274073508527 7.442234954840856 7.27500799819747 7.148593203578363 7.062990570983537 7.018200100412999 7.014221791866739 7.051055645344769 7.128701660847081 7.247159838373675 7.406430177924551 7.606512679499707 7.847407343099156 8.129114168722884 8.451633156370889 8.814964306043182 9.219107617739759 9.664063091460617 10.14983072720575 10.67641052497519 11.2438024847689 11.85200660658688 12.50102289042916 13.19085133629572 13.92149194418656 14.69294471410169 15.5052096460411 16.35828674000479 17.25217599599275 18.18687741400502 19.16239099404156 20.17871673610239 21.23585464018749 22.33380470629689 23.47256693443057 24.65214132458853 25.87252787677075 27.13372659097729 28.4357374672081 29.77856050546319 31.16219570574254 32.58664306804622 34.05190259237416 35.55797427872638 37.10485812710287 38.69255413750368 40.32106230992873 41.99038264437812 43.70051514085175 45.45145979934964 47.24321661987188 49.07578560241836 50.94916674698913 52.86336005358419 54.81836552220351 56.81418315284714 58.85081294551507 60.92825490020724 63.04650901692369 65.20557529566449 67.40545373642949 69.64614433921882 71.92764710403243 74.24996203087034 76.61308911973251 79.01702837061895 81.46177978352968 83.94734335846472 86.47371909542403 89.04090699440761 91.64890705541545 94.2977192784476 96.98734366350406 99.71778021058479 102.4890289196897 105.301089790819 108.1539628239726 111.0476480191505 113.9821453763526 116.9574548955791 119.9735765768298 123.0305104201047 126.128256425404 129.2668145927276 132.4461849220754 135.6663674134475 138.9273620668439 142.2291688822646 145.5717878597096 148.9552189991788 152.3794623006724 155.8445177641902 159.3503853897323 162.8970651772987 166.4845571268893 170.1128612385044 173.7819775121435 177.4919059478071 181.2426465454949
+ 7.891394341511949 7.725797830741425 7.601013481995191 7.517041295273237 7.473881270575575 7.47153340790218 7.509997707253085 7.589274168628263 7.709362792027727 7.870263577451478 8.071976524899508 8.314501634371814 8.597838905868411 8.921988339389294 9.286949934934459 9.692723692503902 10.13930961209763 10.62670769371564 11.15491793735794 11.72394034302452 12.33377491071538 12.98442164043052 13.67588053216996 14.40815158593367 15.18123480172166 15.99513017953396 16.8498377193705 17.74535742123135 18.68168928511648 19.65883331102589 20.67678949895959 21.73555784891756 22.83513836089982 23.97553103490637 25.1567358709372 26.37875286899231 27.64158202907171 28.94522335117539 30.28967683530334 31.67494248145559 33.1010202896321 34.56791025983291 36.07561239205801 37.6241266863074 39.21345314258107 40.843591760879 42.51454254120122 44.22630548354773 45.97888058791854 47.7722678543136 49.60646728273298 51.48147887317663 53.39730262564453 55.35393854013675 57.35138661665322 59.38964685519402 61.46871925575905 63.58860381834841 65.74930054296203 67.95080942959993 70.19313047826212 72.47626368894861 74.80020906165936 77.16496659639439 79.57053629315369 82.01691815193735 84.50411217274527 87.03211835557738 89.60093670043386 92.21056720731461 94.86100987621961 97.55226470714891 100.2843317001026 103.0572108550804 105.8709021720825 108.7254056511091 111.6207212921597 114.5568490952348 117.533789060334 120.5515411874576 123.6101054766054 126.7094819277775 129.849670540974 133.0306713161948 136.2524842534397 139.515109352709 142.8185466140025 146.1627960373203 149.5478576226625 152.9737313700289 156.4404172794196 159.9479153508346 163.4962255842738 167.0853479797373 170.7152825372252 174.3860292567372 178.0975881382737 181.8499591818343 185.6431423874193 189.4771377550286
+ 8.091305260315247 8.008963519466164 7.967433940641371 7.966716523840854 8.006811269064624 8.087718176312672 8.209437245585008 8.371968476881625 8.575311870202524 8.819467425547709 9.104435142917174 9.430215022310925 9.796807063728959 10.20421126717127 10.65242763263788 11.14145616012876 11.67129684964392 12.24194970118337 12.85341471474711 13.50569189033512 14.19878122794742 14.932682727584 15.70739638924487 16.52292221293002 17.37926019863946 18.27641034637317 19.21437265613116 20.19314712791344 21.21273376172001 22.27313255755087 23.374343515406 24.51636663528541 25.6992019171891 26.92284936111711 28.18730896706935 29.49258073504592 30.83866466504673 32.22556075707185 33.65326901112124 35.12178942719493 36.6311220052929 38.18126674541514 39.77222364756165 41.40399271173247 43.07657393792758 44.78996732614692 46.54417287639063 48.33919058865855 50.17502046295081 52.05166249926732 53.96911669760811 55.92738305797318 57.92646158036253 59.96635226477623 62.04705511121413 64.16857011967633 66.33089729016284 68.5340366226736 70.77798811720864 73.06275177376799 75.38832759235164 77.75471557295955 80.16191571559176 82.60992802024825 85.09875248692897 87.62838911563404 90.19883790636339 92.81009885911698 95.4621719738949 98.15505725069707 100.8887546895236 103.6632642903742 106.4785860532493 109.3347199781486 112.2316660650722 115.16942431402 118.1479947249922 121.1673772979887 124.2275720330094 127.3285789300544 130.4703979891237 133.6530292102172 136.8764725933351 140.1407281384773 143.4457958456437 146.7916757148344 150.1783677460494 153.6058719392887 157.0741882945522 160.58331681184 164.1332574911522 167.7240103324887 171.3555753358493 175.0279525012344 178.7411418286435 182.4951433180771 186.2899569695349 190.1255827830171 194.0020207585234 197.9192708960541
+ 8.498858110610398 8.499771139682743 8.541496330779388 8.624033683900302 8.747383199045514 8.911544876214993 9.116518715408766 9.36230471662682 9.648902879869151 9.976313205135774 10.34453569242668 10.75357034174186 11.20341715308133 11.69407612644509 12.22554726183313 12.79783055924545 13.41092601868204 14.06483364014293 14.75955342362809 15.49508536913756 16.27142947667128 17.0885857462293 17.94655417781161 18.84533477141819 19.78492752704906 20.76533244470421 21.78654952438365 22.84857876608736 23.95142016981537 25.09507373556764 26.27953946334423 27.50481735314505 28.7709074049702 30.07780961881963 31.42552399469333 32.8140505325913 34.24338923251358 35.71354009446011 37.22450311843096 38.77627830442607 40.36886565244549 42.00226516248915 43.67647683455711 45.39150066864938 47.14733666476592 48.94398482290671 50.78144514307179 52.65971762526119 54.57880226947488 56.53869907571282 58.53940804397505 60.5809291742616 62.66326246657236 64.78640792090744 66.95036553726683 69.15513531565043 71.40071725605843 73.68711135849065 76.01431762294709 78.38233604942785 80.791166637933 83.24080938846232 85.73126430101593 88.26253137559381 90.83461061219604 93.44750201082252 96.10120557147329 98.79572129414836 101.5310491788477 104.3071892255712 107.1241414343192 109.9819058050913 112.8804823378879 115.8198710327085 118.8000718895536 121.8210849084229 124.8829100893166 127.9855474322344 131.1289969371765 134.313258604143 137.5383324331337 140.8042184241487 144.110916577188 147.4584268922516 150.8467493693395 154.2758840084516 157.7458308095881 161.2565897727487 164.8081608979337 168.4005441851431 172.0337396343766 175.7077472456345 179.4225670189165 183.178198954223 186.9746430515537 190.8118993109085 194.689967732288 198.6088483156916 202.5685410611193 206.5690459685715
+ 9.114052892397384 9.198220691391175 9.323200652409252 9.488992775451605 9.695597060518251 9.943013507609171 10.23124211672437 10.56028288786387 10.93013582102764 11.3408009162157 11.79227817342804 12.28456759266466 12.81766917392556 13.39158291721075 14.00630882252023 14.66184688985398 15.35819711921201 16.09535951059435 16.87333406400096 17.69212077943185 18.55171965688702 19.45213069636647 20.39335389787021 21.37538926139823 22.39823678695053 23.46189647452713 24.56636832412799 25.71165233575314 26.89774850940259 28.1246568450763 29.39237734277432 30.70091000249658 32.05025482424315 33.44041180801403 34.87138095380917 36.34316226162859 37.85575573147229 39.40916136334027 41.00337915723253 42.63840911314909 44.31425123108993 46.03090551105503 47.78837195304445 49.58665055705816 51.42574132309613 53.30564425115833 55.22635934124487 57.18788659335575 59.19022600749084 61.2333775836502 63.31734132183387 65.44211722204183 67.60770528427408 69.81410550853059 72.06131789481135 74.34934244311646 76.67817915344585 79.04782802579948 81.45828906017741 83.90956225657966 86.40164761500615 88.93454513545694 91.50825481793201 94.12277666243135 96.77811066895495 99.47425683750295 102.2112151680751 104.9889856606716 107.8075683152924 110.6669631319374 113.5671701106067 116.5081892513004 119.4900205540182 122.5126640187604 125.576119645527 128.6803874343176 131.8254673851326 135.011359497972 138.2380637728356 141.5055802097235 144.8139088086357 148.1630495695721 151.5530024925329 154.9837675775179 158.4553448245271 161.9677342335608 165.5209358046186 169.1149495377007 172.7497754328072 176.4254134899379 180.1418637090929 183.8991260902722 187.6972006334758 191.5360873387036 195.4157862059557 199.3362972352322 203.2976204265328 207.2997557798578 211.3427032952073 215.4264629725806
+ 9.936889605676217 10.10431217459145 10.31254690553095 10.56159379849475 10.85145285348283 11.18212407049518 11.55360744953183 11.96590299059274 12.41901069367796 12.91293055878746 13.44766258592124 14.0232067750793 14.63956312626163 15.29673163946827 15.99471231469918 16.73350515195437 17.51311015123384 18.33352731253759 19.19475663586564 20.09679812121797 21.03965176859458 22.02331757799547 23.04779554942064 24.11308568287012 25.21918797834384 26.36610243584188 27.55382905536418 28.78236783691077 30.05171878048165 31.3618818860768 32.71285715369624 34.10464458333997 35.53724417500797 37.01065592870027 38.52487984441683 40.0799159221577 41.67576416192286 43.31242456371227 44.98989712752598 46.70818185336397 48.46727874122626 50.26718779111279 52.10790900302362 53.98944237695877 55.91178791291817 57.87494561090183 59.8789154709098 61.92369749294208 64.00929167699863 66.13569802307948 68.30291653118458 70.51094720131394 72.75979003346764 75.04944502764555 77.37991218384781 79.75119150207433 82.16328298232514 84.61618662460023 87.10990242889955 89.64443039522322 92.21977052357117 94.83592281394341 97.49288726633992 100.1906638807607 102.9292526572058 105.7086535956751 108.5288666961688 111.3898919586867 114.2917293832289 117.2343789697953 120.2178407183862 123.2421146290012 126.3072007016406 129.4130989363042 132.559809332992 135.7473318917042 138.9756666124407 142.2448134952015 145.5547725399865 148.9055437467958 152.2971271156295 155.7295226464873 159.2027303393694 162.716750194276 166.2715822112066 169.8672263901617 173.503682731141 177.1809512341445 180.8990318991724 184.6579247262245 188.457629715301 192.2981468664017 196.1794761795267 200.1016176546761 204.0645712918495 208.0683370910475 212.1129150522696 216.198305175516 220.3245074607867 224.4915219080817
+ 10.96736825044689 11.21804558928356 11.5095350901445 11.84183675302973 12.21495057793925 12.62887656487305 13.08361471383113 13.57916502481349 14.11552749782014 14.69270213285107 15.31068892990627 15.96948788898577 16.66909901008955 17.40952229321762 18.19075773836996 19.01280534554659 19.8756651147475 20.7793370459727 21.72382113922219 22.70911739449594 23.735225811794 24.80214639111632 25.90987913246292 27.05842403583382 28.24778110122901 29.47795032864846 30.74893171809223 32.06072526956024 33.41333098305255 34.80674885856914 36.24097889611003 37.71602109567518 39.23187545726463 40.78854198087836 42.38602066651637 44.02431151417867 45.70341452386524 47.42332969557609 49.18405702931124 50.98559652507067 52.82794818285438 54.71111200266238 56.63508798449464 58.59987612835122 60.60547643423205 62.65188890213717 64.7391135320666 66.8671503240203 69.03599927799826 71.24566039400051 73.49613367202709 75.78741911207788 78.11951671415299 80.49242647825241 82.90614840437605 85.36068249252398 87.8560287426963 90.3921871548928 92.96915772911363 95.58694046535868 98.24553536362804 100.9449424239217 103.6851616462396 106.4661930305819 109.2880365769484 112.1506922853392 115.0541601557542 117.9984401881937 120.9835323826572 124.0094367391452 127.0761532576574 130.1836819381938 133.3320227807546 136.5211757853397 139.751140951949 143.0219182805827 146.3335077712406 149.6859094239227 153.0791232386293 156.51314921536 159.9879873541151 163.5036376548944 167.0601001176979 170.6573747425259 174.2954615293781 177.9743604782545 181.6940715891553 185.4545948620802 189.2559302970296 193.0980778940032 196.9810376530011 200.9048095740233 204.8693936570696 208.8747899021403 212.9209983092353 217.0080188783545 221.1358516094981 225.304496502666 229.5139535578581 233.7642227750747
+ 12.2054888267094 12.53942093546749 12.91416520624987 13.32972163905655 13.78609023388749 14.28327099074273 14.82126390962225 15.40006899052604 16.01968623345413 16.6801156384065 17.38135720538314 18.12341093438408 18.90627682540929 19.72995487845879 20.59444509353257 21.49974747063064 22.44586200975298 23.43278871089962 24.46052757407053 25.52907859926574 26.63844178648522 27.78861713572898 28.97960464699702 30.21140432028936 31.48401615560598 32.79744015294688 34.15167631231206 35.5467246337015 36.98258511711526 38.4592577625533 39.9767425700156 41.5350395395022 43.13414867101307 44.77406996454826 46.45480342010769 48.17634903769143 49.93870681729943 51.74187675893172 53.5858588625883 55.4706531282692 57.39625955597434 59.36267814570376 61.36990889745744 63.41795181123545 65.50680688703777 67.63647412486428 69.80695352471514 72.01824508659028 74.27034881048971 76.56326469641334 78.89699274436137 81.27153295433365 83.68688532633018 86.14304986035098 88.64002655639608 91.17781541446551 93.75641643455917 96.37582961667718 99.0360549608194 101.737092466986 104.4789421351767 107.2616039653918 110.0850779576312 112.9493641118949 115.8544624281828 118.800372906495 121.7870955468316 124.8146303491924 127.8829773135775 130.9921364399868 134.1421077284205 137.3328911788784 140.5644867913606 143.8368945658671 147.1501145023978 150.5041466009529 153.8989908615322 157.3346472841359 160.8111158687637 164.3283966154159 167.8864895240925 171.4853945947932 175.1251118275183 178.8056412222676 182.5269827790412 186.289136497839 190.0921023786613 193.9358804215077 197.8204706263784 201.7458729932733 205.7120875221927 209.7191142131363 213.7669530661042 217.8556040810964 221.9850672581127 226.1553425971536 230.3664300982186 234.6183297613078 238.9110415864214 243.2445655735592
+ 13.65125133446376 14.06843821314329 14.52643725384712 15.02524845657521 15.5648718213276 16.14530734810427 16.76655503690523 17.42861488773046 18.13148690057998 18.87517107545379 19.65966741235187 20.48497591127424 21.35109657222089 22.25802939519183 23.20577438018705 24.19433152720655 25.22370083625034 26.29388230731839 27.40487594041076 28.55668173552738 29.7492996926683 30.98272981183351 32.25697209302299 33.57202653623676 34.92789314147481 36.32457190873715 37.76206283802377 39.24036592933466 40.75948118266986 42.31940859802933 43.92014817541308 45.56169991482109 47.24406381625341 48.96723987971001 50.7312281051909 52.53602849269608 54.38164104222553 56.26806575377923 58.1953026273573 60.16335166295956 62.17221286058617 64.22188622023701 66.31237174191217 68.4436694256116 70.61577927133533 72.82870127908329 75.08243544885559 77.37698178065217 79.71234027447304 82.08851093031818 84.50549374818755 86.96328872808127 89.46189586999925 92.00131517394151 94.58154663990805 97.20259026789884 99.86444605791399 102.5671140099534 105.3105941240171 108.094886400105 110.9199908382173 113.7859074383539 116.6926362005146 119.6401771246998 122.6285302109092 125.6576954591428 128.7276728694007 131.838462441683 134.9900641759894 138.1824780723202 141.4157041306754 144.6897423510547 148.0045927334583 151.3602552778863 154.7567299843385 158.194016852815 161.6721158833158 165.1910270758409 168.7507504303903 172.3512859469638 175.9926336255618 179.6747934661839 183.3977654688303 187.1615496335012 190.9661459601962 194.8115544489155 198.6977750996592 202.624807912427 206.5926528872192 210.6013100240357 214.6507793228764 218.7410607837413 222.8721544066308 227.0440601915443 231.2567781384822 235.5103082474444 239.8046505184308 244.1398049514415 248.5157715464767 252.9325503035358
+ 15.30465577370996 15.80509742231093 16.3463512329362 16.92841720558572 17.55129534025956 18.21498563695766 18.91948809568006 19.66480271642672 20.45092949919768 21.27786844399293 22.14561955081245 23.05418281965625 24.00355825052435 24.99374584341671 26.02474559833337 27.09655751527432 28.20918159423953 29.36261783522902 30.55686623824283 31.79192680328089 33.06779953034325 34.38448441942989 35.74198147054081 37.14029068367601 38.57941205883549 40.05934559601928 41.58009129522733 43.14164915645964 44.74401917971629 46.38720136499718 48.07119571230239 49.79600222163187 51.56162089298559 53.36805172636364 55.21529472176595 57.10334987919256 59.03221719864343 61.00189668011861 63.01238832361805 65.0636921291418 67.15580809668984 69.28873622626213 71.4624765178587 73.6770289714796 75.93239358712475 78.22857036479418 80.56555930448789 82.94336040620591 85.36197366994817 87.82139909571474 90.32163668350562 92.86268643332076 95.44454834516013 98.06722241902393 100.7307086549119 103.4350070528241 106.1801176127607 108.9660403347215 111.7927752187066 114.660322264716 117.5686814727497 120.5178528428077 123.5078363748898 126.5386320689965 129.6102399251273 132.7226599432824 135.8758921234617 139.0699364656654 142.3047929698934 145.5804616361457 148.8969424644222 152.2542354547229 155.652340607048 159.0912579213975 162.5709873977711 166.0915290361689 169.6528828365911 173.2550487990377 176.8980269235084 180.5818172100035 184.3064196585229 188.0718342690666 191.8780610416343 195.7250999762267 199.6129510728431 203.5416143314839 207.5110897521489 211.5213773348383 215.5724770795518 219.6643889862897 223.7971130550519 227.9706492858384 232.1849976786492 236.4401582334842 240.7361309503436 245.072915829227 249.450512870135 253.8689220730671 258.3281434380235 262.8281769650043
+ 17.165702144448 17.74939856297042 18.37390714351711 19.03922788608809 19.74536079068335 20.49230585730289 21.28006308594671 22.10863247661482 22.97801402930723 23.8882077440239 24.83921362076487 25.8310316595301 26.86366186031963 27.93710422313344 29.05135874797154 30.2064254348339 31.40230428372057 32.63899529463149 33.91649846756673 35.23481380252621 36.59394129951004 37.9938809585181 39.43463277955047 40.9161967626071 42.43857290768803 44.00176121479325 45.60576168392274 47.25057431507653 48.93619910825456 50.66263606345689 52.42988518068353 54.23794645993443 56.08681990120964 57.97650550450912 59.90700326983284 61.87831319718092 63.89043528655323 65.94336953794985 68.03711595137072 70.17167452681589 72.34704526428536 74.56322816377907 76.82022322529711 79.11803044883939 81.45664983440597 83.83608138199686 86.25632509161201 88.71738096325149 91.21924899691521 93.76192919260322 96.34542155031546 98.96972607005205 101.6348427518129 104.3407715955981 107.0875126014075 109.8750657692412 112.7034310990991 115.5726085909815 118.482598244888 121.4334000608189 124.425014038774 127.4574401787533 130.530678480757 133.644728944785 136.7995915708372 139.9952663589138 143.2317533090147 146.5090524211397 149.8271636952891 153.1860871314627 156.5858227296607 160.026370489883 163.5077304121295 167.0299024964004 170.5928867426954 174.1966831510147 177.8412917213584 181.5267124537264 185.2529453481186 189.0199904045351 192.827847622976 196.676517003441 200.5659985459303 204.4962922504438 208.4673981169819 212.479316145544 216.5320463361306 220.6255886887413 224.7599432033764 228.9351098800356 233.1510887187193 237.4078797194273 241.7054828821593 246.0438982069159 250.4231256936966 254.8431653425017 259.304017153331 263.8056811261845 268.3481572610625 272.9314455579646
+ 19.2343904466779 19.90134163512174 20.60910498558988 21.35768049808228 22.147068172599 22.97726800913997 23.84828000770524 24.76010416829476 25.7127404909086 26.70618897554672 27.74044962220913 28.81552243089579 29.93140740160674 31.08810453434201 32.28561382910155 33.52393528588535 34.80306890469345 36.12301468552584 37.48377262838249 38.88534273326343 40.32772500016865 41.81091942909817 43.33492602005197 44.89974477303003 46.50537568803242 48.15181876505903 49.83907400410998 51.56714140518516 53.3360209682847 55.14571269340846 56.99621658055651 58.88753262972887 60.81966084092548 62.79260121414642 64.80635374939159 66.86091844666107 68.95629530595484 71.09248432727287 73.26948551061523 75.48729885598182 77.74592436337269 80.04536203278789 82.38561186422737 84.76667385769109 87.18854801317912 89.65123433069144 92.154732810228 94.69904345178892 97.28416625537398 99.91010122098351 102.5768483486172 105.2844076382752 108.0327790899575 110.8219627036641 113.6519584793949 116.5227664171501 119.4343865169295 122.3868187787333 125.3800632025613 128.4141197884135 131.4889885362901 134.6046694461909 137.7611625181161 140.9584677520654 144.1965851480391 147.4755147060371 150.7952564260594 154.1558103081059 157.5571763521767 160.9993545582719 164.4823449263912 168.0061474565349 171.5707621487028 175.1761890028951 178.8224280191116 182.5094791973523 186.2373425376175 190.0060180399069 193.8155057042205 197.6658055305585 201.5569175189208 205.4888416693072 209.461577981718 213.475126456153 217.5294870926124 221.6246598910961 225.760644851604 229.937441974136 234.1550512586927 238.4134727052734 242.7127063138785 247.0527520845079 251.4336100171612 255.8552801118393 260.3177623685416 264.8210567872679 269.3651633680188 273.9500821107937 278.5758130155932 283.2423560824167
+ 21.51072068039961 22.26092663876489 23.05194475915446 23.88377504156831 24.75641748600643 25.66987209246885 26.62413886095554 27.61921779146654 28.6551088840018 29.73181213856134 30.84932755514518 32.0076551337533 33.20679487438569 34.44674677704241 35.72751084172337 37.04908706842861 38.41147545715813 39.81467600791193 41.25868872069004 42.74351359549242 44.26915063231909 45.83559983117002 47.44286119204528 49.09093471494477 50.77982039986858 52.50951824681666 54.28002825578901 56.09135042678566 57.94348475980662 59.8364312548518 61.77018991192129 63.74476073101509 65.76014371213316 67.8163388552755 69.91334616044213 72.05116562763304 74.22979725684826 76.4492410480877 78.70949700135147 81.01056511663953 83.3524453939519 85.73513783328848 88.15864243464939 90.62295919803454 93.12808812344407 95.67402921087776 98.26078246033579 100.8883478718181 103.5567254453247 106.2659151808555 109.0159170784107 111.8067311379902 114.6383573595939 117.5107957432218 120.4240462888742 123.3781089965508 126.3729838662517 129.4086708979768 132.4851700917262 135.6024814475 138.7606049652979 141.9595406451202 145.1992884869667 148.4798484908375 151.8012206567327 155.1634049846521 158.5664014745958 162.0102101265638 165.4948309405561 169.0202639165726 172.5865090546134 176.1935663546785 179.841435816768 183.5301174408816 187.2596112270196 191.0299171751818 194.8410352853683 198.6929655575792 202.5857079918143 206.5192625880736 210.4936293463573 214.5088082666653 218.5647993489975 222.661602593354 226.7992179997348 230.9776455681398 235.1968852985692 239.4569371910229 243.7578012455009 248.099477462003 252.4819658405295 256.9052663810803 261.3693790836552 265.8743039482545 270.4200409748782 275.0065901635261 279.6339515141983 284.3021250268948 289.0111107016157 293.7609085383606
+ 23.99469284561319 24.82815357389991 25.7024264642109 26.61751151654618 27.57340873090576 28.57011810728962 29.60763964569774 30.68597334613017 31.80511920858688 32.96507723306787 34.16584741957313 35.40742976810267 36.6898242786565 38.01303095123465 39.37704978583706 40.78188078246373 42.2275239411147 43.71397926178994 45.24124674448949 46.80932638921328 48.41821819596141 50.06792216473375 51.75843829553045 53.4897665883514 55.26190704319666 57.07485966006617 58.92862443895994 60.823201379878 62.7585904828204 64.73479174778704 66.75180517477801 68.80963076379319 70.90826851483267 73.04771842789651 75.22798050298456 77.44905474009693 79.71094113923353 82.01363970039445 84.35715042357965 86.74147330878912 89.16660835602291 91.63255556528097 94.13931493656328 96.68688646986993 99.27527016520082 101.904466022556 104.5744740419354 107.2852942233392 110.0369265667672 112.8293710722195 115.6626277396961 118.536696569197 121.4515775607222 124.4072707142716 127.4037760298453 130.4410935074434 133.5192231470657 136.6381649487122 139.7979189123831 142.9984850380782 146.2398633257978 149.5220537755415 152.8450563873094 156.2088711611017 159.6134980969183 163.0589371947591 166.5451884546243 170.0722518765136 173.6401274604274 177.2488152063653 180.8983151143276 184.5886271843141 188.3197514163249 192.09168781036 195.9044363664195 199.7579970845031 203.6523699646111 207.5875550067434 211.5635522108999 215.5803615770808 219.6379831052859 223.7364167955153 227.8756626477689 232.0557206620468 236.2765908383489 240.5382731766756 244.8407676770263 249.1840743394014 253.5681931638007 257.9931241502245 262.4588672986722 266.9654226091447 271.5127900816411 276.1009697161619 280.729961512707 285.3997654712762 290.1103815918698 294.8618098744877 299.6540503191299 304.4871029257964
+ 26.68630694231859 27.60302244052676 28.56055010075921 29.55888992301592 30.59804190729694 31.67800605360223 32.79878236193178 33.96037083228565 35.16277146466378 36.40598425906621 37.69000921549291 39.0148463339439 40.38049561441917 41.78695705691873 43.23423066144257 44.72231642799069 46.25121435656309 47.8209244471598 49.43144669978076 51.08278111442603 52.77492769109555 54.50788642978937 56.28165733050751 58.09624039324988 59.95163561801655 61.84784300480755 63.78486255362273 65.76269426446223 67.78133813732607 69.8407941722141 71.94106236912653 74.08214272806319 76.26403524902409 78.48673993200933 80.75025677701883 83.05458578405263 85.39972695311069 87.78568028419302 90.21244577729964 92.68002343243059 95.18841324958586 97.73761522876529 100.3276293699691 102.9584556731971 105.6300941384494 108.3425447657261 111.095807555027 113.8898825063521 116.7247696197016 119.6004688950754 122.5169803324733 125.4743039318957 128.4724396933423 131.5113876168132 134.5911477023083 137.7117199498278 140.8731043593715 144.0753009309396 147.3183096645318 150.6021305601485 153.9267636177893 157.2922088374545 160.6984662191439 164.1455357628577 167.6334174685957 171.162111336358 174.7316173661445 178.3419355579553 181.9930659117905 185.6850084276498 189.4177631055336 193.1913299454416 197.0057089473738 200.8609001113304 204.7569034373113 208.6937189253163 212.6713465753458 216.6897863873994 220.7490383614774 224.8491024975795 228.9899787957062 233.171667255857 237.394167878032 241.6574806622314 245.9616056084551 250.3065427167031 254.6922919869753 259.1188534192718 263.5862270135926 268.0944127699377 272.6434106883071 277.2332207687008 281.8638430111187 286.5352774155608 291.2475239820274 296.0005827105182 300.7944536010332 305.6291366535725 310.5046318681362 315.4209392447241
+ 29.58556297051584 30.58553323864545 31.62631566879935 32.70791026097748 33.83031701517993 34.99353593140666 36.19756700965767 37.44241024993294 38.72806565223255 40.0545332165564 41.42181294290456 42.82990483127697 44.27880888167365 45.76852509409467 47.29905346853993 48.87039400500949 50.48254670350335 52.13551156402144 53.8292885865639 55.56387777113057 57.33927911772158 59.1554926263368 61.0125182969763 62.91035612964017 64.84900612432827 66.82846828104067 68.84874259977732 70.90982908053829 73.0117277233235 75.15443852813306 77.33796149496688 79.56229662382495 81.82744391470732 84.13340336761399 86.48017498254494 88.86775875950016 91.2961546984797 93.76536279948344 96.27538306251152 98.82621548756384 101.4178600746406 104.0503168237414 106.7235857348667 109.4376668080161 112.19256004319 114.9882654403879 117.8247829996103 120.7021127208569 123.6202546041279 126.579208649423 129.5789748567425 132.6195532260863 135.7009437574543 138.8231464508466 141.9861613062633 145.1899883237041 148.4346275031693 151.7200788446587 155.0463423481724 158.4134180137105 161.8213058412728 165.2700058308594 168.7595179824702 172.2898422961054 175.8609787717648 179.4729274094486 183.1256882091565 186.8192611708889 190.5536462946455 194.3288435804263 198.1448530282314 202.0016746380609 205.8993084099145 209.8377543437926 213.8170124396948 217.8370826976214 221.8979651175722 225.9996596995473 230.1421664435466 234.3254853495704 238.5496164176184 242.8145596476906 247.1203150397871 251.4668825939079 255.854262310053 260.2824541882226 264.751458228416 269.261274430634 273.8119027948763 278.4033433211428 283.0355960094336 287.7086608597488 292.4225378720881 297.1772270464518 301.9727283828398 306.8090418812519 311.6861675416884 316.604105364149 321.5628553486343 326.5624174951435
+ 32.69246093020494 33.77568596825596 34.89972316833129 36.06457253043089 37.27023405455476 38.51670774070291 39.80399358887536 41.13209159907209 42.5010017712931 43.91072410553839 45.36125860180798 46.85260526010183 48.38476408041999 49.95773506276244 51.5715182071291 53.22611351352012 54.92152098193539 56.65774061237497 58.43477240483882 60.25261635932693 62.11127247583935 64.01074075437602 65.95102119493703 67.93211379752228 69.95401856213182 72.01673548876565 74.12026457742375 76.26460582810616 78.44975924081282 80.67572481554379 82.94250255229906 85.25009245107857 87.59849451188235 89.98770873471045 92.41773511956285 94.88857366643951 97.40022437534043 99.95268724626557 102.5459622792152 105.1800494741889 107.854948831187 110.5706603502094 113.327184031256 116.1245198743269 118.9626678794222 121.8416280465416 124.7614003756854 127.7219848668535 130.7233815200458 133.7655903352625 136.8486113125034 139.9724444517685 143.137089753058 146.3425472163719 149.5888168417098 152.8758986290722 156.2037925784588 159.5724986898697 162.9820169633048 166.4323473987643 169.923489996248 173.455444755756 177.0282116772883 180.6417907608449 184.2961820064258 187.991385414031 191.7274009836603 195.5042287153142 199.3218686089921 203.1803206646944 207.0795848824211 211.0196612621719 215.000549803947 219.0222505077465 223.0847633735701 227.188088401418 231.3322255912905 235.5171749431869 239.7429364571076 244.009510133053 248.3168959710223 252.665093971016 257.0541041330338 261.4839264570763 265.9545609431427 270.4660075912337 275.0182664013486 279.6113373734882 284.2452205076517 288.9199158038396 293.635423262052 298.3917428822885 303.1888746645492 308.0268186088343 312.9055747151436 317.8251429834773 322.7855234138353 327.7867160062176 332.828720760624 337.911537677055
+ 36.00700082138589 37.17348062935836 38.3807725993551 39.62887673137614 40.91779302542144 42.24752148149107 43.61806209958493 45.02941487970308 46.48157982184553 47.97455692601228 49.50834619220331 51.08294762041859 52.69836121065818 54.35458696292201 56.05162487721023 57.78947495352261 59.56813719185936 61.38761159222034 63.24789815460561 65.14899687901513 67.09090776544902 69.07363081390719 71.09716602438955 73.16151339689628 75.26667293142722 77.41264462798252 79.59942848656208 81.82702450716589 84.09543268979399 86.40465303444641 88.75468554112311 91.14553020982403 93.57718704054933 96.04965603329885 98.56293718807262 101.1170305048708 103.7119359836931 106.3476536245398 109.0241834274107 111.7415253923059 114.4996795192255 117.2986458081692 120.1384242591374 123.0190148721298 125.9404176471464 128.9026325841872 131.9056596832524 134.949498944342 138.0341503674557 141.1596139525938 144.3258896997562 147.5329776089428 150.7808776801537 154.0695899133889 157.3991143086483 160.7694508659322 164.1805995852401 167.6325604665725 171.1253335099291 174.6589187153099 178.2333160827152 181.8485256121446 185.5045473035985 189.2013811570764 192.9390271725787 196.7174853501053 200.5367556896563 204.3968381912313 208.2977328548308 212.2394396804545 216.2219586681026 220.2452898177748 224.3094331294715 228.4143886031923 232.5601562389374 236.7467360367069 240.9741279965005 245.2423321183185 249.5513484021608 253.9011768480272 258.2918174559181 262.7232702258333 267.1955351577727 271.7086122517366 276.2625015077244 280.8572029257365 285.4927165057732 290.1690422478341 294.8861801519191 299.6441302180286 304.4428924461623 309.2824668363202 314.1628533885024 319.0840521027089 324.0460629789396 329.0488860171948 334.0925212174741 339.1769685797777 344.3022281041057 349.468299790458
+ 39.52918264405869 40.77891722195256 42.06946396187076 43.40082286381322 44.77299392777999 46.18597715377103 47.63977254178635 49.13438009182595 50.66979980388982 52.24603167797804 53.86307571409045 55.52093191222717 57.21960027238818 58.95908079457351 60.73937347878307 62.56047832501696 64.42239533327511 66.32512450355753 68.26866583586425 70.25301933019526 72.27818498655058 74.34416280493011 76.45095278533398 78.59855492776209 80.7869692322145 83.01619569869121 85.2862343271922 87.59708511771744 89.94874807026699 92.34122318484083 94.77451046143895 97.24860990006134 99.76352150070805 102.319245263379 104.9157811880742 107.5531292747938 110.2312895235376 112.9502619343057 115.710046507098 118.5106432419147 121.3520521387558 124.234273197621 127.1573064185105 130.1211518014242 133.1258093463623 136.1712790533247 139.2575609223113 142.3846549533223 145.5525611463575 148.761279501417 152.0108100185008 155.3011526976088 158.6323075387412 162.0042745418978 165.4170537070787 168.8706450342839 172.3650485235134 175.9002641747671 179.4762919880453 183.0931319633476 186.7507841006742 190.4492484000251 194.1885248614002 197.9686134847997 201.7895142702234 205.6512272176715 209.5537523271439 213.4970895986404 217.4812390321613 221.5062006277065 225.571974385276 229.6785603048696 233.8259583864876 238.0141686301299 242.2431910357965 246.5130256034873 250.8236723332024 255.1751312249419 259.5674022787056 264.0004854944938 268.474380872306 272.9890884121425 277.5446081140034 282.1409399778885 286.7780840037979 291.4560401917316 296.1748085416895 300.9343890536719 305.7347817276785 310.5759865637092 315.4580035617642 320.3808327218437 325.3444740439474 330.3489275280754 335.3941931742274 340.4802709824041 345.6071609526048 350.77486308483 355.9833773790793 361.2327038353528
+ 43.25900639822328 44.59199574603863 45.96579725587828 47.38041092774219 48.83583676163038 50.33207475754281 51.8691249154796 53.44698723544064 55.06566171742593 56.72514836143556 58.42544716746943 60.1665581355276 61.94848126561006 63.77121655771678 65.63476401184786 67.53912362800314 69.48429540618272 71.47027934638662 73.49707544861472 75.56468371286716 77.67310413914392 79.82233672744493 82.01238147777019 84.24323839011981 86.51490746449363 88.8273887008918 91.18068209931417 93.57478765976087 96.00970538223186 98.48543526672712 101.0019773132467 103.5593315217905 106.1574978923587 108.796476424951 111.4762671195678 114.1968699762087 116.958284994874 119.7605121755635 122.6035515182773 125.4874030230154 128.4120666897779 131.3775425185645 134.3838305093754 137.4309306622107 140.5188429770702 143.647567453954 146.8171040928621 150.0274528937945 153.2786138567511 156.5705869817321 159.9033722687372 163.2769697177668 166.6913793288205 170.1466011018985 173.6426350370009 177.1794811341276 180.7571393932786 184.3756098144538 188.0348923976531 191.7349871428769 195.475894050125 199.2576131193973 203.0801443506939 206.9434877440149 210.8476432993601 214.7926110167295 218.7783908961233 222.8049829375413 226.8723871409836 230.9806035064503 235.129632033941 239.3194727234563 243.5501255749957 247.8215905885596 252.1338677641474 256.4869571017596 260.8808586013963 265.3155722630573 269.7910980867425 274.3074360724518 278.8645862201856 283.4625485299436 288.1013230017257 292.7809096355324 297.5013084313632 302.2625193892184 307.0645425090978 311.9073777910015 316.7910252349294 321.7154848408817 326.6807566088582 331.6868405388591 336.7337366308842 341.8214448849337 346.9499653010074 352.1192978791054 357.3294426192275 362.580399521374 367.8721685855449 373.2047498117398
+ 47.19647208387971 48.61271620161651 50.06977248137757 51.56764092316291 53.10632152697255 54.68581429280643 56.30611922066466 57.96723631054709 59.66916556245389 61.41190697638493 63.19546055234025 65.01982629031981 66.88500419032374 68.79099425235192 70.73779647640438 72.72541086248113 74.75383741058214 76.82307612070744 78.93312699285708 81.08399002703089 83.2756652232291 85.5081525814515 87.78145210169822 90.09556378396925 92.45048762826453 94.84622363458411 97.28277180292795 99.76013213329605 102.2783046256885 104.8372892801053 107.4370860965462 110.0776950750115 112.7591162155011 115.4813495180148 118.244394982553 121.0482526091154 123.8929223977021 126.7784043483131 129.7046984609484 132.6718047356078 135.6797231722917 138.7284537709998 141.8179965317322 144.9483514544889 148.1195185392698 151.331497786075 154.5842891949046 157.8778927657584 161.2123084986364 164.5875363935389 168.0035764504655 171.4604286694164 174.9580930503916 178.4965695933911 182.075858298415 185.6959591654631 189.3568721945354 193.058597385632 196.8011347387529 200.5844842538982 204.4086459310676 208.2736197702614 212.1794057714795 216.1260039347218 220.1134142599884 224.1416367472793 228.2106713965945 232.3205182079339 236.4711771812977 240.6626483166858 244.894931614098 249.1680270735346 253.4819346949956 257.8366544784807 262.2321864239902 266.668530531524 271.1456868010819 275.6636552326642 280.2224358262709 284.8220285819016 289.4624334995569 294.1436505792363 298.86567982094 303.628521224668 308.4321747904202 313.2766405181969 318.1619184079976 323.0880084598227 328.0549106736723 333.062625049546 338.1111515874439 343.2004902873661 348.3306411493126 353.5016041732837 358.7133793592787 363.9659667072981 369.2593662173418 374.5935778894096 379.9686017235021 385.3844377196182
+ 51.34157970102805 52.84107858868624 54.38138963836879 55.96251285007555 57.58444822380665 59.24719575956193 60.95075545734157 62.69512731714548 64.48031133897366 66.30630752282617 68.17311586870291 70.08073637660398 72.02916904652928 74.01841387847891 76.04847087245281 78.11934002845099 80.23102134647347 82.38351482652017 84.57682046859125 86.81093827268654 89.08586823880619 91.40161036695 93.75816465711819 96.15553110931067 98.59370972352731 101.0727004997683 103.5925034380336 106.1531185383232 108.7545458006371 111.3967852249752 114.0798368113376 116.8037005597244 119.5683764701353 122.3738645425706 125.2201647770302 128.107277173514 131.0352017320221 134.0039384525546 137.0134873351113 140.0638483796922 143.1550215862975 146.287006954927 149.4598044855809 152.673414178259 155.9278360329613 159.223070049688 162.559116228439 165.9359745692142 169.3536450720138 172.8121277368375 176.3114225636856 179.8515295525581 183.4324487034546 187.0541800163756 190.7167234913207 194.4200791282903 198.1642469272841 201.9492268883022 205.7750190113445 209.6416232964112 213.5490397435021 217.4972683526173 221.4863091237569 225.5161620569205 229.5868271521086 233.698304409321 237.8505938285577 242.0436954098186 246.2776091531037 250.5523350584131 254.8678731257471 259.224223355105 263.6213857464872 268.0593602998939 272.5381470153247 277.0577458927799 281.6181569322594 286.2193801337631 290.8614154972912 295.5442630228434 300.26792271042 305.0323945600209 309.8376785716459 314.6837747452956 319.5706830809693 324.4984035786674 329.4669362383896 334.476281060136 339.526438043907 344.6174071897021 349.7491884975215 354.9217819673652 360.1351875992331 365.3894053931256 370.6844353490421 376.0202774669829 381.3969317469479 386.8143981889374 392.272676792951 397.7717675589892
+ 55.6943292496682 57.27708290724786 58.90064872685183 60.56502670848001 62.27021685213252 64.0162191578093 65.80303362551037 67.6306602552357 69.49909904698531 71.40835000075926 73.35841311655741 75.34928839437995 77.38097583422667 79.45347543609772 81.56678719999309 83.72091112591269 85.91584721385659 88.15159546382475 90.42815587581721 92.74552844983397 95.10371318587504 97.5027100839403 99.94251914402989 102.4231403661438 104.944573750282 107.5068192964445 110.1098770046312 112.7537468748422 115.4384289070775 118.163923101337 120.9302294576209 123.737347975929 126.5852786562615 129.4740214986181 132.4035765029992 135.3739436694045 138.385122997834 141.437114488288 144.529918140766 147.6635339552684 150.8379619317952 154.0532020703461 157.3092543709213 160.6061188335208 163.9437954581447 167.3222842447928 170.7415851934652 174.2016983041619 177.7026235768828 181.2443610116281 184.8269106083976 188.4502723671914 192.1144462880096 195.819432370852 199.5652306157185 203.3518410226095 207.1792635915247 211.0474983224643 214.9565452154279 218.9064042704162 222.8970754874285 226.928558866465 231.0008544075261 235.1139621106111 239.2678819757208 243.4626140028545 247.6981581920126 251.974514543195 256.2916830564014 260.6496637316325 265.0484565688876 269.4880615681671 273.9684787294709 278.489708052799 283.0517495381512 287.6546031855278 292.2982689949288 296.9827469663539 301.7080370998033 306.4741393952773 311.2810538527751 316.1287804722975 321.017319253844 325.9466701974149 330.91683330301 335.9278085706296 340.9795960002732 346.0721955919413 351.2056073456337 356.3798312613501 361.5948673390909 366.850715578856 372.1473759806452 377.4848485444592 382.8631332702975 388.2822301581595 393.7421392080461 399.2428604199569 404.7843937938921 410.3667393298514
+ 60.2547207298002 61.9207291573013 63.62754974682669 65.37518249837632 67.16362741195024 68.99288448754844 70.86295372517101 72.77383512481775 74.72552868648887 76.71803441018417 78.75135229590384 80.82548234364774 82.94042455341588 85.09617892520845 87.29274545902517 89.53012415486626 91.80831501273155 94.12731803262119 96.48713321453511 98.8877605584732 101.3292000644357 103.8114517324225 106.3345155624336 108.8983915544689 111.5030797085284 114.1485800246123 116.8348925027205 119.562017142853 122.3299539450097 125.1387029091907 127.988264035396 130.8786373236256 133.8098227738794 136.7818203861576 139.79463016046 142.8482520967868 145.9426861951378 149.077932455513 152.2539908779126 155.4708614623364 158.7285442087846 162.027039117257 165.3663461877537 168.7464654202747 172.16739681482 175.6291403713895 179.1316960899833 182.6750639706013 186.2592440132437 189.8842362179105 193.5500405846015 197.2566571133167 201.0040858040562 204.79232665682 208.6213796716082 212.4912448484205 216.4019221872573 220.3534116881181 224.3457133510034 228.3788271759129 232.4527531628467 236.5674913118047 240.7230416227872 244.9194040957938 249.1565787308248 253.43456552788 257.7533644869595 262.1129756080632 266.5133988911913 270.9546343363436 275.4366819435203 279.9595417127211 284.5232136439462 289.1276977371959 293.7729939924696 298.4591024097678 303.1860229890899 307.9537557304366 312.7623006338075 317.6116576992026 322.5018269266221 327.4328083160658 332.4046018675339 337.4172075810263 342.4706254565427 347.5648554940836 352.6998976936487 357.8757520552383 363.0924185788519 368.34989726449 373.6481881121524 378.987291121839 384.3672062935498 389.7879336272851 395.2494731230444 400.7518247808279 406.2949886006359 411.8789645824682 417.503752726325 423.1693530322058
+ 65.02275414142404 66.77201733884652 68.56209269829336 70.3929802197644 72.26467990325982 74.17719174877946 76.1305157563234 78.1246519258916 80.15960025748412 82.23536075110093 84.35193340674196 86.50931822440734 88.70751520409696 90.94652434581087 93.2263456495491 95.54697911531157 97.90842474309835 100.3106825329094 102.7537524847448 105.2376345986043 107.7623288744883 110.3278353123965 112.9341539123289 115.5812846742858 118.2692275982668 120.9979826842721 123.7675499323016 126.5779293423555 129.4291209144337 132.3211246485361 135.2539405446629 138.2275686028139 141.2420088229892 144.2972612051888 147.3933257494127 150.5302024556608 153.7078913239333 156.92639235423 160.1857055465509 163.4858309008963 166.8267684172659 170.2085180956596 173.6310799360777 177.0944539385202 180.5986401029869 184.1436384294778 187.7294489179932 191.3560715685328 195.0235063810966 198.7317533556848 202.4808124922971 206.2706837909338 210.1013672515947 213.97286287428 217.8851706589896 221.8382906057234 225.8322227144814 229.8669669852638 233.9425234180704 238.0588920129013 242.2160727697566 246.4140656886364 250.6528707695399 254.932488012468 259.2529174174203 263.6141589843971 268.0162127133981 272.4590786044231 276.9427566574727 281.4672468725464 286.0325492496447 290.6386637887668 295.2855904899135 299.9733293530845 304.7018803782796 309.471243565499 314.281418914743 319.132406426011 324.0242060993033 328.95681793462 333.9302419319608 338.9444780913259 343.9995264127155 349.0953868961294 354.2320595415672 359.4095443490298 364.6278413185161 369.886950450027 375.1868717435623 380.5276051991216 385.9091508167053 391.3315085963133 396.7946785379456 402.2986606416021 407.8434549072831 413.4290613349884 419.0554799247175 424.7227106764713 430.4307535902493 436.1796086660516
+ 69.99842948453974 71.8309474518837 73.70427758125194 75.61841987264447 77.57337432606128 79.56914094150238 81.60571971896771 83.68311065845738 85.80131375997136 87.9603290235096 90.16015644907209 92.40079603665883 94.68224778626995 97.00451169790539 99.36758777156497 101.771476007249 104.2161764049571 106.7016889646895 109.2280136864464 111.7951505702274 114.4030996160328 117.0518608238624 119.7414341937163 122.4718197255945 125.243017419497 128.0550272754237 130.9078492933747 133.8014834733501 136.7359298153498 139.7111883193736 142.7272589854217 145.7841418134942 148.881836803591 152.020343955712 155.1996632698573 158.4197947460268 161.6807383842207 164.9824941844389 168.3250621466813 171.708442270948 175.1326345572391 178.5976390055542 182.1034556158939 185.6500843882578 189.2375253226459 192.8657784190584 196.534843677495 200.244721097956 203.9954106804414 207.7869124249508 211.6192263314847 215.4923524000428 219.4062906306252 223.3610410232319 227.356603577863 231.3929782945182 235.4701651731976 239.5881642139016 243.7469754166296 247.9465987813819 252.1870343081586 256.4682819969595 260.7903418477847 265.1532138606344 269.5568980355082 274.0013943724064 278.4867028713286 283.0128235322754 287.5797563552462 292.1875013402415 296.8360584872608 301.5254277963047 306.2556092673728 311.0266029004651 315.8384086955818 320.6910266527227 325.5844567718878 330.5186990530772 335.4937534962913 340.5096201015292 345.5662988687917 350.6637897980781 355.8020928893891 360.9812081427243 366.2011355580835 371.4618751354676 376.7634268748754 382.1057907763079 387.4889668397645 392.9129550652452 398.3777554527504 403.8833680022799 409.4297927138335 415.0170295874116 420.6450786230139 426.3139398206405 432.0236131802916 437.7740987019666 443.565396385666 449.3975062313896
+ 75.18174675914723 77.09751949641264 79.0541043957023 81.05150145701629 83.08971068035451 85.16873206571701 87.2885656131039 89.44921132251494 91.65066919395035 93.89293922741 96.17602142289392 98.49991578040216 100.8646222999347 103.2701409814915 105.7164718250726 108.2036148306779 110.7315699983075 113.3003373279614 115.9099168196397 118.5603084733422 121.2515122890689 123.98352826682 126.7563564065954 129.569996708395 132.4244491722189 135.3197137980671 138.2557905859396 141.2326795358363 144.2503806477574 147.3088939217027 150.4082193576723 153.5483569556662 156.7293067156843 159.9510686377269 163.2136427217936 166.5170289678846 169.8612273759999 173.2462379461396 176.6720606783034 180.1386955724914 183.646142628704 187.1944018469408 190.7834732272017 194.413356769487 198.0840524737966 201.7955603401304 205.5478803684885 209.3410125588711 213.1749569112776 217.0497134257087 220.965282102164 224.9216629406436 228.9188559411473 232.9568611036754 237.035678428228 241.1553079148046 245.3157495634057 249.5170033740308 253.7590693466804 258.0419474813542 262.3656377780524 266.7301402367747 271.1354548575213 275.5815816402923 280.0685205850876 284.5962716919071 289.1648349607508 293.774210391619 298.4243979845114 303.1153977394279 307.8472096563689 312.6198337353341 317.4332699763236 322.2875183793375 327.1825789443756 332.1184516714379 337.0951365605245 342.1126336116355 347.1709428247705 352.2700641999302 357.4099977371138 362.590743436322 367.8123012975543 373.0746713208109 378.3778535060915 383.7218478533971 389.1066543627265 394.5322730340802 399.9987038674581 405.5059468628606 411.054002020287 416.6428693397381 422.2725488212131 427.9430404647128 433.6543442702364 439.4064602377842 445.1993883673568 451.0331286589531 456.9076811125743 462.8230457282192
+ 80.57270596524657 82.57173347243339 84.61157314164448 86.69222497287991 88.81368896613955 90.97596512142353 93.1790534387318 95.42295391806429 97.70766655942111 100.0331913628023 102.3995283282076 104.8066774556373 107.2546387450911 109.7434121965694 112.272997810072 114.8433955855988 117.4546055231499 120.1066276227252 122.7994618843249 125.5331083079488 128.307566893597 131.1228376412695 133.9789205509662 136.8758156226873 139.8135228564327 142.7920422522023 145.8113738099962 148.8715175298144 151.9724734116569 155.1142414555236 158.2968216614147 161.5202140293301 164.7844185592696 168.0894352512335 171.4352641052217 174.8219051212342 178.2493582992709 181.7176236393319 185.2267011414172 188.7765908055269 192.3672926316608 195.9988066198188 199.6711327700014 203.384271082208 207.1382215564391 210.9329841926944 214.7685589909738 218.6449459512778 222.5621450736059 226.5201563579584 230.518979804335 234.5586154127361 238.6390631831614 242.7603231156108 246.9223952100847 251.125279466583 255.3689758851053 259.653484465652 263.9788052082231 268.3449381128181 272.7518831794378 277.1996404080816 281.6882097987497 286.2175913514421 290.7877850661587 295.3987909428998 300.050608981665 304.7432391824545 309.4766815452683 314.2509360701064 319.0660027569689 323.9218816058554 328.8185726167663 333.7560757897016 338.7343911246611 343.7535186216449 348.8134582806529 353.9142101016854 359.0557740847419 364.2381502298227 369.4613385369281 374.7253390060574 380.0301516372111 385.3757764303895 390.7622133855918 396.1894625028185 401.6575237820693 407.1663972233445 412.7160828266441 418.3065805919675 423.9378905193155 429.6100126086881 435.3229468600846 441.0766932735056 446.8712518489509 452.7066225864201 458.5828054859139 464.4998005474319 470.4576077709744 476.4562271565407
+ 86.17130710283784 88.25358937994609 90.37668381907865 92.5405904202355 94.74530918341659 96.99084010862198 99.27718319585166 101.6043384451057 103.9723058563839 106.3810854296865 108.8306771650133 111.3210810623643 113.8522971217398 116.4243253431395 119.0371657265634 121.6908182720116 124.3852829794842 127.1205598489809 129.896648880502 132.7135500740473 135.571263429617 138.469788947211 141.4091266268292 144.3892764684717 147.4102384721384 150.4720126378296 153.5745989655448 156.7179974552845 159.9022081070484 163.1272309208366 166.3930658966491 169.6997130344859 173.047172334347 176.4354437962323 179.8645274201418 183.3344232060759 186.845131154034 190.3966512640164 193.9889835360232 197.6221279700542 201.2960845661095 205.0108533241891 208.766434244293 212.5628273264211 216.4000325705736 220.2780499767503 224.1968795449513 228.1565212751766 232.1569751674263 236.1982412217001 240.2803194379981 244.4032098163207 248.5669123566674 252.7714270590384 257.0167539234336 261.3028929498532 265.6298441382972 269.9976074887654 274.4061830012576 278.8555706757743 283.3457705123152 287.8767825108806 292.4486066714701 297.0612429940839 301.714691478722 306.4089521253846 311.1440249340711 315.919909904782 320.7366070375173 325.5941163322769 330.4924377890608 335.4315714078687 340.4115171887011 345.4322751315577 350.4938452364388 355.596227503344 360.7394219322734 365.9234285232271 371.1482472762054 376.4138781912076 381.7203212682343 387.0675765072854 392.4556439083603 397.8845234714602 403.3542151965838 408.8647190837318 414.4160351329044 420.0081633441009 425.6411037173218 431.3148562525669 437.0294209498363 442.78479780913 448.580986830448 454.4179880137909 460.295801359157 466.214426866548 472.1738645359634 478.1741143674026 484.2151763608665 490.2970505163544
+ 91.97755017192085 94.14308721895051 96.34943642800451 98.59659779908282 100.8845713321854 103.2133570273121 105.5829548844632 107.9933649036387 110.4445870848384 112.9366214280624 115.4694679333106 118.0431266005832 120.65759742988 123.3128804212011 126.0089755745465 128.7458828899161 131.5236023673101 134.3421340067283 137.2014778081708 140.1016337716376 143.0426018971288 146.0243821846441 149.0469746341837 152.1103792457477 155.2145960193359 158.3596249549484 161.5454660525852 164.7721193122462 168.0395847339316 171.3478623176412 174.6969520633752 178.0868539711335 181.5175680409158 184.9890942727227 188.5014326665537 192.0545832224091 195.6485459402887 199.2833208201925 202.9589078621206 206.6753070660733 210.4325184320501 214.230541960051 218.0693776500761 221.9490255021258 225.8694855161997 229.830757692298 233.8328420304204 237.8757385305671 241.9594471927382 246.0839680169335 250.249301003153 254.4554461513969 258.702403461665 262.9901729339576 267.3187545682742 271.6881483646152 276.0983543229805 280.5493724433701 285.0412027257838 289.5738451702221 294.1472997766843 298.7615665451714 303.4166454756821 308.1125365682173 312.849239822777 317.6267552393609 322.445082817969 327.3042225586014 332.204174461258 337.144938525939 342.1265147526442 347.1489031413738 352.2121036921277 357.3161164049056 362.460941279708 367.6465783165346 372.8730275153857 378.1402888762608 383.4483623991603 388.7972480840838 394.1869459310323 399.6174559400046 405.0887781110013 410.6009124440222 416.1538589390674 421.747617596137 427.3821884152307 433.0575713963486 438.7737665394912 444.5307738446577 450.3285933118487 456.1672249410638 462.0466687323037 467.9669246855673 473.9279928008551 479.9298730781674 485.9725655175039 492.0560701188649 498.1803868822503 504.3455158076596
+ 97.99143517249581 100.2402269894469 102.5298309684224 104.860247109422 107.2314754124461 109.6435158774944 112.0963685045669 114.5900332936637 117.1245102447849 119.6997993579303 122.3159006330999 124.9728140702939 127.6705396695122 130.4090774307547 133.1884273540216 136.0085894393127 138.869563686628 141.7713500959677 144.7139486673316 147.6973594007199 150.7215822961325 153.7866173535693 156.8924645730303 160.0391239545158 163.2265954980254 166.4548792035593 169.7239750711175 173.0338831007001 176.3846032923068 179.7761356459379 183.2084801615933 186.6816368392729 190.1956056789768 193.7503866807049 197.3459798444574 200.9823851702342 204.6596026580353 208.3776323078607 212.1364741197103 215.9361280935842 219.7765942294825 223.6578725274049 227.5799629873518 231.5428656093228 235.546580393318 239.5911073393376 243.6764464473815 247.8025977174498 251.969561149542 256.1773367436588 260.4259244997997 264.7153244179652 269.0455364981549 273.4165607403687 277.8283971446068 282.2810457108694 286.7745064391558 291.3087793294669 295.8838643818023 300.4997615961618 305.1564709725457 309.8539925109537 314.5923262113863 319.3714720738429 324.1914300983238 329.0522002848292 333.9537826333588 338.8961771439126 343.8793838164906 348.9034026510928 353.9682336477197 359.0738768063707 364.2203321270461 369.4075996097456 374.6356792544693 379.9045710612174 385.2142750299899 390.5647911607866 395.9561194536075 401.3882599084527 406.8612125253222 412.3749773042156 417.929554245134 423.5249433480765 429.1611446130429 434.8381580400342 440.5559836290495 446.3146213800889 452.1140712931527 457.9543333682404 463.8354076053531 469.7572940044896 475.7199925656507 481.7235032888359 487.7678261740452 493.852961221279 499.9789084305371 506.1456678018193 512.3532393351261 518.6016230304569
+ 104.2129621045624 106.5450086914351 108.917867440332 111.3315383512531 113.7860214241986 116.2813166591682 118.8174240561622 121.3943436151805 124.0120753362231 126.6706192192899 129.369975264381 132.1101434714964 134.8911238406361 137.7129163718001 140.5755210649884 143.4789379202009 146.4231669374378 149.4082081166988 152.4340614579842 155.5007269612939 158.6082046266279 161.7564944539861 164.9455964433686 168.1755105947755 171.4462369082066 174.7577753836619 178.1101260211416 181.5032888206455 184.9372637821736 188.4120509057261 191.9276501913031 195.4840616389042 199.0812852485295 202.7193210201791 206.3981689538531 210.1178290495514 213.8783013072737 217.6795857270206 221.5216823087917 225.404591052587 229.3283119584065 233.2928450262503 237.2981902561186 241.3443476480112 245.431317201928 249.5590989178689 253.7276927958343 257.9370988358239 262.1873170378378 266.4783474018757 270.8101899279384 275.182844616025 279.5963114661361 284.0505904782715 288.5456816524309 293.0815849886148 297.658300486823 302.2758281470554 306.9341679693122 311.6333199535933 316.3732840998985 321.1540604082281 325.9756488785819 330.8380495109601 335.7412623053625 340.6852872617893 345.6701243802403 350.6957736607154 355.762235103215 360.8695087077389 366.0175944742871 371.2064924028593 376.4362024934561 381.7067247460772 387.0180591607224 392.3702057373918 397.7631644760855 403.1969353768038 408.6715184395461 414.1869136643127 419.7431210511037 425.3401405999189 430.9779723107587 436.6566161836226 442.3760722185104 448.1363404154228 453.9374207743595 459.7793132953205 465.6620179783056 471.5855348233151 477.549863830349 483.5550049994068 489.6009583304893 495.6877238235959 501.8153014787269 507.9836912958824 514.1928932750617 520.4429074162651 526.7337337194933 533.0653721847456
+ 110.642130968121 113.057432324915 115.5135458437334 118.0104715245759 120.5482093674428 123.126759372334 125.7461215392494 128.4062958681891 131.1072823591531 133.8490810121414 136.6316918271539 139.4551148041907 142.3193499432518 145.2243972443373 148.170256707447 151.156928332581 154.1844121197392 157.2527080689218 160.3618161801286 163.5117364533596 166.702468888615 169.9340134858949 173.2063702451988 176.519539166527 179.8735202498797 183.2683134952564 186.7039189026574 190.1803364720828 193.6975662035325 197.2556080970063 200.8544621525047 204.4941283700271 208.174606749574 211.8958972911451 215.6579999947403 219.46091486036 223.3046418880039 227.1891810776722 231.1145324293645 235.0806959430812 239.0876716188225 243.1354594565879 247.2240594563773 251.3534716181913 255.5236959420296 259.7347324278921 263.9865810757787 268.2792418856898 272.6127148576252 276.9869999915848 281.4020972875687 285.858006745577 290.3547283656094 294.8922621476661 299.4706080917471 304.0897661978525 308.749736465982 313.4505188961359 318.1921134883141 322.9745202425164 327.7977391587431 332.6617702369941 337.5666134772695 342.512268879569 347.4987364438929 352.5260161702411 357.5941080586134 362.7030121090102 367.8527283214309 373.0432566958762 378.274597232346 383.5467499308398 388.859714791358 394.2134918139004 399.6080809984671 405.0434823450576 410.5196958536734 416.0367215243127 421.5945593569768 427.1932093516646 432.8326715083772 438.5129458271139 444.2340323078748 449.99593095066 455.7986417554696 461.6421647223033 467.5264998511611 473.4516471420439 479.4176065949505 485.4243782098815 491.4719619868367 497.5603579258162 503.6895660268199 509.8595862898479 516.0704187149003 522.3220633019769 528.6145200510778 534.9477889622033 541.3218700353527 547.7367632705264
+ 117.2789417631715 119.777497889887 122.3168661786267 124.8970466293907 127.518039242179 130.1798440169916 132.8824609538285 135.6258900526896 138.4101313135751 141.2351847364847 144.1010503214188 147.007728068377 149.9552179773596 152.9435200483664 155.9726342813976 159.042560676453 162.1532992335327 165.3048499526367 168.497212833765 171.7303878769174 175.0043750820944 178.3191744492954 181.6747859785208 185.0712096697706 188.5084455230446 191.9864935383427 195.5053537156653 199.065026055012 202.6655105563833 206.3068072197786 209.9889160451983 213.7118370326423 217.4755701821104 221.280115493603 225.1254729671198 229.0116426026608 232.9386244002262 236.906418359816 240.9150244814298 244.964442765068 249.0546732107306 253.1857158184173 257.3575705881284 261.5702375198637 265.8237166136232 270.1180078694073 274.4531112872154 278.829026867048 283.2457546089048 287.7032945127857 292.2016465786911 296.7408108066206 301.3207871965745 305.941575748553 310.6031764625552 315.305589338582 320.048814376633 324.8328515767083 329.6577009388079 334.5233624629318 339.4298361490799 344.3771219972522 349.3652200074491 354.39413017967 359.4638525139153 364.574387010185 369.7257336684788 374.9178924887972 380.1508634711392 385.4246466155062 390.739241921897 396.0946493903124 401.490869020752 406.9279008132158 412.4057447677039 417.9244008842164 423.4838691627531 429.084149603314 434.7252422058993 440.4071469705086 446.1298638971426 451.8933929858007 457.6977342364831 463.5428876491901 469.4288532239206 475.3556309606761 481.3232208594556 487.3316229202595 493.3808371430874 499.4708635279399 505.6017020748168 511.7733527837176 517.9858156546427 524.2390906875922 530.5331778825658 536.8680772395641 543.2437887585861 549.6603124396329 556.1176482827042 562.6157962877992
+ 124.1233944897137 126.7052053863506 129.3278284450118 131.9912636656973 134.695511048407 137.440570593141 140.2264422998992 143.0531261686818 145.9206221994887 148.8289303923199 151.7780507471754 154.767983264055 157.7987279429591 160.8702847838874 163.9826537868399 167.1358349518169 170.3298282788179 173.5646337678433 176.8402514188931 180.156681231967 183.5139232070653 186.9119773441878 190.3508436433346 193.8305221045058 197.3510127277011 200.9123155129209 204.5144304601649 208.1573575694331 211.8410968407256 215.5656482740424 219.3310118693835 223.1371876267488 226.9841755461385 230.8719756275526 234.8005878709907 238.7700122764532 242.7802488439401 246.8312975734511 250.9231584649866 255.0558315185461 259.2293167341301 263.4436141117382 267.6987236513709 271.9946453530277 276.3313792167087 280.7089252424141 285.1272834301437 289.5864537798976 294.0864362916759 298.6272309654783 303.2088378013051 307.8312567991562 312.4944879590314 317.198531280931 321.943386764855 326.7290544108032 331.5555342187756 336.4228261887723 341.3309303207934 346.2798466148388 351.2695750709083 356.3001156890022 361.3714684691203 366.4836334112628 371.6366105154294 376.8303997816207 382.0650012098359 387.3404148000752 392.6566405523393 398.0136784666276 403.4115285429399 408.8501907812768 414.3296651816376 419.849951744023 425.4110504684323 431.0129613548661 436.6556844033244 442.3392196138068 448.0635669863137 453.8287265208444 459.6346982173998 465.4814820759792 471.3690780965831 477.2974862792112 483.2667066238637 489.2767391305406 495.3275837992415 501.4192406299665 507.5517096227162 513.7249907774898 519.9390840942879 526.1939895731106 532.4897072139569 538.8262370168281 545.2035789817231 551.6217331086428 558.0806993975865 564.5804778485546 571.1210684615473 577.7024712365636
+ 131.1754891477478 133.840554814306 136.5464326428886 139.2931226334956 142.0806247861267 144.9089391007822 147.7780655774619 150.6880042161659 153.6387550168943 156.6303179796469 159.6626931044237 162.7358803912249 165.8498798400503 169.0046914509 172.2003152237741 175.4367511586723 178.713999255595 182.0320595145418 185.3909319355129 188.7906165185083 192.231113263528 195.7124221705721 199.2345432396402 202.797476470733 206.4012218638497 210.0457794189908 213.7311491361561 217.4573310153459 221.2243250565599 225.0321312597981 228.8807496250606 232.7701801523475 236.7004228416585 240.671477692994 244.6833447063536 248.7360238817376 252.8295152191458 256.9638187185784 261.1389343800353 265.3548622035163 269.6116021890217 273.9091543365513 278.2475186461052 282.6266951176833 287.046683751286 291.5074845469126 296.0090975045638 300.5515226242393 305.1347599059389 309.7588093496628 314.4236709554108 319.1293447231835 323.8758306529802 328.6631287448012 333.4912389986466 338.3601614145162 343.2698959924101 348.2204427323283 353.2118016342708 358.2439726982375 363.3169559242285 368.4307513122439 373.5853588622833 378.7807785743473 384.0170104484355 389.294054484548 394.6119106826849 399.9705790428458 405.3700595650308 410.8103522492405 416.2914570954747 421.8133741037325 427.3761032740152 432.9796446063218 438.6239981006529 444.309163757008 450.0351415753878 455.8019315557915 461.6095336982197 467.4579480026719 473.3471744691489 479.2772130976497 485.248063888175 491.2597268407246 497.3122019552982 503.4054892318964 509.5395886705189 515.7145002711657 521.9302240338367 528.1867599585316 534.4841080452512 540.822268293995 547.2012407047633 553.6210252775555 560.0816220123723 566.5830309092131 573.1252519680787 579.7082851889678 586.3321305718819 592.9967881168196
+ 138.4352257372737 141.1835461737536 143.9726787722576 146.8026235327859 149.6733804553385 152.5849495399154 155.5373307865166 158.530524195142 161.5645297657918 164.6393474984659 167.7549773931641 170.9114194498867 174.1086736686335 177.3467400494048 180.6256185922002 183.9453092970199 187.3058121638639 190.7071271927321 194.1492543836247 197.6321937365417 201.1559452514828 204.7205089284481 208.3258847674379 211.972072768452 215.6590729314901 219.3868852565527 223.1555097436395 226.9649463927506 230.8151952038862 234.7062561770459 238.6381293122298 242.6108146094381 246.6243120686707 250.6786216899277 254.7737434732085 258.909677418514 263.0864235258435 267.3039817951975 271.5623522265757 275.8615348199783 280.2015295754052 284.5823364928561 289.0039555723317 293.4663868138313 297.9696302173552 302.5136857829033 307.0985535104759 311.7242334000728 316.3907254516938 321.0980296653392 325.8461460410089 330.6350745787026 335.464815278421 340.3353681401636 345.2467331639302 350.1989103497213 355.1918996975367 360.2257012073763 365.30031487924 370.4157407131283 375.5719787090409 380.7690288669775 386.0068911869386 391.2855656689239 396.6050523129333 401.9653511189676 407.3664620870255 412.8083852171079 418.2911205092149 423.8146679633456 429.3790275795011 434.9841993576807 440.6301832978845 446.3169794001127 452.0445876643651 457.813008090642 463.6222406789428 469.4722854292683 475.3631423416179 481.2948114159917 487.2672926523899 493.2805860508121 499.3346916112587 505.4296093337296 511.5653392182252 517.7418812647447 523.9592354732882 530.2174018438565 536.516380376449 542.8561710710655 549.2367739277068 555.6581889463719 562.1204161270613 568.6234554697755 575.1673069745135 581.7519706412758 588.3774464700628 595.0437344608735 601.7508346137088 608.498746928568
+ 145.9026042582915 148.7341794646927 151.6065668331181 154.519766363568 157.473778056042 160.4686019105403 163.5042379270629 166.5806861056098 169.697946446181 172.8560189487765 176.0549036133962 179.2946004400402 182.5751094287086 185.8964305794012 189.258563892118 192.6615093668591 196.1052670036248 199.5898368024144 203.1152187632284 206.6814128860667 210.2884191709293 213.9362376178161 217.6248682267274 221.3543109976627 225.1245659306225 228.9356330256064 232.7875122826147 236.6802037016472 240.6137072827041 244.5880230257853 248.6031509308907 252.6590909980203 256.7558432271744 260.8934076183526 265.0717841715551 269.2909728867819 273.550973764033 277.8517868033084 282.1934120046081 286.5758493679321 290.9990988932805 295.4631605806527 299.9680344300496 304.5137204414708 309.1002186149159 313.7275289503859 318.3956514478797 323.1045861073981 327.8543329289406 332.6448919125072 337.4762630580983 342.3484463657137 347.2614418353534 352.2152494670173 357.2098692607054 362.2453012164179 367.3215453341547 372.4386016139158 377.596470055701 382.7951506595108 388.0346434253446 393.3149483532029 398.6360654430853 403.9979946949921 409.4007361089232 414.8442896848783 420.328655422858 425.8538333228622 431.41982338489 437.0266256089425 442.6742399950197 448.3626665431207 454.0919052532457 459.8619561253952 465.672819159569 471.5244943557672 477.4169817139895 483.3502812342363 489.3243929165075 495.3393167608028 501.3950527671224 507.4916009354664 513.6289612658344 519.8071337582267 526.0261184126433 532.2859152290846 538.5865242075496 544.9279453480391 551.3101786505532 557.7332241150912 564.1970817416534 570.7017515302404 577.2472334808513 583.8335275934863 590.4606338681459 597.1285523048298 603.8372829035378 610.5868256642701 617.3771805870272 624.2083476718079
+ 153.5776247108012 156.4924546871238 159.4480968254707 162.444551125842 165.4818175882374 168.5598962126572 171.6787869991012 174.8384899475696 178.0390050580622 181.2803323305791 184.5624717651204 187.8854233616858 191.2491871202754 194.6537630408895 198.099151123528 201.5853513681904 205.1123637748774 208.6801883435886 212.2888250743239 215.9382739670837 219.6285350218677 223.359608238676 227.1314936175086 230.9441911583654 234.7977008612465 238.692022726152 242.6271567530817 246.6031029420357 250.619861293014 254.6774318060165 258.7758144810434 262.9150093180945 267.09501631717 271.3158354782698 275.5774668013937 279.879910286542 284.2231659337144 288.6072337429112 293.0321137141325 297.4978058473779 302.0043101426477 306.5516265999416 311.1397552192597 315.7686960006023 320.4384489439691 325.1490140493601 329.9003913167757 334.6925807462152 339.5255823376792 344.3993960911675 349.3140220066799 354.2694600842167 359.265710323778 364.3027727253631 369.3806472889729 374.4993340146068 379.6588329022649 384.8591439519475 390.1002671636543 395.3822025373852 400.7049500731407 406.0685097709202 411.4728816307242 416.9180656525523 422.4040618364048 427.9308701822816 433.4984906901823 439.1069233601081 444.7561681920575 450.4462251860313 456.1770943420299 461.948775660052 467.7612691400989 473.6145747821701 479.5086925862653 485.4436225523847 491.4193646805286 497.4359189706971 503.4932854228894 509.5914640371059 515.7304548133471 521.9102577516123 528.1308728519019 534.3923001142156 540.6945395385537 547.0375911249164 553.421454873303 559.8461307837138 566.3116188561492 572.8179190906089 579.3650314870931 585.9529560456008 592.5816927661332 599.25124164869 605.9616026932709 612.7127758998763 619.5047612685056 626.3375587991596 633.2111684918376 640.12559034654
+ 161.4602870948027 164.4583718410468 167.4972687493151 170.5769778196077 173.6974990519246 176.8588324462659 180.0609780026313 183.3039357210211 186.5877056014351 189.9122876438736 193.2776818483361 196.6838882148229 200.1309067433341 203.6187374338697 207.1473802864294 210.7168353010135 214.3271024776218 217.9781818162543 221.6700733169112 225.4027769795923 229.1762928042979 232.9906207910276 236.8457609397816 240.7417132505599 244.6784777233624 248.6560543581894 252.6744431550406 256.733644113916 260.8336572348157 264.9744825177397 269.156119962688 273.3785695696605 277.6418313386573 281.9459052696786 286.290791362724 290.6764896177936 295.1030000348877 299.5703226140059 304.0784573551484 308.6274042583153 313.2171633235064 317.8477345507218 322.5191179399615 327.2313134912254 331.9843212045137 336.7781410798263 341.612773117163 346.4882173165241 351.4044736779095 356.3615422013191 361.3594228867533 366.3981157342116 371.4776207436938 376.5979379152008 381.7590672487317 386.9610087442871 392.2037624018668 397.4873282214706 402.8117062030988 408.1768963467513 413.5828986524284 419.0297131201294 424.5173397498546 430.0457785416044 435.6150294953783 441.2250926111765 446.875967888999 452.5676553288454 458.3001549307166 464.073466694612 469.8875906205317 475.7425267084755 481.6382749584437 487.574835370436 493.552207944453 499.5703926804938 505.6293895785593 511.7291986386489 517.8698198607626 524.051253244901 530.2734987910634 536.5365564992501 542.8404263694613 549.1851084016965 555.5706025959558 561.9969089522398 568.4640274705482 574.9719581508804 581.5207009932369 588.1102559976183 594.7406231640233 601.4118024924528 608.1237939829067 614.8765976353849 621.6702134498873 628.504641426414 635.379881564965 642.2959338655401 649.2527983281402 656.2504749527637
+ 169.5505914102959 172.6319309264615 175.7540826046512 178.9170464448653 182.1208224471036 185.3654106113663 188.6508109376532 191.9770234259643 195.3440480762998 198.7518848886597 202.2005338630438 205.6899949994521 209.2202682978846 212.7913537583415 216.4032513808227 220.0559611653283 223.7494831118579 227.4838172204121 231.2589634909903 235.0749219235929 238.93169251822 242.829275274871 246.7676701935465 250.7468772742463 254.7668965169703 258.8277279217185 262.9293714884912 267.071827217288 271.2550951081093 275.4791751609545 279.7440673758243 284.0497717527182 288.3962882916366 292.7836169925792 297.211757855546 301.6807108805371 306.1904760675526 310.7410534165922 315.3324429276562 319.9646446007446 324.6376584358572 329.3514844329939 334.106122592155 338.9015729133405 343.7378353965502 348.6149100417841 353.5327968490424 358.4914958183248 363.4910069496318 368.531330242963 373.6124656983181 378.7344133156981 383.8971730951019 389.1007450365302 394.3451291399825 399.6303254054595 404.9563338329606 410.323154422486 415.7307871740355 421.1792320876093 426.6684891632077 432.1985584008301 437.7694398004772 443.3811333621481 449.0336390858433 454.7269569715631 460.461087019307 466.2360292290752 472.0517836008674 477.9083501346845 483.8057288305255 489.7439196883908 495.7229227082804 501.7427378901944 507.8033652341325 513.9048047400946 520.0470564080819 526.2301202380925 532.4539962301282 538.7186843841878 545.0241847002718 551.37049717838 557.7576218185118 564.1855586206686 570.6543075848497 577.163868711055 583.7142419992848 590.3054274495387 596.9374250618168 603.610234836119 610.3238567724459 617.0782908707971 623.873537131172 630.7095955535717 637.5864661379954 644.5041488844435 651.4626437929162 658.461950863413 665.5020700959338 672.583001490479
+ 177.8485376572812 181.0131319433681 184.2185383914793 187.4647570016148 190.7517877737745 194.0796307079588 197.4482858041671 200.8577530623997 204.3080324826566 207.7991240649378 211.3310278092433 214.9037437155731 218.5172717839271 222.1716120143055 225.8667644067081 229.6027289611351 233.3795056775863 237.1970945560617 241.0554955965616 244.9547087990855 248.8947341636338 252.8755716902066 256.8972213788034 260.9596832294246 265.0629572420701 269.2070434167397 273.3919417534337 277.617652252152 281.8841749128947 286.1915097356615 290.5396567204527 294.9286158672681 299.3583871761078 303.8289706469719 308.3403662798601 312.8925740747727 317.4855940317095 322.1194261506707 326.794070431656 331.5095268746658 336.2657954796999 341.0628762467583 345.9007691758408 350.7794742669475 355.6989915200787 360.6593209352339 365.6604625124138 370.7024162516176 375.7851821528461 380.9087602160985 386.0731504413754 391.2783528286765 396.524367378002 401.8111940893517 407.1388329627256 412.5072839981238 417.9165471955461 423.3666225549931 428.857510076464 434.3892097599597 439.9617216054791 445.5750456130229 451.2291817825915 456.9241301141839 462.6598906078005 468.4364632634417 474.2538480811068 480.1120450607966 486.0110542025106 491.9508755062486 497.9315089720114 503.9529545997981 510.0152123896092 516.1182823414446 522.2621644553042 528.4468587311876 534.6723651690962 540.9386837690287 547.2458145309853 553.5937574549663 559.982512540972 566.4120797890012 572.8824591990552 579.3936507711334 585.9456545052359 592.5384704013626 599.1720984595137 605.8465386796888 612.5617910618884 619.3178556061123 626.1147323123603 632.9524211806328 639.8309222109298 646.7502354032509 653.7103607575959 660.7112982739657 667.7530479523593 674.8356097927776 681.95898379522 689.1231699596867
+ 186.3541258357581 189.6019748917665 192.8906361097991 196.220109489856 199.5903950319372 203.0014927360428 206.4534026021725 209.9461246303266 213.4796588205051 217.0540051727078 220.6691636869346 224.3251343631858 228.0219172014613 231.7595122017611 235.5379193640851 239.3571386884334 243.2171701748061 247.1180138232031 251.0596696336241 255.0421376060697 259.0654177405396 263.1295100370335 267.2344144955519 271.3801311160944 275.5666598986613 279.7940008432526 284.062153949868 288.3711192185078 292.7208966491717 297.11148624186 301.5428879965728 306.0151019133096 310.5281279920707 315.0819662328562 319.6766166356659 324.3120792005 328.9883539273582 333.7054408162408 338.4633398671476 343.2620510800788 348.1015744550343 352.9819099920139 357.9030576910178 362.8650175520461 367.8677895750988 372.9113737601755 377.9957701072767 383.1209786164021 388.2869992875519 393.4938321207259 398.7414771159242 404.0299342731468 409.3592035923934 414.7292850736644 420.1401787169599 425.5918845222796 431.0844024896236 436.617732618992 442.1918749103844 447.806829363801 453.4625959792424 459.1591747567073 464.8965656961972 470.674768797711 476.4937840612494 482.3536114868119 488.2542510743988 494.1957028240097 500.1779667356452 506.2010428093046 512.2649310449889 518.369631442697 524.5151440024295 530.701468724186 536.9286056079671 543.1965546537726 549.5053158616024 555.8548892314565 562.2452747633344 568.6764724572366 575.1484823131636 581.6613043311145 588.2149385110898 594.8093848530892 601.4446433571135 608.1207140231614 614.8375968512341 621.5952918413309 628.3937989934518 635.2331183075969 642.1132497837664 649.0341934219605 655.9959492221784 662.9985171844212 670.0418973086878 677.1260895949787 684.2510940432942 691.4169106536336 698.6235394259976 705.8709803603857
+ 195.067355945727 198.3984597716568 201.7703757596109 205.1831039095892 208.636644221592 212.1309966956187 215.6661613316701 219.2421381297457 222.8589270898454 226.5165282119695 230.2149414961179 233.9541669422905 237.7342045504874 241.5550543207087 245.4167162529543 249.319190347224 253.2624766035181 257.2465750218365 261.271485602179 265.3372083445461 269.4437432489372 273.5910903153527 277.7792495437924 282.0082209342564 286.2780044867447 290.5886002012575 294.9400080777943 299.3322281163555 303.7652603169411 308.2391046795506 312.7537612041849 317.3092298908432 321.9055107395255 326.5426037502326 331.2205089229637 335.9392262577192 340.698755754499 345.4990974133027 350.3402512341312 355.2222172169836 360.1449953618607 365.1085856687619 370.1129881376872 375.158202768637 380.2442295616108 385.3710685166092 390.5387196336316 395.7471829126784 400.9964583537498 406.2865459568451 411.6174457219648 416.989157649109 422.4016817382771 427.8550179894697 433.3491664026866 438.8841269779275 444.459899715193 450.0764846144824 455.7338816757967 461.4320908991346 467.1711122844974 472.9509458318843 478.7715915412952 484.6330494127308 490.5353194461903 496.4784016416742 502.4622959991827 508.487002518715 514.5525212002717 520.6588520438531 526.8059950494583 532.9939502170877 539.2227175467418 545.4922970384202 551.8026886921225 558.1538925078494 564.5459084856003 570.9787366253759 577.4523769271756 583.9668293909991 590.5220940168476 597.1181708047199 603.7550597546167 610.432760866538 617.1512741404831 623.9105995764527 630.7107371744464 637.5516869344646 644.4334488565071 651.3560229405742 658.3194091866646 665.3236075947802 672.36861816492 679.4544408970839 686.5810757912716 693.7485228474843 700.9567820657211 708.2058534459821 715.4957369882674 722.8264326925772
+ 203.9882279871875 207.4025865830388 210.8577573409144 214.3537402608142 217.8905353427384 221.4681425866868 225.0865619926594 228.7457935606563 232.4458372906777 236.186693182723 239.9683612367929 243.790841452887 247.6541338310053 251.5582383711481 255.5031550733148 259.4888839375062 263.5154249637217 267.5827781519613 271.6909435022255 275.8399210145139 280.0297106888266 284.2603125251635 288.5317265235246 292.8439526839101 297.19699100632 301.590841490754 306.0255041372123 310.5009789456949 315.0172659162018 319.574365048733 324.1722763432884 328.8109997998682 333.4905354184722 338.2108831991006 342.972043141753 347.7740152464302 352.6167995131312 357.5003959418565 362.4248045326063 367.3900252853805 372.3960582001786 377.4429032770011 382.5305605158482 387.6590299167194 392.8283114796149 398.0384052045343 403.2893110914783 408.581029140447 413.9135593514394 419.2869017244561 424.7010562594974 430.1560229565628 435.6518018156524 441.1883928367666 446.7657960199048 452.3840113650674 458.043038872254 463.7428785414651 469.4835303727004 475.2649943659603 481.0872705212441 486.9503588385523 492.854259317885 498.7989719592417 504.784496762623 510.8108337280283 516.8779828554581 522.9859441449119 529.1347175963901 535.3243032098926 541.5547009854196 547.8259109229706 554.137933022546 560.4907672841455 566.8844137077693 573.3188722934176 579.7941430410901 586.310225950787 592.8671210225081 599.4648282562533 606.1033476520231 612.782679209817 619.502822929635 626.2637788114778 633.0655468553442 639.9081270612354 646.7915194291508 653.7157239590906 660.680740651054 667.6865695050423 674.7332105210546 681.8206636990914 688.9489290391527 696.1180065412381 703.3278962053474 710.5785980314814 717.8701120196396 725.2024381698218 732.5755764820285 739.9895269562595
+
+
+# name: X
+# type: matrix
+# rows: 97
+# columns: 2
+ 1 6.1101
+ 1 5.5277
+ 1 8.518599999999999
+ 1 7.0032
+ 1 5.8598
+ 1 8.382899999999999
+ 1 7.4764
+ 1 8.578099999999999
+ 1 6.4862
+ 1 5.0546
+ 1 5.7107
+ 1 14.164
+ 1 5.734
+ 1 8.4084
+ 1 5.6407
+ 1 5.3794
+ 1 6.3654
+ 1 5.1301
+ 1 6.4296
+ 1 7.0708
+ 1 6.1891
+ 1 20.27
+ 1 5.4901
+ 1 6.3261
+ 1 5.5649
+ 1 18.945
+ 1 12.828
+ 1 10.957
+ 1 13.176
+ 1 22.203
+ 1 5.2524
+ 1 6.5894
+ 1 9.248200000000001
+ 1 5.8918
+ 1 8.2111
+ 1 7.9334
+ 1 8.0959
+ 1 5.6063
+ 1 12.836
+ 1 6.3534
+ 1 5.4069
+ 1 6.8825
+ 1 11.708
+ 1 5.7737
+ 1 7.8247
+ 1 7.0931
+ 1 5.0702
+ 1 5.8014
+ 1 11.7
+ 1 5.5416
+ 1 7.5402
+ 1 5.3077
+ 1 7.4239
+ 1 7.6031
+ 1 6.3328
+ 1 6.3589
+ 1 6.2742
+ 1 5.6397
+ 1 9.3102
+ 1 9.4536
+ 1 8.8254
+ 1 5.1793
+ 1 21.279
+ 1 14.908
+ 1 18.959
+ 1 7.2182
+ 1 8.2951
+ 1 10.236
+ 1 5.4994
+ 1 20.341
+ 1 10.136
+ 1 7.3345
+ 1 6.0062
+ 1 7.2259
+ 1 5.0269
+ 1 6.5479
+ 1 7.5386
+ 1 5.0365
+ 1 10.274
+ 1 5.1077
+ 1 5.7292
+ 1 5.1884
+ 1 6.3557
+ 1 9.768700000000001
+ 1 6.5159
+ 1 8.517200000000001
+ 1 9.180199999999999
+ 1 6.002
+ 1 5.5204
+ 1 5.0594
+ 1 5.7077
+ 1 7.6366
+ 1 5.8707
+ 1 5.3054
+ 1 8.2934
+ 1 13.394
+ 1 5.4369
+
+
+# name: alpha
+# type: scalar
+0.01
+
+
+# name: ans
+# type: diagonal matrix
+# rows: 5
+# columns: 5
+1
+1
+1
+1
+1
+
+
+# name: data
+# type: matrix
+# rows: 97
+# columns: 2
+ 6.1101 17.592
+ 5.5277 9.1302
+ 8.518599999999999 13.662
+ 7.0032 11.854
+ 5.8598 6.8233
+ 8.382899999999999 11.886
+ 7.4764 4.3483
+ 8.578099999999999 12
+ 6.4862 6.5987
+ 5.0546 3.8166
+ 5.7107 3.2522
+ 14.164 15.505
+ 5.734 3.1551
+ 8.4084 7.2258
+ 5.6407 0.71618
+ 5.3794 3.5129
+ 6.3654 5.3048
+ 5.1301 0.56077
+ 6.4296 3.6518
+ 7.0708 5.3893
+ 6.1891 3.1386
+ 20.27 21.767
+ 5.4901 4.263
+ 6.3261 5.1875
+ 5.5649 3.0825
+ 18.945 22.638
+ 12.828 13.501
+ 10.957 7.0467
+ 13.176 14.692
+ 22.203 24.147
+ 5.2524 -1.22
+ 6.5894 5.9966
+ 9.248200000000001 12.134
+ 5.8918 1.8495
+ 8.2111 6.5426
+ 7.9334 4.5623
+ 8.0959 4.1164
+ 5.6063 3.3928
+ 12.836 10.117
+ 6.3534 5.4974
+ 5.4069 0.55657
+ 6.8825 3.9115
+ 11.708 5.3854
+ 5.7737 2.4406
+ 7.8247 6.7318
+ 7.0931 1.0463
+ 5.0702 5.1337
+ 5.8014 1.844
+ 11.7 8.004300000000001
+ 5.5416 1.0179
+ 7.5402 6.7504
+ 5.3077 1.8396
+ 7.4239 4.2885
+ 7.6031 4.9981
+ 6.3328 1.4233
+ 6.3589 -1.4211
+ 6.2742 2.4756
+ 5.6397 4.6042
+ 9.3102 3.9624
+ 9.4536 5.4141
+ 8.8254 5.1694
+ 5.1793 -0.74279
+ 21.279 17.929
+ 14.908 12.054
+ 18.959 17.054
+ 7.2182 4.8852
+ 8.2951 5.7442
+ 10.236 7.7754
+ 5.4994 1.0173
+ 20.341 20.992
+ 10.136 6.6799
+ 7.3345 4.0259
+ 6.0062 1.2784
+ 7.2259 3.3411
+ 5.0269 -2.6807
+ 6.5479 0.29678
+ 7.5386 3.8845
+ 5.0365 5.7014
+ 10.274 6.7526
+ 5.1077 2.0576
+ 5.7292 0.47953
+ 5.1884 0.20421
+ 6.3557 0.67861
+ 9.768700000000001 7.5435
+ 6.5159 5.3436
+ 8.517200000000001 4.2415
+ 9.180199999999999 6.7981
+ 6.002 0.9269500000000001
+ 5.5204 0.152
+ 5.0594 2.8214
+ 5.7077 1.8451
+ 7.6366 4.2959
+ 5.8707 7.2029
+ 5.3054 1.9869
+ 8.2934 0.14454
+ 13.394 9.055099999999999
+ 5.4369 0.61705
+
+
+# name: i
+# type: scalar
+100
+
+
+# name: iterations
+# type: scalar
+1500
+
+
+# name: j
+# type: scalar
+100
+
+
+# name: m
+# type: scalar
+97
+
+
+# name: predict1
+# type: scalar
+0.4519767867701767
+
+
+# name: predict2
+# type: scalar
+4.534245012944714
+
+
+# name: t
+# type: matrix
+# rows: 1
+# columns: 6
+ 0 0.01 0.02 0.03 0.04 0.05
+
+
+# name: theta
+# type: matrix
+# rows: 2
+# columns: 1
+ -3.63029143940436
+ 1.166362350335582
+
+
+# name: theta0_vals
+# type: matrix
+# rows: 1
+# columns: 100
+ -10 -9.797979797979798 -9.595959595959595 -9.393939393939394 -9.191919191919192 -8.98989898989899 -8.787878787878787 -8.585858585858587 -8.383838383838384 -8.181818181818182 -7.979797979797979 -7.777777777777778 -7.575757575757576 -7.373737373737374 -7.171717171717171 -6.96969696969697 -6.767676767676768 -6.565656565656566 -6.363636363636363 -6.161616161616162 -5.959595959595959 -5.757575757575758 -5.555555555555555 -5.353535353535354 -5.151515151515151 -4.94949494949495 -4.747474747474747 -4.545454545454546 -4.343434343434343 -4.141414141414142 -3.939393939393939 -3.737373737373738 -3.535353535353535 -3.333333333333333 -3.131313131313131 -2.929292929292929 -2.727272727272728 -2.525252525252525 -2.323232323232324 -2.121212121212121 -1.919191919191919 -1.717171717171718 -1.515151515151516 -1.313131313131313 -1.111111111111111 -0.9090909090909101 -0.7070707070707076 -0.5050505050505052 -0.3030303030303028 -0.1010101010101003 0.1010101010101003 0.3030303030303028 0.5050505050505052 0.7070707070707076 0.9090909090909083 1.111111111111111 1.313131313131313 1.515151515151516 1.717171717171716 1.919191919191919 2.121212121212121 2.323232323232324 2.525252525252524 2.727272727272727 2.929292929292929 3.131313131313131 3.333333333333334 3.535353535353535 3.737373737373737 3.939393939393939 4.141414141414142 4.343434343434343 4.545454545454545 4.747474747474747 4.94949494949495 5.15151515151515 5.353535353535353 5.555555555555555 5.757575757575758 5.959595959595958 6.161616161616163 6.363636363636363 6.565656565656564 6.767676767676768 6.969696969696969 7.171717171717173 7.373737373737374 7.575757575757574 7.777777777777779 7.979797979797979 8.18181818181818 8.383838383838384 8.585858585858585 8.787878787878789 8.98989898989899 9.19191919191919 9.393939393939394 9.595959595959595 9.797979797979799 10
+
+
+# name: theta1_vals
+# type: matrix
+# rows: 1
+# columns: 100
+ -1 -0.9494949494949495 -0.898989898989899 -0.8484848484848485 -0.797979797979798 -0.7474747474747474 -0.696969696969697 -0.6464646464646464 -0.595959595959596 -0.5454545454545454 -0.4949494949494949 -0.4444444444444444 -0.3939393939393939 -0.3434343434343434 -0.2929292929292929 -0.2424242424242424 -0.1919191919191919 -0.1414141414141414 -0.09090909090909094 -0.04040404040404044 0.01010101010101017 0.06060606060606055 0.1111111111111112 0.1616161616161615 0.2121212121212122 0.2626262626262625 0.3131313131313131 0.3636363636363635 0.4141414141414141 0.4646464646464645 0.5151515151515151 0.5656565656565655 0.6161616161616161 0.6666666666666667 0.7171717171717171 0.7676767676767677 0.8181818181818181 0.8686868686868687 0.9191919191919191 0.9696969696969697 1.02020202020202 1.07070707070707 1.121212121212121 1.171717171717172 1.222222222222222 1.272727272727272 1.323232323232323 1.373737373737374 1.424242424242424 1.474747474747475 1.525252525252525 1.575757575757576 1.626262626262626 1.676767676767677 1.727272727272727 1.777777777777778 1.828282828282828 1.878787878787879 1.929292929292929 1.97979797979798 2.03030303030303 2.080808080808081 2.131313131313131 2.181818181818182 2.232323232323232 2.282828282828283 2.333333333333333 2.383838383838384 2.434343434343434 2.484848484848485 2.535353535353535 2.585858585858586 2.636363636363636 2.686868686868687 2.737373737373737 2.787878787878788 2.838383838383838 2.888888888888889 2.939393939393939 2.98989898989899 3.040404040404041 3.090909090909091 3.141414141414141 3.191919191919192 3.242424242424242 3.292929292929293 3.343434343434343 3.393939393939394 3.444444444444445 3.494949494949495 3.545454545454545 3.595959595959596 3.646464646464646 3.696969696969697 3.747474747474747 3.797979797979798 3.848484848484849 3.898989898989899 3.94949494949495 4
+
+
+# name: y
+# type: matrix
+# rows: 97
+# columns: 1
+ 17.592
+ 9.1302
+ 13.662
+ 11.854
+ 6.8233
+ 11.886
+ 4.3483
+ 12
+ 6.5987
+ 3.8166
+ 3.2522
+ 15.505
+ 3.1551
+ 7.2258
+ 0.71618
+ 3.5129
+ 5.3048
+ 0.56077
+ 3.6518
+ 5.3893
+ 3.1386
+ 21.767
+ 4.263
+ 5.1875
+ 3.0825
+ 22.638
+ 13.501
+ 7.0467
+ 14.692
+ 24.147
+ -1.22
+ 5.9966
+ 12.134
+ 1.8495
+ 6.5426
+ 4.5623
+ 4.1164
+ 3.3928
+ 10.117
+ 5.4974
+ 0.55657
+ 3.9115
+ 5.3854
+ 2.4406
+ 6.7318
+ 1.0463
+ 5.1337
+ 1.844
+ 8.004300000000001
+ 1.0179
+ 6.7504
+ 1.8396
+ 4.2885
+ 4.9981
+ 1.4233
+ -1.4211
+ 2.4756
+ 4.6042
+ 3.9624
+ 5.4141
+ 5.1694
+ -0.74279
+ 17.929
+ 12.054
+ 17.054
+ 4.8852
+ 5.7442
+ 7.7754
+ 1.0173
+ 20.992
+ 6.6799
+ 4.0259
+ 1.2784
+ 3.3411
+ -2.6807
+ 0.29678
+ 3.8845
+ 5.7014
+ 6.7526
+ 2.0576
+ 0.47953
+ 0.20421
+ 0.67861
+ 7.5435
+ 5.3436
+ 4.2415
+ 6.7981
+ 0.9269500000000001
+ 0.152
+ 2.8214
+ 1.8451
+ 4.2959
+ 7.2029
+ 1.9869
+ 0.14454
+ 9.055099999999999
+ 0.61705
+
+