Propositions: Fundamental units of information. You can assert/deny, agree/disagree, believe/not believe
- ~A is true only when A is false
- A & B is true, only when both A and B are true
| import java.util.LinkedList; | |
| /** | |
| * @author thiru | |
| * | |
| */ | |
| public class SecondLargest { | |
| private class TreeNode { | |
| int item; |
| # Really cool algorithm I learnt from a blog somewhere | |
| # Also sometimes called russian's peasents algorithm | |
| def fast_multiply(a,b): | |
| z=0; | |
| while a > 0: | |
| if a % 2 == 1: | |
| z = z + b | |
| a = a >> 1 | |
| b = b << 1 |
| # Syntax: All in one line or by escape characters | |
| # [ <some expression to be evaluated and put in another list> | |
| # for <some iterating variable in the list> | |
| # in <some list> | |
| # if <some condition holds true> | |
| # ] | |
| mylist = [10,20,30,40,50,60,70,80,90,100] | |
| # create a new list containing variables in the list divided by 10 |
| import java.util.Map; | |
| import java.util.HashMap; | |
| public class BitBoolean { | |
| //Holds boolean data as bits | |
| //Each byte can hold 8 boolean values | |
| //So index = booleanDataIndex + booleanMappingIndex | |
| //booleanDataIndex = index/8 | |
| //boleanMappingIndex, see booleanMapping variable |
| Dependent variable = y what we predict | |
| Independent variable = x's. What we use to predict y. | |
| Baseline Prediction: We take the average of all y in the training set and predict that no matter what x is input into the model. | |
| One variable linear regression: | |
| y_i = B_0 + B_1 * x_i + e_i | |
| y_i = i'th independent variable | |
| B_0 = intercept term (the value of y when x is 0) |