// Copyright (c) 2014, Salesforce.com, Inc.  All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// - Redistributions of source code must retain the above copyright
//   notice, this list of conditions and the following disclaimer.
// - Redistributions in binary form must reproduce the above copyright
//   notice, this list of conditions and the following disclaimer in the
//   documentation and/or other materials provided with the distribution.
// - Neither the name of Salesforce.com nor the names of its contributors
//   may be used to endorse or promote products derived from this
//   software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
// COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
// TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

package protobuf.distributions;

//----------------------------------------------------------------------------
// Clustering

message Clustering
{
  message PitmanYor
  {
    required float alpha = 1;
    required float d = 2;
  }

  message LowEntropy
  {
    required uint64 dataset_size = 1;
  }

  // simulate a sum type
  optional PitmanYor pitman_yor = 1;
  optional LowEntropy low_entropy = 2;
}

//----------------------------------------------------------------------------
// Models

message BetaBernoulli {
  message Shared {
    required float alpha = 1;
    required float beta = 2;
  }

  message Group {
    required uint64 heads = 1;
    required uint64 tails = 2;
  }
}

message DirichletDiscrete {
  message Shared {
    repeated float alphas = 1;
  }

  message Group {
    repeated uint64 counts = 1;
  }
}

message DirichletProcessDiscrete {
  message Shared {
    required float gamma = 1;
    required float alpha = 2;
    repeated uint32 values = 3;
    repeated float betas = 4;
    repeated uint64 counts = 5;
  }

  message Group {
    repeated uint32 keys = 1;
    repeated uint64 values = 2;
  }
}

message PitmanYorProcessDiscrete {
  message Shared {
    required float alpha = 1;
    repeated float d = 2;
    repeated uint64 counts = 3;
  }

  message Group {
    repeated uint32 keys = 1;
    repeated uint64 values = 2;
  }
}

message GammaPoisson {
  message Shared {
    required float alpha = 1;
    required float inv_beta = 2;
  }

  message Group {
    required uint64 count = 1;
    required uint64 sum = 2;
    required float log_prod = 3;
  }
}

message BetaNegativeBinomial {
  message Shared {
    required float alpha = 1;
    required float beta = 2;
    required uint64 r = 3;
  }

  message Group {
    required uint64 count = 1;
    required uint64 sum = 2;
  }
}

message NormalInverseChiSq {
  message Shared {
    required float mu = 1;
    required float kappa = 2;
    required float sigmasq = 3;
    required float nu = 4;
  }

  message Group {
    required uint64 count = 1;
    required float mean = 2;
    required float count_times_variance = 3;
  }
}

