Question: I am writing a basic neural network in Java and I am writing the activation functions (currently I have just written the sigmoid function). I am trying to use `double`s (as apposed to `BigDecimal`) with hopes that training will actually take a reasonable amount of time. However, I've noticed that the function doesn't work with larger inputs. Currently my function is:

```
public static double sigmoid(double t){

    return (1 / (1 + Math.pow(Math.E, -t)));

}

```

This function returns pretty precise values all the way down to when `t = -100`, but when `t >= 37` the function returns `1.0`. **In a typical neural network when the input is normalized is this fine? Will a neuron ever get inputs summing over ~37? If the size of the sum of inputs fed into the activation function vary from NN to NN, what are some of the factors the affect it?** Also, is there any way to make this function more precise? Is there an alternative that is more precise and/or faster?

Answer: 
thanks to gmcnaughton I created this solution

```
ids = Contractor.order("name").pluck(:id)
 @listcons = ids.paginate(:page => params[:page], :per_page => 50)
 @groupedcons = Contractor.joins(:contracts)
     .where(id: @listcons)
     .select("contractors.id,name,ico,city,country,count(resultinfo_id)")
     .group("contractors.id,name,ico,city,country")
     .order("name")

```

and I had to add to initializers require 'will\_paginate/array' because otherwise it shows undefined total\_pages method for an array
Mixing `paginate` and `group` is tricky. `paginate` sets an OFFSET and LIMIT on the query, which get applied to the result of the GROUP BY -- rather than limiting what records will get grouped.

If you want to paginate through the all Contracts, then group each page of 50 results (one page at a time), try this:

```
def listcontractors
  # get one page of contract ids
  ids = Contract.paginate(:page => params[:page], :per_page => 50).pluck(:id)

  # group just the items in that page
  @listcons = Contract.where(id: ids)
                      .select("contractors.id,name,ico,city,country,count(resultinfo_id)")
                      .group("contractors.id,name,ico,city,country")
                      .order("name")
end

```

Hope that helps!