Monday, October 26, 2015

Ben Carson: don't stomp on Jesus or else.

So this one was a bit of a rabbit hole. It started when I saw the following posted on Facebook.


I read the text, which didn't really seem to explain the headline. So then I listened to all the audio (the video and the radio recordings). There was missing context with what he was asked. They (the reporters, or whatever you call them now) had to lead him by the hand all the way to the finish line. He kept going on and on about extremism in colleges, but never said liberal or conservative. But what in the hell is he talking about? What extremist university is he thinking about that would justify transforming the department of education into some kind of 1984 monitoring system to keep tabs on all the lessons in the country? Whether or not he meant it for liberals in his own head, the 'reporter' had to throw it in there for him by making sure he was only wanting to censure 'liberal' biases, and that 'conservative' biases wouldn't be.

Ben made sure to point out he is only concerned with stopping 'extreme political bias'. But what example is he talking about? The only one he gives is from a story from several years about where a professor told students to 'stomp on Jesus', where a student claims he was then suspended for not participating. I mean, yeah that sounds pretty extreme. It sounds like a professor wanted to piss off his christian students: yet another example of the liberal bias in university every conservative knows about.

So, I was curious where this happened. It wasn't difficult to find the story, which happened back in 2013. I never heard it before, and probably because it is mainly a conservative talking point. The first few pages of google will be filled with conservative news organizations covering the story, which are all essentially the same. Here is even a follow up story several months later, in the summer, just in case the conservatives forgot about it:


This only reinforces the story of christian persecution, and worse, it appears the university doesn't even care that it's happening right in the classroom.

But at least now I knew the details. I finally found the official statement from the university:


Better yet, more information on what happened:

The exercise was based on an example presented in a study guide to the textbook Intercultural Communication: A Contextual Approach, 5 th Edition, written by a college professor who is unaffiliated with FAU.
So, why would an intercultural communications textbook be promoting christian persecution? Isn't that a bit ironic?

So, I try to track down the exact lesson. I have the name of the book, but it's actually supposedly in the study guide to the textbook, but I couldn't find it online. However, I don't think I need to read it. I did find a report generated by the university because of this incident which describes what the lesson was supposed to be and why they disciplined the student (which of course was not mentioned at all in the follow up article on fox news):

http://fau.edu/ufsgov/Final%20AFDPC%20Report%206-24-2013.pdf

Here is an excerpt of the intended lesson:

The exercise asked students to write the letters “J-E-S-U-S” on a sheet of paper, to place the paper on the floor, to think about it for a short time, and then Dr. Poole asked the students to step on their papers. The stated purpose of this exercise is to start a discussion on the importance of symbolism and its cultural context. The exercise followed by Dr. Poole is included among the instructors’ resources that accompany the course textbook.

It also goes on the state it is optional, of course, because the purpose of the exercise is not to insult anyone. The purpose is to make the lesson that people take symbols seriously. It didn't have to be jesus on the piece of paper, it could be whatever the person would feel negatively about stepping on. If you can't step on it, then maybe they should feel empathy when other peoples symbols get stepped on.

It seems like a completely logical lesson in context. However, it seems the student in question didn't get the point of it. So much so that he decided to stay after class to threaten the professor

The agitated student allegedly approached Dr. Poole in a threatening manner saying, “I want to hit you,” while punching his fist into his open palm. Dr. Poole also said that the student told Dr. Poole never to use this exercise again, and pounded on Dr. Poole’s desk with his fist several times yelling, “Don’t you ever do that again! Do you hear me?” Dr. Poole insisted that both students leave immediately, which they did. 
A witness also after class corroborates this in a later email.

I am at a loss for words regarding what happened tonight. I just wanted to make it clear that I do not share the same views as my colleague and have the utmost respect for you as a professor

That is when the university notified the student he was being charged under the university student code of conduct. Not because he didn't want to participate in the lesson, which is in the past by this point.

After an initial determination by this office that the student conduct process should proceed, you are being charged with violating FAU’s Student Code of Conduct, Regulation 4.007, specifically: (N) Acts of verbal, written (including electronic communications) or physical abuse, threats, intimidation, harassment, coercion or other conduct which threaten the health, safety or welfare of any person.

 I think it is safe to say Ben Carson is completely unaware of any of this. Or the fact that it may have well been partially racially motivated. This is clearly after anyone was going to step on the papers, and so after the student supposedly had already been disciplined for not participating in the 'stomping'.

Dr. Poole then asked the students in the class to discuss their personal reactions to the idea of stepping on their papers. Dr. Poole said that one student vociferously objected to stepping on the paper. The offended student remained disruptive, repeatedly calling out, “hey brother!” to reengage Dr. Poole in a one-on one dialogue during class. Dr. Poole told the AFDPC that he instructed the student to stop calling him “brother,” but ultimately dismissed the class early 

Not that it should matter, but Dr. Poole is black. The reason he was removed from work was because he received death threats after the media coverage, not because of the lesson.

https://www.insidehighered.com/news/2013/04/01/interview-professor-center-jesus-debate-florida-atlantic

One of the threats said that I might find myself hanging from a tree
The conservative media took some college student who clearly has anger problems, who lost his temper at a professor because he couldn't think outside of his own culture (in an intercultural class), threatened his professor, and the media just encourages and stirs up more anger and threats. The entire thing was built to make people angry.

Now, here we are over 2 years later, and this same half-story is being trolled out. Not just for the conservatives, but also now for the liberals. Ben Carson is just the tip of the ice-burg, and probably doesn't even know what he's referring to half of the time. He just knows what seems to get 'conservatives' attention, and they know how to play him like a flute. It's such a shame it's not even a funny any more. Now he's being used to get this story to make liberals angry too. Does he really believe the dept. of education should censure colleges, or did someone just tell him to say it? It seems like he had trouble remembering what to say, and even needed a second interview to clear things up with some help.

Noone seems to even know or care about what's happened anymore.





Sunday, October 11, 2015

Generating a large number of pseudo-random numbers in WebGL/OpenGL

I needed to make a large number of random numbers, but OpenGL doesn't really give a function that does this. I found a few quick and dirty tricks on the internet to get random like textures, but I really wasn't satisfied with the results. So I went a different path to try to get good results and performance.

Here is a demo of the generator: http://kcdodd.github.io/random-webgl/

My current implementation starts with a large random texture being pre-computed and loaded to the gpu, call it S. Each pixel is a random rgba value with uniform distribution between 0 and 1. This texture is constant and serves as a source of entropy for random values.

My random texture is also initialized with it's own random values, call it texture H, which is smaller than S. H.b, and H.a (blue and alpha channels) represent a texture position in S. At each iteration, H is updated by computing a new position, and looking up new values in S. S.b and S.a are mixed into H.b and H.a in a non-linear way to provide addition entropy to the position from which S itself is being sampled. However, this causes H.b, and H.a to not have a uniformly random value in the way I have done it, and is why I don't simply use that method directly for random values.

S.r, and S.g are sampled to preserve the uniform distribution of H.r and H.g (red and green), which are the values I will actually use as random numbers, ignoring the blue and alpha. They are simply added together, then mod 1 to stay on the interval [0.1].

To step the position in S, I am using the logistic map function with r = 4.

\[x^{i+1} = 4 x^i (1 - x^i) \]

I have tried to use this before as a random number generator, since it is chaotic by itself, but I have never been able to get a very desirable distribution from it. However, I don't really care about the distribution of positions, since it is the distribution of values it looks up that matters. As long as the two are independent of one another, I should get a uniform distribution, with a long non-repeating sequences due to the logistic map.

The random texture (red and green channels) can be thought of a random permutation of a random subset of S, both of which change in a chaotic way.

Just to mix the position a little further, I mix a small amount of S into x as well at each step (currently 0.1% worth). This means that the next value it generates is a function of the entire history of that pixel.

Here is the fragment shader for stepping H (which is called u_rand). S is u_entropy.


Thursday, October 1, 2015

Particle Pushing with Boris Method Matrix-Vector

This is going to a fairly technical post. I'm using the Boris method of charged particle pushing for my current project and just thought I'd share my notes. I first saw the Boris method described here : https://www.particleincell.com/2011/vxb-rotation/. Which provides a good explanation of why it was developed and compares it with other methods. 
However, the last time I did this I desired a simple form of computation based on a matrix/vector multiplication and addition. Something like

\[v^{n+1/2} = R v^{n-1/2} + A \]

Where R is the result of rotation in a magnetic field (not the R mentioned earlier in the linked article), and A is due to electric acceleration and interaction between electric and magnetic accelerations. And \(v^{n}\) is the velocity of the particle being stepped in time at the nth time marker. The position of the particle would be stepped in a leap-frog method as described in those documents.

I don't know if it has been put in this form before, it could have so I'm not trying to take credit for anything. I'm just following my notes. I start with the final equations listed in the link.

\[v^{n+1/2} = v^{n-1/2} + \frac{q \delta t}{m} \left (E + \frac{v^{n-1/2} + v^{n+1/2}}{2} \times  B\right ) \]
\[v^{n-1/2} = v^{-} - \frac{q \delta t}{2m} E \] 
\[v^{n+1/2} = v^{+} + \frac{q \delta t}{2m} E \]
\[v^{+} = v^{-} + \frac{q \delta t}{2m} \left (v^{+} + v^{-} \right ) \times B \]

They give a series of steps to velocity calculation. But I wanted a single multiply and add. I preferred renaming \(t = \phi \) for the next two steps. I think of \(\phi\) as like a angular vector of rotation due to the magnetic field.

\[\phi \equiv h B \]
\[h \equiv \frac{q \delta t}{2m} \]
\[v' = v^{-} + v^{-} \times \phi \]
\[v^{+} = v^{-} + v' \times \phi \frac{2}{1+ \phi^2}\]

Ok, just plugging step 3 into step 4.

\[ v^{+} = v^{-} + \left (v^{-} + v^{-} \times \phi \right ) \times \phi \frac{2}{1+ \phi^2} \]

Then start expanding the terms.

\[ v^{+} = v^{-}  + \frac{2}{1+ \phi^2} \left ( v^{-} \times \phi + (v^{-} \times \phi ) \times \phi \right )\]

\[ v^{+} = v^{-}  + \frac{2}{1+ \phi^2} \left ( v^{-} \times \phi + \phi \times (\phi \times v^{-}) \right )\]

Then use the vector identity \(a \times (b \times c) = (a \cdot c) b - (a \cdot b) c \), and \(\phi \cdot \phi = \phi^2 \)

\[ v^{+} = v^{-}  + \frac{2}{1+ \phi^2} \left ( v^{-} \times \phi + \phi (\phi \cdot v^{-} ) - \phi^2 v^{-} \right )\]

Now, pull out the \(v^{-}\). This will look really strange because of the 'dangling' vector operations. However, those can be converted into a matrix, which when a vector is multiplied through will have the desired result. But I will wait on computing that matrix.

\[ v^{+} = v^{-} \left (1  + \frac{2}{1+ \phi^2} \left ( (\times \phi)  + \phi (\phi \cdot  ) - \phi^2  \right ) \right ) \]

But this has to be put in terms of the actual current and next velocity. Basically, you can plug into the equations above to get it in terms of \(v^{n-1/2}\) and \(v^{n+1/2}\). Also re-arranged the terms a bit.

\[ v^{n+1/2} = \left ( v^{n-1/2} + \frac{q \delta t}{2m} E \right ) \left (\left (1 - \frac{2 \phi^2 }{1+ \phi^2} \right )  + \frac{2}{1+ \phi^2} \left ( (\times \phi )  + \phi (\phi \cdot  )  \right ) \right )  + \frac{q \delta t}{2m} E\]

Now expand the first term

\[ v^{n+1/2} = v^{n-1/2} \left (\left (1 - \frac{2 \phi^2 }{1+ \phi^2} \right )  + \frac{2}{1+ \phi^2} \left ( (\times \phi )  + \phi (\phi \cdot  )  \right ) \right )  + \frac{q \delta t}{2m} E \left (\left (1 - \frac{2 \phi^2 }{1+ \phi^2} \right )  + \frac{2}{1+ \phi^2} \left ( (\times \phi )  + \phi (\phi \cdot  )  \right ) \right ) + \frac{q \delta t}{2m} E\]

Ok, I won't torture you any further with this. I'm going to skip to the end and just tell you what the matrices are in terms of the fields. 

\[R = \left ( 1 - \frac{2 h^2 B^2}{1 + h^2 B^2} \right ) I + \frac{2}{1 + h^2B^2}( h (\times B) + h^2 (BB)) \]

\[ I = \begin{bmatrix}1 & 0 & 0 \\ 0 & 1 & 0 \\  0 & 0 & 1 \\ \end{bmatrix}\]

\[ (\times B) = \begin{bmatrix}0 & B_3 & -B_2 \\ -B_3 & 0 & B_1 \\  B_2 & -B_1 & 0 \\ \end{bmatrix}\]

\[ (BB) = \begin{bmatrix} B_1 B_1 & B_1 B_2 & B_1 B_3 \\  B_2 B_1 & B_2 B_2 & B_2 B_3 \\  B_3 B_1 & B_3 B_2 & B_3 B_3 \\ \end{bmatrix}\]

\[A = h \left ( 2 - \frac{2 h^2 B^2}{1 + h^2 B^2} \right ) E + \frac{2}{1 + h^2B^2}\left ( h^2 (E \times B) + h^3 (E \cdot B) B \right ) \]

The impressiveness of this method can maybe be seen now being 3rd order in the delta time (the h constant), even taking into account for \(E\times B\) drift and energy being gained or lost to the fields through \(E\cdot B\). While at the same time conserving energy in the pure rotation part.

The idea is R and A would be pre-calculated once per step (assuming it is time-dependent) as a function of position given the fields E and B, with a total of 12 parameters. Then, when particles are pushed the matrix at position \(x^{n}\) is looked up and a multiply and add is done to update the velocity, which is a total of 9 multiply and 9 add operations per particle.