22 June 2005

Reality Bitchslap

On the one hand we have Molly Ivins' June 16th column:

"Big Bird is not in favor of affirmative action. Bert and Ernie are not gay. Miss Piggy is not a feminist. "The Three Tenors," "Antiques Roadshow," "Masterpiece Theater," "Wall Street Week" and nature programs do not have a political agenda. "The NewsHour with Jim Lehrer" is biased in favor of boring, old, white guys who appear on painfully well-balanced panels. "Washington Week in Review" is a showcase for "Inside the Beltway," conventional wisdom, power-parroting, political-geekhead, Establishment journalism -- there is nothing liberal about it."

On the other we have Wanda's exasperated rant in "A Fish Called Wanda":

"Aristotle was not Belgian, the principle of Buddhism is not 'every man for himself', and the London Underground is not a political movement. Those are all mistakes, Otto. I looked them up."

I think we now have a new paradigm in metaphors for the seeming detachment of the right from reality.

11 June 2005

When it rains, there's a rainbow; and all of the colors are black

This has been posted many places and I probably ought to propagate it further. We have here the blog of a 16-year-old kid whose reward for coming out to his parents has been to get thrown into a "boot camp"-style program in order to make him stop being gay.

I will have more to say about it later. For the moment, he can speak for himself.

27 February 2005

import javagently.*;
import java.io.*;

class Integrator
{
public static void main(String args[])
{
ReadFile();
RectangleIntegrate(ReadFile.x[i], ReadFile.y[i], ReadFile.N);
TrapezoidIntegrate(ReadFile.x[i], ReadFile.y[i], ReadFile.N);
SimpsonIntegrate(ReadFile.x[i], ReadFile.y[i], ReadFile.N);
LeastSquares(ReadFile.x[i], ReadFile.y[i], ReadFile.N);
/* Graph(ReadFile.x[i], ReadFile.y[i], ReadFile.N, LeastSquares.m, LeastSquares.b); */
WriteFile(ReadFile.outFile, RectangleIntegral.rectangle, TrapezoidIntegral.trapezoid, SimpsonIntegral.simpson, LeastSquares.m, LeastSquares.b);
}

public static void ReadFile() throws IOException
{
Display display = new Display("Data files");
display.prompt("Input file name","input.data");
display.prompt("Output file name","output.data");
display.ready("Click to begin!");
String inFilename = display.getString("Input file name");
String outFilename = display.getString("Output file name");
BufferedReader fin = Text.open(inFilename);
int N = Text.readInt(fin);
double x[] = new double[N+1];
double y[] = new double[N+1];
for (int i = 1; i <= N; i++)
{x[i] = Text.readDouble(fin); }
for (int i = 1; i <= N; i++)
{y[i] = Text.readDouble(fin); }
}

public static double RectangleIntegrate(double x[], double y[], int N)
{
double width = 0, height= 0, SubArea= 0, trapezoid = 0;
for (int i = 1; i <= N; i++)
{
width = x[i+1] - x[i];
height = (y[i] + y[i+1])/2;
SubArea = width * height;
trapezoid += SubArea;
System.out.println("Trapezoid integral: " + trapezoid);
}
}

public static double TrapezoidIntegrate(double x[], double y[], int N)
{
double width = 0, height= 0, SubArea= 0, trapezoid = 0;
for (int i = 1; i <= N; i++)
{
width = x[i+1] - x[i];
height = (y[i] + y[i+1])/2;
SubArea = width * height;
trapezoid += SubArea;
System.out.println("Trapezoid integral: " + trapezoid);
}
}

public static double SimpsonIntegrate(double x[], double y[], int N)
{
double width = 0, height = 0, SubArea = 0, TotArea = 0;
for(int i = 2; i <= N - 1; i = i+2)
{
width = (x[i+1] - x[i-1])/3;
height = y[i-1] + (4 * y[i]) + y[i+1];
SubArea = width * height;
TotArea += SubArea;
System.out.println(TotArea);
}
}

public static void LeastSquares(double x[], double y[], int N)
{
double sumX = 0, sumY = 0, sumX2 = 0, sumXY = 0, m = 0, b = 0;
for(int i = 1; 1 <= N; i++)
{
sumX += x[i];
sumY += y[i];
sumX2 += x[i] * x[i];
sumXY += x[i] * y[i];
}
m = ((sumX * sumXY) - (sumX2 * sumY)) / ((sumX * sumX) - (N * sumX2));
b = ((sumX * sumY) - (N * sumXY)) / ((sumX * sumX) - (N * sumX2));
}

/* Graph goes here */

static void WriteFile(String outfile, double rectangle, double trapezoid, double simpson, double m, double b) throws IOException
{
display.println("Writing to file " + outFilename);
PrintWriter fout = Text.create(outFilename);
fout.println("The rectangular integral is " + rectangle);
fout.println("The trapezoidal integral is " + trapezoid);
fout.println("The Simpson's rule integral is " + simpson);
fout.println("The best-fit line is: f(x) = " + m + "x + " + b);
fout.close();
}
}