37 #ifndef SHARK_DATA_DATADISTRIBUTION_H 38 #define SHARK_DATA_DATADISTRIBUTION_H 56 template <
class InputType>
80 std::vector<InputType> data(size);
83 for (std::size_t i = 0; i < size; ++i){
107 template <
class InputType,
class LabelType>
117 virtual void draw(
InputType& input, LabelType& label)
const = 0;
121 std::pair<InputType,LabelType> ret;
122 draw(ret.first,ret.second);
131 std::vector<InputType> inputs(size);
132 std::vector<LabelType> labels(size);
135 for (std::size_t i = 0; i < size; ++i){
136 draw(inputs[i], labels[i]);
160 m_noiselevel = noiselevel;
164 void draw(RealVector& input,
unsigned int& label)
const{
166 unsigned int j, t = 0;
167 for (j = 0; j < 2; j++)
189 Wave(
double stddev = 0.1,
double range = 5.0){
195 void draw(RealVector& input, RealVector& label)
const{
220 PamiToy(
unsigned int size_useful = 5,
unsigned int size_noise = 5,
double noise_position = 0.0,
double noise_variance = 1.0 )
221 : m_size( size_useful+size_noise ),
222 m_sizeUseful( size_useful ),
223 m_sizeNoise( size_noise ),
224 m_noisePos( noise_position) ,
225 m_noiseVar( noise_variance )
228 void draw(RealVector& input,
unsigned int& label)
const{
229 input.resize( m_size );
231 double y2 = label - 0.5;
233 for (
unsigned int i=0; i<m_sizeUseful; i++ ) {
237 for (
unsigned int i=m_sizeUseful; i<m_size; i++ ) {
256 CircleInSquare(
unsigned int dimensions = 2,
double noiselevel = 0.0,
bool class_prob_equal =
false )
257 : m_dimensions( dimensions ),
258 m_noiselevel( noiselevel ),
262 m_inner_radius2( 0.5*0.5 ),
263 m_outer_radius2( 0.5*0.5 ),
264 m_equal_class_prob( class_prob_equal )
268 void setLimits(
double lower_limit,
double upper_limit,
double inner_radius,
double outer_radius )
272 RANGE_CHECK( 2*outer_radius <= upper_limit-lower_limit );
273 m_lowerLimit = lower_limit;
274 m_upperLimit = upper_limit;
275 m_centerpoint = (upper_limit-lower_limit)/2.0;
276 m_inner_radius2 = inner_radius*inner_radius;
277 m_outer_radius2 = outer_radius*outer_radius;
280 void draw(RealVector& input,
unsigned int& label)
const 282 input.resize( m_dimensions );
285 if ( m_equal_class_prob ) {
287 label = ( this_label ? 1 : 0 );
293 for (
unsigned int i=0; i<m_dimensions; i++ ) {
296 dist += (v-m_centerpoint)*(v-m_centerpoint);
298 }
while( dist > m_inner_radius2 );
303 for (
unsigned int i=0; i<m_dimensions; i++ ) {
306 dist += (v-m_centerpoint)*(v-m_centerpoint);
308 }
while( dist < m_outer_radius2 );
314 for (
unsigned int i=0; i<m_dimensions; i++ ) {
317 dist += (v-m_centerpoint)*(v-m_centerpoint);
319 label = ( dist < m_inner_radius2 ? 1 : 0 );
322 }
while( dist > m_inner_radius2 && dist < m_outer_radius2 );
346 : m_radius2( radius*radius ),
347 m_noiselevel(
noise )
350 void draw(RealVector& input,
unsigned int& label)
const 362 if ( (3-x)*(3-x) + (1-y)*(1-y) < m_radius2 )
385 diag(covariance) = blas::repeat(1.0,dim);
386 m_dist.setCovarianceMatrix(covariance);
389 :m_dist(covariance), m_offset(offset){
390 SIZE_CHECK(offset.size() == covariance.size1());
392 void draw(RealVector& input)
const{
393 input.resize(m_offset.size());
394 noalias(input) = m_offset;
407 std::size_t imageWidth, std::size_t imageHeight,
408 std::size_t patchWidth, std::size_t patchHeight
410 , m_imageWidth(imageWidth)
411 , m_imageHeight(imageHeight)
412 , m_patchWidth(patchWidth)
413 , m_patchHeight(patchHeight)
414 ,m_numImages(m_images.numberOfElements()){}
416 void draw(RealVector& input)
const{
426 input.resize(m_patchWidth * m_patchHeight);
427 std::size_t rowStart = m_startY * m_imageWidth + m_startX;
428 for (
size_t y = 0; y < m_patchHeight; ++y){
429 for (
size_t x = 0; x < m_patchWidth; ++x){
430 input(y * m_patchWidth + x) = image(rowStart+x);
432 rowStart += m_imageWidth;
437 std::size_t m_imageWidth;
438 std::size_t m_imageHeight;
439 std::size_t m_patchWidth;
440 std::size_t m_patchHeight;
441 std::size_t m_numImages;