Navigation Menu

Skip to content

Commit

Permalink
first working method
Browse files Browse the repository at this point in the history
  • Loading branch information
karlnapf committed Jul 22, 2012
1 parent 9f65805 commit f1232bc
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/shogun/features/DataGenerator.cpp
Expand Up @@ -8,6 +8,7 @@
*/

#include <shogun/features/DataGenerator.h>
#include <shogun/mathematics/Math.h>

using namespace shogun;

Expand All @@ -24,3 +25,19 @@ CDataGenerator::~CDataGenerator()
void CDataGenerator::init()
{
}

SGMatrix<float64_t> CDataGenerator::generate_mean_data(index_t m,
index_t dim, float64_t mean_shift)
{
SGMatrix<float64_t> result(dim, m);

for (index_t i=0; i<m; ++i)
{
for (index_t j=0; j<dim; ++j)
result(j,i)=CMath::randn_double();

result(0,i)+=mean_shift;
}

return result;
}
13 changes: 13 additions & 0 deletions src/shogun/features/DataGenerator.h
Expand Up @@ -11,6 +11,7 @@
#define __DATAGENERATOR_H_

#include <shogun/base/SGObject.h>
#include <shogun/lib/SGMatrix.h>

namespace shogun
{
Expand All @@ -25,6 +26,18 @@ class CDataGenerator: public CSGObject

virtual ~CDataGenerator();

/** produces a set of vectors, where each dimension is standard normally
* distributed and the mean of the first dimension is shifted by a
* provided value
*
* @param m number of samples to generate
* @param dim dimension of generated samples
* @param mean_shift is added mean of first dimension
* @return matrix with samples
*/
SGMatrix<float64_t> generate_mean_data(index_t m, index_t dim,
float64_t mean_shift);

inline virtual const char* get_name() const { return "DataGenerator"; }

private:
Expand Down

0 comments on commit f1232bc

Please sign in to comment.