diff --git a/content/_index.md b/content/_index.md index 41bfbb0..bc5211b 100644 --- a/content/_index.md +++ b/content/_index.md @@ -1,4 +1,5 @@ --- title: Brandon Rozek description: "Software Developer, Researcher, and Linux Enthusiast." ---- \ No newline at end of file +--- + diff --git a/content/blog/2015-10-10-javascript-data-types.md b/content/blog/2015-10-10-javascript-data-types.md index a3354f0..ad4d1cd 100644 --- a/content/blog/2015-10-10-javascript-data-types.md +++ b/content/blog/2015-10-10-javascript-data-types.md @@ -20,288 +20,266 @@ tags: ["Web", "JS"] --- Javascript has multiple ways you can store your data. Each of these different ways is called a data type, and they each carry different “methods” which are helpful commands. Today, I’ll show you the different data types and methods that I use and how they’re useful. - - This post is by far not a comprehenive list of all the Data types and their methods. If you want one of those, please check out [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects) and/or [WebPlatform](http://docs.webplatform.org/wiki/javascript/objects){.broken_link}. This is the second lecture of the web development class I’m teaching for the newer folks over at [Math I/O](http://math-io.com). Due to the nature of Math I/O (making math games and all), the next few posts will be Javascript centric. We’re getting ready to build a new game, so I want to prepare them as much as possible. \*Excited\* ^_^ Ilya Kantor does a good job of descibing Javascript data types and their many methods in [Mastering Data Types](http://javascript.info/tutorial/mastering-data-types) which I made the recommended reading for this lecture. -### String {#string} +### String A string is one or more characters. -
var name = "Brandon";
+```javascript +var name = "Brandon"; +``` You can access a character inside of a string by using [] notation. Inside the [] you put the index of the character you want. An index is the numeral location of the character starting from the left. It is important to note that Javascript starts counting from 0. - - - +| B | r | a | n | d | o | n | +| ---- | ---- | ---- | ---- | ---- | ---- | ---- | +| 0 | 1 | 2 | 3 | 4 | 5 | 6 | - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- B - - r - - a - - n - - d - - o - - n -
- - 1 - - 2 - - 3 - - 4 - - 5 - - 6 -
+```javascript +var firstInitial = "Brandon"[0]; +``` +Now the value of firstInitial is the letter `"B"`. -
var firstInitial = "Brandon"[0];
+#### Some useful methods for strings -Now the value of firstInitial is the letter "B". - -#### Some useful methods for strings {#some-useful-methods-for-strings} - -##### String.prototype.indexOf(); {#string.prototype.indexof();} +##### `String.prototype.indexOf` This can be used to find the index of any character(s) in a string. I primarily use it for when I need to check if something exists in a string. Do I have a ‘z’ in my name? -
"Brandon".indexOf('z');
+```javascript +"Brandon".indexOf('z'); +``` -Nope, so Javascript will return a -1. How about a ‘d’? +Nope, so Javascript will return a `-1`. How about a ‘d’? -
"Brandon".indexOf('d');
+```javascript +"Brandon".indexOf('d'); +``` -Yes, Javascript will return 5 which is the index of the letter ‘d’. +Yes, Javascript will return `5` which is the index of the letter `‘d’`. -##### String.prototype.replace(); {#string.prototype.replace();} +##### `String.prototype.replace` -The replace method can replace any character(s) with other character(s). For more complex replacing, look into [Regular Expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions) and how you can use them in .replace(). Replace the first ‘n’ in my name with an ‘m’. +The replace method can replace any character(s) with other character(s). For more complex replacing, look into [Regular Expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions) and how you can use them in `.replace()`. Replace the first `‘n’` in my name with an `‘m’`. -

+```javascript
 var modifiedName = "Brandon".replace('n', 'm');
-
 console.log(modifiedName);
-
+``` -Logs "Bramdon". +Logs `"Bramdon"`. -##### String.prototype.toUpperCase(); {#string.prototype.touppercase();} +##### `String.prototype.toUpperCase` This method returns the string with all the lowercase characters converted to uppercase and can be useful for when you’re checking user input and you don’t want to worry about different cases. -
"Brandon".toUpperCase();
+```javascript +"Brandon".toUpperCase(); +``` -Returns "BRANDON". +Returns `"BRANDON"`. -##### String.prototype.toLowerCase(); {#string.prototype.tolowercase();} +##### `String.prototype.toLowerCase()` Same as above but instead of converting lowercase to uppercase, it converts uppercase to lowercase. -
"Brandon".toLowerCase();
+```javascript +"Brandon".toLowerCase(); +``` -Returns "brandon". +Returns `"brandon"`. -#### A couple useful escape secquences {#a-couple-useful-escape-secquences} +#### A couple useful escape secquences - * n for newline. - * t for tab character. + * `\n` for newline. + * `\t` for tab character. -You can also use escape sequnces if you want to add “” or ‘’ to your strings. - -

-var greeting = "Hello "Brandon"";
+You can also use escape sequnces if you want to add `“”` or `‘’` to your strings.
 
+```javascript
+var greeting = "Hello \"Brandon\"";
 console.log(greeting);
-
+``` -Returns "Hello "Brandon"". +Returns `"Hello "Brandon""`. -### Number {#number} +### Number -Any number between -(253 – 1) and (253 – 1). +Any number between -(2^53 – 1) and (2^53 – 1). -#### Number Methods {#number-methods} +#### Number Methods Number methods are useful when trying to represent complex numbers. -##### Number.prototype.toExponential(); {#number.prototype.toexponential();} +##### `Number.prototype.toExponential()` Returns a string representing a number in exponential notation. -
77.1234.toExponential(2);
+```javascript +77.1234.toExponential(2); +``` -Returns "7.71e+1". +Returns `"7.71e+1"`. -##### Number.prototype.toFixed(); {#number.prototype.tofixed();} +##### `Number.prototype.toFixed()` Returns a string representing a number fixed to x amount of decimal places. -
12345.6789.toFixed(1);
+```javascript +12345.6789.toFixed(1); +``` -Returns "12345.7". +Returns `"12345.7"`. -##### Number.prototype.toPrecision(); {#number.prototype.toprecision();} +##### `Number.prototype.toPrecision();` Returns a string representing a number using x amount of significant figures. -
5.123456.toPrecision(2);
+```javascript +5.123456.toPrecision(2); +``` -Returns "5.1". +Returns `"5.1"`. -#### Math properties/methods {#math-properties/methods} +#### Math properties/methods In Javascript there is a Math object which contains many properties and methods which are useful for mathmatical calculations. -##### Return Euler’s constant {#return-euler's-constant} +##### Return Euler’s constant -Math.E which returns ~2.718. +`Math.E` which returns ~2.718. -##### Return the natural log of x {#return-the-natural-log-of-x} +##### Return the natural log of x -Math.log(x) +```javascript +Math.log(x) +``` -##### Rise x to the y power {#rise-x-to-the-y-power} +##### Rise x to the y power -Math.pow(x,y) +```javascript +Math.pow(x,y) +``` -##### Return a psuedo random number [0,1) {#return-a-psuedo-random-number-[0,1)} +##### Return a psuedo random number \[0,1\) -Math.random() +```javascript +Math.random() +``` -##### Round x to the nearest integer {#round-x-to-the-nearest-integer} +##### Round x to the nearest integer -Math.round(x) +```javascript +Math.round(x) +``` -### Boolean {#boolean} +### Boolean -Booleans are either true or false and are typically used in conditional statements. You can either create them explicitly - -
var alive = true;
+Booleans are either `true` or `false` and are typically used in conditional statements. You can either create them explicitly +```javascript +var alive = true; +``` or by evaluating a [comparison](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators). -

+```javascript
 var dead = false;
 var isAlive = !dead;
-
+``` -isAlive equals true. +isAlive equals `true`. -### Array {#array} +### Array An array is a list of items. In Javascript these items can be any data type, even arrays themselves. -
var mixedBag = ['sword', 24, true, [Math.PI, Math.E], 'shield'];
+```javascript +var mixedBag = ['sword', 24, true, [Math.PI, Math.E], 'shield']; +``` To access an item in an array use [] notation with an index as mentioned over at strings. -
['sword', 'shield', 'helmet'][1];
+```javascript +['sword', 'shield', 'helmet'][1]; +``` -Returns 'shield'. to figure out how many items are in the array. +Returns `'shield'`. In order to figure out how many items are in the array: -

+```javascript
 var inventory = ['boots', 'gloves', 'pants', 'shirt'];
 var inventoryAmt = inventory.length;
-
+``` -inventoryAmt is 4 since there are 4 items in inventory. +inventoryAmt is `4` since there are 4 items in inventory. -#### Array Methods {#array-methods} +#### Array Methods -##### Array.prototype.push(); {#array.prototype.push();} +##### `Array.prototype.push()` Adds whatever is inside the parenthesis to the end of the array. Great for adding items to a list. For example, test scores. -
[100,92,95].push(80);
+```javascript +[100,92,95].push(80); +``` -Returns [100,92,95,80]. +Returns `[100,92,95,80]`. -##### Array.prototype.reverse(); {#array.prototype.reverse();} +##### `Array.prototype.reverse()` Reverses the order of all the items in the array. -
[1,2,3].reverse();
+```javascript +[1,2,3].reverse(); +``` -Returns [3,2,1]. +Returns `[3,2,1]`. -##### Array.prototype.concat(); {#array.prototype.concat();} +##### `Array.prototype.concat()` -Combines two arrays, putting the items from the array in the parenthesis to the end of the main array. This method is a lot faster than grabbing each item by their index and adding them using the .push() method. +Combines two arrays, putting the items from the array in the parenthesis to the end of the main array. This method is a lot faster than grabbing each item by their index and adding them using the `.push()` method. -
['a','b','c'].concat([1,2,3]);
+```javascript +['a','b','c'].concat([1,2,3]); +``` -Returns ['a','b','c',1,2,3]. +Returns `['a','b','c',1,2,3]`. -##### Array.prototype.join(); {#array.prototype.join();} +##### `Array.prototype.join()` Converts the array into a string, with each item seperated by whatever is in the parenthesis. Useful for telling the user the items in their inventory, for example. -

+```javascript
 var inventory = ['books','apples','pencils'];
 console.log("You have " + inventory.join(", ") + " in your inventory.");
-
+``` -Logs "You have books, apples, pencils in your inventory." +Logs `"You have books, apples, pencils in your inventory."` -##### Array.prototype.indexOf(); {#array.prototype.indexof();} +##### `Array.prototype.indexOf()` Similar to String.prototype.indexOf(), it returns the index of the item inside the parenthesis. -
['chicken','pizza','tacos'].indexOf('tacos');
+```javascript +['chicken','pizza','tacos'].indexOf('tacos'); +``` -Returns 2. +Returns `2`. -### Objects {#objects} +### Objects Objects are like arrays, however they’re easier for establishing the relationship between properties and their values. You can store any data type as a property of an object. -

+```javascript
 var player = {};
 player.name = "Brandon";
 player.health = Number.POSITIVE_INFINITY;
 console.log(player.name + " has " + player.health + " health.");
-
+``` -Logs "Brandon has Infinity health" Yup that sounds about right. +Logs `"Brandon has Infinity health"`. Yup that sounds about right. -### Conclusion {#conclusion} +### Conclusion -All of the different data types in Javascript are tools for you to get the job done. When assigning a variable, think to yourself which tool you should use. I had fun doing this lecture. We finished earlier than expected, due to my extra preparations. (Still shuddering over my unpreparedness from last week). We had finished so early in fact, that I went ahead and started teaching next week’s material. Do not worry though, my lovely reader’s only get the most structured of lesson materials. So you’ll have to wait until next week to hear more. 🙂 \ No newline at end of file +All of the different data types in Javascript are tools for you to get the job done. When assigning a variable, think to yourself which tool you should use. I had fun doing this lecture. We finished earlier than expected, due to my extra preparations. (Still shuddering over my unpreparedness from last week). We had finished so early in fact, that I went ahead and started teaching next week's material. Do not worry though, my lovely readers only get the most structured of lesson materials. So you'll have to wait until next week to hear more. 🙂 \ No newline at end of file diff --git a/content/blog/2015-10-25-functions.md b/content/blog/2015-10-25-functions.md index ef9934a..ae89eab 100644 --- a/content/blog/2015-10-25-functions.md +++ b/content/blog/2015-10-25-functions.md @@ -17,9 +17,7 @@ tags: ["Web", "JS"] --- Ever had a snippet of code that appears multiple times in different places in your program? Whenever you had to change that snippet, you end up playing this game of search and replace. Functions can help. They exist to abstract your code, making it not only easier to change that little snippet, but to read and debug your code as well. - - -### How to create/execute a function {#how-to-create/execute-a-function} +### How to create/execute a function To make a function @@ -35,7 +33,7 @@ To call the above function to execute doSomething(); ``` -### Arguments {#arguments} +### Arguments You can also add in arguments (parameters that go inside the paraenthesis next to the word function) for the functions to use. @@ -51,13 +49,13 @@ And when you use the `return` keyword, like the function above. You can store th var total = add(1, 3); ``` -total here will equal `4` +`total` here will equal `4` -### Scope {#scope} +### Scope Functions create their own scope, which means that variables created inside the function will only be able available within that function. -The snippet below will output an error like total is not defined +The snippet below will output an error like `total is not defined`. ```javascript var add = function(number1, number2) { @@ -80,7 +78,7 @@ Below is a correct example of the concept It’s also important to note that functions can use variables outside of it; granted it resides in the same scope. -Here is an example of a variable that doesn’t reside in the same scope as the function. (The below code will fail) +Here is an example of a variable that doesn't reside in the same scope as the function. (The below code will fail) ```javascript var something = function() { @@ -104,8 +102,8 @@ Below, is an example of where the variable does reside in the same scope as the var sum = addX(6); ``` -sum here will equal 11 +`sum` here will equal `11` -### Conclusion {#conclusion} +### Conclusion As long as you name them appropriately, functions are useful for abstracting your code, making them easier to understand. This concludes another lecture made for the members over at Math I/O. Until next week 🙂 \ No newline at end of file diff --git a/content/blog/2015-11-14-service-workers.md b/content/blog/2015-11-14-service-workers.md index 23e296e..d1ad781 100644 --- a/content/blog/2015-11-14-service-workers.md +++ b/content/blog/2015-11-14-service-workers.md @@ -62,7 +62,7 @@ var offlineFundamentals = [ ``` -Since cache.addAll() hasn’t been implemented yet in any of the browsers, and the polyfill implementation didn’t work for my needs. I pieced together my own. +Since `cache.addAll()` hasn’t been implemented yet in any of the browsers, and the polyfill implementation didn’t work for my needs. I pieced together my own. ```javascript var updateStaticCache = function() { @@ -85,8 +85,8 @@ var updateStaticCache = function() { Let’s go through this chunk of code. - 1. Open the cache called 'v2.0.24:fundamentals' - 2. Go through all of the offlineFundamental‘s URLs + 1. Open the cache called `'v2.0.24:fundamentals'` + 2. Go through all of the `offlineFundamental`‘s URLs * Does the file I ask for come from the same domain as my site? * No. Then, make the request ‘no-cors’ (I had difficulty getting my asset files in cors mode. If the cors headers are included in the response, then you can take out this line) * Fetch the file from the network and then cache it. @@ -140,7 +140,7 @@ self.addEventListener("activate", function(event) { The cool thing about service worker’s is that it can handle file requests. We could cache all files requested for offline use, and if a fetch for a resource failed, then the service worker can look for it in the cache or provide an alternative. This is a large section, so I’m going to attempt to break it down as much as I can. -## Limit the cache {#limit-the-cache} +## Limit the cache If the visitor started browsing all of the pages on my site, his or her cache would start to get bloated with files. To not burden my visitors, I decided to only keep the latest 25 pages and latest 10 images in the cache. @@ -159,7 +159,7 @@ We’ll call it later in the code. ## Fetch from network and cache -Every time I fetch a file from the network I throw it into a specific cache container. 'pages' for HTML files, 'images' for CSS files, and 'assets' for any other file. This is so I can handle the cache limiting above easier. Defined within the `fetch` event. +Every time I fetch a file from the network I throw it into a specific cache container: `'pages'` for HTML files, `'images'` for CSS files, and `'assets'` for any other file. This is so I can handle the cache limiting above easier. Defined within the `fetch` event. ```javascript var fetchFromNetwork = function(response) { @@ -371,4 +371,4 @@ self.addEventListener("fetch", function(event) { self.addEventListener("activate", function(event) { event.waitUntil(clearOldCaches()) }); -``` \ No newline at end of file +``` diff --git a/content/blog/2015-12-22-playing-with-qr-codes.md b/content/blog/2015-12-22-playing-with-qr-codes.md index bdd4e6d..f75beca 100644 --- a/content/blog/2015-12-22-playing-with-qr-codes.md +++ b/content/blog/2015-12-22-playing-with-qr-codes.md @@ -18,26 +18,21 @@ bridgy_syndication: https://twitter.com/B_RozekJournal/status/790337750280970241 --- -Looking at Aaron Parecki’s [“Fun with QR Codes”](https://aaronparecki.com/articles/2015/10/05/1/fun-with-qr-codes) inspired me to play with QR Codes myself. Using the tool [QArt Coder](http://research.swtch.com/qr/draw) made by [Russ Cox](https://plus.google.com/116810148281701144465), I made a QR Code with my face in it! +Looking at Aaron Parecki's [“Fun with QR Codes”](https://aaronparecki.com/articles/2015/10/05/1/fun-with-qr-codes) inspired me to play with QR Codes myself. Using the tool [QArt Coder](http://research.swtch.com/qr/draw) made by [Russ Cox](https://plus.google.com/116810148281701144465), I made a QR Code with my face in it! - +![](https://brandonrozek.com/wp-content/uploads/2016/10/qrcode-large-1.png) -qrcode-large ### Why QR Codes? -QR Codes aren’t prevalent in the United States of America. In fact, they’re often viewed by technologists as a [joke](http://picturesofpeoplescanningqrcodes.tumblr.com/). But as [Christina Xu](http://www.christinaxu.org/) points out on her Medium post [“Pictures of Chinese People Scanning QR Codes”](https://medium.com/chrysaora-weekly/pictures-of-chinese-people-scanning-qr-codes-a564047ec58f), it’s not a joke everywhere. In fact, many people actually depend on this humble little QR code to get by in their day. Another story, my family and I go out to eat sometimes. Occasionally, we’ll knock into a Heinz Ketchup bottle. +QR Codes aren't prevalent in the United States of America. In fact, they're often viewed by technologists as a [joke](http://picturesofpeoplescanningqrcodes.tumblr.com/). But as [Christina Xu](http://www.christinaxu.org/) points out on her Medium post [“Pictures of Chinese People Scanning QR Codes”](https://medium.com/chrysaora-weekly/pictures-of-chinese-people-scanning-qr-codes-a564047ec58f), it's not a joke everywhere. In fact, many people actually depend on this humble little QR code to get by in their day. Another story, my family and I go out to eat sometimes. Occasionally, we'll knock into a Heinz Ketchup bottle. -
- Picture of Heinz ketchup bottle with QR Code. +![Picture of Heinz ketch bottle with QR Code](https://brandonrozek.com/wp-content/uploads/2016/10/heinz-2-768x1024.jpg) -

- Picture by Azad Zahoory -

-
My brother would get so excited whenever he saw this. This little ketchup bottle meant that we got to play a +Image by Azad Zahoory. -trivia game. No matter what you think of QR Codes, vanity or not, there are people who use it every day. So have some fun and make yourself a QR Code of your own. You know, just in case 😉 +My brother would get so excited whenever he saw this. This little ketchup bottle meant that we got to play a [trivia game](http://www.heinztablegames.com/game_selector.html). No matter what you think of QR Codes, vanity or not, there are people who use it every day. So have some fun and make yourself a QR Code of your own. You know, just in case 😉 ### Setting up the QR Code -First, you need a picture. I used a picture of myself. Then for the QArt Coder site to work correctly, the image needs to be in high-contrast. Meaning, it needs to be mostly black and white. To accomplish this, fire up [Gimp](https://www.gimp.org/) (or your image editor of choice), and hit Color -> Threshold. That will give you a black and white version of the picture where you can then play around with the slider to get it just how you want it. After that, open up [QArt Coder](http://research.swtch.com/qr/draw) and upload the image onto the site. Once that’s accomplished, you might need to play with the QR Size, Image Size, Rotation, and other options. After that, hit “Save this QR Code” and viola! You got yourself three different sizes of QR codes to use. What should you do with the QR Code after you get it? First, brag to your friends about how cool it looks. Then maybe put it on your [business card](https://www.webdesignerdepot.com/2011/07/30-creative-qr-code-business-cards/). If you can think of any other excuses uses of QR Codes [contact me](mailto:brozek@brandonrozek.com) 🙂 \ No newline at end of file +First, you need a picture. I used a picture of myself. Then for the QArt Coder site to work correctly, the image needs to be in high-contrast. Meaning, it needs to be mostly black and white. To accomplish this, fire up [Gimp](https://www.gimp.org/) (or your image editor of choice), and hit Color -> Threshold. That will give you a black and white version of the picture where you can then play around with the slider to get it just how you want it. After that, open up [QArt Coder](http://research.swtch.com/qr/draw) and upload the image onto the site. Once that's accomplished, you might need to play with the QR Size, Image Size, Rotation, and other options. After that, hit “Save this QR Code” and viola! You got yourself three different sizes of QR codes to use. What should you do with the QR Code after you get it? First, brag to your friends about how cool it looks. Then maybe put it on your [business card](https://www.webdesignerdepot.com/2011/07/30-creative-qr-code-business-cards/). If you can think of any other ~~excuses~~ uses of QR Codes [contact me](mailto:brozek@brandonrozek.com) 🙂 diff --git a/content/blog/2015-12-27-creating-vcards-from-h-cards.md b/content/blog/2015-12-27-creating-vcards-from-h-cards.md index 26b0c61..bf296af 100644 --- a/content/blog/2015-12-27-creating-vcards-from-h-cards.md +++ b/content/blog/2015-12-27-creating-vcards-from-h-cards.md @@ -23,11 +23,11 @@ Microformats is semantic HTML used to convey metadata. Using an userscript, I ca [H-card](http://microformats.org/wiki/h-card) is a type of microformat that serves as a contact card for people and organizations. -[vCard](https://en.wikipedia.org/wiki/VCard) is the standard for electronic business cards. They’re most likely used in your phone to store contacts. +[vCard](https://en.wikipedia.org/wiki/VCard) is the standard for electronic business cards. They're most likely used in your phone to store contacts. Userscript is essentially JavaScript that runs in the [Greasemonkey](http://www.greasespot.net/) extension. -### What I’ll need +### What I'll need * Microformat parser * Way to find the representative h-card @@ -40,7 +40,7 @@ To keep everything in small [reusable components](https://en.wikipedia.org/wiki/ Next, I need to find the representative h-card of the page. Following the [instructions](http://microformats.org/wiki/representative-h-card-parsing) on the microformats wiki, I wrote the following code. -

+```javascript
 /*
    representative-h-card - v0.1.0
    Copyright (c) 2015 Brandon Rozek
@@ -60,7 +60,7 @@ var representativeHCard = function(hCards, url) {
 		hCard.items = [hCards.items[0]];
 		return hCard
 	} else {
-		for (var i = 0; i < hCards.items.length; i++) {
+		for (var i = 0; i < hCards.items.length; i++) {
 			if (urlsMatchURL(hCards.items[i], url) && (uidsMatchURL(hCards.items[i], url) || relMeMatchURL(hCards, url))) {
 				hCard = hCards;
 				hCard.items = [hCards.items[i]];
@@ -75,7 +75,7 @@ var representativeHCard = function(hCards, url) {
 var urlsMatchURL = function(hCard, url) {
 	var urls = hCard.properties.url;
 	if (typeof(urls) == "object") {
-		for (var i = 0; i < urls.length; i++) {
+		for (var i = 0; i < urls.length; i++) {
 			if (new URL(urls[i]).toString() == new URL(url).toString()) {
 				return true;
 			}
@@ -86,7 +86,7 @@ var urlsMatchURL = function(hCard, url) {
 var uidsMatchURL = function(hCard, url) {
 	var uids = hCard.properties.uid;
 	if (typeof(uids) == "object") {
-		for (var i = 0; i < uids.length; i++) {
+		for (var i = 0; i < uids.length; i++) {
 			if (new URL(uids[i]).toString() == new URL(url).toString()) {
 				return true;
 			}
@@ -97,7 +97,7 @@ var uidsMatchURL = function(hCard, url) {
 var relMeMatchURL = function(microformats, url) {
 	var me = microformats.rels.me;
 	if (typeof(me) == "object") {
-		for (var i = 0; i < me.length; i++) {
+		for (var i = 0; i < me.length; i++) {
 			if (new URL(me[i]).toString() == new URL(url).toString()) {
 				return true;
 			}
@@ -105,9 +105,9 @@ var relMeMatchURL = function(microformats, url) {
 	}
 	return false;
 }
-
+``` -Next up, is making the vCard. For this, I had to look at the [vCard 4.0 specification](https://tools.ietf.org/html/rfc6350) to figure out what the property names and values are. Then I browsed around different sites (takes you to a random [Indieweb](https://indiewebcamp.com/) site)  to figure out which properties are the most common. +Next up, is making the vCard. For this, I had to look at the [vCard 4.0 specification](https://tools.ietf.org/html/rfc6350) to figure out what the property names and values are. Then I browsed around different [sites](http://indieweb.thatmustbe.us/) (takes you to a random [Indieweb](https://indiewebcamp.com/) site)  to figure out which properties are the most common. The properties I ended up adding to the vCard. @@ -123,7 +123,7 @@ The properties I ended up adding to the vCard.  As I was browsing around, I noticed that a few people would have empty values for certain properties on their h-card. To avoid having this show up on the vCard, I added a filter that takes out empty strings. -

+```javascript
 /*
    vCard-from-h-card - v0.1.0
    Copyright (c) 2015 Brandon Rozek
@@ -180,7 +180,7 @@ var makeVCard = function(hCard) {
 	//Add IMPP (Instant Messaging and Presence Protocol)
 	if (typeof(impp) == "object") {
 		impp.removeEmptyStrings();
-		for (var i = 0; i < impp.length; i++) {
+		for (var i = 0; i < impp.length; i++) {
 			vCard += "IMPP;PREF=" + (i + 1) + ": " + impp[i] + "n";
 		}
 	}
@@ -189,7 +189,7 @@ var makeVCard = function(hCard) {
 	var email = hCard.items[0].properties.email;
 	if (typeof(email) == "object") {
 		email.removeEmptyStrings();
-		for (var i = 0; i < email.length; i++) {
+		for (var i = 0; i < email.length; i++) {
 			try {
 				vCard += "EMAIL: " + new URL(email[i]).pathname + "n";
 			} catch (e) { 
@@ -238,10 +238,9 @@ var makeVCard = function(hCard) {
 Array.prototype.removeEmptyStrings = function() {
 	return this.filter(function(i) { return i !== "" })
 }
+```
 
-
- -Now for the final part, making the userscript. Inspired by [Ryan Barret](https://snarfed.org/) and his userscript [Let’s Talk,](https://github.com/snarfed/misc/blob/master/userscripts/lets_talk.user.js) this userscript brings all of the above modules together. First it grabs the microformats from the page using microformat-shiv. +Now for the final part, making the userscript. Inspired by [Ryan Barret](https://snarfed.org/) and his userscript [Let's Talk,](https://github.com/snarfed/misc/blob/master/userscripts/lets_talk.user.js) this userscript brings all of the above modules together. First it grabs the microformats from the page using microformat-shiv. For some reason, when I tried filtering it by ‘h-card’ it froze my computer. So I wrote my own little filter instead. @@ -249,7 +248,7 @@ After I grab the representative h-card from the page using the little module I w The link is actually a [data uri](https://developer.mozilla.org/en-US/docs/Web/HTTP/data_URIs) that has all of the information of the vCard encoded in it. Depending on your browser, once you click the link you might have to hit CTRL-S to save. -

+```javascript
 /*
    show-vCard - v0.1.0
    Copyright (c) 2015 Brandon Rozek
@@ -257,8 +256,8 @@ The link is actually a [data uri](https://developer.mozilla.org/en-US/docs/Web/H
 */
 var filterMicroformats = function(items, filter) {
 	var newItems = [];
-	for (var i = 0; i < items.items.length; i++) {
-		for (var k = 0; k < items.items[i].type.length; k++) {
+	for (var i = 0; i < items.items.length; i++) {
+		for (var k = 0; k < items.items[i].type.length; k++) {
 			if (filter.indexOf(items.items[i].type[k]) != -1) {
 				newItems.push(items.items[i]);
 			}
@@ -306,16 +305,16 @@ var render = function() {
 document.addEventListener("DOMContentLoaded", function() {
 	render();
 });
-
+``` -Sadly, I have no way of controlling the file name when you save it so you’ll have to manually rename it to something more meaningful than a random string of characters. Also remember to add the extension ‘.vcf’ for it to be recognized by some devices. +Sadly, I have no way of controlling the file name when you save it so you'll have to manually rename it to something more meaningful than a random string of characters. Also remember to add the extension ‘.vcf’ for it to be recognized by some devices. ### Conclusion -Fire up your favorite userscript handling tool and add the [script](https://gist.github.com/brandonrozek/e0153b2733e947fa9c87) in! Of course, since it’s pure JavaScript, you can also add it to your own site to serve the same purpose. +Fire up your favorite userscript handling tool and add the [script](https://gist.github.com/brandonrozek/e0153b2733e947fa9c87) in! Of course, since it's pure JavaScript, you can also add it to your own site to serve the same purpose. -I ran into a small problem loading a contact onto my Android 5.0.2 phone. Apparently, they don’t support vCard 4.0 yet so I had to go into the file and change the line that says “VERSION 4.0” to “VERSION 3.0” which then allowed me to import the file into my contacts. +I ran into a small problem loading a contact onto my Android 5.0.2 phone. Apparently, they don't support vCard 4.0 yet so I had to go into the file and change the line that says “VERSION 4.0” to “VERSION 3.0” which then allowed me to import the file into my contacts. As with all the code I write, feel free to comment/criticize. I love hearing feedback so if you spot anything, [contact me](mailto:brozek@brandonrozek.com) 🙂 -Also posted on [IndieNews](http://news.indiewebcamp.com/en){.u-syndication} \ No newline at end of file +Also posted on [IndieNews](http://news.indiewebcamp.com/en){.u-syndication} diff --git a/content/blog/2017-03-07-uniformity-math-random.md b/content/blog/2017-03-07-uniformity-math-random.md index bb6bf64..fe4d2a2 100644 --- a/content/blog/2017-03-07-uniformity-math-random.md +++ b/content/blog/2017-03-07-uniformity-math-random.md @@ -31,7 +31,7 @@ HA: The random numbers outputted do not follow the uniform distribution I wrote a small [website](http://share.zeropointshift.com/files/2017/03/random.html) and obtained my data by getting the CSV outputted when I use IE11, Firefox, and Chrome. -The website works by producing a random number using Math.random() between 1 and 1000 inclusive and calls the function 1,000,000 times. Storing it’s results in a file +The website works by producing a random number using `Math.random()` between 1 and 1000 inclusive and calls the function 1,000,000 times. Storing its results in a file This website produces a file with all the numbers separated by a comma. We want these commas to be replaced by newlines. To do so, we can run a simple command in the terminal @@ -45,13 +45,13 @@ Here are a copy of my files for [Firefox](https://brandonrozek.com/wp-content/up ## Check Conditions -Since we’re interested in if the random values occur uniformly, we need to perform a Chi-Square test for Goodness of Fit. With every test comes some assumptions +Since we're interested in if the random values occur uniformly, we need to perform a Chi-Square test for Goodness of Fit. With every test comes some assumptions -Counted Data Condition: The data can be converted from quantatative to count data. +**Counted Data Condition:** The data can be converted from quantatative to count data. -Independence Assumption: One random value does not affect another. +**Independence Assumption:** One random value does not affect another. -Expected Cell Frequency Condition: The expected counts are going to be 10000 +**Expected Cell Frequency Condition:** The expected counts are going to be 10000 Since all of the conditions are met, we can use the Chi-square test of Goodness of Fit diff --git a/content/blog/2017-05-24-viewing-java-applets.md b/content/blog/2017-05-24-viewing-java-applets.md index a370290..c41560a 100644 --- a/content/blog/2017-05-24-viewing-java-applets.md +++ b/content/blog/2017-05-24-viewing-java-applets.md @@ -18,13 +18,14 @@ tags: ["Java"] --- When you use an IDE there are many things you can take for granted. A section of an intro level computer science course at my university uses [JGrasp](http://www.jgrasp.org/) to build Java Applets. -Following around using a normal text editor, I found that I couldn’t just compile and run the code like I have with my java programs in the past. To be able to help around and assist in the course, I need to be able to build and run these applications. The rest of this article describes the process I underwent to be able to use my existing setup to write and build java applets. Of course you can always install JGrasp and have that all built in, but it’s always nice to not have to change your workflow. - - +Following around using a normal text editor, I found that I couldn't just compile and run the code like I have with my java programs in the past. To be able to help around and assist in the course, I need to be able to build and run these applications. The rest of this article describes the process I underwent to be able to use my existing setup to write and build java applets. Of course you can always install JGrasp and have that all built in, but it's always nice to not have to change your workflow. When I tried following along, I would receive the following error +``` Main method not found in class HelloWorld, please define main method as... +``` + Which makes sense since I have never defined a main method inside my source code. So how do I go about doing this? @@ -32,20 +33,20 @@ Which makes sense since I have never defined a main method inside my source code Java Applets are meant to run on web pages, because of this one needs an html file to host the applet. The following code gives you the bare minimum for setting up the html file. I called it `HelloWorld.html`. -

-<html>
-    <head><title>Applet Container<title>
-    <body>
-        <applet code='HelloWorld.class' width=400 height=400></applet>
-    </body>
-</html>
-
+```html +; + Applet Container + + + + +``` ## Hello World Program To get it up and running, I will show a “Hello World” like application for applets. -

+```java
 import javax.swing.JApplet;
 import java.awt.Graphics;
 
@@ -54,18 +55,22 @@ public class HelloWorld extends JApplet {
         g.drawString("Hello World", 30, 30);
     }
 } 
-
+``` ## Running the Applet Now we need to compile the code -
javac HelloWorld.java
+```bash +javac HelloWorld.java +``` Then run the appletviewer -
appletviewer HelloWorld.html
+```bash +appletviewer HelloWorld.html +``` ## Conclusion -This tutorial concludes the setup of running a simple Java applet. From here you can look at the different methods in the [Graphics library](https://docs.oracle.com/javase/7/docs/api/java/awt/Graphics.html) and play around 😀 \ No newline at end of file +This tutorial concludes the setup of running a simple Java applet. From here you can look at the different methods in the [Graphics library](https://docs.oracle.com/javase/7/docs/api/java/awt/Graphics.html) and play around 😀 diff --git a/content/blog/2017-06-05-java-swing-components.md b/content/blog/2017-06-05-java-swing-components.md index 665610f..5dbe6c8 100644 --- a/content/blog/2017-06-05-java-swing-components.md +++ b/content/blog/2017-06-05-java-swing-components.md @@ -22,41 +22,43 @@ This post, over time, will serve as a reference to myself and others of the diff Buttons are created using the JButton component. The constructor takes the text placed inside the button. -

+```java
 JButton stopBtn = new JButton("Stop");
-
+``` + +![](https://brandonrozek.com/wp-content/uploads/2017/06/stopbutton.png) - You can also add images inside a button. To do that you need to get the image and make it into an icon. The following code grabs the image file “smallpanda.jpg” from the current working directory. -

+```java
 Image img = this.getImage(this.getCodeBase(), "smallpanda.jpg");
 ImageIcon imgIcon = new ImageIcon(img);
 JButton feedBtn = new JButton("Feed", imgIcon);
-
+``` Sometimes, you want to change the location of the text in the button. Like say, we want to place the text in the center horizontally and bottom vertically. -

+```java
 feedBtn.setHorizontalTextPosition(JButton.CENTER);
 feedBtn.setVerticalTextPosition(JButton.BOTTOM);
-
+``` -Don’t forget to add your buttons to the screen! +Don't forget to add your buttons to the screen! -

+```java
 this.add(stopBtn);
 this.add(feedBtn);
-
+``` + +![](https://brandonrozek.com/wp-content/uploads/2017/06/smallpandabutton.png) - ### Labels and Textfields One of the most common forms of input is a text field, usually distinguished with a label. Those components are called JTextField and JLabel respectively. The constructor for JTextArea can take just the width of the text field, or another common use is to have already inputed text and its width. -

+```java
     JLabel nameLabel = new JLabel("Enter in your name: ");
 
     // Create an input and set the width to be 10px wide
@@ -67,28 +69,30 @@ One of the most common forms of input is a text field, usually distinguished wit
     
     this.add(nameLabel);
     this.add(nameInput);
-
+``` + +![](https://brandonrozek.com/wp-content/uploads/2017/06/labeltextfield.png) - ### Checkboxes Checkboxes are commonly used when giving the possibility for multiple answers. Such as, check all of the foods that you like. -

+```java
     JCheckBox pizza = new JCheckBox("Pizza");
     JCheckBox noodles = new JCheckBox("Noodles");
     JCheckBox rice = new JCheckBox("Rice");
     this.add(pizza);
     this.add(noodles);
     this.add(rice);
-
+``` - +![](https://brandonrozek.com/wp-content/uploads/2017/06/checkboxes.png) -You can even replace the default look of the checkbox with an image. To do this, you need to make image icons for both when it’s checked and when it’s unchecked. -

+You can even replace the default look of the checkbox with an image. To do this, you need to make image icons for both when it's checked and when it's unchecked.
+
+```java
 Image checkedImage = this.getImage(this.getCodeBase(), "checked.png");
 Image uncheckedImage = this.getImage(this.getCodeBase(), "unchecked.png");
 
@@ -99,32 +103,33 @@ JCheckBox checkbox = new JCheckBox("Check Me", uncheckedIcon);
 checkbox.setSelectedIcon(checkedIcon);
 
 this.add(checkbox);
-
+``` + +![](https://brandonrozek.com/wp-content/uploads/2017/06/unchecked.png) +![](https://brandonrozek.com/wp-content/uploads/2017/06/checked.png) - - ### Text Areas -Text Areas are different from text fields in which it is made to be able to hold multiple lines of text. It’s called JTextArea and its construction takes a width and height as it’s arguments. +Text Areas are different from text fields in which it is made to be able to hold multiple lines of text. It's called JTextArea and its construction takes a width and height as it's arguments. -

+```java
 JTextArea textarea = new JTextArea(10, 10);
-
+``` -By default, when the someone inputs more text than the size can hold, it will automatically grow with the text inputted. To override this behaviour and instead introuduce scroll bars. One must define a ScrollPane and put the TextArea inside of it by using it as the scroll pane’s argument for its constructor. +By default, when the someone inputs more text than the size can hold, it will automatically grow with the text inputted. To override this behaviour and instead introuduce scroll bars. One must define a ScrollPane and put the TextArea inside of it by using it as the scroll pane's argument for its constructor. -

+```java
 JScrollPane scrollPane = new JScrollPane(textarea);
-
+``` - +![](https://brandonrozek.com/wp-content/uploads/2017/06/textarea.png) ### Radio Buttons Radio buttons are used for when you only want one out of many different options to be selected. For this, one needs to define a button group that houses the radio buttons for the user to choose from. This can be achieved with ButtonGroup and JRadioButton respectively. -

+```java
 // Make the radio buttons
 JRadioButton radio1 = new JRadioButton("Pies");
 JRadioButton radio2 = new JRadioButton("Cakes");
@@ -140,55 +145,56 @@ desserts.add(radio3);
 this.add(radio1);
 this.add(radio2);
 this.add(radio3);
-
+``` + +![](https://brandonrozek.com/wp-content/uploads/2017/06/radiobuttons.png) - ### JList -To display a list of items that are clickable by the user, you can use a `JList`. JLists require a model that stores the list implementation, we’ll use `DefaultListModel` to achieve this purpose. +To display a list of items that are clickable by the user, you can use a `JList`. JLists require a model that stores the list implementation, we'll use `DefaultListModel` to achieve this purpose. -

+```java
 DefaultListModel model = new DefaultListModel();
 JList list = new JList(model);
-
+``` To add scrolling capabilities, remember to add it to a scroll pane -

+```java
 JScollPane sp = new JScrollPane(list);
-
+``` You can set the number of items you wish to see in the list. The example below, allows us to see three items in the list. -

+```java
 list.setVisibleRowCount(3);
-
+``` There are a variety of ways to add items to the list. If a number is specified that tells it to place it at the index specified. Starting from the top at zero, to the button. -

+```java
 model.addElement("Apples")
 model.addElement("Cherries");
 model.addElement("Bananas");
 // Adds 'Oranges' to the top
 model.add(0, "Oranges");
-
+``` -Sometimes, you want to only let the user select one item. At the end, don’t forget to add the component to the screen! +Sometimes, you want to only let the user select one item. At the end, don't forget to add the component to the screen! -

+```java
 list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
 this.add(sp);
-
+``` - +![](https://brandonrozek.com/wp-content/uploads/2017/06/JList.png) ### JComboBox To create a dropdown list of different options, consider using a JComboBox. -

+```java
 JComboBox cb = new JComboBox();
 cb.addItem("Select Food Option");
 cb.addItem("Pizza");
@@ -197,6 +203,6 @@ cb.addItem("Hot Dog");
 cb.addItem("Steak");
 // Add it to the screen
 this.add(cb);
-
+``` - \ No newline at end of file +![](https://brandonrozek.com/wp-content/uploads/2017/06/JComboBox.png) diff --git a/content/blog/2017-06-05-using-system-themes-java-swing.md b/content/blog/2017-06-05-using-system-themes-java-swing.md index 37c0409..b46d0e6 100644 --- a/content/blog/2017-06-05-using-system-themes-java-swing.md +++ b/content/blog/2017-06-05-using-system-themes-java-swing.md @@ -24,12 +24,12 @@ The default theme for Java Swing components is a cross-platform theme called  In the init method of your java application, place the following code. -

+```java
 try {
     UIManager.setLookAndFeel(UIManager
                                .getSystemLookAndFeelClassName());
 } catch(Exception e) {}
-
+``` Here the application will attempt to look up the system theme and set that as the default styles for the Swing components. If the lookup fails, then it will default back to the metal theme. @@ -37,6 +37,6 @@ For more information, check out this page from [Oracle](http://docs.oracle.com/j ### Discussion -If it is so easy to set up applications that look native to each desktop environment, why not have that by default? With the cross platform metal theme, you can ensure that the style of your application is the same across all the operating systems. In this fashion, you don’t need to worry about spacing between components and have full control of the “look and feel” of your application. +If it is so easy to set up applications that look native to each desktop environment, why not have that by default? With the cross platform metal theme, you can ensure that the style of your application is the same across all the operating systems. In this fashion, you don't need to worry about spacing between components and have full control of the “look and feel” of your application. -Since I am used to development for the web, I don’t have strong motivation to have an application look the same on all platforms. I prefer the application to match the system theme and look like it was built for the platform that I am on. One loses partial control on the presentation of your application across different desktop environmnets, but with a strong layout, it is possible to make it look organized and integrated. \ No newline at end of file +Since I am used to development for the web, I don't have strong motivation to have an application look the same on all platforms. I prefer the application to match the system theme and look like it was built for the platform that I am on. One loses partial control on the presentation of your application across different desktop environmnets, but with a strong layout, it is possible to make it look organized and integrated. diff --git a/content/blog/2018-01-22-identifying-misspelled-words-dataset-hunspell.md b/content/blog/2018-01-22-identifying-misspelled-words-dataset-hunspell.md index 5f0ff29..65afd61 100644 --- a/content/blog/2018-01-22-identifying-misspelled-words-dataset-hunspell.md +++ b/content/blog/2018-01-22-identifying-misspelled-words-dataset-hunspell.md @@ -14,7 +14,7 @@ mf2_syndication: - 'a:1:{i:0;s:60:"https://twitter.com/B_RozekJournal/status/955308388384235521";}' tags: [] --- -This article is based on one written by [Markus Konrad](https://datascience.blog.wzb.eu/author/markus_konrad/) at this link https://datascience.blog.wzb.eu/2016/07/13/autocorrecting-misspelled-words-in-python-using-hunspell/ +This article is based on one written by [Markus Konrad](https://datascience.blog.wzb.eu/author/markus_konrad/) at this link [https://datascience.blog.wzb.eu/2016/07/13/autocorrecting-misspelled-words-in-python-using-hunspell/](https://datascience.blog.wzb.eu/2016/07/13/autocorrecting-misspelled-words-in-python-using-hunspell/). I assume in this article that you have hunspell and it's integration with python installed. If not, please refer to the article mention above and follow the prerequisite steps. @@ -24,8 +24,10 @@ This article is inspired from the need to correct misspelled words in the [Dress Misspelled words are common when dealing with survey data or data where humans type in the responses manually. In the Dress Attributes Dataset this is apparent when looking at the sleeve lengths of the different dresses. -
dresses_data['SleeveLength'].value_counts()
-
+```python +dresses_data['SleeveLength'].value_counts() +``` + | Word | Frequency | | -------------- | --------- | @@ -45,7 +47,7 @@ Misspelled words are common when dealing with survey data or data where humans t | turndowncollor | 1 | | sleveless | 1 | | butterfly | 1 | -| threequater | 1 |
+| threequater | 1 | Ouch, so many misspelled words. This is when my brain is racking up all the ways I can automate this problem away. Hence my stumbling upon Markus' post. @@ -55,20 +57,22 @@ First, I decided to completely ignore what Markus warns in his post and automati To begin the code, let's import and create an instance of the spellchecker: -
from hunspell import HunSpell
-spellchecker = HunSpell('/usr/share/hunspell/en_US.dic', '/usr/share/hunspell/en_US.aff')
-
+```python +from hunspell import HunSpell +spellchecker = HunSpell('/usr/share/hunspell/en_US.dic', '/usr/share/hunspell/en_US.aff') +``` I modified his `correct_words` function so that it only corrects one word and so I can `apply` it along the `SleeveLength` column. -
def correct_word(checker, word, add_to_dict=[]):
+```python
+def correct_word(checker, word, add_to_dict=[]):
     "Takes in a hunspell object and a word and corrects the word if needed"   
     # Add custom words to the dictionary
     for w in add_to_dict:
         checker.add(w)
 
     corrected = ""
-    # Check to see if it's a string
+    # Check to see if it's a string
     if isinstance(word, str):
         # Check the spelling
         ok = checker.spell(word)
@@ -89,15 +93,17 @@ I modified his `correct_words` function so that it only corrects one word and so
         ## Not a string. Return original
         corrected = word
     return corrected
-
+``` Now let's apply the function over the `SleeveLength` column of the dataset: -
dresses_data['SleeveLength'] = dresses_data['SleeveLength'].apply(
-    lambda x: correct_word(spellchecker, x))
-
+```python +dresses_data['SleeveLength'] = dresses_data['SleeveLength'].apply( + lambda x: correct_word(spellchecker, x) +) +``` -Doing so creates the following series:
+Doing so creates the following series: | Word | Frequency | | -------------- | --------- | @@ -114,7 +120,7 @@ Doing so creates the following series:
| turndowncollor | 1 | | half | 1 | | landownership | 1 | -| forequarter | 1 |
+| forequarter | 1 | As you might be able to tell, this process didn't go as intended. `landownership` isn't even a length of a sleeve! @@ -124,7 +130,8 @@ This is when I have to remember, technology isn't perfect. Instead we should rel Keeping that in mind, I modified the function again to take in a list of the data, and return a dictionary that has the misspelled words as the keys and suggestions as the values represented as a list. -
def list_word_suggestions(checker, words, echo = True, add_to_dict=[]):
+```python
+def list_word_suggestions(checker, words, echo = True, add_to_dict=[]):
     "Takes in a list of words and returns a dictionary with mispellt words as keys and suggestions as a list. Also prints it out"
     # add custom words to the dictionary
     for w in add_to_dict:
@@ -141,34 +148,37 @@ Keeping that in mind, I modified the function again to take in a list of the dat
                 elif echo:
                     print(word + ": " + "[", ", ".join(repr(i) for i in suggestions[word]), "]")
     return suggestions
-
+``` With that, I can use the function on my data. To do so, I convert the pandas values to a list and pass it to the function: -
s = list_word_suggestions(spellchecker, dresses_data['SleeveLength'].values.tolist())
-
+```python +s = list_word_suggestions(spellchecker, dresses_data['SleeveLength'].values.tolist()) +``` These are the suggestions it produces: -
sleevless: [ 'sleeveless', 'sleepless', 'sleeves', 'sleekness', 'sleeve', 'lossless' ]
-threequarter: [ 'three quarter', 'three-quarter', 'forequarter' ]
-halfsleeve: ['half sleeve', 'half-sleeve', 'sleeveless' ]
+```
+sleevless: [ 'sleeveless', 'sleepless', 'sleeves', 'sleekness', 'sleeve', 'lossless' ]
+threequarter: [ 'three quarter', 'three-quarter', 'forequarter' ]
+halfsleeve: ['half sleeve', 'half-sleeve', 'sleeveless' ]
 turndowncollor: No suggestions
-threequater: [ 'forequarter' ]
-capsleeves: [ 'cap sleeves', 'cap-sleeves', 'capsules' ]
-sleeevless: [ 'sleeveless', 'sleepless', 'sleeves', 'sleekness', 'sleeve' ]
-urndowncollor: [ 'landownership' ]
-thressqatar: [ 'throatiness' ]
-sleveless: [ 'sleeveless', 'levelness', 'valveless', 'loveless', 'sleepless' ]
-
+threequater: [ 'forequarter' ] +capsleeves: [ 'cap sleeves', 'cap-sleeves', 'capsules' ] +sleeevless: [ 'sleeveless', 'sleepless', 'sleeves', 'sleekness', 'sleeve' ] +urndowncollor: [ 'landownership' ] +thressqatar: [ 'throatiness' ] +sleveless: [ 'sleeveless', 'levelness', 'valveless', 'loveless', 'sleepless' ] +``` From here, you can analyze the output and do the replacements yourself: -
dresses_data['SleeveLength'].replace('sleevless', 'sleeveless', inplace = True)
-
+```python +dresses_data['SleeveLength'].replace('sleevless', 'sleeveless', inplace = True) +``` ### What's the Benefit? This is where you ask "What's the difference if it doesn't automatically fix my data?" -When you have large datasets, it can be hard to individually identify which items are misspelled. Using this method will allow you to have a list of all the items that are misspelled which can let you deal with it in a systematic way. \ No newline at end of file +When you have large datasets, it can be hard to individually identify which items are misspelled. Using this method will allow you to have a list of all the items that are misspelled which can let you deal with it in a systematic way. diff --git a/content/blog/abstractdef.md b/content/blog/abstractdef.md index c761611..9683b7d 100644 --- a/content/blog/abstractdef.md +++ b/content/blog/abstractdef.md @@ -71,9 +71,9 @@ An ideal $J$ of a commutative ring is said to be a **prime ideal** if for any tw $$ ab \in J \implies a \in J \text{ or } b \in J $$ -Theorem: If $J$ is a prime ideal of a community ring with unity $A$, then the quotient ring $A / J$ is an integral domain. +**Theorem:** If $J$ is a prime ideal of a community ring with unity $A$, then the quotient ring $A / J$ is an integral domain. An ideal $J$ of $A$ with $J \ne A$ is called a **maximal ideal** if there exists no proper ideal $K$ of $A$ such that $J \subseteq K$ with $J \ne K$. -Theorem: If $A$ is a commutative ring with unity, then $J$ is a maximal ideal of $A$ iff $A/J$ is a field. +**Theorem:** If $A$ is a commutative ring with unity, then $J$ is a maximal ideal of $A$ iff $A/J$ is a field. diff --git a/content/blog/albuquerque.md b/content/blog/albuquerque.md index d8a288d..167a2de 100644 --- a/content/blog/albuquerque.md +++ b/content/blog/albuquerque.md @@ -76,31 +76,31 @@ coefficients of CUST2 and the y-intercept. ##### Checking the Conditions for Inference Before we conclude with the analysis, we must first check the conditions for inference to see if the technique is appropriate for our data. -Independence Assumption: +**Independence Assumption:** A house’s selling price can depend on another’s so this condition is not met. -Randomization Condition: +**Randomization Condition:** The dataset is comprised of a random sample of records of resale of homes which satisfies the randomization condition. -Straight Enough Condition: +**Straight Enough Condition:** The scatterplot matrix in Figure 20 shows that for the predictors square footage and tax that the scatterplot is straight enough and doesn’t have any bends or curves. -Equal Variance Assumption: +**Equal Variance Assumption:** The residual analysis in Figure 21 shows that the outliers are not spread equally on the scatterplot. Therefore, the equal variance assumption is not met. -Nearly Normal Condition: +**Nearly Normal Condition:** The QQ-Plot in Figure 21 shows that the residuals follow a unimodal and symmetric distribution. Taking out the outliers in the model also did not introduce any new outliers in the boxplot. -Missing At Random Condition: +**Missing At Random Condition:** 7The discussion in the descriptive statistics section about the missing data tells us that the data is missing evenly with respect to the different variables. Therefore, it is safe to assume that the data is missing at random -Multicollinearity Condition: +**Multicollinearity Condition:** All of the VIF values are lower than 10, therefore this condition is met. -The conditions for inference are not fully met due to the equal variance assumption. This means that our model will be more inaccurate for some price range of homes than others. Looking at our residual analysis, it appears that the inaccuracies happen when the price of the home is higher. There weren’t many outliers in the dataset (6 out of 117 or 5%) so removing these outliers makes the model more representative to the majority of the houses in the market. Since this model is intended to be used when analyzing prices of homes in the area, it is better not to include the outliers that most people don’t intend to buy. Since the error term is unimodal and symmetric, we can be at ease that there isn’t any other confounding factor in our model. Overall, this is a good model to use for inference and prediction as long as one doesn’t use it to describe the outliers. +The conditions for inference are not fully met due to the equal variance assumption. This means that our model will be more inaccurate for some price range of homes than others. Looking at our residual analysis, it appears that the inaccuracies happen when the price of the home is higher. There weren’t many outliers in the dataset (6 out of 117 or 5%) so removing these outliers makes the model more representative to the majority of the houses in the market. Since this model is intended to be used when analyzing prices of homes in the area, it is better not to include the outliers that most people don't intend to buy. Since the error term is unimodal and symmetric, we can be at ease that there isn’t any other confounding factor in our model. Overall, this is a good model to use for inference and prediction as long as one doesn’t use it to describe the outliers. ### Conclusion The multiple imputation model without outliers is the best model outlined in this paper for describing the price of housing in this region. The formula is re-expressed here PRICE = 76.47917 + 0.64130(TAX) + 0.27290(SQFT) + 77.58816(CUST2) -This states that for every dollar of tax spent on the home, the home increases on average by $64 given the other parameters stay constant. The same concept applies to square footage and custom design. For every square foot added to the home, the value of it increases on average by $27. Having a home with a custom design increases the value of the home by $7700. This model is more reliable the lower the price of the home is. When it comes to high cost homes, the error produced by the model increases. From this model, we conclude that property tax, square footage, and whether or not a home is built from a custom design are the most significant factors in the price of a home in Albuquerque, New Mexico. \ No newline at end of file +This states that for every dollar of tax spent on the home, the home increases on average by $64 given the other parameters stay constant. The same concept applies to square footage and custom design. For every square foot added to the home, the value of it increases on average by $27. Having a home with a custom design increases the value of the home by $7700. This model is more reliable the lower the price of the home is. When it comes to high cost homes, the error produced by the model increases. From this model, we conclude that property tax, square footage, and whether or not a home is built from a custom design are the most significant factors in the price of a home in Albuquerque, New Mexico. diff --git a/content/blog/introrfpoweramp.md b/content/blog/introrfpoweramp.md index 0b77d2d..8c0bedc 100644 --- a/content/blog/introrfpoweramp.md +++ b/content/blog/introrfpoweramp.md @@ -18,7 +18,7 @@ I opened up mini-circuits and was greeted with the following table. (Shorted for | LZV-22+ | 0.1 | 200 | 43 | 8.9 | 42 | 52 | 1.4 | 4 | 24 | 6000 | | ZHL-1W-63-S+ | 600 | 6000 | 35 | 12 | 30 | 35 | 2.5 | 3.5 | 15 | 1000 | -Definitions +### Definitions F Low: Lowest frequency supported by the power amplifier diff --git a/content/blog/male-vs-female-life-expectancy.md b/content/blog/male-vs-female-life-expectancy.md index 2755d5a..1442309 100644 --- a/content/blog/male-vs-female-life-expectancy.md +++ b/content/blog/male-vs-female-life-expectancy.md @@ -14,7 +14,6 @@ tags: ["Statistics"] It is well known that females live longer than males, but does that statement hold statistically? Matthew Martinez and I set out to find out. - ## Population and the hypothesis @@ -26,7 +25,7 @@ HA: The average female life expectancy is higher than the average male life expe ## Data preparation -Since the website gives us an overlook at all of the counties in the United States we want to take a small sample of that so we can perform statistics. Using the entire dataset will result in looking at population parameters which doesn’t leave room for inference. +Since the website gives us an overlook at all of the counties in the United States we want to take a small sample of that so we can perform statistics. Using the entire dataset will result in looking at population parameters which doesn't leave room for inference. A random number was chosen to pick the state and then the county. This was done a total of 101 times. The CSV file is located [here](https://brandonrozek.com/wp-content/uploads/2017/03/LifeExpectancy.csv) for convenience. @@ -46,9 +45,9 @@ femaleExpectancy = LifeExpectancy$Life.Expectancy.Female ## Summary Statistics -Before we begin our inferential statistics, it is a good idea to look at what we have in our sample. It will give us a good feeling for what we’re working with and help us answer some questions involving the assumptions in parametric tests. +Before we begin our inferential statistics, it is a good idea to look at what we have in our sample. It will give us a good feeling for what we're working with and help us answer some questions involving the assumptions in parametric tests. -We’re interested in the minimum, mean, maximum, and interquartile range of the data +We're interested in the minimum, mean, maximum, and interquartile range of the data ```R # Summary statistics @@ -65,7 +64,7 @@ Looking at the table below, we can see that the average male lives to be around summary ## Min Mean Max IQR ## Male 69.0 74.952 80.9 2.775 -## Female 76.1 80.416 84.1 2.350 +## Female 76.1 80.416 84.1 2.350 ``` ## Inferential Statistics @@ -78,11 +77,11 @@ Since our data is quantitative in nature, we will attempt to perform a two sampl Performing a t-test comes with several assumptions we need to check before confidently reporting our results. -Independence Condition: One county’s life span does not affect the lifespan of another. +**Independence Condition:** One county's life span does not affect the lifespan of another. -Independent groups assumption: The lifespan of a male does not directly impact a lifespan of a female. +**Independent groups assumption:** The lifespan of a male does not directly impact a lifespan of a female. -Nearly Normal Condition: We need to check the histograms to see if they’re unimodal and symmetric and check to see if any outliers exist +**Nearly Normal Condition:** We need to check the histograms to see if they're unimodal and symmetric and check to see if any outliers exist The male life expectancy distribution appears to be unimodal and symmetric. @@ -91,7 +90,7 @@ The male life expectancy distribution appears to be unimodal and symmetric. hist(maleExpectancy, main = "Male Life Expectancy", xlab = "Age") ``` - +![](https://brandonrozek.com/wp-content/uploads/2017/03/maleLifeExpectancyHist.png) Same with the female life expectancy distribution @@ -99,15 +98,16 @@ Same with the female life expectancy distribution hist(femaleExpectancy, main = "Female Life Expectancy", xlab = "Age") ``` - +![](https://brandonrozek.com/wp-content/uploads/2017/03/femaleLifeExpectancyHist.png) -Looking at the boxplot, we can see that the IQR of the female life expectancy is higher than the one of the males. The hypothesis test will show us if this is of significant difference. On the male’s side there are two outliers. This violates the Nearly Normal Condition so we must proceed with caution in our test. + +Looking at the boxplot, we can see that the IQR of the female life expectancy is higher than the one of the males. The hypothesis test will show us if this is of significant difference. On the male's side there are two outliers. This violates the Nearly Normal Condition so we must proceed with caution in our test. ```R boxplot(maleExpectancy, femaleExpectancy, names = c("Male Life Expectancy", "Female Life Expectancy"), ylab = "Age") ``` - +![](https://brandonrozek.com/wp-content/uploads/2017/03/LifeExpectancyBoxplot.png) Since the nearly normal condition was not met, we do not meet the assumptions necessary to perform a t-test. However, since the condition was violated by an outlier, let us perform a t-test with the outlier and without the outlier and compare the results. @@ -175,7 +175,7 @@ Looking at the boxplot, there are no more outliers present boxplot(maleExpectancy2, ylab = "Age", main = "Male Life Expectancy w/o Outliers") ``` - +![](https://brandonrozek.com/wp-content/uploads/2017/03/MLifeExpectBoxplotNoOutliers.png) The histogram still appears to be unimodal and symmetric @@ -183,7 +183,7 @@ The histogram still appears to be unimodal and symmetric hist(maleExpectancy2, xlab = "Age", main = "Male Life Expectancy w/o Outliers") ``` - +![](https://brandonrozek.com/wp-content/uploads/2017/03/MLifeExpectHistNoOutliers.png) Without the outliers present, the nearly normal condition is now met. We can perform the t-test. @@ -229,4 +229,4 @@ t.test(femaleExpectancy, maleExpectancy2) ## Conclusion -By running the tests and checking the effects of the outliers in the dataset and seeing that the results did not change, we can safely conclude that our interpretations stated before are correct. There is enough evidence to suggest that females in the United States live on average longer than males. We are 95% confident that they live longer than males by 5 to 6 years. \ No newline at end of file +By running the tests and checking the effects of the outliers in the dataset and seeing that the results did not change, we can safely conclude that our interpretations stated before are correct. There is enough evidence to suggest that females in the United States live on average longer than males. We are 95% confident that they live longer than males by 5 to 6 years. diff --git a/content/blog/rsynckey.md b/content/blog/rsynckey.md index 0107003..965ec5c 100644 --- a/content/blog/rsynckey.md +++ b/content/blog/rsynckey.md @@ -22,7 +22,7 @@ Quick option definitions (from man page) | Option | Description | | -------------- | ------------------------------------------------------------ | | -e | Allows you to override the default shell used as the transport for rsync. Command line options are permitted after the command name. | -| -a, --archive | This is equivalent to -rlptgoD. It is a quick way of saying you want recursion and want to preserve almost everything (with -H being a notable omission). The only exception to the above equivalence is when --files-from is specified, in which case -r is not implied.
Note that -a does not preserve hardlinks, because finding multiply-linked files is expensive. You must separately specify -H. | +| -a, --archive | This is equivalent to -rlptgoD. It is a quick way of saying you want recursion and want to preserve almost everything (with -H being a notable omission). The only exception to the above equivalence is when --files-from is specified, in which case -r is not implied. Note that -a does not preserve hardlinks, because finding multiply-linked files is expensive. You must separately specify -H. | | -P | Equivalent to --partial --progress. Its purpose is to make it much easier to specify these two options for a long transfer that may be interrupted. | | -z, --compress | Compress file data during the transfer | | --delete | Delete extraneous files from dest dirs | diff --git a/content/blog/simulators.md b/content/blog/simulators.md index 8037891..8117a94 100644 --- a/content/blog/simulators.md +++ b/content/blog/simulators.md @@ -9,7 +9,7 @@ Part of my job involves integrating multiple different sensors together to make Now since we're working with sensor data, it doesn't always make sense to need to be connected to a whole system. There's also the additional hassle of dealing with safety and working outside. So in order to do some programming and still be at ease that we didn't break anything, we make heavy use of simulators. -Example: Have a GPS hooked up to your system? Well with a tool you can make waypoints and generate a file which you then feed in as a fake GPS device! +**Example**: Have a GPS hooked up to your system? Well with a tool you can make waypoints and generate a file which you then feed in as a fake GPS device! Now when I say fake device, I don't mean I'm actually emulating the device on the machine. It's easier to have your device interfacers publish to the local network and have your other parts of the application subscribe to it. So in this case, you will just need to produce those messages directly. diff --git a/content/blog/sshconnectionsharing.md b/content/blog/sshconnectionsharing.md index 2e9e5e1..ae2fac3 100644 --- a/content/blog/sshconnectionsharing.md +++ b/content/blog/sshconnectionsharing.md @@ -18,7 +18,7 @@ ControlPath ~/.ssh/sockets/socket-%r@%h:%p | Option | Description | | ---------------- | ------------------------------------------------------------ | | `ControlMaster` | Allows connection sharing | -| `ControlPersist` | `yes` to keep connection up even when no clients are connected.
`2s` (or custom timeout) to keep the connection up for 2 seconds after no clients are connected.
`no` to disconnect immediately | +| `ControlPersist` | `yes` to keep connection up even when no clients are connected. `2s` (or custom timeout) to keep the connection up for 2 seconds after no clients are connected.`no` to disconnect immediately | | `ControlPath` | Where to store connection information. This should not be writable by other users. | diff --git a/content/notes/.Stat381.md.swp b/content/notes/.Stat381.md.swp deleted file mode 100644 index fb7c6e9..0000000 Binary files a/content/notes/.Stat381.md.swp and /dev/null differ diff --git a/content/notes/abstract2def.md b/content/notes/abstract2def.md index 4c1b755..8797912 100644 --- a/content/notes/abstract2def.md +++ b/content/notes/abstract2def.md @@ -71,9 +71,9 @@ An ideal $J$ of a commutative ring is said to be a **prime ideal** if for any tw $$ ab \in J \implies a \in J \text{ or } b \in J $$ -Theorem: If $J$ is a prime ideal of a community ring with unity $A$, then the quotient ring $A / J$ is an integral domain. +**Theorem:** If $J$ is a prime ideal of a community ring with unity $A$, then the quotient ring $A / J$ is an integral domain. An ideal $J$ of $A$ with $J \ne A$ is called a **maximal ideal** if there exists no proper ideal $K$ of $A$ such that $J \subseteq K$ with $J \ne K$. -Theorem: If $A$ is a commutative ring with unity, then $J$ is a maximal ideal of $A$ iff $A/J$ is a field. +**Theorem:** If $A$ is a commutative ring with unity, then $J$ is a maximal ideal of $A$ iff $A/J$ is a field. diff --git a/content/notes/algorithms/dynamic.md b/content/notes/algorithms/dynamic.md index f4b8efb..712983e 100644 --- a/content/notes/algorithms/dynamic.md +++ b/content/notes/algorithms/dynamic.md @@ -49,7 +49,7 @@ IterFibo(n): Here the linear complexity becomes super apparent! -Interesting snippet +*Interesting snippet* "We had a very interesting gentleman in Washington named Wilson. He was secretary of Defense, and he actually had a pathological fear and hatred of the word *research*. I’m not using the term lightly; I’m using it precisely. His face would suffuse, he would turn red, and he would get violent if people used the term *research* in his presence. You can imagine how he felt, then, about the term *mathematical*.... I felt I had to do something to shield Wilson and the Air Force from the fact that I was really doing mathematics inside the RAND Corporation. What title, what name, could I choose?" diff --git a/content/notes/dimensionalityreduction/optimalitycriteria.md b/content/notes/dimensionalityreduction/optimalitycriteria.md index f896a35..ae4a1ff 100644 --- a/content/notes/dimensionalityreduction/optimalitycriteria.md +++ b/content/notes/dimensionalityreduction/optimalitycriteria.md @@ -6,7 +6,7 @@ Falling under wrapper methods, optimality criterion are often used to aid in mod ## Akaike Information Criterion (AIC) -AIC is an estimator of relative quality of statistical models for a given set of data. Given a collection of models for the data, AIC estimates the quality of each model relative to each other. +AIC is an estimator of *relative<* quality of statistical models for a given set of data. Given a collection of models for the data, AIC estimates the quality of each model relative to each other. This way, AIC provides a means for model selection. AIC offers an estimate of the relative information lost when a given model is used. @@ -79,7 +79,7 @@ $$ ## Deviance Information Criterion -The DIC is a hierarchical modeling generalization of the AIC and BIC. it is useful in Bayesian model selection problems where posterior distributions of the model was obtained by a Markov Chain Monte Carlo simulation. +The DIC is a hierarchical modeling generalization of the AIC and BIC. it is useful in Bayesian model selection problems where posterior distributions of the model was *obtained by a Markov Chain Monte Carlo simulation*. This method is only valid if the posterior distribution is approximately multivariate normal. diff --git a/content/notes/quadraticcongruences.md b/content/notes/quadraticcongruences.md index c957286..2ae305f 100644 --- a/content/notes/quadraticcongruences.md +++ b/content/notes/quadraticcongruences.md @@ -6,7 +6,7 @@ math: true ## Number of Solutions -For congruences mod 2 +*For congruences mod 2* **Proposition 16.1**. Let $f(x) = ax^2 + bx + c$ with $a$ odd, and let $\Delta = b^2 - 4ac$ be the discriminant of $f(x)$. Then, diff --git a/content/notes/realanalysis.md b/content/notes/realanalysis.md index c8109a1..ed650c6 100644 --- a/content/notes/realanalysis.md +++ b/content/notes/realanalysis.md @@ -64,7 +64,7 @@ Let $s_1 > 0$ be arbitrary, and define $s_{n + 1} = \frac{1}{2}(s_n + \frac{a}{s **Corollary:** If $X = (x_n) \subseteq \mathbb{R}$ has a subsequence that diverges then $X$ diverges. -**Monotone Sequence Theorem**: If $X = (x_n) \subseteq \mathbb{R}$, then it contains a monotone subsequence. +**Monotone Sequence Theorem**: If $X = (x_n) \subseteq \mathbb{R}$, then it contains a *monotone subsequence*. **Bolzano-Weierstrass Theorem:** Every bounded sequence in $\mathbb{R}$ has a convergent subsequence. diff --git a/content/projects/mathio.md b/content/projects/mathio.md index 99aa6eb..201758a 100644 --- a/content/projects/mathio.md +++ b/content/projects/mathio.md @@ -7,16 +7,15 @@ layout: revision guid: http://brandonrozek.com/2016/10/362-revision-v1/ permalink: /2016/10/362-revision-v1/ --- -Screenshot of the Math I/O Website -### [Math I/O](http://math-io.com) {.project-title} +![Screenshot of the Math I/O Website](https://brandonrozek.com/wp-content/uploads/2016/10/Math-I-O.png) + +### [Math I/O](http://math-io.com) Math I/O is a website I founded with [David Thames](http://davidcthames.com) and Stephen Shamaiengar. The goal of this website is to help reinforce high school level math concepts in the form of enjoyable games. Most of the games are made using HTML5 Canvas and Javascript. You can check them out [here](http://math-io.com/). - - I ran Math I/O for a year until I moved away from the area. During that year, I worked on the Darts game, Speed Transformations, and Theta. I then took about a year off to get adjusted to my new place when I moved. While I was away, Math I/O gained many new people, making it hard for them to work as one large group. David then decided to split the group up into smaller teams, inviting me to come back and lead one. I never ran a team remotely before, so I was excited to see how it would be like. -The team I lead are mostly full of people starting out in programming. To help them out, I started giving lectures once a week to introduce concepts, and posted them here on my writings page. We would then practice these concepts while making a new game during the meetings. I couldn’t ask for a better team, their enthusiasm drives me to keep working at Math I/O. \ No newline at end of file +The team I lead are mostly full of people starting out in programming. To help them out, I started giving lectures once a week to introduce concepts, and posted them here on my writings page. We would then practice these concepts while making a new game during the meetings. I couldn't ask for a better team, their enthusiasm drives me to keep working at Math I/O. diff --git a/content/projects/sentenceworthy.md b/content/projects/sentenceworthy.md index 8fd70a4..85314ee 100644 --- a/content/projects/sentenceworthy.md +++ b/content/projects/sentenceworthy.md @@ -7,14 +7,10 @@ layout: revision guid: http://brandonrozek.com/2016/10/360-revision-v1/ permalink: /2016/10/360-revision-v1/ --- -SentenceWorthy +![](https://brandonrozek.com/wp-content/uploads/2016/10/SentenceWorthy.jpg) -### [Sentence Worthy](http://sentenceworthy.com) {.project-title} +### [Sentence Worthy](http://sentenceworthy.com) Sentence Worthy is a side project created by [Tori Dayton](http://toridayton.com) and I. We combine both of our passions, writing and photography, and make something for others to enjoy. Have a look at our [creation](http://sentenceworthy.com). - - I am the main developer and photographer of this site. I head out every so often and take pictures of whatever interests me. Then, I email Tori my choice picks and she tells me what she wants to do with the pictures and what ideas she has for them. I then edit the picture with her ideas in mind. After we go back and forth on the picture edits, Tori sends me a one sentence story she made that goes along with the picture. The picture and story then get published together onto the website. Hence the tagline, every picture is worth a sentence. - - \ No newline at end of file diff --git a/content/projects/toridayton.md b/content/projects/toridayton.md index eaa2d11..5d51417 100644 --- a/content/projects/toridayton.md +++ b/content/projects/toridayton.md @@ -7,12 +7,11 @@ layout: revision guid: http://brandonrozek.com/2016/10/364-revision-v1/ permalink: /2016/10/364-revision-v1/ --- -Screenshot of Tori Dayton's website + +![Screenshot of Tori Dayton's website](https://brandonrozek.com/wp-content/uploads/2016/10/Tori-Dayton-1.png) ### [Tori Dayton](http://toridayton.com) {.project-title} -Tori Dayton is a great friend and poet, this is the site I made for her to showcase her writings. It’s the first WordPress project I worked on and it set the tone for all the future ones I did. Check out her [writings!](http://toridayton.com/work) I’m a fan of her work. (Not biased at all) - - +Tori Dayton is a great friend and poet, this is the site I made for her to showcase her writings. It's the first WordPress project I worked on and it set the tone for all the future ones I did. Check out her [writings!](http://toridayton.com/work) I'm a fan of her work. (Not biased at all) Fun Fact: I also worked on the [Tori Bot](http://toridayton.com/category/tori-bot/) on the site. Tori Bot takes existing poems and tries to generate a new one using the [Natural Language Toolkit](http://www.nltk.org/) library made for Python. \ No newline at end of file diff --git a/content/research/clusteranalysis/notes/lec1.md b/content/research/clusteranalysis/notes/lec1.md index a1bbd11..c409cce 100644 --- a/content/research/clusteranalysis/notes/lec1.md +++ b/content/research/clusteranalysis/notes/lec1.md @@ -24,11 +24,11 @@ An extensive list of similarity measures for binary data exist, the reason for s In some cases, zero-zero matches are equivalent to one-one matches and therefore should be included in the calculated similarity measure -Example: Gender, where there is no preference as to which of the two categories should be coded as zero or one +**Example**: Gender, where there is no preference as to which of the two categories should be coded as zero or one In other cases the inclusion or otherwise of the matches is more problematic -Example: When the zero category corresponds to the genuine absence of some property, such as wings in a study of insects +**Example**: When the zero category corresponds to the genuine absence of some property, such as wings in a study of insects The question that then needs to be asked is do the co-absences contain useful information about the similarity of the two objects? @@ -152,7 +152,7 @@ Since for correlation coefficients we have that $-1 \le \phi_{ij} \le 1$ with th The use of correlation coefficients in this context is far more contentious than its noncontroversial role in assessing the linear relationship between two variables based on $n$ observations. -When correlations between two individuals are used to quantify their similarity the rows of the data matrix are standardized, not its columns. +When correlations between two individuals are used to quantify their similarity the *rows of the data matrix are standardized*, not its columns. **Disadvantages** @@ -164,7 +164,7 @@ In addition, the correlation coefficient is unable to measure the difference in However, the use of a correlation coefficient can be justified for situations where all of the variables have been measured on the same scale and precise values taken are important only to the extent that they provide information about the subject's relative profile -Example: In classifying animals or plants, the absolute size of the organisms or their parts are often less important than their shapes. In such studies the investigator requires a dissimilarity coefficient that takes the value zero if and only if two individuals' profiles are multiples of each other. The angular separation dissimilarity measure has this property. +**Example:** In classifying animals or plants, the absolute size of the organisms or their parts are often less important than their shapes. In such studies the investigator requires a dissimilarity coefficient that takes the value zero if and only if two individuals' profiles are multiples of each other. The angular separation dissimilarity measure has this property. **Further considerations** @@ -271,25 +271,26 @@ By also employing within-group correlations, the Mahalanobis distance takes acco The use of Mahalanobis implies that the investigator is willing to **assume** that the covariance matrices are at least approximately the same in the two groups. When this is not so, this measure is an inappropriate inter-group measure. Other alternatives exist such as the one proposed by Anderson and Bahadur -equation +![](http://proquest.safaribooksonline.com.ezproxy.umw.edu/getfile?item=cjlhZWEzNDg0N2R0cGMvaS9zMG1nODk0czcvN3MwczM3L2UwLXMzL2VpL3RtYTBjMGdzY2QwLmkxLWdtaWY-) Another alternative is the *normal information radius* suggested by Jardine and Sibson -equation +![](http://proquest.safaribooksonline.com.ezproxy.umw.edu/getfile?item=cjlhZWEzNDg0N2R0cGMvaS9zMG1nODk0czcvN3MwczM4L2UwLXMzL2VpL3RtYTBjMGdzY2QwLmkxLWdtaWY-) + ### Inter-group Proximity Based on Group Summaries for Categorical Data Approaches for measuring inter-group dissimilarities between groups of individuals for which categorical variables have been observed have been considered by a number of authors. Balakrishnan and Sanghvi (1968), for example, proposed a dissimilarity index of the form -![equation](http://proquest.safaribooksonline.com.ezproxy.umw.edu/getfile?item=cjlhZWEzNDg0N2R0cGMvaS9zMG1nODk0czcvN3MwczMwL2UwLXMzL2VpL3RtYTBjMGdzY2QwLmkyLWdtaWY-) +![](http://proquest.safaribooksonline.com.ezproxy.umw.edu/getfile?item=cjlhZWEzNDg0N2R0cGMvaS9zMG1nODk0czcvN3MwczMwL2UwLXMzL2VpL3RtYTBjMGdzY2QwLmkyLWdtaWY-) -where $p_{Akl}$ and $p_{Bkl}$ are the proportions of the lth category of the kth variable in group A and B respectively, ![img](http://proquest.safaribooksonline.com.ezproxy.umw.edu/getfile?item=cjlhZWEzNDg0N2R0cGMvaS9zMG1nODk0czcvN3MwczNmL2VnMi8zbGVpL3RtYTBjbmdzaWUuMGlpbg--), ck + 1 is the number of categories for the kth variable and p is the number of variables. +where $p_{Akl}$ and $p_{Bkl}$ are the proportions of the lth category of the kth variable in group A and B respectively, ![](http://proquest.safaribooksonline.com.ezproxy.umw.edu/getfile?item=cjlhZWEzNDg0N2R0cGMvaS9zMG1nODk0czcvN3MwczNmL2VnMi8zbGVpL3RtYTBjbmdzaWUuMGlpbg--), ck + 1 is the number of categories for the kth variable and p is the number of variables. Kurczynski (1969) suggested adapting the generalized Mahalanobis distance, with categorical variables replacing quantitative variables. In its most general form, this measure for inter-group distance is given by -![equation](http://proquest.safaribooksonline.com.ezproxy.umw.edu/getfile?item=cjlhZWEzNDg0N2R0cGMvaS9zMG1nODk0czcvN3MwczMxL2UwLXMzL2VpL3RtYTBjMGdzY2QwLmkyLWdtaWY-) +![](http://proquest.safaribooksonline.com.ezproxy.umw.edu/getfile?item=cjlhZWEzNDg0N2R0cGMvaS9zMG1nODk0czcvN3MwczMxL2UwLXMzL2VpL3RtYTBjMGdzY2QwLmkyLWdtaWY-) -where ![img](http://proquest.safaribooksonline.com.ezproxy.umw.edu/getfile?item=cjlhZWEzNDg0N2R0cGMvaS9zMG1nODk0czcvN3MwczNmL2VnMy8zbGVpL3RtYTBjbmdzaWUuMGlpbg--) contains sample proportions in group A and ![img](http://proquest.safaribooksonline.com.ezproxy.umw.edu/getfile?item=cjlhZWEzNDg0N2R0cGMvaS9zMG1nODk0czcvN3MwczNmL2VnNC8zbGVpL3RtYTBjbmdzaWUuMGlpbg--) is defined in a similar manner, and ![img](http://proquest.safaribooksonline.com.ezproxy.umw.edu/getfile?item=cjlhZWEzNDg0N2R0cGMvaS9zMG1nODk0czcvN3MwczNmL2VnNS8zbGVpL3RtYTBjbmdzaWUuMGlpbg--) is the m × m common sample covariance matrix, where ![img](http://proquest.safaribooksonline.com.ezproxy.umw.edu/getfile?item=cjlhZWEzNDg0N2R0cGMvaS9zMG1nODk0czcvN3MwczNmL2VnNi8zbGVpL3RtYTBjbmdzaWUuMGlpbg--). +where ![](http://proquest.safaribooksonline.com.ezproxy.umw.edu/getfile?item=cjlhZWEzNDg0N2R0cGMvaS9zMG1nODk0czcvN3MwczNmL2VnMy8zbGVpL3RtYTBjbmdzaWUuMGlpbg--) contains sample proportions in group A and ![](http://proquest.safaribooksonline.com.ezproxy.umw.edu/getfile?item=cjlhZWEzNDg0N2R0cGMvaS9zMG1nODk0czcvN3MwczNmL2VnNC8zbGVpL3RtYTBjbmdzaWUuMGlpbg--) is defined in a similar manner, and ![](http://proquest.safaribooksonline.com.ezproxy.umw.edu/getfile?item=cjlhZWEzNDg0N2R0cGMvaS9zMG1nODk0czcvN3MwczNmL2VnNS8zbGVpL3RtYTBjbmdzaWUuMGlpbg--) is the m × m common sample covariance matrix, where ![](http://proquest.safaribooksonline.com.ezproxy.umw.edu/getfile?item=cjlhZWEzNDg0N2R0cGMvaS9zMG1nODk0czcvN3MwczNmL2VnNi8zbGVpL3RtYTBjbmdzaWUuMGlpbg--). ## Weighting Variables diff --git a/content/research/clusteranalysis/notes/lec5.md b/content/research/clusteranalysis/notes/lec5.md index cb42cb5..417b515 100644 --- a/content/research/clusteranalysis/notes/lec5.md +++ b/content/research/clusteranalysis/notes/lec5.md @@ -11,9 +11,9 @@ Hierarchal Clustering techniques can be subdivided depending on the method of go First there are two different methods in forming the clusters *Agglomerative* and *Divisive* -Agglomerative is when you combine the n individuals into groups through each iteration +**Agglomerative** is when you combine the n individuals into groups through each iteration -Divisive is when you are separating one giant group into finer groupings with each iteration. +**Divisive** is when you are separating one giant group into finer groupings with each iteration. Hierarchical methods are an irrevocable algorithm, once it joins or separates a grouping, it cannot be undone. As Kaufman and Rousseeuw (1990) colorfully comment: *"A hierarchical method suffers from the defect that it can never repair what was done in previous steps"*. diff --git a/content/research/progcomp/numbertheory.md b/content/research/progcomp/numbertheory.md index 05da935..605b784 100644 --- a/content/research/progcomp/numbertheory.md +++ b/content/research/progcomp/numbertheory.md @@ -130,7 +130,7 @@ These events coincide every twenty years, because $lcm(4, 10) = 20$. We are not always interested in full answers, however. Sometimes the remainder suffices for our purposes. -Example: Suppose your birthday this year falls on a Wednesday. What day of the week will it fall on next year? +**Example:** Suppose your birthday this year falls on a Wednesday. What day of the week will it fall on next year? The remainder of the number of days between now and then (365 or 366) mod the number of days in a week. $365$ mod $7 = 1$. Which means that your birthday will fall on a Thursday. @@ -138,7 +138,7 @@ The remainder of the number of days between now and then (365 or 366) mod the nu **Addition**: $(x + y)$ mod $n$ $=$ $((x $ mod $n) + (y$ mod $n))$ mod $n$ -Example: How much small change will I have if given \$123.45 by my mother and \$94.67 by my father? +**Example:** How much small change will I have if given \$123.45 by my mother and \$94.67 by my father? $$ \begin{align*} (12345 \text{ mod } 100) + (9467 \text{ mod } 100) &= (45 + 67) \text{ mod } 100 \\ @@ -147,7 +147,7 @@ $$ $$ **Subtraction** (Essentially addition with negatives): -Example: Based on the previous example, how much small change will I have after spending \$52.53? +**Example:** Based on the previous example, how much small change will I have after spending \$52.53? $$ (12 \text{ mod } 100) - (53 \text{ mod } 100) = -41 \text{ mod } 100 = 59 \text{ mod } 100 $$ @@ -159,7 +159,7 @@ $$ $$ xy \text{ mod } n = (x \text{ mod } n)(y \text{ mod } n) \text{ mod n} $$ -Example: How much change will you have if you earn \$17.28 per hour for 2,143 hours? +**Example:** How much change will you have if you earn \$17.28 per hour for 2,143 hours? $$ \begin{align*} (1728 * 2143) \text{ mod } 100 &= (28 \text{ mod } 100)(43 \text{ mod 100}) \\ @@ -170,7 +170,7 @@ $$ $$ x^y \text{ mod } n =(x \text{ mod n})^y \text{ mod } n $$ -Example: What is the last digit of $2^{100}$? +**Example:** What is the last digit of $2^{100}$? $$ \begin{align*} 2^3 \text{ mod } 10 &= 8 \\ diff --git a/content/research/reinforcementlearning/notes/dynamic.md b/content/research/reinforcementlearning/notes/dynamic.md index 55d79bb..3ca1413 100644 --- a/content/research/reinforcementlearning/notes/dynamic.md +++ b/content/research/reinforcementlearning/notes/dynamic.md @@ -24,7 +24,7 @@ This algorithm is called *iterative policy evaluation*. To produce each successive approximation, $v_{k + 1}$ from $v_k$, iterative policy evaluation applies the same operation to each state $s$: it replaces the old value of $s$ with a new value obtained from the old values of the successor states of $s$, and the expected immediate rewards, along all the one-step transitions possible under the policy being evaluated. -**Iterative Policy Evaluation** +**Iterative Policy Evaluation** ``` Input π, the policy to be evaluated @@ -69,7 +69,7 @@ Each policy is guaranteed to be a strict improvement over the previous one (unle This way of finding an optimal policy is called *policy iteration*. -Algorithm +**Algorithm** ``` 1. Initialization diff --git a/content/research/reinforcementlearning/notes/mcmethods.md b/content/research/reinforcementlearning/notes/mcmethods.md index a2b8fa6..54087a1 100644 --- a/content/research/reinforcementlearning/notes/mcmethods.md +++ b/content/research/reinforcementlearning/notes/mcmethods.md @@ -16,7 +16,7 @@ Recall that the value of a state is the expected return -- expected cumulative f Each occurrence of state $s$ in an episode is called a *visit* to $s$. The *first-visit MC method* estimates $v_\pi(s)$ as the average of the returns following first visits to $s$, whereas the *every-visit MC method* averages the returns following all visits to $s$. These two Monte Carlo methods are very similar but have slightly different theoretical properties. -First-visit MC prediction +**First-visit MC prediction** ``` Initialize: @@ -45,7 +45,7 @@ This is the general problem of *maintaining exploration*. For policy evaluation We made two unlikely assumptions above in order to easily obtain this guarantee of convergence for the Monte Carlo method. One was that the episodes have exploring starts, and the other was that policy evaluation could be done with an infinite number of episodes. -Monte Carlo Exploring Starts +**Monte Carlo Exploring Starts** ``` Initialize, for all s ∈ S, a ∈ A(s): @@ -74,7 +74,7 @@ On-policy methods attempt to evaluate or improve the policy that is used to make In on-policy control methods the policy is generally *soft*, meaning that $\pi(a|s)$ for all $a \in \mathcal{A}(s)$. The on-policy methods in this section uses $\epsilon$-greedy policies, meaning that most of the time they choose an action that has maximal estimated action value, but with probability $\epsilon$ they instead select an action at random. -On-policy first-visit MC control (for $\epsilon$-soft policies) +**On-policy first-visit MC control (for $\epsilon$-soft policies)** ``` diff --git a/content/ta/spring2018/cpsc220/jan30.md b/content/ta/spring2018/cpsc220/jan30.md index e5e8095..379c3db 100644 --- a/content/ta/spring2018/cpsc220/jan30.md +++ b/content/ta/spring2018/cpsc220/jan30.md @@ -76,7 +76,7 @@ The third underline is the number of decimal places The the final underline is the specifier `f` for decimal and `d` for integer -Example +**Example** ```java double amount = 0.5;