letsthinkabout.us

technology, healthcare, people

The Next 30 Years: 2015 - 2045

At any given moment in history, there exists a generational constellation. The mix of generations currently alive and the events that shaped their existence dictates society’s reaction to future events. At times, these events are perpetuated by a single generation, other times will see all generations putting differences aside and coming together.


“History doesn’t repeat itself, but it rhymes.”


The demographics of 2014 America consists of:

Silent Generation (born 1925 - 1942): 

  • Exiting elders born during the Great Depression during low birthrates. 
  • Not old enough to fight WWII, but fought Korea. No one celebrated their homecoming. 
  • They married early. 
  • They were too old to be hippies. 
  • They divorced in adulthood, conformed to new social change, left behind broken homes. 
  • They retired during the 1990’s economic boom, benefitted from it. 
  • Now 80+ years old, society resembles what they grew up with—global-scale conflict brewing amidst economic crisis.

Baby-Boomers (born 1943 - 1960): 

  • Late-adulthood generation who brought about social change in their youth as hippies. 
  • Hailed as the future of America in childhood. 
  • Extremely high birth rates. 
  • Today, their age-demographic is disproportionately large compared to any other living generation. 
  • Rebelled against their elders, initiated a stagnant economy during this rebellion
  • While entering adulthood, gender roles narrowed, drug and alcohol abuse was rampant, and the society their elders built was devoid of spirituality. 
  • In early adulthood, they championed individuality, turned the world inwards and they created the longest recorded expansion of GDP in American history (1990’s). 
  • They stuck it to The Man in the 70’s, they became The Man in the 90’s.

Generation X (born 1961 - 1981): 

Millennials (born 1982 - 2004?): 

  • The generation entering adulthood 
  • This generation grew up chatting with each other over the internet. AOL Instant Messenger 
  • They frequented forums and MySpace, later Facebook, Twitter, Instagram, Snapchat. Now, their community is Reddit, YouTube and just about every aspect of their life is misunderstood by their elders. 
  • Seen as narcissistic and constantly criticized now by a Generation X dominated media.
  • Protected by Baby Boomers.
  • This is a community-centered generation that will soon have a large burden on its shoulders.

Homeland Generation (2004? - 2024?):

  • A generation being born who resembles the eldest generation. Born at a time of low birth rates, economic downtown, and a stirring global conflict pot. 


The current generation constellation is the only valid litmus test to gauge the times. Western society has followed a simple 4-pronged pattern traceable to Martin Luther igniting social upheaval in 1517.


Here, we color the generations by type. As described above, the Homeland generation is a rhyme of the Silent generation. Each era ends in a culmination event, where the generations shift in age. 1967 marked the summer of love and explosion of hippies. 1984 marked the re-election of Ronald Reagan. 2007 marked the economic collapse and 2030 will likely mark the end of our current era. Similar dates not shown in the figure are the market crash of 1929 and D-Day 1945.

 

Describing these eras briefly:


Outer-Driven Era:

  • The world just resolved a crisis. Now, (western) society is of good-feelings and community.
  • Children are overindulged and hailed as the future of the economy and the birthrate booms.
  • Early-adulthood generation conforms to society.
  • The generation in adulthood are not spiritual, and hold the largest span of secular power known in any generational-constellation.
  • Elders are left behind and disregarded, their way of thinking regarded as backwards and not conducive to society.
  • Society homogenizes. But it’s prosperous.
  • The last instance of this was the 1950’s.

Social-Upheaval:

  • Children of the outer-driven era, now in their 20’s find that society shaped by their elders crawls rampant with spiritual poverty.
  • They rebel against the excesses of the previous era, against their elders and usher in social change with a stagnant economy.
  • They break down community and champion individualism.
  • Children born during this era are largely unwanted.
  • Those in adulthood, who conformed to society in the previous era embrace the change being brought in, but because they are too old, they are not the vanguards. They conform again to the new standards and suffer an identity crisis.
  • Those entering elderhood see their secular power crumble before their eyes and watch the constructs of their world burn.
  • The last instance of this was the late 60’s and 70’s.

Inner-Driven Era:

  • The vanguards of change during Social-Upheaval are now adults. They start to resemble their parents who they rebelled against
  • The “losers” born during the upheaval emerge as angry, their culture dissonant.
  • Late-adulthood are silent.
  • Elders are still busy with their civic duty and community.
  • The world turns inwards as people are focused only on themselves—a result of heavy individualism.
  • The birthrates increase and children born during this time are seen positively.
  • There is an overwhelming sentiment: “How long can we keep this up?”
  • The last instance of this was the 80’s and 90’s.

Crisis:

  • An era marked by hardship.
  • Economic and political struggles rampant.
  • Birth-rates are at an all-time low
  • Children born are being over-protected
  • Early-adulthood generation can’t seem to catch a break in society.
  • Mid-adulthood generation have lost an overwhelming majority of their share on society.
  • Elders try to step up as leaders, but are too fragmented on moral and spiritual grounds to be effective.
  • This era culminates in a catastrophic event where the early-adulthood generation must emerge victorious. In instances where they do not (American Civil War), that generation becomes displaced.
  • We are currently in this era.

 

Based on the events of the past 80 years, we are right on track for following this pattern. The Roaring 20’s repeated itself during the 1990’s as a period of unbridled economic expansion perpetuated by an idealist generation (Baby Boomers) centered on individualism. The Great Depression and the rise of totalitarianism are repeating themselves in the form of today’s Great Recession emerging in 2007 and the foreign affairs crisis of 2014. As this pattern persisted then, it will re-occur again, and the outcomes of the world are predictable.

The cycle described above is allowed to continue under 1 condition: that young adults fighting in the crisis emerge victorious. Those who fought WWII came home as heroes and took to public life quickly, without question from any other generation (John F Kennedy). This cycle was broken once in 1865, when the American Civil War ended, there wasn’t truly a victor and those who fought the war became a reactive generation.


Time will tell if I am correct:

 

2015 – 2020:

  • Feminism will reach a legendary event never to be seen again this lifetime. Between 2016 - 2024 is the most likely time a woman will win the presidency in America. If it doesn't happen during this time, no one alive today >20 years old will ever see it achieved.
  • 2016: Wearable technology starts to take off
  • 2017: Internet of Things emerges
  • 2018: US healthcare crumbles under its own weight, brings down massive parts of the economy with it. The nation will be in limbo during this time.
  • Immigration in the US continues to decline
  • Birth rates will stay low
  • Children are over-protected, compared to the 70’s.
  • Global conflict is still brewing in this time period, amidst intermittent illusions of peace and economic recovery. The longer it brews, the more intense it will become.

2020 – 2030:

  • By 2025, a true global crisis will have exploded onto the world scene, not seen since 1939. This can include disease, famine, natural disaster, war and any combination. An extraordinary human cost will be imposed on the world, unfortunately.
  • Late-Millennials (born 90’s - early 2000’s) will fight the conflict. They will win by 2030 and emerge as heroes.
  • Policies set following crisis resolution in 2030 will be the seed for immediate and future conflict.
  • 2028: First Millennial president elected in the US.
  • Claims will be made this decade that humanity has achieved self-aware computing. They will all be false.
  • The 20’s will be seen as an absolute low-point of all humanity up to this point.

2030 - 2040:

  • 2030, self-aware objects will begin to emerge. Technology is community and forges the outer-world as the Millennials see fit.
  • What we see as computers in 2030 would be unrecognizable today. The paradigm will fundamentally change. Computers will reach the capacity of several human brains.
  • Birth rate will explode. Children born in this time will be hailed as the future of the world and will be over-indulged.
  • Young adults, Homelanders, conform to society’s wishes. They will be obedient, subservient, as their life stagnates during this time. They will make life-decisions they will regret 20 years later in the 50’s. If they fight a conflict or assist in a crisis, they won’t have a joyous homecoming, nor will their work be appreciated at this time.
  • Society begins a period of homogenization. People all have similar fashions, all have the same products, all have very similar ideals. Being your own person is acceptable, but you are nothing without the community which will exist in a virtual reality.
  • The economy will be reborn, in a way only Millennials could shape. It will boom, news outlets will describe a new American Dream, different and deemed more prosperous than the old one. Virtual currency use is widespread.
  • Gender roles will widen. Feminism of 1970 – 2020 will be completely lost, and this will be justified due to atrocities seen during the 20’s.
  • Millennials take the House and Senate and their use of technology will be integrated into law. Humans will no longer be allowed to drive vehicles in the name of safety, convenience and productivity.
  • Political discourse now focuses on technology. Do self-aware objects have rights? Is limiting their progress considered inhumane? Should they pay tax? Can they vote? Is erasing their memory violating their rights?
  • Millennials disregard Generation X, who they will see as a relic of the past-- backwards and wrong.
  • Social Security and Medicare are changed in a way where Generation X, now eligible age, will not receive benefits.
  • Generation X’ers lives will stagnate. They will reminisce on times where individuals had power and their life was fast-paced (90’s) and fade out of public life completely.
  • Millennials will begin to purge their own cohorts from communities. Those who were not in the “correct” community in the 10’s will be cast out in witchhunt fashion (ala McCarthyism)

2040 – 2045:

  • The secular world is focused on stability, which it has achieved. The economy is sustained and growing, with some scattered recessions.
  • $1000 of computing equipment will have the processing capability of several thousand humans.
  • There will be a coexistence of human and technology. It will either be integrated into or exist alongside humans.
  • Millennial-dominated government will legislatively side with technology in every possible way.
  • 2045: emergence of self-aware, self-replicating computers.

The events of 2045 will ignite an awakening among 20-year olds at this time. The Millennials of the 30’s leveraged technology to achieve stability, safety, convenience and productivity at the cost of personal liberty. 2045 crosses the threshold. Young-adults will look back at the society of the 30’s as vile, disgusting. They will begin to rebel against the Millennials, much like the hippies did against the GI in the late 1960’s. Their sheer population will be overwhelming and their ideas will overtake every facet of life. Generation X will simply observe as they see the world had left them behind years ago. Millennials will scramble to fight this awakening, but without effect. Homelanders will be too old to rebel, but will conform to new societal change as they denounce their earlier life decisions and pass through a mid-life crisis. The economy will stagnate and there will be a torrential pouring of revolt around the world.

While the most immediate predictions we discussed here are dark and gloomy, please remember this: the last 3 generational cycles (14 generations ago) starting with the founding of America have achieved technology, an economy, a standard of living, and a level of human freedom never before seen at any other time in history. As the world descends into barbarism during this era, it is merely the winter to the glorious spring that will emerge. No pressure Millennials, we just have to win at all costs.

Android Custom Ad- MoPub Edition

Custom Views in Android are easy. In this post, I will describe how to use the MoPub SDK to serve marketplace ads, as well as your own when loading fails.

If you'd like to see this the code sample on GitHub: https://github.com/bbhsu2/AndroidCustomAd

First, create a boilerplate Android project and include the MoPub SDK, either as a project or a .jar.

Then, create a class named AdView:

    public class AdView extends MoPubView implements BannerAdListener{
 
	ImageView homeBrewAd;
	Context context;
	
	public AdView(Context context) {
		super(context);
	}
	
	public AdView(Context context, AttributeSet attrs){
		super(context, attrs);
		this.context = context;
		
		//TODO: Set your Ad Unit ID!
		this.setAdUnitId(""); 
		this.loadAd();
		this.setBannerAdListener(this);
	}
    }


Let's sift through what's going on here. First, our AdView class extends MoPubView, which has superclass View. Next, it implements the interface BannerAdListener (of MoPub SDK), which has 4 methods:


@Override
public void onBannerClicked(MoPubView arg0) {
}
 
@Override
public void onBannerCollapsed(MoPubView arg0) {
}
 
@Override
public void onBannerExpanded(MoPubView arg0) {
}
 
@Override
public void onBannerFailed(MoPubView arg0, MoPubErrorCode arg1) {
}


We also declare pointers to Context and ImageView in our AdView class. We use the constructor

	public AdView(Context context, AttributeSet attrs)

which is called when the view is inflated via XML.  In the constructor, we create the ad object and load it. If it fails, no image will appear. So we will add in these instructions:


@Override
public void onBannerFailed(MoPubView arg0, MoPubErrorCode arg1) {
	homeBrewAd = new ImageView(context);
	homeBrewAd.setImageBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.nlv_adbanner));
	homeBrewAd.setOnClickListener(new OnClickListener() {	
		@Override
		public void onClick(View v) {
			Intent intent = new Intent(Intent.ACTION_VIEW);
			intent.setData(Uri.parse("market://details?id=com.allgoodpeopleus.NormalLabValues"));
			v.getContext().startActivity(intent);
		}
	});
	addView(homeBrewAd);
}

  1. Create the ImageView object pointed to homeBrewAd.
  2. Set the Image to a custom ad in R.drawable
  3. set the OnClickListener of the image and create an intent that will launch. Here we are launching to a Google Play Store app that has the package name com.allgoodpeopleus.NormalLabValues
  4. Add the ImageView to the View.


This will set your AdView to a custom ad that will go to an app in the Google Play store when it is clicked.  You now have 60 seconds before MoPub SDK will try another request. If successful, you must clear out your homeBrewAd from the View.  That's easy to do. When the Banner Load is successful, this method is called:

@Override
public void onBannerLoaded(MoPubView arg0) {
	if (homeBrewAd != null){
		homeBrewAd.setVisibility(View.INVISIBLE);
		homeBrewAd.setImageBitmap(null);
		homeBrewAd.setOnClickListener(null);
	}
}

And now we hide the homeBrewAd and show the MoPub marketplace advertisement.


Now, we've created our view. How do we declare it in XML?  

In activity_main.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <views.AdView
        android:layout_width="fill_parent"
        android:layout_height="50dp" />

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" 
        android:textSize="40sp"
        android:text="Did you remember to set your own Ad ID in views.AdView?"
        android:gravity="center"
        android:layout_gravity="center"/>

</LinearLayout>


Which is set as the Content View in MainActivity:

public class MainActivity extends Activity{
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
	}
}


In my opinion, Android is the hardest mobile platform to learn development. Java is clear, but its verbosity is overwhelming. The sheer amount of boilerplate needed to start an Android project is daunting to the beginner. Eclipse as the IDE and a cryptic Logcat making things difficult to debug for the beginner will turn off just about anyone. 

On the plus, once you learn the essentials, it's a fun, flexible and open platform. As the most popular platform in the world, your download numbers will break iOS and Windows Phone by leaps and bounds. Also, the declarative nature of XML files makes prototyping accurate and swift. Have fun with development and the experience will ultimately be supremely rewarding!

Android Game of Life

Conway’s Game of Life

The live demo for this can be seen here: 



Game of Life is a cellular automaton created in 1970 by mathematician John Conway. There are only 4 rules of the game:

  1. An alive cell with 0 or 1 alive neighbors dies in the next generation (underpopulation)
  2. An alive cell with 2 or 3 alive neighbors lives in the next generation
  3. An alive cell with > 3 alive neighbors dies in the next generation (overpopulation)
  4. A dead cell with exactly 3 neighbors comes to life in the next generation.



The implementation here uses a 2D boolean array that serves as the "board." Using a standard model of states, we iterate over the entire array in each generation to determine which cells will be alive or dead in the next generation.  If you are interested in the code, see the implementation in the GitHub project here.

Runge Kutta in Fortran

Fortran is the grand-daddy of programming languages.

Much like the other Runge Kutta implementations I've written about for other languages, our target is still the same:



First, before we discuss Runge Kutta in code, we have to establish our number precision. If you are numerically evaluating values, you want 64-bit doubles. You need to declare that in Fortran:

module mod_constants
    integer, parameter :: DP = selected_real_kind (15, 307)
end module mod_constants

If your background is in C-based languages, this will strike you as odd since every single "real" will be declared as "real(DP)" and every value will be declared as x.x_DP.  This will give you precise numerical evaluation.


Next, lets declare our RungeKutta module:

module mod_rungekutta
	use mod_constants, only: DP
	implicit none
	private
	public :: rk4
	real(DP), parameter :: sixth = 1.0_dp / 6.0_dp
 
	contains
        real(DP) function rk4(x, y, dx, f)
            real(DP), intent(in) :: x, y, dx
            interface
                function f(x, y) result(r)
                    import DP
                    real(DP), intent(in) :: x, y
                    real(DP) :: r
                end function
            end interface
            real(DP) :: k1, k2, k3, k4, halfdx
 
            halfdx = 0.5_dp * dx
            k1 = dx * f(x, y)
            k2 = dx * f(x + halfdx, y + k1*halfdx)
            k3 = dx * f(x + halfdx, y + k2*halfdx)
            k4 = dx * f(x + dx, y + k3*dx)
            rk4 = y + sixth * (k1 + 2*k2 + 2*k3 + k4)
    end function
End Module

Here, the rk4 function is something interesting to see. We declare the input variables x,y and dx. The 4th argument "f" is a function that takes 2 arguments (x, y) both type real(DP) with intent(in) and returns a real(DP) named r. This is shown for values k1, k2 k3 and k4. This is the same as the C# delegate.


Now, lets declare our Equation object, enclosed within an Module named mod_equation:

Module mod_equation
	use mod_constants
	use mod_rungekutta
	implicit none
 
	type, public :: equation
		real(dp) :: x = 0.0_dp, y = 1.0_dp, target
		real(dp) :: dx = 0.0001
		contains
			procedure :: init => equation_init
			procedure :: run => equation_run
	end type equation
 
	contains
		subroutine equation_init(this, x, y, dx, target)
			class(equation), intent(inout) :: this
			real(DP), intent(in) 	:: x, y, dx, target
 
			this%x = x
			this%y = y
			this%dx = dx
			this%target = target
		end subroutine
 
		subroutine equation_run(this)
			class(equation), intent(inout) :: this
 
			do while(this%x < this%target)
				this%y = rk4(this%x, this%y, this%dx, dy_dt)
				this%x = this%x + this%dx
			end do
			write(*,*) 'x:', this%x, 'y:', this%y
		end subroutine
 
		real(dp) function dy_dt(t,y)
			real(dp), intent(in) :: t, y
			dy_dt = y
		end function
end module mod_equation

Lets break it down: we declare an object named "equation" in type,public :: equation.  We give it properties x, y, dx and target. It also has class procedures (methods) named init and run, which refer to the subroutines named equation_init and equation_run within the module.

The 2 subroutines: equation_init and equation_run are both class methods of the equation object. 


subroutine equation_init(this, x, y, dx, target)

equation_init declares 5 arguments, however it only takes 4. The "this" argument indicates that it is callable only as a method of an instance of the equation object. This is exactly how Python does its instance methods.

We also declare the dy_dt(t, y) function as well, which is the function pointer that will serve as the "f" in rk4().


Our equation is:


 Which is the equation y = exp(x)


Finally, we put everything together at the entry point:

program Program
use mod_constants
use mod_equation
	type(equation) :: equation_object
	call equation_object%init(0.0_dp, 1.0_dp, 0.0001_dp, 1.0_dp)
	call equation_object%run()
end program Program


The output here is:


Which is very close to e = 2.7182818284590452353602874713527 


Next Steps:

This is a simple implementation of Runge Kutta using a simple ODE. In numerical simulations, often an array of ODE's need evaluation, and they are often interrelated. This method can be generalized further so the function f in rk4() in can be used to take an argument of type double(:) instead.

This Fortran version is structurally more similar to the C# implementation than it is compared to the one in Java.  It also happens to be faster than both by an order of magnitude 3 for very small timesteps.

Runge Kutta in Java

In my opinion, Java is more a “pure” object oriented language than C#. Learning object-oriented concepts proves much easier in Java than C#. Reason being is that Java is simply more clear for simple implementations. However, its clarity is a product of its overwhelming verbosity, which can be burdensome in larger products.

The scheme for numerically solving an ordinary differential equation (ODE) via 4th-order Runge Kutta is language-agnostic:

 

 

A Java interface is a contract. An object that implements an interface is guaranteed to have the methods and properties declared by the interface. Here we declare the interface:

public interface Delegate{
        double dy_dt(double t, double y);
    }

 

Next, we declare the Equation object, that implements the interface. 

public class Equation implements Delegate {
	double x, y, dx, target;
 
	public Equation(double x, double y, double dx, double target) {
		this.= x;
		this.= y;
		this.dx = dx;
		this.target = target;
	}
 
	public void Run() {
		while (x < target) {
			y = RungeKutta.rk4(x, y, dx, this);
			x += dx;
		}
		System.out.printf("x: %.15f, y: %.15f", x, y);
	}
 
	@Override
	public double dt_dt(double t, double y) {
		return y;
	}

 

Our equation is

 

 Which is the equation y = exp(x)

 

Then, we use the static method RungeKutta.rk4( … ) as our calculation powerhouse.  Here, delegate f is the Equation object we are using in order to call the method dt_dt( … ).

public class RungeKutta {
	static final double sixth = 1.0 / 6.0;
 
	public static double rk4(double x, double y, double dx, Delegate f) {
		double halfdx = 0.5 * dx;
 
		double k1 = dx * f.dt_dt(x, y);
		double k2 = dx * f.dt_dt(x + halfdx, y + k1 * halfdx);
		double k3 = dx * f.dt_dt(x + halfdx, y + k2 * halfdx);
		double k4 = dx * f.dt_dt(x + dx, y + k3 * dx);
 
		return (y + sixth * (k1 + 2 * k2 + 2 * k3 + k4));
 
	}


Finally, we create an Equation object, and call Run()

	public static void main(String[] args) {
		Equation e = new Equation(0.01.00.00011.0);
                e.Run();
	}

 

The result?

x: 1.000099999999906, y: 2.718417755010002

Which is very close to the value of e = 2.7182818284590452353602874713527


As compared to the C# version, this Java implementation is more a "pure" object oriented way of calculating Runge Kutta. Notice the slight increase in verbosity due to the declaration of an interface, and forcing class Equation to implement it. However, to a newcomer to object-oriented programming, this may be more clear to one learning. It also certainly helps in understanding the idea of an Interface as well.


Next Steps

This is a simple implementation of Runge Kutta using a simple ODE. In numerical simulations, often an array of ODE's need evaluation, and they are often interrelated. This method can be generalized further so the double dt_dt() in Delegate can be used to take an argument of type double[] instead.

One more detail: this Java version can be copied and pasted, changing the word "implements" with ":", System.out.printf with Console.WriteLine( .. ) and giving Main a capital M, and this can be compiled as C# code, with the exact same result. The converse is not true!