STATISTICAL MECHANICS OF JAMMING AND SEGREGATION IN GRANULAR MEDIA