28 #ifndef SHARK_DATA_DATADISTRIBUTION_H
29 #define SHARK_DATA_DATADISTRIBUTION_H
46 template <
class InputType>
56 virtual void draw(InputType& input)
const = 0;
70 std::size_t batches = (size + maximumBatchSize - 1) / maximumBatchSize;
71 std::size_t optimalBatchSize = size / batches;
72 std::size_t remainder = size - batches * optimalBatchSize;
77 for (std::size_t i=0; i<batches; ++i)
79 std::size_t batchsize = (i<remainder) ? optimalBatchSize + 1 : optimalBatchSize;
83 for (std::size_t j=0; j<batchsize; j++)
85 if (j != 0)
draw(input);
109 template <
class InputType,
class LabelType>
119 virtual void draw(InputType& input, LabelType& label)
const = 0;
123 std::pair<InputType,LabelType> ret;
124 draw(ret.first,ret.second);
135 std::size_t batches = (size + maximumBatchSize - 1) / maximumBatchSize;
136 std::size_t optimalBatchSize = size / batches;
137 std::size_t remainder = size - batches * optimalBatchSize;
144 for (std::size_t i=0; i<batches; ++i)
146 std::size_t batchsize = (i<remainder) ? optimalBatchSize + 1 : optimalBatchSize;
150 for (std::size_t j=0; j<batchsize; j++)
152 if (j != 0)
draw(input, label);
182 void draw(RealVector& input,
unsigned int& label)
const{
184 unsigned int j, t = 0;
185 for (j = 0; j < 2; j++)
187 double v = Rng::uni(0.0, (
double)
m_size);
192 if (Rng::uni(0.0, 1.0) <
m_noiselevel) label = 1 - label;
213 void draw(RealVector& input, RealVector& label)
const{
218 label(0) = sin(input(0)) / input(0) + Rng::gauss(0.0,
m_stddev);
220 label(0) = Rng::gauss(0.0,
m_stddev);
238 PamiToy(
unsigned int size_useful = 5,
unsigned int size_noise = 5,
double noise_position = 0.0,
double noise_variance = 1.0 )
239 :
m_size( size_useful+size_noise ),
246 void draw(RealVector& input,
unsigned int& label)
const{
248 label = Rng::discrete( 0, 1 );
249 double y2 = label - 0.5;
255 for (
unsigned int i=m_sizeUseful; i<
m_size; i++ ) {
274 CircleInSquare(
unsigned int dimensions = 2,
double noiselevel = 0.0,
bool class_prob_equal =
false )
286 void setLimits(
double lower_limit,
double upper_limit,
double inner_radius,
double outer_radius )
290 RANGE_CHECK( 2*outer_radius <= upper_limit-lower_limit );
298 void draw(RealVector& input,
unsigned int& label)
304 bool this_label = Rng::coinToss();
305 label = ( this_label ? 1 : 0 );
368 void draw(RealVector& input,
unsigned int& label)
372 x = Rng::uni( 0, 4 );
373 y = Rng::uni( 0, 4 );
380 if ( (3-x)*(3-x) + (1-y)*(1-y) <
m_radius2 )