<commit_before>using Distributions

export Landscape

type Landscape
  n::Int64
  k::Int64
  a::Int64
  links::Matrix{Int64}
  contribs::Array{Float64}
end

function Landscape(n::Int64, k::Int64, p::Float64, a::Int64)
  if k >= n
    error("k must be strictly less than n")
  end
  links = zeros(Int64, n, k + 1)
  for i = 1:n
    links[i,:] = [i, sample(setdiff(1:n, [i]), k, replace=false) |> sort]
  end
  contribs = rand(Float64, n, (ones(Int, k + 1) * a)...)
  # Zero contributions with probability p.
  contribs[rand(Float64, size(contribs)...) .< p] = 0.0
  return Landscape(n, k, a, links, contribs)
end

Landscape(n::Int64, k::Int64) = Landscape(n, k, 0.0, 2)
Landscape(n::Int64, k::Int64, p::Float64) = Landscape(n, k, p, 2)
Landscape(n::Int64, k::Int64, a::Int64) = Landscape(n, k, 0.0, a)

<commit_msg>Add p parameter.<commit_after>using Distributions

export Landscape

type Landscape
  n::Int64
  k::Int64
  a::Int64
  p::Float64
  links::Matrix{Int64}
  contribs::Array{Float64}
end

function Landscape(n::Int64, k::Int64, p::Float64, a::Int64)
  if k >= n
    error("k must be strictly less than n")
  end
  links = zeros(Int64, n, k + 1)
  for i = 1:n
    links[i,:] = [i, sample(setdiff(1:n, [i]), k, replace=false) |> sort]
  end
  contribs = rand(Float64, n, (ones(Int, k + 1) * a)...)
  # Zero contributions with probability p.
  contribs[rand(Float64, size(contribs)...) .< p] = 0.0
  return Landscape(n, k, a, p, links, contribs)
end

Landscape(n::Int64, k::Int64) = Landscape(n, k, 0.0, 2)
Landscape(n::Int64, k::Int64, p::Float64) = Landscape(n, k, p, 2)
Landscape(n::Int64, k::Int64, a::Int64) = Landscape(n, k, 0.0, a)


{'fraction_non_alphanumeric': 0.18336369156041288, 'fraction_numerical': 0.06435944140862174, 'mean_word_length': 4.215189873417722, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2832600', 'n_tokens_mistral': 756, 'n_tokens_neox': 685, 'n_words': 178}