Finance 102: Financial Categories

We can categorize financial savings into common groups based on different types of expenses:

  • Hard Savings: Short-term variable expenses, which fall under expense management (Hawley, 2018). It is also known as Cost Savings (Dawson, 2018). In other words, savings that have a direct impact now, like cost reduction or revenue enhancement (WarehouseBlueprint, 2017). Here we want to have proactive disciplined spending to help fund investment opportunities down the line (Hawley, 2018). For instance, if you reduce your outside dining experience over the next month or two, to save money.
  • Cost Avoidance: Consumption of resources, this falls under part of optimization (Hawley, 2018). Another way to look at cost avoidance is to lower your potential incurred future expenses by reducing the gap in financial losses (Dawson, 2018; Study.com, n.d.). You will need to be managing and planning for your needs and wants (Hawley, 2018). Here, this reminds me of using everything you got in the kitchen before you buy a new set of groceries. Find new recipes and reduce your costs of buying more food, while older food gets unused and expires. The avoidance of expiring food is cost avoidance.
  • Potential Savings: Consumption of resources, which also falls under part of optimization. You should be identifying new opportunities and offerings to meet your needs and wants (Hawley, 2018). This is usually longer-term savings, like finding ways to cut your budget for the long-term, like reducing your phone bill to just a cell-phone bill or removing an unused gym membership expense from your budget. Another example is when you begin shifting your energy use to off energy peak hours.
  • Write-downs: Amortization and Depreciation, which is essentially debt that needs to following financial compliance and to adjust the balance sheet numbers (Hawley, 2018; Investing Answers, 2019). This is the reduction of the book value of an asset-based (Investing Answers, 2019). For example, the mortgage on your house and the tax write-offs associated with it. Also, there can be the value of your car which depreciates when you drive it off the lot and is based on fundamental changes like mileage, age, and condition.
  • Delayed Savings: Extrapolated values for investments and funded projects, which could depend on a variety of factors (Girosi, et. al., 2005). We should be asking ourselves here if the investments are aligned to our objects, risk profile, and goals (Hawley, 2018). For an illustration, buying solar panels now may incur a cost today, but the eventual savings on the electric bill will be realized in the future.
  • Future Debt: Debt to be incurred when undergoing investments and funded projects (Hawley, 2018). It is a debt that will be created or is created but will not be due today (The Law Dictionary, n.d.). For instance, future rental properties one finances to create cash flow, where a portion of the money will go to paying the mortgage and the rest goes elsewhere.

None of this can come into fruition without periodic reviews of your budget, expenses, and other data points so that you can adjust your plan of action.

Reference:

Parallel Programming: Logical Clocks

In a distributed system nodes can talk (cooperate) to each other and coordinate their systems.  However, the different nodes can execute concurrently, there is no global clock in which all nodes function on, and some of these nodes can fail independently (Sandén, 2011).  Since nodes talk to each other, we must study them as they interact with each other.  Thus, a need to use logical clocks (because we don’t have global clocks) which show that distances in time are lost (Sandén, 2011). In logical clocks: all nodes agree on an order of events, partially (where something can happen before another event).  They only describe the order of events, not with respect to time.  If nodes are completely disjoint in a logical clock, then a node can fail independently. This is one way to visualize the complex nature of nodes.

The following is an example of a logical clock:

Capture

Reference

Parallel Programming: Locks

A lock for a Node could be for the latest service request. Nodes in a group have to agree on which one of them holds the lock during any one moment of time, which can be seen on a vector graph if we note which one holds the lock. A node can release and request a lock.

Mutual exclusion algorithms can have a centralized coordinator node that handles the requests for the lock, which then means if that node fails so will the program (Sandén, 2011). Mutual exclusion algorithms can allow for a contention-based exclusion where nodes compete for the lock equally, and a queue is created for pending requests.  Finally, controlled exclusions have a logical piece of code to visit each node at a regulated interval of time to lend them the lock.

Lamport’s clock can help order the contention-based scenario where every node is trying to get the lock and it can only be had through a queue (Sandén, 2011). The queue tracks their request through a timestamp. Nodes can earn a lock if it has all the reply messages it needs to run its task and it’s on the top of the list in its queue.

Sandén (2011), states that multicast is done to all nodes that the lock has been released, and abolishing this message can optimize the process. Thus, the node should get the request from the next in the queue and postpone it until is done with the lock.

Reference

Parallel Programming: Logical Clocks

Per Sandén (2011), in a distributed system nodes can talk (cooperate) to each other and coordinate their systems.  However, the different nodes can execute concurrently, there is no global clock in which all nodes function on, and some of these nodes can fail independently.  Since nodes talk to each other, we must study them as they interact with each other.  Thus, there is a need to use logical clocks (because we don’t have global clocks) which show that distances in time that is lost.

In logical clocks: all nodes agree on an order of events, partially (where something can happen before another event).  They only describe the order of events, not with respect to time.  If nodes are completely disjoint in a logical clock, then a node can fail independently.

Reference

To Do List: Home Network for Working Remotely

During 2020, with the rise of Corona Virus 2019 (Covid-19) we have seen a rise in working remotely. However, we soon realized that not everyone has the same connectivity speeds in their homes. We also have realized that there are internet connectivity deserts in the United States, where students from K-University may not have reliable access to the internet. Though this post is not going to address internet access and connectivity deserts in the U.S., it will address tips and techniques to help improve connectivity speeds in your home network. Even when people live in areas where internet connectivity can be taken for granted, connection speeds can be variable from home to home, which can impact performance for working remotely. A quick test is if you can stream Disney+, Netflix, Hulu, YouTube, or any other video streaming platform on your devices via a wireless network you should be able to work from home using WebEx, Zoom, etc. Essentially, 20 megabytes per second or greater will suffice. However, 20-30 megabytes per second is pushing it, especially if you are not single or have many other devices.

Your wireless connection is based on bandwidth and depending on the type of connection plan with your service provider that plan has a usually fixed amount, i.e. 20 megabytes per second, 50 megabytes per second, 1 gigabyte per second, etc. Therefore, it is imperative to squeeze every byte effectively. How many devices do you have connected to your network? For me, I have at least 8 devices on my network, with usually 5 connected to it at any one moment in time. Even though your cell phone is not streaming anything, it is still interacting with your network, consuming a small bit of your network’s bandwidth.

However, if I have 5 items connected to the network, I do not have them all streaming something at the same time. If we can do a crude extrapolation out from my anecdotal case, for a family of four, there could be about 20 devices connected to one network. What do we do? Consider budgeting and prioritizing streaming times, for a more cost-effective solution. However, depending on where you live you may be able to contact your service provider to increase your bandwidth. Also, check to see if your house or neighborhood has been wired up for Fiber or just DSL (fiber-optic connection is best as of the writing of the post) and switch if you are not on Fiber. Fiber connection allows for a higher connectivity speed.

Age plays a role in internet connectivity speeds, even if you have paid for the higher speeds from your provider. The older the house, the older the wiring to connect to the internet provider. With time, internet cable connections can degrade which can also impact performance. Also, the age of the router is important. The older the router, it may not be compatible with receiving higher speeds from your service provider. If you are renting one, contact your service provider to upgrade the router for free. If you have purchased one (recommended and more cost-effective), it may be time to upgrade it if it is old.

Even with newer routers, does it have the latest security patch? Computer viruses can impact your routers and degrade your connectivity speeds. It is always wise, regardless of your device to accept new upgrades and security patches. There is a caveat here, given the haste that some patches come out, I personally and typically wait some time depending on the need for a patch (if the current vulnerability is high the sooner I accept the patch), before I install one. Sometimes, security patches may cause more issues if installed in haste than warranted.

When you have set up wireless in your house, you may have dead spots or streaming bottlenecks. It is often best to test your connection speed by using apps a connection speed test website like www.speedtest.net. Start testing in the same room and nearest the router. There are two goals to testing near the router: (1) to test to see if your speed is within 5-10 megabytes per second to what you are paying for from your internet provider, (2) to set up a baseline of what you should be connecting to around the house. If you are not getting the right speed according to your contract, check the age and security patches on your router and retest again. If not, contact your service provider to address the situation. Once within the 5-10 megabyte per second variance from your contract, you should go around and test each room. You will see that as the further away from the router the connection speed may drop. You can also see that the connection in different rooms may vary significantly too. Different devices based on their age may also have a variable connection speed. A 6-year-old laptop may have slower connection speeds than the latest mobile device. 

To get the best solution when working from home is to install your router and wireless connection in the same room as your working station and if at all possible use the wired connection from your laptop to your router direct, bypassing wireless all together for your work device. Now, if you are testing the speed of your connectivity while connected via wire to the router is significantly faster than if it were connected via wireless, you then know that there may be an issue with the wireless. You can either buy a new wireless box if yours is old or troubleshoot from that point moving forward.

In summary, once you have addressed the above when working from home, reconsider the following to preserve your bandwidth: (1) limit as you can unnecessary video chatting via online meeting platforms; (2) limit streaming video on your work device; (3) limit streaming music on your work device; and (4) limit the number of devices connected and streaming data to your at-home network. This is because live video takes more data to stream than prerecorded video (from YouTube, Netflix, etc.) than streaming live voice over the network (Voice over internet protocol) than streaming music (Pandora, google music, etc.).

Parallel Programming: Deadlocks

Deadlock occurs while you are getting an additional resource while holding another or more resource, especially when it creates a circularity  (Sandén, 2011).

Sandén (2011), stated that to prevent deadlocks, resources need to be controlled.  One should do a wait chain diagram to make sure your design can help prevent a deadlock.  Especially when there is a mix of transactions occurring.  It is also best to know how many threads/entities are needed to be called on simultaneously before a deadlock can occur, especially true when you have multiple threads calling on shared resources.

Thus, we should manage the resources to ensure no circularity, limit the number of entities to just below the threshold to cause a deadlock, eliminate wait.

There are many in real life like the one shown in Sandén (2011) with each of 4 cars halfway into an intersection. The following is a real-life suggested a deadlock scenario:  

There is one set of measuring cup (1/2 a cup).  There are no other ways to measure this amount.  Jack and Jill are backing a cake at the same time.  They have all the objects need, eggs, cake mix, oil, and milk.  However, they need the only measuring cup to measure oil and milk and they reach for it at the same time.  This is a deadlock.

To un-deadlock this scenario, Jack can pour the eggs, and cake mix, while Jill measures and pours the oil and milk.  When Jill is done, Jack measures and pours the oil and milk and Jill pours the cake mix and eggs.  The same could be done with up to four people.  Where each person is a thread and the measuring cup is the resource.

Once we introduce a fifth or more person, the wait chain has unnecessarily long periods of wait for one thread to be able to begin to use a resource.

Reference

Parallel Programming: Resource Guard

A quick note:

“In the resource-guard-thread pattern, resource-guard threads represent resources.  Such threads are arranged in a virtual assembly line and connected by queues implemented as safe objects” (Saden, 2011)

By the definition above, the search and insertion threads have exclusive data to perform subdivision and legalization through an insertion point, not a queue, thus this is a resource-user thread pattern.

“As long as each resource user has exclusive access to no more than one resource at a time, the designer can usually choose between a solution with resource-guard threads and one with resource threads.  In this sense, the two patterns are dual.” (Saden, 2011)

A dual solution would look like: The search and insertion threads would return an index to a safe object, which would house all the data.  The data can then be a queue from in order to proceed with step two which is subdivision and legalization.

Reference

Parallel Programming: Safe objects and shared objects

Shared objects that force mutual exclusion on threads that try to call it are “safe objects”.  The mutual exclusion on threads/operations can be relaxed when threads don’t change any data, this may be a read of the data in the “safe object” (Sanden, 2011).  In the examples for this course, we have dealt with such Java “safe objects” which are called synchronized.

  1. A safe object in a jukebox represents the CD player. Customer threads call an operation to queue up to play a song.
    • Input into Song Queue: data can be added by multiple people on multiple devices that only have one set of CDs, and can only play one song from a CD.  Data is stored in an array.
    • Change Song order in the Queue: The Song Queue can be prioritized based on predefined parameters, like the DJ, can have ultimate priority to adjust the order and make their own request, but customers have a less priority.  If there is a tiered pay structure then we can see a higher priority placed on a Song on the Song Queue for those willing to pay more. This means that the data stored in the array can be rearranged depending on the thread’s priority.
    • Remove Song from Queue: after the song is done playing, the song’s name is removed from the Song Queue position number one. This will force the array values to shift up by one.
    • Read Song Queue: though not needed to be mutually exclusive, it is still an operation that is needed in order to find the next song to play.  This shouldn’t change any data in the array, it is only reading the song in position 0 of the array.
  1. In a different design, the safe object in a jukebox represents a queue of song requests. Customer threads call an operation to add a song request to the queue. A CD thread calls a different operation to retrieve the next request.
    • All of those that are required for a song queue in the previous example could be applied to this example or a subset.  An example of a sufficient subset would be {Input into Song Queue, Remove Song from Queue, Read Song Queue}
    • Locate the next CD request: Based on the data in Input into Song Queue, pull, locate the CD containing the next Song to be played.
    • Play Song on CD: One song from one CD can be played at any time.
    • Transition Song on CD: As one song ends, fade out the noise exponentially in the last 10 seconds and begin the next song on the Song Queue by increasing the song volume exponentially in the first 5 seconds to normal volume.
    • Put away the CD from the last song played: places the cd back into its predetermined location for future use. Once completed it will call on the Locate next CD Request Safe Operation.

References:

Parallel Programming: Synchronized Objects

Sanden (2011) shows how to use synchronized objects (concurrency in Java), which is a “safe” object, that are protected by locks in critical synchronized methods.  Through Java we can create threads by: (1) extend class Thread or (2) implement the interface Runnable.  The latter defines the code of a thread under a method: void run ( ), and the thread completes its execution when it reaches the end of the method (which is essentially a subroutine in FORTRAN).  Using the former you need the contractors public Thread ( ) and public Thread (Runnable runObject) along with methods like public start ( ).

Additional Examples:

MapReduce

According to Hortonworks (2013), MapReduce’s Process in a high level is: Input -> Map -> Shuffle and Sort -> Reduce -> Output.

Tasks:  Mappers, create and process transactions on a data set filed away in a distributed system and places the wanted data on a map/aggregate with a certain key.  Reducers will know what the key values are, and will take all the values stored in a similar map but in different nodes on a cluster (per the distributed system) from the mapper to reduce the amount of data that is relevant (Hortonworks, 2013). Reducers can work on different keys.

Example: A great example of this a MapReduce: Request, is to look at all CTU graduate students and sum up their current outstanding school loans per degree level.  Thus, the final output from our example would be:

  • Doctoral Students Current Outstanding School Loan Amount
  • Master Students Current Outstanding School Loan Amount.

Now let’s assume that this ran in Hadoop, which can do MapReduce.   Also, let’s assume that I could use 50 nodes (threads) to process this transaction request.  The bad data that gets thrown out in the mapper phase would be the Undergraduate Students, given that it does not match the initial search criteria.  The safe data will be those that are associated with Doctoral and Masters Students.  So, during the mapping phase, the threads will assign Doctoral Students to one key, and Master students would get another key.  Each node (thread) will use the same keys for their respective students, thus the keys are similar in all nodes (threads).  The reducer uses these keys and the safe objects in them, to sum up, all of the current outstanding school loan amounts get processed under the correct group.  Thus, once all nodes (threads) use the reducer part, we will have our two amounts:

  • Doctoral Students Current Outstanding School Loan
  • Masters Students Current Outstanding School Loan

Complexity could be added if we only wanted to look into graduate students that are currently active and non-active service members.  Or they could be complicated by gender, profession, diversity signifiers, we can even map to the current industry.

Resources

Parallel Programming: Threads

A thread is a unit (or sequence of code) that can be executed by a scheduler, essentially a task (Sanden, 2011). A single thread (task) will have one program counter and a sequence of code. Multi-threading occurs when one program counter shares a common code. Thus, the counter in multi-threading has many sequences of code that can be assigned to different processors to run in parallel (simultaneously) to speed up a task. Another way for multi-threading is to have the counter execute the same code on different processors with different inputs. If data is shared between the threads, there is a need for a “safe” object through synchronization, where one thread can access the data stored in a “safe” object at one time. It is through these “safe” objects that a thread can communicate with another thread.

An additional example that may help illustrate the material: 

Maybe we would like to know the average of the sum of all the credits and the average of the sum of all the debits made in personal checking accounts in December in Suntrust Bank. After Map-Reduce techniques using multiple threading, we can go through their entire database system to find accounts and timestamp transactions, map out all the data and reduce it to what we need to return the two numbers in our query. 

Resources: