Class: Radiocarbon::C14Date

Inherits:
Object
  • Object
show all
Defined in:
lib/radiocarbon/c14_date.rb

Overview

Represents an uncalibrated radiocarbon date.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(age, error) ⇒ C14Date

Returns a new instance of C14Date.



11
12
13
14
# File 'lib/radiocarbon/c14_date.rb', line 11

def initialize(age, error)
  @age = age
  @error = error
end

Instance Attribute Details

#ageObject

Conventional radiocarbon age (CRA)



6
7
8
# File 'lib/radiocarbon/c14_date.rb', line 6

def age
  @age
end

#errorObject

Measurement error



9
10
11
# File 'lib/radiocarbon/c14_date.rb', line 9

def error
  @error
end

Instance Method Details

#calibrate(curve = "IntCal20") ⇒ CalDate

Calibrates a radiocarbon date

Parameters:

  • curve (String) (defaults to: "IntCal20")

    Name of the calibration curve to use. Must be present in Radiocarbon::CURVES.

Returns:

  • (CalDate)

    A calibrated radiocarbon date



33
34
35
# File 'lib/radiocarbon/c14_date.rb', line 33

def calibrate(curve = "IntCal20")
  Radiocarbon::CalDate.new(self, curve)
end

#dnorm(x, add_error = 0) ⇒ Double

Normal probability density function

Parameters:

  • x (Integer)

    Uncalibrated age

  • x (Double)

    Additional error term

Returns:

  • (Double)

    Probability at x



22
23
24
25
# File 'lib/radiocarbon/c14_date.rb', line 22

def dnorm(x, add_error = 0)
  sd = Math.sqrt(error**2 + add_error**2)
  (1 / (sd * Math.sqrt(2 * Math::PI))) * Math.exp(-0.5 * ((x - age) / sd)**2)
end