class Rlid::TestProbabilities

Public Class Methods

new(lang, perc_lang=0.8, perc_lang_and_common=0.98) click to toggle source
Calls superclass method Rlid::LanguageProbabilities::new
# File lib/rlid/probabilities/language_probabilities.rb, line 154
def initialize(lang, perc_lang=0.8, perc_lang_and_common=0.98)
  @lang = lang
  @perc_lang = perc_lang
  common = COMMON_LANGUAGES - [lang]
  other = LANGUAGES - COMMON_LANGUAGES - [lang]
  @common_size = common.size
  @other_size = other.size
  @perc_common = perc_lang_and_common - perc_lang
  @perc_other = 1 - perc_lang_and_common
  super(lang => @perc_lang, common => @perc_common, other => @perc_other)
end

Public Instance Methods

probabilities() click to toggle source

common = [] @common_size.times do

common << probs.random_language_and_delete

end other = [] @other_size.times do

other << probs.random_language_and_delete

end

LanguageProbabilities.new(

lang => @perc_lang,
common => @perc_common,
other => @perc_other)
# File lib/rlid/probabilities/language_probabilities.rb, line 194
def probabilities
  LanguageProbabilities.new(percentage)
end
random_permutation() click to toggle source
# File lib/rlid/probabilities/language_probabilities.rb, line 166
def random_permutation
  lang = random_language
  return self if lang == @lang

  probs = probabilities

  top_lang = probs.first

  probs.percentage[lang], probs.percentage[top_lang] =
    probs.percentage[top_lang], probs.percentage[lang]

  probs
end