Skip to content

Instantly share code, notes, and snippets.

@jamiecook
Created December 3, 2014 23:27
Show Gist options
  • Save jamiecook/d593548c8401e5095db5 to your computer and use it in GitHub Desktop.
Save jamiecook/d593548c8401e5095db5 to your computer and use it in GitHub Desktop.
def build_report_data
@counts_audience = Array.new(UPPER_FREQUENCY_LIMIT, 0)
@reaches = Array.new(UPPER_FREQUENCY_LIMIT, 0)
@cumulative_counts = Array.new(UPPER_FREQUENCY_LIMIT, 0)
@cumulative_reaches = Array.new(UPPER_FREQUENCY_LIMIT, 0)
@reaches_market_discrete = Array.new(UPPER_FREQUENCY_LIMIT, 0)
@total_contacts = 0
position = self.counts.length - 1
total_counts = 0
cached_potentials = potentials
cached_oztam_factor = oztam_factor
self.counts.sort.each do |kfc|
@reaches_market_discrete[position] = kfc.to_f
@counts_audience[position] = kfc * cached_oztam_factor
@reaches[position] = kfc.to_f / cached_potentials
total_counts += kfc.to_i * cached_oztam_factor
@cumulative_counts[position] = (total_counts)
@cumulative_reaches[position] = total_counts.to_f / cached_potentials if cached_potentials != 0
position -= 1
end
@total_reach = total_counts.to_f / cached_potentials
@total_audience = total_counts
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment