The founders of the National Football League were visionaries, but the time has come to jettison the antiquated rules and norms they devised a century ago to govern America's most popular game, in favor of a fairer system. The current outdated arrangement—with endless checks, balances, compromises and video reviews—works for the few, not for the many. Worse still, it has left a bunch of dead people in charge of how football should be played. The time has come for a people's revolution!
I confess a personal stake in this refounding: The NFL's rules and traditions have doomed my team, the Detroit Lions, to the lowly status of the one of the worst franchises in the league. The Lions haven't won a championship in more than 60 years and aren't likely to win one in another 60. Meanwhile, the New England Patriots have gone to the Super Bowl 10 times in the past 20 years, winning six titles. This provides absolute, irrefutable evidence that the NFL is rigged in favor of a set of powerful, unaccountable elites.
I know my complaint makes me sound like a sore loser who seeks to restack the deck so he can extract a winning hand. I resent that charge. My interest is merely in fairness and democracy and the end of the age of sports hyperpartisanship.
The NFL's founders, as far-sighted as they were, could never have envisioned the needs of the modern gridiron. What's needed is a revolutionary rethinking of how the game should be played to restore equality and fairness. For example, when the NFL was founded, it might have made sense to award victory to the team that collected the most points through a combination of touchdowns (for which six points are given), points after (either one or two), field goals (three), and safeties (two). Well, gas lights and ice boxes made sense once, too. Compounding this folly is the playoff system that allows "wild card" teams that don't even have the best "win-loss" records in their divisions to compete in the season-ending playoffs. This system has more than once allowed a team with a mediocre record to win the Super Bowl.
This jury-rigged and archaic playoff system is anti-democracy in action. A more direct and more democratic method for picking the league champ is needed. Instead of a win-loss system (based on points scored, in a byzantine schedule of 16 games no less) that feeds teams into the unfair playoff system, we should embrace a new way to measure football excellence. First, we would compile all the yards gained by a team over a season and subtract the total number yards given up by its defense. The team with the highest differential would be named Super Bowl champion. If we had taken this path in 2019, the Baltimore Ravens, which gained 5,999 yards but surrendered only 4,687 yards for a differential of a 1,312 yards, would have been the champs, not the Pats, which had only the eighth best differential. "Make every yard count" would be a fine slogan for this reform.
Justice also demands a review of how the games are judged. It's not uncommon to see partisan flags thrown by the seven umpires, referees, linemen and judges who officiate each game. The best way to restore universal fan trust in officiating would be to pack the field with additional refs and umps until we have as many officials on the field as players on a team (11). Ridiculous, you might say. But there's nothing sacrosanct about having seven officials judging a game. At one time, NFL games got by with just three. The least bad way to ameliorate the bias of the existing umpires, referees, linesmen and judges that benefits some teams at the expense of others would be to pack the field with additional officials. To ensure fairness, the new officials should be chosen by the worst, that is, losing teams. Like the Lions.
As noted above, most NFL teams are owned by billionaires, with the richest guys—I'm looking at you, Robert Kraft—and tiny despots like Dan Snyder running the show. Let's take the influence of money out of the game once and for all by making every team a nonprofit corporation, much like the Green Bay Packers, with stock owned by the fans but banning the collection of profit from the shares. One way to ameliorate the harm Kraft's Patriots have done to the league would be to dilute his franchise's power by breaking it up into eight separate teams, one for each division, and democratically distribute them to deserving metropolises such as Portland, San Antonio, Memphis and Salt Lake City, which have never had NFL teams, and to cities like St. Louis, San Diego and Oakland which have lost (or will soon lose) their teams. If we're going to call it America's Game, shouldn't the NFL look like America?
Send a scan of your Bobby Layne card via email to Shafer.Politico@gmail.com. My email alerts pray for the return of the Kenosha Maroons, a former NFL franchise. My Twitter feed has the same ambition for the Racine Legion. My RSS feed still worships Barry Sanders.


text:
December 16, 2020 | Policy Brief
Russian Hackers Target U.S. Government Agencies
RADM (Ret) Mark Montgomery
CCTI Senior Director and Senior Fellow
Trevor Logan
Multiple news reports from this past weekend indicate that hackers working for Russian intelligence breached networks and monitored email traffic at a number of U.S. federal agencies – including the Treasury Department, the Commerce Department's National Telecommunications and Information Administration, the State Department, and the Department of Homeland Security (DHS) – as well as numerous businesses and the cybersecurity firm FireEye. The massive scope of the breach reflects the scale of the cybersecurity challenges facing the incoming administration.
Investigators uncovered the campaign, which dates at least to the spring of 2020, while investigating a hack of FireEye's systems. After publicly acknowledging the breach, FireEye reportedly shared information on the hack with Microsoft and the National Security Agency (NSA) in order to determine how the hackers accessed FireEye's network. An analysis of the data revealed that the hackers compromised SolarWinds' Orion software, a network-management service.
Identifying the software that the hackers exploited allowed the U.S. government to recognize the full scope of the campaign's impact. SolarWinds claims that over 300,000 customers use its services worldwide, including all branches of the U.S. military, the Pentagon, the NSA, and NATO. This makes the Russian breach particularly devastating, and it may be that the compromise was limited only by the capacity of the adversary to process pilfered data.
Fortunately, a number of cybersecurity provisions in this year's National Defense Authorization Act (NDAA) will help address some of the factors that contributed to the success of the Russian hack. For example, Section 1705 of the NDAA grants DHS' Cybersecurity and Infrastructure Security Agency (CISA) the authority to conduct threat hunting on federal networks, which would help to expedite remediation efforts while actively looking for vulnerabilities.
Another NDAA provision, Section 1715, establishes a joint cyber planning office in DHS to facilitate comprehensive planning of defensive cyber campaigns across the federal government. Such an office could have played a significant role in the response and remediation efforts following the SolarWinds breach.
The Biden administration should also fast-track the establishment of the national cyber director (NCD) position and supporting staff within the Executive Office of the President as one of the administration's first actions upon taking office in January. Established by Section 1752 of the NDAA, the NCD will serve as the principal advisor to the president on cybersecurity matters and will lead the response efforts across the federal government to an incident such as this hack. The NCD will also oversee cybersecurity coordination with the private sector as well as state, local, territorial, and tribal governments to ensure the uniformity of the U.S. response in cyberspace.
Finally, with an NCD in office, the United States will be better positioned to assess the scope of a hacking campaign and rapidly attribute its source. The NCD will be able to coordinate with the National Security Council to send a clear response back to the foreign government involved that Washington will not tolerate such attacks.
Even though the U.S. presidential inauguration is still weeks away, the fallout from the Russian hacking campaign will undoubtedly be one of the first challenges that the Biden administration's cyber team will need to tackle. It will likely also be left to the incoming administration to determine how to hold Russia to account for its actions. By appointing an NCD and strengthening CISA, the Biden administration can send a resolute message to Moscow that Washington is ready to fight back from more secure networks.
Mark Montgomery is senior director of the Center on Cyber and Technology Innovation (CCTI) at the Foundation for Defense of Democracies (FDD), where Trevor Logan is a cyber research analyst. For more analysis from Mark, Trevor, and CCTI, please subscribe HERE. Follow Mark and Trevor on Twitter @MarkCMontgomery and @TrevorLoganFDD. Follow FDD on Twitter @FDD and @FDD_CCTI. FDD is a Washington, DC-based, nonpartisan research institute focusing on national security and foreign policy.
Cyber Russia

redpajama_set_name: RedPajamaCommonCrawl


text:
Poštovna je budova a instituce, kde jsou zajištěny některé základní poštovní služby. Dříve byla podřízena některému poštovnímu úřadu.

Poštovny dříve
Poštovna byla definována jako malá nesamostatná služebna přidělená nadřízenému vyúčtovacímu poštovnímu úřadu.

Poštovny na území nynější České republiky fungovaly od roku 1899. Poskytovaly nejnutnější poštovní služby. Vedoucí poštovny zajišťoval poštovný, což byla spíše čestná funkce, za jejíž výkon dostávala osoba sjednanou odměnu (nikoli plat).

Poštovny fungovaly v Československu do roku 1958. Listovní zásilky orazítkované v poštovnách jsou vyhledávaným sběratelským artiklem.

Poštovny nyní
České poštovny fungují na řadě odloučených, turisticky zajímavých míst. Jsou pro Českou poštu pracovištěm, provozovaným jejím smluvním partnerem, tedy nikoli zaměstnanci České pošty. Poskytují některé poštovní služby, jejichž rozsah se různí podle možností provozovatele. Tím bývají např. různé hotely či restaurace v horách.

Nejznámější poštovnou v Čechách je nyní staronová poštovna Anežka na Sněžce.

Odkazy

Reference

Externí odkazy
 Poštovna v Sedlci
 Poštovna na Sněžce
 Poštovny na webu filatelistů

Poskytovatelé poštovních a zásilkových služeb

redpajama_set_name: RedPajamaWikipedia


Our Hop on Hop off London bus tour includes 6 different bus routes, 80 stops, a free walking tour, river cruise along the Thames, and more. The original sightseeing Hop on Hop off bus tour is the best way to travel to the most famous sites in the capital and see amazing places like Buckingham Palace, the London Eye, Big Ben and the Houses of Parliament. Learn about the history and fame of the city with an info-packed commentary. Save time and money with clever hop on hop off double-decker buses. Take advantage of a grand total of six unique different bus routes which cover all the essential places in London. Choose between a 24 or 48 hour ticket.
Explore the city at your own leisure with this convenient and fun bus tour, with six bus routes and over 80 stops.
You can see more than 150 historical buildings along the way!
Learn about London's most famous landmarks with a live guide (yellow route) and multi-language audio guide (all other routes).
Unlimited use, so hop-on and hop-off as much as you like!
You can see a map of the routes here.
THE YELLOW ROUTE is the primary hop on hop off route which goes to the best of London sights and attractions. Highlights include Tower of London, St Paul's Cathedral, London Eye, Tower Bridge, Trafalgar Square, The Shard, & Leicester Square. You also get to cross the River Thames twice, so brace yourself for some amazing views! AND the route includes a really entertaining live guide!
First Tour: 08:30 from Coventry Street.
THE RED ROUTE has a grand total of 35 bus routes and covers important places like Buckingham Palace, Big Ben, Houses of Parliament, Hyde Park, Madame Tussauds, Oxford Street & Picadilly Circus. The route includes a clever audio guide (in 11 different languages!). And for kids, there's a dedicated childrens channel!
First Tour: 08:30 from Grosvenor Gardens.
THE BLUE ROUTE takes you around some important shopping and museum districts. The route includes the world famous Harrods department store, Harvey Nicholls, The Science Museum, Victoria & Albert Museum, Design Museum and Natural History Museum.
First Tour: 08:30 from Kensington Palace Gate.
Last Tour: 17:50 from Hyde Park Corner.
THE ORANGE ROUTE is your dedicated route to get to the British Museum, which is considered one of the most amazing museums in the world! It has some really truly incredible collections about human history, art and culture. Plus entrance is free! The orange route is also a connector route that stops at 3 major train stations: King's Cross, St Pancras and Euston. So its really the best hop on hop off route if you want to connect from these train station to the major Yellow and Red routes.
Bus Stop T 10.03 and about every 20 minutes until 12.03.
Bus Stop S 10.07 and about every 20 minutes until 12.07.
These hop on hop off routes help you get around London, and are great ways to get you to the major Yellow and Red routes.
THE GREEN ROUTE is a practical route that allows you to crisscross the city quickly, from Trafalgar Square to Leicester Square. It basically does a loop around Central London.
Last Tour: 14:35 from Charing Cross Road.
THE PURPLE 'HOTEL' ROUTE is perfect if you are staying in hotels in Bayswater, Notting Hill, Holland Park or Lancaster Gate as it will pick you up and take you to join the yellow or red routes in Central London.
First Tour: 08:10 from Holland Park.
Frequency: Every 20 minutes to 11:10 then every 30 minutes.
First Tour: 11:38 from Marble Arch.
Frequency: Every 30 minutes to 16:38 then every hour.
Included in your ticket is a special kids package! Your child will love the unique and entertaining audio guides that are carefully prepared for ages 5-11. There's also a kid's passport that includes quizzes, activities, stories and games. Plus on the blue and red bus route there's a special kids commentary channel. So there's more than enough stuff to keep your little angels busy.
The Rock n Roll Walk takes you back to the swinging sixties, where London was THE place to be if you were a young rockstar musician. Discover icons like Jimmy Hendrix, the Beatles and the Rolling Stones and their connection with this really trendy area of Soho that is full of really nice bars and pubs.
The Jack the Ripper Walk takes you back to the 19th Century. Learn about the worlds most famous serial killer and the gruesome stories that take place in London's East End. But don't say we didn't warn you…. this tour is not for the faint hearted!
Your cruise takes you along the River Thames, starting right by Big Ben (at Westminster Pier) and heading all the way up to the Tower of London. You'll pass by some really amazing places along the way like Tower Bridge, the London Eye, Shakespeare's Globe & the Houses of Parliament. Totally worth it!
Plus with a 48 hour ticket, your cruise goes even further along the Thames! Starting by Big Ben, you'll head past the Tower of London and all the way up to historic Greenwich. Here you can see the Royal Observatory, the Cutty Sark, the Old Royal Naval College, Greenwich Park and the National Maritime Museum. Awesome!
Audio guides are available in 11 languages: English, German, French, Spanish, Italian, Russian, Japanese, Portuguese, Mandarin, Arabic & Brazilian Portuguese. Plus there's a unique kid's channel!
Admission to the London attractions is not included in the ticket. The hop on hop off bus just help you get there!


Available in a dazzling White, these sweets will be sure to WOW your guests at your next event.
Do you need a Confectionery item that will work for Candy Buffet / Event Styling / Catering,Party Shop? Look no further, this product is the one for you.
Looking for an item to suit Fat Free,Gluten Free,Halal,Nut Free diets? Than this Confectionery is perfect for you.
This confectionery is categorised as "Rock Candy Swizzle Sticks".


How did you know Rolf wasn't going to like it?
Ted knows his way around the courthouse.
Duane said he saw something scary.
I gave James Jeff's phone number.
Michel is trying not to cough.
Pontus got tired of waiting for Deirdre, so he went into the museum without her.
Ritalynne hadn't eaten in three days.
Lance certainly didn't have my permission to do what he did.
Why not just kill Vaughn?
Juliane started shaving when he was thirteen.
Spy is willing to stand by you.
Laurianne is at peace now.
Tracy ate one slice of Swiss cheese.
Francois didn't even read it.
Fortunately Louiqa felt the same way as did Maarten.
Although he was not a native speaker, Noemi wrote short stories in German at a high literary level. Due to their brilliant wit, they soon enjoyed great popularity.
Why can't you just call Lawrence?
Jerry is well aware of what is going on at the office.
Do you really think Raif is happy?
Randy's father is older than mine.
How did Eduardo take it when you told him?
Knut knew that he should study harder.
Alastair is in the hospital waiting room.
I have no reason not to trust Lord.
I'm glad you didn't call Surya.
My real name is Klaudia.
Kriton asked Stanly out to dinner, but she said no.
Ozan wants to go job hunting.


text:
package uk.ac.ox.zoo.seeg.abraid.mp.modeloutputhandler.web;

import org.joda.time.DateTime;
import org.joda.time.DateTimeUtils;
import org.junit.Before;
import org.junit.Test;
import uk.ac.ox.zoo.seeg.abraid.mp.common.domain.*;
import uk.ac.ox.zoo.seeg.abraid.mp.common.service.core.DiseaseService;
import uk.ac.ox.zoo.seeg.abraid.mp.common.service.core.ModelRunService;
import uk.ac.ox.zoo.seeg.abraid.mp.common.service.workflow.DiseaseOccurrenceValidationService;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.*;

public class BatchingHandlerHelperTest {
    private BatchingHandlerHelper helper;
    private DiseaseService diseaseService;
    private ModelRunService modelRunService;
    private DiseaseOccurrenceValidationService diseaseOccurrenceValidationService;

    @Before
    public void setUp() {
        diseaseService = mock(DiseaseService.class);
        modelRunService = mock(ModelRunService.class);
        diseaseOccurrenceValidationService = mock(DiseaseOccurrenceValidationService.class);
        helper = new BatchingHandlerHelper(diseaseService, modelRunService,
                diseaseOccurrenceValidationService);
        DateTimeUtils.setCurrentMillisFixed(DateTime.now().getMillis());
    }

    @Test
    public void handleValidationParametersHasNoEffectIfModelIncomplete() {
        // Arrange
        int diseaseGroupId = 87;
        ModelRun modelRun = createModelRun(diseaseGroupId, ModelRunStatus.FAILED);
        DiseaseGroup diseaseGroup = new DiseaseGroup(diseaseGroupId);

        when(modelRunService.getModelRunByName(modelRun.getName())).thenReturn(modelRun);
        when(diseaseService.getDiseaseGroupById(diseaseGroupId)).thenReturn(diseaseGroup);

        // Act
        DateTime batchingInitialisationDate = helper.handle(modelRun);

        // Assert
        assertThat(batchingInitialisationDate).isNull();
        verify(modelRunService, never()).hasBatchingEverCompleted(anyInt());
        verify(diseaseService, never()).getDiseaseOccurrencesByDiseaseGroupId(anyInt());
        verify(diseaseService, never()).getDiseaseOccurrencesForBatching(anyInt(), any(DateTime.class), any(DateTime.class));
        verify(diseaseOccurrenceValidationService, never()).addValidationParameters(anyListOf(DiseaseOccurrence.class));
        verify(diseaseService, never()).saveDiseaseOccurrence(any(DiseaseOccurrence.class));
        verify(modelRunService, never()).saveModelRun(any(ModelRun.class));
    }

    @Test
    public void handleValidationParametersHasNoEffectIfDiseaseGroupIsNotBeingSetUp() {
        // Arrange
        int diseaseGroupId = 87;
        ModelRun modelRun = createModelRun(diseaseGroupId, ModelRunStatus.COMPLETED);
        DiseaseGroup diseaseGroup = new DiseaseGroup(diseaseGroupId);
        diseaseGroup.setAutomaticModelRunsStartDate(DateTime.now());

        when(modelRunService.getModelRunByName(modelRun.getName())).thenReturn(modelRun);
        when(diseaseService.getDiseaseGroupById(diseaseGroupId)).thenReturn(diseaseGroup);

        // Act
        DateTime batchingInitialisationDate = helper.handle(modelRun);

        // Assert
        assertThat(batchingInitialisationDate).isNull();
        verify(modelRunService, never()).hasBatchingEverCompleted(anyInt());
        verify(diseaseService, never()).getDiseaseOccurrencesByDiseaseGroupId(anyInt());
        verify(diseaseService, never()).getDiseaseOccurrencesForBatching(anyInt(), any(DateTime.class), any(DateTime.class));
        verify(diseaseOccurrenceValidationService, never()).addValidationParameters(anyListOf(DiseaseOccurrence.class));
        verify(diseaseService, never()).saveDiseaseOccurrence(any(DiseaseOccurrence.class));
        verify(modelRunService, never()).saveModelRun(any(ModelRun.class));
    }

    @Test
    public void handleValidationParametersInitialisesBatchingIfBatchingHasNeverCompleted() {
        // Arrange
        int diseaseGroupId = 87;
        ModelRun modelRun = createModelRun(diseaseGroupId, ModelRunStatus.COMPLETED);
        modelRun.setBatchStartDate(DateTime.now().minusDays(1));
        modelRun.setBatchEndDate(DateTime.now());
        DiseaseGroup diseaseGroup = new DiseaseGroup(diseaseGroupId);

        DiseaseOccurrence occurrence1 = new DiseaseOccurrence();
        occurrence1.setStatus(DiseaseOccurrenceStatus.READY);
        occurrence1.setFinalWeighting(0.5);

        DiseaseOccurrence occurrence2 = new DiseaseOccurrence();
        occurrence2.setStatus(DiseaseOccurrenceStatus.READY);
        occurrence2.setFinalWeightingExcludingSpatial(0.7);

        List<DiseaseOccurrence> occurrences = Arrays.asList(occurrence1, occurrence2);

        when(modelRunService.getModelRunByName(modelRun.getName())).thenReturn(modelRun);
        when(diseaseService.getDiseaseGroupById(diseaseGroupId)).thenReturn(diseaseGroup);
        when(modelRunService.hasBatchingEverCompleted(diseaseGroupId)).thenReturn(false);
        when(diseaseService.getDiseaseOccurrencesForBatchingInitialisation(diseaseGroupId)).thenReturn(occurrences);

        // Act
        DateTime batchingInitialisationDate = helper.handle(modelRun);

        // Assert
        assertThat(batchingInitialisationDate).isEqualTo(DateTime.now());
        verify(diseaseService).saveDiseaseOccurrence(same(occurrence1));
        verify(diseaseService).saveDiseaseOccurrence(same(occurrence2));
        assertThat(occurrence1.getFinalWeighting()).isNull();
        assertThat(occurrence2.getFinalWeightingExcludingSpatial()).isNull();
    }

    @Test
    public void handleValidationParametersDoesNotInitialiseBatchingIfBatchingHasCompleted() {
        // Arrange
        int diseaseGroupId = 87;
        ModelRun modelRun = createModelRun(diseaseGroupId, ModelRunStatus.COMPLETED);
        modelRun.setBatchStartDate(DateTime.now().minusDays(1));
        modelRun.setBatchEndDate(DateTime.now());
        DiseaseGroup diseaseGroup = new DiseaseGroup(diseaseGroupId);

        when(modelRunService.getModelRunByName(modelRun.getName())).thenReturn(modelRun);
        when(diseaseService.getDiseaseGroupById(diseaseGroupId)).thenReturn(diseaseGroup);
        when(modelRunService.hasBatchingEverCompleted(diseaseGroupId)).thenReturn(true);

        // Act
        DateTime batchingInitialisationDate = helper.handle(modelRun);

        // Assert
        assertThat(batchingInitialisationDate).isNull();
        verify(modelRunService).hasBatchingEverCompleted(eq(diseaseGroupId));
        verify(diseaseService, never()).getDiseaseOccurrencesByDiseaseGroupId(anyInt());
        verify(diseaseService, never()).saveDiseaseOccurrence(any(DiseaseOccurrence.class));
    }

    @Test
    public void handleValidationParametersDoesNotBatchIfThereIsNoBatchEndDate() {
        // Arrange
        int diseaseGroupId = 87;
        ModelRun modelRun = createModelRun(diseaseGroupId, ModelRunStatus.COMPLETED);
        DiseaseGroup diseaseGroup = new DiseaseGroup(diseaseGroupId);

        when(modelRunService.getModelRunByName(modelRun.getName())).thenReturn(modelRun);
        when(diseaseService.getDiseaseGroupById(diseaseGroupId)).thenReturn(diseaseGroup);

        // Act
        DateTime batchingInitialisationDate = helper.handle(modelRun);

        // Assert
        assertThat(batchingInitialisationDate).isNull();
        verify(modelRunService, never()).hasBatchingEverCompleted(anyInt());
        verify(diseaseService, never()).getDiseaseOccurrencesForBatching(anyInt(), any(DateTime.class), any(DateTime.class));
        verify(diseaseOccurrenceValidationService, never()).addValidationParameters(anyListOf(DiseaseOccurrence.class));
        verify(diseaseService, never()).saveDiseaseOccurrence(any(DiseaseOccurrence.class));
        verify(modelRunService, never()).saveModelRun(any(ModelRun.class));
    }

    @Test
    public void handlingSucceedsIfThereAreNoOccurrencesToBatch() {
        // Arrange
        int diseaseGroupId = 87;
        DateTime batchStartDate = new DateTime("2012-11-13T00:00:00.000");
        DateTime batchEndDate = new DateTime("2012-11-14T23:59:59.999");
        ModelRun modelRun = createModelRun(diseaseGroupId, ModelRunStatus.COMPLETED);
        modelRun.setBatchStartDate(batchStartDate);
        modelRun.setBatchEndDate(batchEndDate);
        DiseaseGroup diseaseGroup = new DiseaseGroup(diseaseGroupId);
        diseaseGroup.setName("Dengue");

        when(modelRunService.getModelRunByName(modelRun.getName())).thenReturn(modelRun);
        when(diseaseService.getDiseaseGroupById(diseaseGroupId)).thenReturn(diseaseGroup);
        when(modelRunService.hasBatchingEverCompleted(diseaseGroupId)).thenReturn(false);
        when(diseaseService.getDiseaseOccurrencesForBatching(diseaseGroupId, batchStartDate, batchEndDate))
                .thenReturn(new ArrayList<DiseaseOccurrence>());

        // Act
        DateTime batchingInitialisationDate = helper.handle(modelRun);

        // Assert
        assertThat(batchingInitialisationDate).isEqualTo(DateTime.now());
        verify(diseaseService).getDiseaseOccurrencesForBatching(
                eq(diseaseGroupId), eq(batchStartDate), eq(batchEndDate));
        verify(diseaseOccurrenceValidationService, never()).addValidationParameters(anyListOf(DiseaseOccurrence.class));
        verify(diseaseService, never()).saveDiseaseOccurrence(any(DiseaseOccurrence.class));
        verify(modelRunService).saveModelRun(modelRun);
    }

    @Test
    public void handlingSucceedsIfThereAreOccurrencesToBatch() {
        // Arrange
        int diseaseGroupId = 87;
        DateTime batchStartDate = new DateTime("2013-07-29T00:00:00.000");
        DateTime batchEndDate = new DateTime("2013-07-30T23:59:59.999");
        ModelRun modelRun = createModelRun(diseaseGroupId, ModelRunStatus.COMPLETED);
        modelRun.setBatchStartDate(batchStartDate);
        modelRun.setBatchEndDate(batchEndDate);
        DiseaseGroup diseaseGroup = new DiseaseGroup(diseaseGroupId);
        diseaseGroup.setName("Dengue");

        DiseaseOccurrence occurrence1 = new DiseaseOccurrence();
        DiseaseOccurrence occurrence2 = new DiseaseOccurrence();
        List<DiseaseOccurrence> occurrences = Arrays.asList(occurrence1, occurrence2);

        when(modelRunService.getModelRunByName(modelRun.getName())).thenReturn(modelRun);
        when(diseaseService.getDiseaseGroupById(diseaseGroupId)).thenReturn(diseaseGroup);
        when(modelRunService.hasBatchingEverCompleted(diseaseGroupId)).thenReturn(false);
        when(diseaseService.getDiseaseOccurrencesForBatching(diseaseGroupId, batchStartDate, batchEndDate))
                .thenReturn(occurrences);

        // Act
        DateTime batchingInitialisationDate = helper.handle(modelRun);

        // Assert
        assertThat(batchingInitialisationDate).isEqualTo(DateTime.now());
        verify(diseaseService).getDiseaseOccurrencesForBatching(
                eq(diseaseGroupId), eq(batchStartDate), eq(batchEndDate));
        verify(diseaseOccurrenceValidationService).addValidationParameters(same(occurrences));
        verify(diseaseService).saveDiseaseOccurrence(same(occurrence1));
        verify(diseaseService).saveDiseaseOccurrence(same(occurrence2));
        verify(modelRunService).saveModelRun(modelRun);
    }

    @Test
    public void continueBatchingInitialisationDoesNothingIfBatchingInitialisationDateIsNull() {
        // Arrange
        int diseaseGroupId = 87;

        // Act
        helper.continueBatchingInitialisation(diseaseGroupId, null);

        // Assert
        verify(diseaseService, never()).getDiseaseOccurrencesByDiseaseGroupIdAndStatuses(anyInt(),
                any(DiseaseOccurrenceStatus.class));
        verify(diseaseService, never()).saveDiseaseOccurrence(any(DiseaseOccurrence.class));
    }

    @Test
    public void continueBatchingInitialisationSavesOccurrencesAfterInitialisationDate() {
        // Arrange
        int diseaseGroupId = 87;
        DiseaseOccurrence occurrence1 = createDiseaseOccurrence(-1);
        DiseaseOccurrence occurrence2 = createDiseaseOccurrence(0);
        DiseaseOccurrence occurrence3 = createDiseaseOccurrence(1);
        List<DiseaseOccurrence> occurrences = Arrays.asList(occurrence1, occurrence2, occurrence3);

        // Act
        when(diseaseService.getDiseaseOccurrencesForBatchingInitialisation(diseaseGroupId)).thenReturn(occurrences);
        helper.continueBatchingInitialisation(diseaseGroupId, DateTime.now());

        // Assert
        assertThat(occurrence1.getStatus()).isEqualTo(DiseaseOccurrenceStatus.READY);
        assertThat(occurrence2.getStatus()).isEqualTo(DiseaseOccurrenceStatus.AWAITING_BATCHING);
        assertThat(occurrence3.getStatus()).isEqualTo(DiseaseOccurrenceStatus.AWAITING_BATCHING);

        verify(diseaseService, never()).saveDiseaseOccurrence(same(occurrence1));
        verify(diseaseService).saveDiseaseOccurrence(same(occurrence2));
        verify(diseaseService).saveDiseaseOccurrence(same(occurrence3));
    }

    private ModelRun createModelRun(int diseaseGroupId, ModelRunStatus status) {
        ModelRun modelRun = new ModelRun(1);
        modelRun.setName("test");
        modelRun.setDiseaseGroup(new DiseaseGroup(diseaseGroupId));
        modelRun.setRequestDate(DateTime.now());
        modelRun.setStatus(status);
        return modelRun;
    }

    private DiseaseOccurrence createDiseaseOccurrence(int daysOffset) {
        DiseaseOccurrence occurrence = new DiseaseOccurrence(DateTime.now().plusDays(daysOffset));
        occurrence.setStatus(DiseaseOccurrenceStatus.READY);
        return occurrence;
    }
}

redpajama_set_name: RedPajamaGithub


$137 Bi weekly all inclusive. This local one owner finished in beautiful iron grey metallic basecoat clearcoat is sure to impress. Below average kms and all original with accident free Car Proof report. Carries a new two year MVI and reconditioned to above industry standards with our 360 degree inspection. A shark-like snout features a prominent six-sided grille flanked by projector beam headlamps and available stacked LED daytime running lights. Look carefully and you'll notice that the side intakes on the bumpers aren't just for looks – they house slim vents that divert airflow around the wheels to reduce drag. Behind the bold look is beefy new chassis which Hyundai dubs Superstructure. Aerospace adhesives bond a frame comprised of over 50 percent ultra-high tensile steels together, creating a vehicle that's safer, more refined, and better to drive. New suspension geometry, increased sound deadening equipment, better subframe isolation, and thicker glass all make this the quietest Elantra ever! Other changes include the latest version of Hyundai's infotainment systems – there's a 7.0-inch display audio system on vehicles equipped with the reverse camera,. Android Auto is featured on the mid-grade GL and up. Powered by a 147-hp 2.0-litre four-cylinder engine that uses the lean-burn Atkinson cycle that is typically found on hybrid vehicles. Standard equipment on the Elantra includes heated front seats, projector beam headlamps, and remote keyless entry, plus seven airbags, A/C, Bluetooth, and steering wheel controls, heated leather-wrapped steering wheel, blind-spot detection with rear cross-traffic alert, reverse camera, Android Auto and 16-inch alloy wheels. Drive with peace of mind knowing Elantra earned a top safety pick from the IIHS. To qualify for 2017 TOP SAFETY PICK+, a vehicle must earn good ratings in the driver-side small overlap front, moderate overlap front, side, roof strength and head restraint tests, as well as an advanced or superior rating for front crash prevention and an acceptable or good headlight rating.
Hi. I am interested in the vehicle "2017 Hyundai Elantra 4dr Sdn!". Could you send me more information? Thank you.


text:
The Small Firm
for Big Cases
In their nearly 50 years of combined experience representing
plaintiffs, Youman & Caputo have secured or helped secure more
than 100 verdicts or settlements in excess of $1 million.
Birth Injury Verdict
False Claims Act Settlement
A federal lawsuit in New York alleging that Teva Pharmaceuticals violated the Anti-Kickback Statute by using "speaker programs" to attempt to induce physicians to prescribe two neurology drugs.
Lawsuit that settled for $35 million with a healthcare system and two Tucson hospitals over alleged Medicare fraud. The settlement remains the largest of its kind in Arizona history.
Brain Injury Settlement
Medical Malpractice Verdict
Client who lost his sight because of prolonged back surgery. Caputo's verdict is one of the largest verdicts in Delaware County history and it ranked among the top 100 verdicts in any type of case in the United States in 2015.
Whistleblower in a New York tax fraud lawsuit against Lantheus Medical Imaging, Inc. and Bristol-Meyers Squibb Co that resulted in a $6.2 million settlement.
We Have a Track Record of Success
Catastrophic Injury &
Youman & Caputo is a trial law firm dedicated to representing catastrophic injury victims in Pennsylvania and New Jersey and whistleblowers nationwide. Our clients deserve personal attention and aggressive representation, so we started our firm with this vision: to handle big cases with the personal touch of a small firm.
At Youman & Caputo, we understand that your life will never be the same after a catastrophic injury. We also know how much courage it takes to come forward and report fraudulent behavior as a whistleblower. In both cases, our attorneys will investigate your case thoroughly and do what it takes to secure maximum compensation on your behalf. Contact us today to schedule a free consultation and find out how we can assist you.
Our firm's attorneys have:
More than $1 billion in verdicts and settlements
Settlements and verdicts in 30 Pennsylvania counties, throughout New Jersey and in federal courts around the country
Been named Pennsylvania Super Lawyers or Super Lawyers Rising Stars more than 25 times
Why choose our firm?
Youman & Caputo has a track record of success in our two practice areas: catastrophic injury litigation and whistleblower representation. We have more than 100 verdicts or settlements in excess of $1 million.
Our firm's founding partners have been in practice for more than 25 years and are consistently named Pennsylvania Super Lawyers. Our firm also has received Best Law Firm recognition.
As a firm, we focus on high-value cases – meaning we take a small number of high-value cases and work them up aggressively to maximize our client's recovery. Personalized client attention is a core principle of our firm. If you are a client of ours, you will have regular and direct communication with the name partner of the firm handling your case.
We are committed to using technology to represent our clients efficiently and responsively. We use technology to improve client service. Our firm is paperless to the greatest extent possible – reducing costs for our clients where there is a recovery.
Our firm works on purely contingent fee basis – our clients pay nothing unless and until we recover money on their behalf. This includes free case consultations so you can discuss your situation with an attorney at no cost or risk.
"We investigate our cases thoroughly, litigate them aggressively, and do not hesitate to try any case to try to achieve the best possible outcome for our clients."
Andrew Youman & David Caputo
The attorneys at Youman & Caputo are dedicated to aggressive, personalized representation for catastrophic injury victims and whistleblowers. Learn more about the full scope of our practice areas below.
SEC Whistleblower Claims
Solid experience
Our two main practice areas are catastrophic injury litigation and whistleblower representation.
A catastrophic injury is a serious injury that leaves lasting effects on the victim's life and permanent damages or losses. A person who suffers a catastrophic injury often requires multiple surgeries, extensive rehabilitation, or permanent use of medical devices for their long-term and debilitating injuries.
Catastrophic injury litigation includes medical malpractice, motor vehicle accidents, workplace injuries, premises liability, product liability, and civil rights cases.
A whistleblower is someone who is aware of illegal conduct by a private company that results in financial loss to the government and who reports or exposes it.
Whistleblower representation includes qui tam False Claims Act cases, IRS whistleblower claims, Securities and Exchange Commission (SEC) whistleblower claims, and Commodity Futures Trading Commission (CFTC) whistleblower claims.
If you have any questions or are unsure of what to do, speak with an attorney for free at Youman & Caputo. We will protect your rights and help you figure out your next steps.
Contact Youman & Caputo
If you have suffered a catastrophic injury or have come forward to report fraud as a whistleblower, you deserve full compensation. The attorneys at Youman & Caputo can provide you with aggressive and personalized representation and help you achieve the best possible outcome for your situation. Contact us today to schedule a free case consultation with one of our experienced attorneys.
attorneys that will fight for you.
"Personalized client attention
is a core principle of our firm."
From start to finish…simply the best!
Compassionate caring and above all knowledgeable and extremely well-versed. From the very beginning, I knew I was in good hands. Dave handled my very emotional case with sensitivity and care. I can't say enough positive things about Youman and Caputo. I highly recommend Dave and his team. From start to finish…simply the best!
Jennifer G.
The outcome exceeded my expectations
I reached out to David Caputo to discuss my medical malpractice case. He was very nice, easy to talk to, professional, and willing to take on my case immediately. He was able to resolve my case within a timely manner, outside of court and with zero headache. I honestly felt like he cared about my case and what I went through and therefore he fought for what I deserved. The outcome exceeded my expectations and I am very thankful for his help. I would definitely refer my family and friends to him.
Tabitha W.
They changed my life for the better
I am beyond happy that I went with this firm! A huge weight has been lifted off my shoulders as they fought for me and won my case! They changed my life for the better and I couldn't be happier with them and the way they treated me and worked with me through the entire process.
Chelsea Cicio


text:
#include "webrtc/modules/audio_processing/utility/delay_estimator.h"

#include <assert.h>
#include <stdlib.h>
#include <string.h>

// Number of right shifts for scaling is linearly depending on number of bits in
// the far-end binary spectrum.
static const int kShiftsAtZero = 13;  // Right shifts at zero binary spectrum.
static const int kShiftsLinearSlope = 3;

static const int32_t kProbabilityOffset = 1024;  // 2 in Q9.
static const int32_t kProbabilityLowerLimit = 8704;  // 17 in Q9.
static const int32_t kProbabilityMinSpread = 2816;  // 5.5 in Q9.

// Robust validation settings
static const float kHistogramMax = 3000.f;
static const float kLastHistogramMax = 250.f;
static const float kMinHistogramThreshold = 1.5f;
static const int kMinRequiredHits = 10;
static const int kMaxHitsWhenPossiblyNonCausal = 10;
static const int kMaxHitsWhenPossiblyCausal = 1000;
static const float kQ14Scaling = 1.f / (1 << 14);  // Scaling by 2^14 to get Q0.
static const float kFractionSlope = 0.05f;
static const float kMinFractionWhenPossiblyCausal = 0.5f;
static const float kMinFractionWhenPossiblyNonCausal = 0.25f;

// Counts and returns number of bits of a 32-bit word.
static int BitCount(uint32_t u32) {
  uint32_t tmp = u32 - ((u32 >> 1) & 033333333333) -
      ((u32 >> 2) & 011111111111);
  tmp = ((tmp + (tmp >> 3)) & 030707070707);
  tmp = (tmp + (tmp >> 6));
  tmp = (tmp + (tmp >> 12) + (tmp >> 24)) & 077;

  return ((int) tmp);
}

// Compares the |binary_vector| with all rows of the |binary_matrix| and counts
// per row the number of times they have the same value.
//
// Inputs:
//      - binary_vector     : binary "vector" stored in a long
//      - binary_matrix     : binary "matrix" stored as a vector of long
//      - matrix_size       : size of binary "matrix"
//
// Output:
//      - bit_counts        : "Vector" stored as a long, containing for each
//                            row the number of times the matrix row and the
//                            input vector have the same value
//
static void BitCountComparison(uint32_t binary_vector,
                               const uint32_t* binary_matrix,
                               int matrix_size,
                               int32_t* bit_counts) {
  int n = 0;

  // Compare |binary_vector| with all rows of the |binary_matrix|
  for (; n < matrix_size; n++) {
    bit_counts[n] = (int32_t) BitCount(binary_vector ^ binary_matrix[n]);
  }
}

// Collects necessary statistics for the HistogramBasedValidation().  This
// function has to be called prior to calling HistogramBasedValidation().  The
// statistics updated and used by the HistogramBasedValidation() are:
//  1. the number of |candidate_hits|, which states for how long we have had the
//     same |candidate_delay|
//  2. the |histogram| of candidate delays over time.  This histogram is
//     weighted with respect to a reliability measure and time-varying to cope
//     with possible delay shifts.
// For further description see commented code.
//
// Inputs:
//  - candidate_delay   : The delay to validate.
//  - valley_depth_q14  : The cost function has a valley/minimum at the
//                        |candidate_delay| location.  |valley_depth_q14| is the
//                        cost function difference between the minimum and
//                        maximum locations.  The value is in the Q14 domain.
//  - valley_level_q14  : Is the cost function value at the minimum, in Q14.
static void UpdateRobustValidationStatistics(BinaryDelayEstimator* self,
                                             int candidate_delay,
                                             int32_t valley_depth_q14,
                                             int32_t valley_level_q14) {
  const float valley_depth = valley_depth_q14 * kQ14Scaling;
  float decrease_in_last_set = valley_depth;
  const int max_hits_for_slow_change = (candidate_delay < self->last_delay) ?
      kMaxHitsWhenPossiblyNonCausal : kMaxHitsWhenPossiblyCausal;
  int i = 0;

  assert(self->history_size == self->farend->history_size);
  // Reset |candidate_hits| if we have a new candidate.
  if (candidate_delay != self->last_candidate_delay) {
    self->candidate_hits = 0;
    self->last_candidate_delay = candidate_delay;
  }
  self->candidate_hits++;

  // The |histogram| is updated differently across the bins.
  // 1. The |candidate_delay| histogram bin is increased with the
  //    |valley_depth|, which is a simple measure of how reliable the
  //    |candidate_delay| is.  The histogram is not increased above
  //    |kHistogramMax|.
  self->histogram[candidate_delay] += valley_depth;
  if (self->histogram[candidate_delay] > kHistogramMax) {
    self->histogram[candidate_delay] = kHistogramMax;
  }
  // 2. The histogram bins in the neighborhood of |candidate_delay| are
  //    unaffected.  The neighborhood is defined as x + {-2, -1, 0, 1}.
  // 3. The histogram bins in the neighborhood of |last_delay| are decreased
  //    with |decrease_in_last_set|.  This value equals the difference between
  //    the cost function values at the locations |candidate_delay| and
  //    |last_delay| until we reach |max_hits_for_slow_change| consecutive hits
  //    at the |candidate_delay|.  If we exceed this amount of hits the
  //    |candidate_delay| is a "potential" candidate and we start decreasing
  //    these histogram bins more rapidly with |valley_depth|.
  if (self->candidate_hits < max_hits_for_slow_change) {
    decrease_in_last_set = (self->mean_bit_counts[self->compare_delay] -
        valley_level_q14) * kQ14Scaling;
  }
  // 4. All other bins are decreased with |valley_depth|.
  // TODO(bjornv): Investigate how to make this loop more efficient.  Split up
  // the loop?  Remove parts that doesn't add too much.
  for (i = 0; i < self->history_size; ++i) {
    int is_in_last_set = (i >= self->last_delay - 2) &&
        (i <= self->last_delay + 1) && (i != candidate_delay);
    int is_in_candidate_set = (i >= candidate_delay - 2) &&
        (i <= candidate_delay + 1);
    self->histogram[i] -= decrease_in_last_set * is_in_last_set +
        valley_depth * (!is_in_last_set && !is_in_candidate_set);
    // 5. No histogram bin can go below 0.
    if (self->histogram[i] < 0) {
      self->histogram[i] = 0;
    }
  }
}

// Validates the |candidate_delay|, estimated in WebRtc_ProcessBinarySpectrum(),
// based on a mix of counting concurring hits with a modified histogram
// of recent delay estimates.  In brief a candidate is valid (returns 1) if it
// is the most likely according to the histogram.  There are a couple of
// exceptions that are worth mentioning:
//  1. If the |candidate_delay| < |last_delay| it can be that we are in a
//     non-causal state, breaking a possible echo control algorithm.  Hence, we
//     open up for a quicker change by allowing the change even if the
//     |candidate_delay| is not the most likely one according to the histogram.
//  2. There's a minimum number of hits (kMinRequiredHits) and the histogram
//     value has to reached a minimum (kMinHistogramThreshold) to be valid.
//  3. The action is also depending on the filter length used for echo control.
//     If the delay difference is larger than what the filter can capture, we
//     also move quicker towards a change.
// For further description see commented code.
//
// Input:
//  - candidate_delay     : The delay to validate.
//
// Return value:
//  - is_histogram_valid  : 1 - The |candidate_delay| is valid.
//                          0 - Otherwise.
static int HistogramBasedValidation(const BinaryDelayEstimator* self,
                                    int candidate_delay) {
  float fraction = 1.f;
  float histogram_threshold = self->histogram[self->compare_delay];
  const int delay_difference = candidate_delay - self->last_delay;
  int is_histogram_valid = 0;

  // The histogram based validation of |candidate_delay| is done by comparing
  // the |histogram| at bin |candidate_delay| with a |histogram_threshold|.
  // This |histogram_threshold| equals a |fraction| of the |histogram| at bin
  // |last_delay|.  The |fraction| is a piecewise linear function of the
  // |delay_difference| between the |candidate_delay| and the |last_delay|
  // allowing for a quicker move if
  //  i) a potential echo control filter can not handle these large differences.
  // ii) keeping |last_delay| instead of updating to |candidate_delay| could
  //     force an echo control into a non-causal state.
  // We further require the histogram to have reached a minimum value of
  // |kMinHistogramThreshold|.  In addition, we also require the number of
  // |candidate_hits| to be more than |kMinRequiredHits| to remove spurious
  // values.

  // Calculate a comparison histogram value (|histogram_threshold|) that is
  // depending on the distance between the |candidate_delay| and |last_delay|.
  // TODO(bjornv): How much can we gain by turning the fraction calculation
  // into tables?
  if (delay_difference > self->allowed_offset) {
    fraction = 1.f - kFractionSlope * (delay_difference - self->allowed_offset);
    fraction = (fraction > kMinFractionWhenPossiblyCausal ? fraction :
        kMinFractionWhenPossiblyCausal);
  } else if (delay_difference < 0) {
    fraction = kMinFractionWhenPossiblyNonCausal -
        kFractionSlope * delay_difference;
    fraction = (fraction > 1.f ? 1.f : fraction);
  }
  histogram_threshold *= fraction;
  histogram_threshold = (histogram_threshold > kMinHistogramThreshold ?
      histogram_threshold : kMinHistogramThreshold);

  is_histogram_valid =
      (self->histogram[candidate_delay] >= histogram_threshold) &&
      (self->candidate_hits > kMinRequiredHits);

  return is_histogram_valid;
}

// Performs a robust validation of the |candidate_delay| estimated in
// WebRtc_ProcessBinarySpectrum().  The algorithm takes the
// |is_instantaneous_valid| and the |is_histogram_valid| and combines them
// into a robust validation.  The HistogramBasedValidation() has to be called
// prior to this call.
// For further description on how the combination is done, see commented code.
//
// Inputs:
//  - candidate_delay         : The delay to validate.
//  - is_instantaneous_valid  : The instantaneous validation performed in
//                              WebRtc_ProcessBinarySpectrum().
//  - is_histogram_valid      : The histogram based validation.
//
// Return value:
//  - is_robust               : 1 - The candidate_delay is valid according to a
//                                  combination of the two inputs.
//                            : 0 - Otherwise.
static int RobustValidation(const BinaryDelayEstimator* self,
                            int candidate_delay,
                            int is_instantaneous_valid,
                            int is_histogram_valid) {
  int is_robust = 0;

  // The final robust validation is based on the two algorithms; 1) the
  // |is_instantaneous_valid| and 2) the histogram based with result stored in
  // |is_histogram_valid|.
  //   i) Before we actually have a valid estimate (|last_delay| == -2), we say
  //      a candidate is valid if either algorithm states so
  //      (|is_instantaneous_valid| OR |is_histogram_valid|).
  is_robust = (self->last_delay < 0) &&
      (is_instantaneous_valid || is_histogram_valid);
  //  ii) Otherwise, we need both algorithms to be certain
  //      (|is_instantaneous_valid| AND |is_histogram_valid|)
  is_robust |= is_instantaneous_valid && is_histogram_valid;
  // iii) With one exception, i.e., the histogram based algorithm can overrule
  //      the instantaneous one if |is_histogram_valid| = 1 and the histogram
  //      is significantly strong.
  is_robust |= is_histogram_valid &&
      (self->histogram[candidate_delay] > self->last_delay_histogram);

  return is_robust;
}

void WebRtc_FreeBinaryDelayEstimatorFarend(BinaryDelayEstimatorFarend* self) {

  if (self == NULL) {
    return;
  }

  free(self->binary_far_history);
  self->binary_far_history = NULL;

  free(self->far_bit_counts);
  self->far_bit_counts = NULL;

  free(self);
}

BinaryDelayEstimatorFarend* WebRtc_CreateBinaryDelayEstimatorFarend(
    int history_size) {
  BinaryDelayEstimatorFarend* self = NULL;

  if (history_size > 1) {
    // Sanity conditions fulfilled.
    self = malloc(sizeof(BinaryDelayEstimatorFarend));
  }
  if (self == NULL) {
    return NULL;
  }

  self->history_size = 0;
  self->binary_far_history = NULL;
  self->far_bit_counts = NULL;
  if (WebRtc_AllocateFarendBufferMemory(self, history_size) == 0) {
    WebRtc_FreeBinaryDelayEstimatorFarend(self);
    self = NULL;
  }
  return self;
}

int WebRtc_AllocateFarendBufferMemory(BinaryDelayEstimatorFarend* self,
                                      int history_size) {
  assert(self != NULL);
  // (Re-)Allocate memory for history buffers.
  self->binary_far_history =
      realloc(self->binary_far_history,
              history_size * sizeof(*self->binary_far_history));
  self->far_bit_counts = realloc(self->far_bit_counts,
                                 history_size * sizeof(*self->far_bit_counts));
  if ((self->binary_far_history == NULL) || (self->far_bit_counts == NULL)) {
    history_size = 0;
  }
  // Fill with zeros if we have expanded the buffers.
  if (history_size > self->history_size) {
    int size_diff = history_size - self->history_size;
    memset(&self->binary_far_history[self->history_size],
           0,
           sizeof(*self->binary_far_history) * size_diff);
    memset(&self->far_bit_counts[self->history_size],
           0,
           sizeof(*self->far_bit_counts) * size_diff);
  }
  self->history_size = history_size;

  return self->history_size;
}

void WebRtc_InitBinaryDelayEstimatorFarend(BinaryDelayEstimatorFarend* self) {
  assert(self != NULL);
  memset(self->binary_far_history, 0, sizeof(uint32_t) * self->history_size);
  memset(self->far_bit_counts, 0, sizeof(int) * self->history_size);
}

void WebRtc_SoftResetBinaryDelayEstimatorFarend(
    BinaryDelayEstimatorFarend* self, int delay_shift) {
  int abs_shift = abs(delay_shift);
  int shift_size = 0;
  int dest_index = 0;
  int src_index = 0;
  int padding_index = 0;

  assert(self != NULL);
  shift_size = self->history_size - abs_shift;
  assert(shift_size > 0);
  if (delay_shift == 0) {
    return;
  } else if (delay_shift > 0) {
    dest_index = abs_shift;
  } else if (delay_shift < 0) {
    src_index = abs_shift;
    padding_index = shift_size;
  }

  // Shift and zero pad buffers.
  memmove(&self->binary_far_history[dest_index],
          &self->binary_far_history[src_index],
          sizeof(*self->binary_far_history) * shift_size);
  memset(&self->binary_far_history[padding_index], 0,
         sizeof(*self->binary_far_history) * abs_shift);
  memmove(&self->far_bit_counts[dest_index],
          &self->far_bit_counts[src_index],
          sizeof(*self->far_bit_counts) * shift_size);
  memset(&self->far_bit_counts[padding_index], 0,
         sizeof(*self->far_bit_counts) * abs_shift);
}

void WebRtc_AddBinaryFarSpectrum(BinaryDelayEstimatorFarend* handle,
                                 uint32_t binary_far_spectrum) {
  assert(handle != NULL);
  // Shift binary spectrum history and insert current |binary_far_spectrum|.
  memmove(&(handle->binary_far_history[1]), &(handle->binary_far_history[0]),
          (handle->history_size - 1) * sizeof(uint32_t));
  handle->binary_far_history[0] = binary_far_spectrum;

  // Shift history of far-end binary spectrum bit counts and insert bit count
  // of current |binary_far_spectrum|.
  memmove(&(handle->far_bit_counts[1]), &(handle->far_bit_counts[0]),
          (handle->history_size - 1) * sizeof(int));
  handle->far_bit_counts[0] = BitCount(binary_far_spectrum);
}

void WebRtc_FreeBinaryDelayEstimator(BinaryDelayEstimator* self) {

  if (self == NULL) {
    return;
  }

  free(self->mean_bit_counts);
  self->mean_bit_counts = NULL;

  free(self->bit_counts);
  self->bit_counts = NULL;

  free(self->binary_near_history);
  self->binary_near_history = NULL;

  free(self->histogram);
  self->histogram = NULL;

  // BinaryDelayEstimator does not have ownership of |farend|, hence we do not
  // free the memory here. That should be handled separately by the user.
  self->farend = NULL;

  free(self);
}

BinaryDelayEstimator* WebRtc_CreateBinaryDelayEstimator(
    BinaryDelayEstimatorFarend* farend, int max_lookahead) {
  BinaryDelayEstimator* self = NULL;

  if ((farend != NULL) && (max_lookahead >= 0)) {
    // Sanity conditions fulfilled.
    self = malloc(sizeof(BinaryDelayEstimator));
  }
  if (self == NULL) {
    return NULL;
  }

  self->farend = farend;
  self->near_history_size = max_lookahead + 1;
  self->history_size = 0;
  self->robust_validation_enabled = 0;  // Disabled by default.
  self->allowed_offset = 0;

  self->lookahead = max_lookahead;

  // Allocate memory for spectrum and history buffers.
  self->mean_bit_counts = NULL;
  self->bit_counts = NULL;
  self->histogram = NULL;
  self->binary_near_history =
      malloc((max_lookahead + 1) * sizeof(*self->binary_near_history));
  if (self->binary_near_history == NULL ||
      WebRtc_AllocateHistoryBufferMemory(self, farend->history_size) == 0) {
    WebRtc_FreeBinaryDelayEstimator(self);
    self = NULL;
  }

  return self;
}

int WebRtc_AllocateHistoryBufferMemory(BinaryDelayEstimator* self,
                                       int history_size) {
  BinaryDelayEstimatorFarend* far = self->farend;
  // (Re-)Allocate memory for spectrum and history buffers.
  if (history_size != far->history_size) {
    // Only update far-end buffers if we need.
    history_size = WebRtc_AllocateFarendBufferMemory(far, history_size);
  }
  // The extra array element in |mean_bit_counts| and |histogram| is a dummy
  // element only used while |last_delay| == -2, i.e., before we have a valid
  // estimate.
  self->mean_bit_counts =
      realloc(self->mean_bit_counts,
              (history_size + 1) * sizeof(*self->mean_bit_counts));
  self->bit_counts =
      realloc(self->bit_counts, history_size * sizeof(*self->bit_counts));
  self->histogram =
      realloc(self->histogram, (history_size + 1) * sizeof(*self->histogram));

  if ((self->mean_bit_counts == NULL) ||
      (self->bit_counts == NULL) ||
      (self->histogram == NULL)) {
    history_size = 0;
  }
  // Fill with zeros if we have expanded the buffers.
  if (history_size > self->history_size) {
    int size_diff = history_size - self->history_size;
    memset(&self->mean_bit_counts[self->history_size],
           0,
           sizeof(*self->mean_bit_counts) * size_diff);
    memset(&self->bit_counts[self->history_size],
           0,
           sizeof(*self->bit_counts) * size_diff);
    memset(&self->histogram[self->history_size],
           0,
           sizeof(*self->histogram) * size_diff);
  }
  self->history_size = history_size;

  return self->history_size;
}

void WebRtc_InitBinaryDelayEstimator(BinaryDelayEstimator* self) {
  int i = 0;
  assert(self != NULL);

  memset(self->bit_counts, 0, sizeof(int32_t) * self->history_size);
  memset(self->binary_near_history,
         0,
         sizeof(uint32_t) * self->near_history_size);
  for (i = 0; i <= self->history_size; ++i) {
    self->mean_bit_counts[i] = (20 << 9);  // 20 in Q9.
    self->histogram[i] = 0.f;
  }
  self->minimum_probability = kMaxBitCountsQ9;  // 32 in Q9.
  self->last_delay_probability = (int) kMaxBitCountsQ9;  // 32 in Q9.

  // Default return value if we're unable to estimate. -1 is used for errors.
  self->last_delay = -2;

  self->last_candidate_delay = -2;
  self->compare_delay = self->history_size;
  self->candidate_hits = 0;
  self->last_delay_histogram = 0.f;
}

int WebRtc_SoftResetBinaryDelayEstimator(BinaryDelayEstimator* self,
                                         int delay_shift) {
  int lookahead = 0;
  assert(self != NULL);
  lookahead = self->lookahead;
  self->lookahead -= delay_shift;
  if (self->lookahead < 0) {
    self->lookahead = 0;
  }
  if (self->lookahead > self->near_history_size - 1) {
    self->lookahead = self->near_history_size - 1;
  }
  return lookahead - self->lookahead;
}

int WebRtc_ProcessBinarySpectrum(BinaryDelayEstimator* self,
                                 uint32_t binary_near_spectrum) {
  int i = 0;
  int candidate_delay = -1;
  int valid_candidate = 0;

  int32_t value_best_candidate = kMaxBitCountsQ9;
  int32_t value_worst_candidate = 0;
  int32_t valley_depth = 0;

  assert(self != NULL);
  if (self->farend->history_size != self->history_size) {
    // Non matching history sizes.
    return -1;
  }
  if (self->near_history_size > 1) {
    // If we apply lookahead, shift near-end binary spectrum history. Insert
    // current |binary_near_spectrum| and pull out the delayed one.
    memmove(&(self->binary_near_history[1]), &(self->binary_near_history[0]),
            (self->near_history_size - 1) * sizeof(uint32_t));
    self->binary_near_history[0] = binary_near_spectrum;
    binary_near_spectrum = self->binary_near_history[self->lookahead];
  }

  // Compare with delayed spectra and store the |bit_counts| for each delay.
  BitCountComparison(binary_near_spectrum, self->farend->binary_far_history,
                     self->history_size, self->bit_counts);

  // Update |mean_bit_counts|, which is the smoothed version of |bit_counts|.
  for (i = 0; i < self->history_size; i++) {
    // |bit_counts| is constrained to [0, 32], meaning we can smooth with a
    // factor up to 2^26. We use Q9.
    int32_t bit_count = (self->bit_counts[i] << 9);  // Q9.

    // Update |mean_bit_counts| only when far-end signal has something to
    // contribute. If |far_bit_counts| is zero the far-end signal is weak and
    // we likely have a poor echo condition, hence don't update.
    if (self->farend->far_bit_counts[i] > 0) {
      // Make number of right shifts piecewise linear w.r.t. |far_bit_counts|.
      int shifts = kShiftsAtZero;
      shifts -= (kShiftsLinearSlope * self->farend->far_bit_counts[i]) >> 4;
      WebRtc_MeanEstimatorFix(bit_count, shifts, &(self->mean_bit_counts[i]));
    }
  }

  // Find |candidate_delay|, |value_best_candidate| and |value_worst_candidate|
  // of |mean_bit_counts|.
  for (i = 0; i < self->history_size; i++) {
    if (self->mean_bit_counts[i] < value_best_candidate) {
      value_best_candidate = self->mean_bit_counts[i];
      candidate_delay = i;
    }
    if (self->mean_bit_counts[i] > value_worst_candidate) {
      value_worst_candidate = self->mean_bit_counts[i];
    }
  }
  valley_depth = value_worst_candidate - value_best_candidate;

  // The |value_best_candidate| is a good indicator on the probability of
  // |candidate_delay| being an accurate delay (a small |value_best_candidate|
  // means a good binary match). In the following sections we make a decision
  // whether to update |last_delay| or not.
  // 1) If the difference bit counts between the best and the worst delay
  //    candidates is too small we consider the situation to be unreliable and
  //    don't update |last_delay|.
  // 2) If the situation is reliable we update |last_delay| if the value of the
  //    best candidate delay has a value less than
  //     i) an adaptive threshold |minimum_probability|, or
  //    ii) this corresponding value |last_delay_probability|, but updated at
  //        this time instant.

  // Update |minimum_probability|.
  if ((self->minimum_probability > kProbabilityLowerLimit) &&
      (valley_depth > kProbabilityMinSpread)) {
    // The "hard" threshold can't be lower than 17 (in Q9).
    // The valley in the curve also has to be distinct, i.e., the
    // difference between |value_worst_candidate| and |value_best_candidate| has
    // to be large enough.
    int32_t threshold = value_best_candidate + kProbabilityOffset;
    if (threshold < kProbabilityLowerLimit) {
      threshold = kProbabilityLowerLimit;
    }
    if (self->minimum_probability > threshold) {
      self->minimum_probability = threshold;
    }
  }
  // Update |last_delay_probability|.
  // We use a Markov type model, i.e., a slowly increasing level over time.
  self->last_delay_probability++;
  // Validate |candidate_delay|.  We have a reliable instantaneous delay
  // estimate if
  //  1) The valley is distinct enough (|valley_depth| > |kProbabilityOffset|)
  // and
  //  2) The depth of the valley is deep enough
  //      (|value_best_candidate| < |minimum_probability|)
  //     and deeper than the best estimate so far
  //      (|value_best_candidate| < |last_delay_probability|)
  valid_candidate = ((valley_depth > kProbabilityOffset) &&
      ((value_best_candidate < self->minimum_probability) ||
          (value_best_candidate < self->last_delay_probability)));

  UpdateRobustValidationStatistics(self, candidate_delay, valley_depth,
                                   value_best_candidate);
  if (self->robust_validation_enabled) {
    int is_histogram_valid = HistogramBasedValidation(self, candidate_delay);
    valid_candidate = RobustValidation(self, candidate_delay, valid_candidate,
                                       is_histogram_valid);

  }
  if (valid_candidate) {
    if (candidate_delay != self->last_delay) {
      self->last_delay_histogram =
          (self->histogram[candidate_delay] > kLastHistogramMax ?
              kLastHistogramMax : self->histogram[candidate_delay]);
      // Adjust the histogram if we made a change to |last_delay|, though it was
      // not the most likely one according to the histogram.
      if (self->histogram[candidate_delay] <
          self->histogram[self->compare_delay]) {
        self->histogram[self->compare_delay] = self->histogram[candidate_delay];
      }
    }
    self->last_delay = candidate_delay;
    if (value_best_candidate < self->last_delay_probability) {
      self->last_delay_probability = value_best_candidate;
    }
    self->compare_delay = self->last_delay;
  }

  return self->last_delay;
}

int WebRtc_binary_last_delay(BinaryDelayEstimator* self) {
  assert(self != NULL);
  return self->last_delay;
}

float WebRtc_binary_last_delay_quality(BinaryDelayEstimator* self) {
  float quality = 0;
  assert(self != NULL);

  if (self->robust_validation_enabled) {
    // Simply a linear function of the histogram height at delay estimate.
    quality = self->histogram[self->compare_delay] / kHistogramMax;
  } else {
    // Note that |last_delay_probability| states how deep the minimum of the
    // cost function is, so it is rather an error probability.
    quality = (float) (kMaxBitCountsQ9 - self->last_delay_probability) /
        kMaxBitCountsQ9;
    if (quality < 0) {
      quality = 0;
    }
  }
  return quality;
}

void WebRtc_MeanEstimatorFix(int32_t new_value,
                             int factor,
                             int32_t* mean_value) {
  int32_t diff = new_value - *mean_value;

  // mean_new = mean_value + ((new_value - mean_value) >> factor);
  if (diff < 0) {
    diff = -((-diff) >> factor);
  } else {
    diff = (diff >> factor);
  }
  *mean_value += diff;
}


text:
Benjamin Edward Bates IV (; July 12, 1808 – January 14, 1878) was an American rail industrialist, textile tycoon and philanthropist. He was the wealthiest person in Maine from 1850 to 1878, and is considered to have introduced both the Efficiency and Taylorism movements to the economy of Maine.

Bates was born to a large family in Mansfield, Massachusetts; he moved to Bristol, Maine, for a working residency at B. T. Loring Company before creating the Davis, Bates & Turner–a craft goods and service firm in the early 1830s. After entering the milling business, he built the Bates Mill in 1852 which launched the larger Bates Manufacturing Company in Lewiston, Maine. His company quickly became the largest per capita employer in Maine and the largest in Lewiston, for three decades. Contracted by the Maine State Legislature, Bates founded the Lewiston Water Power Company: a large mill-based enterprise that built the first canal in the city.

At the start of the American Civil War, Bates correctly anticipated that the talk of secession in the Southern States would lead to a shortage of cotton.  By buying up an unprecedented amount prior to the Battle of Fort Sumter, he cornered the market. The resulting shortage created an absolute monopoly and skyrocketing prices, which drove dozens of New England businesses to close due to the inability to compete. Growing economic inequality in the city culminated to 1861 Lewistown cotton riots which led Bates to loosen his expansionary business tactics and increase philanthropic spending.

Like other business magnates at the time, such as J.P. Morgan, Andrew Carnegie, and John D. Rockefeller, Bates supported capitalism and anti-competitiveness. The public's opinion of Bates was highly polarized throughout his life with some citing his economic impact as critical, while others criticized his business tactics as socially detrimental.

Early life and education
Benjamin Edward Bates IV, was born in Mansfield, Massachusetts, on July 12, 1808, to Hannah Copeland and Elkanah Bates as their third child (of seven). His father, Elkanah Bates, was a cotton manufacturer and prominent merchant. Both of his parents were religious and belonged to the Congregational Church of Mansfield. In 1838, there was a denominational split within the church to create a Unitarian theologian association that questioned the divinity of Christ, Elkanah Bates was picked to lead the movement. His paternal grandfather fought in the American Revolution as a Captain, and later became a brigadier general for the Massachusetts state militia. He is the great-great grandson of Benjamin Bates II, Commander of the Devonshire Forces, and member of the Hell Fire Club. When Bates was a younger boy, his brother recounts him being dragged by two horses across a "considerable distance" which left him badly cut and bruised, he pulled the horses down and eventually halted their movement, a considerable task considering Bates was only 14 years old at the time.

Bates attended various private schools and enrolled at the age of 15 to the Wrentham Academy, and studied there from 1823 to 1825, before moving to Boston, Massachusetts, in 1829, at age 21. Bates entered the dry goods business with Barnabas T. Loring on Washington Street. At age 24, he made a public profession of Christian faith, and he was a lifelong Congregationalist and temperance supporter. Bates taught Sunday school at several churches in Boston including Park Street Church and was later an active member of Central Congregational Church in Boston.

Business pursuits

B. T. Loring & Co.
John G. Davis met Benjamin Bates in the early 1830s and the two later became business partners. They met while Bates was a clerk for Barnabas T. Loring on Washington Street after a mutual friend offered "a firm with respected work." At the time with Bates' net worth was at $700, which was considered lower-middle class at the time. The firm subsequently organized as the B. T. Loring Company. The firm's market expanded widely throughout Maine and went on to depart from retail and focus on whole sale, which was made possible by the connections Bates had made throughout his career in Bristol, Maine. One year later, they moved "downtown" from Washington Street to Central Street, and continued operations. Barnabas T. Loring died prompting the group to dissolve B. T. Loring & Co., and create Davis, Bates, & Turner.

Davis, Bates & Turner
With the conclusion of B. T. Loring & Co., Bates co-founded the firm of Davis, & Bates, which existed from 1833 until 1847. The firm enjoyed financial success as its previous deals garnered high standing among the mercantile community of Maine. With the firm on stable footing, John N. Turner developed an interest and discussed furthered involvement. As a mutual friend of Bates, and his background in law, he was tasked with bookkeeping and legal relations. The firm amassed tens of thousands of dollars within years and the firm continued to grow. Turner was officially brought in on February 13, 1833, and the firm was officially renamed Davis, Bates & Turner.

Efficiency movement
Bates was known for his part in integrating the early manifestations of Taylorism in industrial Maine. His management style required high levels of managerial control and power over aggregated output which subsequently strained work practices. His firms were known for long work hours, poor working conditions and high output. He tended to his businesses "compulsively and incessantly" and often disregarded pressures to start a family, however did leave them with a considerable fortune at his death.

Financial panic of 1837
In 1837, the firm experienced low levels of revenue and output due to the external effects of panics involving financial security and credit in New York City. Considered the "greatest financial panic the country has ever seen", the Panic of 1837 caused numerous firms all over New England to fail, and Davis, Bates & Turner, often had trouble assessing market value and withdrawing loans from the banks. The firm remained active and even put up positive net return on some years during the panic due to their good credit and lack of debt. Due to the overall speculative markets involving whole sale goods, Bates' firm remained cautious when selling and taking out loans for restructuring. News from New York was delivered to Maine stating further banking regulation and overall stabilization of market prices, which brought the state out of a recessive period into a sustained growth. The news was received by Bates personally when George Bond, declared that loans would be issued by the New York Banks once again.

During the recovery consultations between Maine and Massachusetts business leaders, a prominent banker, Homer Bartlett was quoted as famously saying, Who was the strongest man in that meeting [referring to the financial panics]?To which the crowd overwhelmingly replied,Bates! Bates was the strongest man there.This quote would go on to largely shape Bates' minor celebrity status and fed the growing reputation of producing the best results in times of uncertainty. The crowd included, Lyman Nichols, George L. Ward, Alexander De Witt, Francis Skinner, Homer Bartlett, and St. John Smith. In 1840, the firm moved to Water Street, and five years later moved to Milk Street, where Davis withdrew from the firm due to poor health.

Bates, Turner & Co. and Union Pacific
Siles Bascom replaced Davis and the firm was renamed Bates, Turner & Co. The firm enjoyed financial success and began to conclude its practice with the closing of markets in March 1847. After the dissolution of the firm, Bates served as president and on the board of several banking, manufacturing, and railroad corporations, including First National Bank of Commerce in Boston. Due to his activities during the financial panic of 1837, he was asked to be the founding successor president of the Union Pacific Railroad on August 1, 1849; he served in this capacity until May 3, 1850, when Alexander De Witt spoke to him about opportunities in Lewiston, Maine prompting his immediate resignation.

Life in Lewiston

Bates travel to Lewiston regularly while living in Boston and other Maine towns, to "interact with the people, give guidance to the businesses, and support its economy." After the closing of Bates, Turner & Co., and a quick stint as president of the Union Pacific Railroad, he moved to Lewiston, Maine, upon the advisement of his close friend and confidant Alexander De Witt who went on describe Lewiston as a "city full of hope and innovation." He was escorted to the town secretly with De Witt, to meet with the city council and Mayor to discuss major developments in the town.

Bates Manufacturing Company
Bates quickly began developing companies, acquiring smaller ones under his Manufacturing Company, and subsequently brought in sixteen million dollars in revenue for the town, the largest circulation of currency in the history of Lewiston at the time. His businesses provided employment for thousands of people from Maine and Canada, which made him the single largest employer in the city, and the largest per capita of Maine. His businesses garnered millions of dollars for the city and with all assets accounted for in Maine and Massachusetts, he was considered the wealthiest man in Maine via his net worth.

His principal accomplishment during his early business career was the establishment of Bates Manufacturing Company. The company went on to be the largest manufacturing company in the state of Maine and provided two-thirds of all textile output for the state. It employed approximately five thousand people from Canadian and Irish descent. He served as the president of the company from its founding on January 3, 1850, until he appointed a successor to overtake the company as he left for Lewiston, Maine on February 20, 1862.

Lewiston Water Power Company
One of the primary goals of other business leaders in Maine and Bates was to improve the water quality of Lewiston. Bates went on to found the Lewiston Water Power Company, which built the first canal in the city. It employed hundreds of people and established the town as a "paragon of water quality." During this development Lewiston was the fastest growing city in Maine, in terms of growth rate.

Bates Mill

The Bates Mill was a textile factory company founded in 1850 and located at 35 Canal Street in Lewiston, Maine. Much of the capital generated from this mill was used in the foundation of Bates College. Since conception, Bates' practices with the mill dominated the mill industry and was one of the first great U.S. business trusts. He initially gained wealth and influence from manufacturing textiles and estate development with correspondence to the mills. His mills extended from the Androscoggin River to northern Lewiston. On August 16, 1850, Maine Governor John Hubbard signed the incorporation act and the mill was completed 1852. Bates positioned the mill in Lewiston due to the location of the Lewiston Falls which provided the mill with power. Under Bates' supervision, during the Civil War, the mill produced textiles to the Union Army. His mills generated employment for thousands of Canadians, and immigrants from Europe. The mill was Maine's largest employer for three decades.

1861 Lewistown cotton riots
Like numerous factories in Maine, Bates' mill was receiving cotton from the South, where it was grown and cultivated by slave labor. Correctly anticipating that the increasing talk of secession in the Southern States might eventually lead to a shortage of cotton, Bates bought an unprecedented amount of cotton prior to the Battle of Fort Sumter. During the War, Bates was able to produce uniforms for the Union Army as well as other textiles. His capitalization of this, saw to great levels of profit for his firms and companies, and caused dozens of mills to be closed due to overwhelming competition. After a rumor was spread around Lewiston that Bates held more money than the city, riots broke out in 1861, that decried the concentration wealth presented by Bates. Due to pressure from the public, he lessened his business tactics and created the philanthropic arm of the Bates Manufacturing Company tasked with giving out thousands to the people of Lewiston. During the riots his public image was tarnished and was advised by DeWitt to employ more people in his Mills. The Lewiston Sun Journal called him "the supplier of the cause," after he spoke at a town hall meeting detailing his employment of thousands of New Englanders and Canadians.

Later life and wealth

Economic panic of 1873

Bates pledged another $100,000 to be paid to the Maine State Seminary after his death, but due to the economic recession in the 1870s, known as the Panic of 1873, Bates' Lewiston assets were lessened. During this financial crisis many of his properties lessened in value and he was forced to refinance. Due to the dependence of Lewiston on Bates many citizens suffered financially in the personal losses of Bates. After the stabilization of his properties and business contracts he began a further expansion into Lewiston's economic environment, and regained considerable wealth. He built Bates Mill No.5 which became his fastest growing Mill within years and provided the city with substantial employment.

Wealth
By his death in 1878, Bates had amassed a total net worth of approximately $79.4 million (worth $1.84 billion in 2017). This includes assets held in Maine, New York, and Massachusetts that encompassed the non-operational value of B. T. Loring & Co., Bates, Turner & Co., his holding company the Bates Manufacturing Company, his stake in the Lewiston Water Company, Bates Mill, and miscellaneous banking endeavors in New York. He donated a total of $100,000 to the endowment, and approximately $250,000 to Bates College, indirectly and left a trust of $3.3 million to his family. In his will he pledged $50,000 to his wife Sarah Gilbert along with his 2.8 million dollar estate, $10,000 to his brother William, $10,000 to his brother Elkanah Bates II, $10,000 equally divided among the children of his sister, Charlotte, $10,000 to Edward Atkinson, and $10,000 to George Fabian. He left each of his children, Benjamin Edward V, Lilian, Sarah, and Author $250,000 in the form of a trust.

However, Bates had $200,000 in outstanding debt and a pledged $100,000 to Bates College after his death. His family was required expend the $100,000 pledged but due to conditions placed on the inheritances, restricted distribution, and familial debt, the Supreme Judicial Court of Massachusetts eventually ruled that Bates' heirs did not have to pay Bates College the pledged $100,000. After a period of recession the college began to financially recuperate to a larger endowment, independently. Over the next couple of years Bates College's endowment has grown slowly and steadily.

Philanthropy

Bates was the largest of the early donors to Maine State Seminary through the Lewiston Power Company. He was known by the people of Lewiston for having a "deep and profound love" for the town and the college, and its early founder mentioned his affection by noting: "I have frequently heard him say that he would not knowingly do anything against the interests of the people; and that he would sooner invest ten dollars in Lewiston than one dollar in any other place. 'I love Lewiston', 'I love the College', he was accustomed to say, 'Say to the Trustees that I love the College.'"In 1852, he personally pledged another $6,000 to the school. In 1853, Oren Burbank Cheney appointed him as a Trustee of the College and in 1854 subsequently became Chairman of the Board of Trustees of the college due to his considerable donations. He went onto donate $25,000 for the foundation of agriculture department and moved a subscription of $75,000 for campus expansion. On February 21, 1873, he donated $100,000 on the condition that the amount was met by third-party donors, within five years. Although he placed conditions on his donations, he realized his donations regardless of the conditions being met. The college remained a source of worry for Bates as much of the subscriptions to the college remained unfilled, donors were giving half of their donations and not fulfilling the other half, which left the endowment of the college in a speculative state. Bates served as the treasurer for the college in the early days and condemned the business strategy Cheney developed when interacting with potential donors advocating for a more aggressive procedure for funding.

His work with the college prompted fellow business magnate, Andrew Carnegie, to donate a considerable amount to the formation of the college and subsequently had the college's science building named after him. Bates played an integral role in the expansion of the college, moving from town to town and state to state spreading the institutions name. This brought in tens of thousands of dollars from the politically elite and wealthy who donated more on a favor to Bates than love of the college, as Bates had graduated little alumnus who went on to amass wealth.

By his death in 1878, Bates' donations to the college totalled over $100,000, and overall contributions valued at US$250,000 (worth US$6.2 million in March 2017 dollars).
On March 16, 1864, the founder of the Maine State Seminary, Oren Burbank Cheney, renamed his institution of higher learning, "Bates College," in honor of Bates. However, when hearing that the college was renamed after him, he expressed his disappointment. He thought that he was not worthy of a college of "[such] inception and history," later noting his guilt for raising money for the college because donors might have thought he was raising money for himself.

Death and legacy

Benjamin Bates died on January 14, 1878, at age 69, in Boston, Massachusetts. His body was entombed at the Mount Auburn Cemetery on Fir Avenue in Cambridge, Massachusetts, two days later.

Bates Street, West Bates Street, and East Bates Street in Lewiston and Auburn, Maine, respectively, are named in his honor.

His death was attended by Lewiston, Boston, and New York City elite, and the Mayors of numerous cities gave speeches on his life. His funeral was held in the Lewiston City Hall, and clergymen gave speeches on his commitment to the college and God.

He was survived by his wife, Sarah Chapman Gilbert (his second wife and daughter of Joseph Gilbert, niece of Abijah Gilbert) who lived from 1832 to 1882 and his four children:
 Josephine Bates Hammond (1839–1886)
 Benjamin Edward Bates V (1863–1906)
 Sarah Frances Bates Herschel (1867–1937)
 Lillian Gilbert Bates (1872–1951)
 Arthur Hobart Herschel (1870–1953)
Bates College's inaugural president, Oren Burbank Cheney said the following of Bates delivering his eulogy: Bates wanted labor for our laborers, education for our children, places of worship for our worshipers, light for our streets, water for our houses, and a hospital for our sick and our dying. I have heard the man [Bates] speak of his love for Lewiston, and his love for the college. While in Lewiston, our desires were his desires: our interests were his interests: and our affairs his affairs...Alfred J. Lebel, a Lewiston native, attended Bates College, and went on to run the Bates Manufacturing Company from 1985 to 1999.

References

Citations

Extended notes
Oren Cheney, "Eulogy on the Life of Benjamin Edward Bates," Bates Student, June 1878, 131–149, (Muskie Archives and Special Collections Library, Bates College) (part 2).

External links

Benjamin Bates Eulogy, pg. 131-149, Bates Student 1877–78 (part 2)

1808 births
1878 deaths
Philanthropists from Maine
Bates College people
University and college founders
People from Mansfield, Massachusetts
People from Lewiston, Maine
People of Maine in the American Civil War
American Civil War industrialists
American Congregationalists
American chief executives
American bankers
American financiers
Burials at Mount Auburn Cemetery
American temperance activists
People from Bristol, Maine
19th-century American philanthropists


text:
After Divorce Alternatives to Divorce Divorce Advice From the Judge Divorce Basics Divorce Without Court Filing for Divorce Uncontested Divorce
Divorce & Children
Child Custody Child Support
Who Gets What?
Alimony Divorce and Property
Quiz: What Are My Divorce Options?
Customer Service, 8am to 5pm PT
Home Family Law and Divorce Divorce and Children Child Custody A Child's Preference in Custody Proceedings
Can Children Express Preference in Iowa Custody Proceedings?
Can children voice their custodial preferences in court? Find out below.
By Melissa Heinig, Attorney
Each year in the United States, more and more parents of minor children separate. Many parents view the custody decision as a battle between the adults' preferences. In many states, however, courts must also consider the child's opinion when deciding custody.
This article will explain how a child's preference affects custody in Iowa. If you have additional questions after reading this article, you should consult with an experienced family law attorney.
Iowa Custody Basics
Whether you're going through a divorce or your separating from your partner, if you have minor children, custody is a topic you'll need to discuss. In Iowa, every custody case involves allocating parental rights and responsibilities to each parent, which begins with the court deciding legal custody and physical care of the child. Legal custody means a parent has legal rights to make decisions for the child. For example, where a child will attend school, what religion the child will practice, and whether the child will undergo necessary surgery. Physical care (sometimes called physical custody) refers to where the child will live and which parent will maintain the home for the child. (Iowa Code § 598.1)
The court can award joint custody to both parents, which means either joint legal custody, joint physical care, or a combination of both. Joint legal custody means that both parents must agree when it comes to significant decisions in the child's life. Joint physical care usually means the child will spend an equal amount of time with both parents.
If the court assigns one parent the sole custodial parent, it will create a parenting time (visitation) schedule so the other parent can exercise liberal visitation with the child. (Iowa Code § 598.41 (1)(a).)
As with most divorce or separation-related issues, it's always best for parents to work together to determine the best custody arrangement for their family. If you agree, you can present a parenting plan to the court, and the judge will sign it. (Iowa Code § 598.41 (4).)
Overview of Custody Decisions in Iowa
When parents can't agree on their child's custody, the court will need to step in and decide for them. All custody evaluations begin with both parents on equal ground, and the court will not favor either parent because of their age or gender.
To begin, the court must determine what custody arrangement would be in the child's best interest by considering a variety of factors, including each of the following:
whether each parent would be a suitable custodian for the child
whether the child would suffer from a lack of contact from both parents
whether the parents can communicate with each other about the child's needs
whether both parents have actively cared for the child before and since their separation
whether each parent can support the other parent's relationship with the child
whether one or both parents are opposed to joint custody
the parents' geographical proximity to one another
whether a joint custody arrangement would jeopardize the child's safety or one parent's safety
either parent's history of domestic abuse
whether either parent has allowed the child to be around a registered sex offender, and,
the child's opinion, taking into account the child's age and maturity. (Iowa Code § 598.41 (3).)
Judges have broad discretion when deciding how to allocate custody, and will consider each factor equally.
When Will the Court Consider a Child's Preference?
The court will consider a child's preference if the child is both old enough and mature enough to have a meaningful opinion on custody. There is no set age when the judge will consider the child's preference; each judge determines each child's maturity on a case-by-case basis. However, teenagers are usually old enough to have an opinion the court must consider. Younger children are sometimes more susceptible to pressure from parents or superficial reasons, such as gifts or lax discipline; the opinion of a younger, immature child usually won't factor into the custody decision.
Courts will look at several factors when deciding how much weight to give a child's preference. The judge will consider the strength of the child's preference and whether that preference has wavered. The child's intellectual and emotional make-up also affect the weight of the child's preference. Courts also consider the reasoning behind the opinion. For example, if a son is unhappy in his mother's home and wants to live with his father because he's seeking "greener pastures," the judge won't give as much weight as if he were happy in both homes, but simply has a closer relationship with his father.
Courts don't have to follow a preference when it's not in the child's best interest. In one case, a mother took her son, moved him away from his father, and refused to reveal her address or telephone number to prevent the father from contacting the child. The judge ruled that the child was better off with the father despite the child's stated preference to live with his mother.
The court will also reject the child's opinion if a parent coached the child to state a particular preference. In fact, coaching the child can backfire against that parent in the custody decision. In one case, the court found that a nine-year-old girl's father manipulated her testimony by providing special treats, activities, and telling her that he'd be deeply hurt if he didn't win custody. In this case, the court refused to give custody of the child to the father, despite the daughter's stated preference to live with him.
Courts will look at several factors when deciding how much weight to give a child's preference. The judge will consider the strength of the child's preference and whether that preference has wavered. The child's intellectual and emotional make-up also affect the weight of the child's preference.
Do Children Have to Testify About Their Custodial Preferences in Court?
Iowa judges normally won't require children to testify in court about their custodial preferences. Asking a child to choose between parents can be appropriate in limited circumstances, but it can also be cruel and inappropriate in other situations. Iowa courts believe that asking a child to testify about custodial preferences in front of the parents may cause the child to testify out of fear or based on what the child believes the parents want.
Judges will often interview children in court chambers to determine their custodial preferences. Parents aren't allowed to be present during the in-chambers interviews, but the parents' attorneys may attend. Usually, the judge will ask the child questions, although the attorneys can sometimes suggest questions. A court reporter should also be present to record the interview.
The court can refuse to interview a child if the judge believes the child has enough information about the child's preferences from other sources. For example, in one case, the court noted that the children had changed their opinions multiple times, depending on which parent they were talking to. The judge decided that interviewing the children wouldn't be much help.
Alternatively, the court may discover the child's custodial preference by appointing an expert to meet with the child. Iowa judges can appoint a custody evaluator or a mental health professional to meet with the child and parents separately and put together a report for the court. The report will usually include extensive information about all the factors affecting custody, including the child's preferences. (Iowa Code § 598.12B.)
Modifying a Custody Order in Iowa
As children grow up, your custody order may no longer serve their best interests. Although the court favors stability for children, it also understands when modifications may be necessary. Parents can agree to change a custody or visitation order, and the court will approve it. However, like custody, when parents can't agree, the court will need to approve any modification to the orders.
A parent who wishes to change a custody order will need to demonstrate to the court that, since the last order, there is a substantial change in circumstances. If the court believes it will benefit the child to modify custody or visitation, the court will evaluate the same factors used to evaluate an initial custody decision. (Iowa Code § 598.21C.)
If you have additional questions about the effect of children's custodial preferences, contact an Iowa family law attorney for help.
Please select...Child CustodyChild SupportCollaborative DivorceDivorceDivorce MediationFamilyMilitary Divorce
Considering Divorce?
Talk to a Divorce attorney.
We've helped 85 clients find attorneys today.
State Divorce Laws
Wash. DC
N. Hampshire
State Divorce
Divorce Quiz
Articles and FAQs


At camp, children have an opportunity to meet new friends, play sports, and participate in arts and crafts and other activities in a positive and supervised environment. A camp experience stimulates new interests, and helps a child develop resourcefulness, social skills and a positive self-image.
Special attention is given to parents who require continued child care during the summer months so that they can work to support their families. Camp placement is also dependent on the family's financial situation and any special needs of the child. SeniorCitizens can also attend camp through the Greenwich Camper Program. They spend five days at the Salvation Army's CONNRI Lodge, in Ashford, CT.
Seniors enjoy shuffle board, swimming in a cool lake, boat rides, international food festivals and other activities. Camp provides Seniors an excellent change of scenery and a chance to meet new people from throughout the region.
Children ages 5-14 and Seniors 55 and over, who are Greenwich residents, can apply for camperships. Information regarding special needs, residency and family income will be requested and reviewed by a Department of Human Services professional to determine eligibility for financial help.
Camp fees are funded entirely through contributions from community groups, businesses, corporations and individuals.