Class: RequestSample

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/request_sample.rb

Instance Method Summary collapse

Instance Method Details

#custom_household_frequencyObject



11
12
13
# File 'app/models/request_sample.rb', line 11

def custom_household_frequency
  self.sample.h_records / self.custom_sampling_ratio
end

#custom_percent_densityObject



15
16
17
# File 'app/models/request_sample.rb', line 15

def custom_percent_density
  self.sample.density / self.custom_sampling_ratio
end

#custom_person_frequencyObject



7
8
9
# File 'app/models/request_sample.rb', line 7

def custom_person_frequency
  self.sample.p_records / self.custom_sampling_ratio
end

#generate_first_household_sampledObject

compute random first hh to sample



20
21
22
23
24
25
26
27
# File 'app/models/request_sample.rb', line 20

def generate_first_household_sampled

  # max_household is equal to ceiling(custom_sampling_ratio)
  max_household = custom_sampling_ratio.ceil

  # first_household-sampled should be at least 1 but no greater than the max_household
  self.first_household_sampled = rand(max_household) + 1;
end