SHOGUN  v3.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
NormalSampler.cpp
Go to the documentation of this file.
00001 /*
00002  * This program is free software; you can redistribute it and/or modify
00003  * it under the terms of the GNU General Public License as published by
00004  * the Free Software Foundation; either version 3 of the License, or
00005  * (at your option) any later version.
00006  *
00007  * Written (W) 2013 Soumyajit De
00008  */
00009 
00010 #include <shogun/lib/common.h>
00011 #include <shogun/lib/SGVector.h>
00012 #include <shogun/mathematics/Random.h>
00013 #include <shogun/mathematics/linalg/ratapprox/tracesampler/NormalSampler.h>
00014 
00015 namespace shogun
00016 {
00017 
00018 CNormalSampler::CNormalSampler()
00019     : CTraceSampler()
00020 {
00021     SG_GCDEBUG("%s created (%p)\n", this->get_name(), this)
00022 }
00023 
00024 CNormalSampler::CNormalSampler(index_t dimension)
00025     : CTraceSampler(dimension)
00026 {
00027     SG_GCDEBUG("%s created (%p)\n", this->get_name(), this)
00028 }
00029 
00030 CNormalSampler::~CNormalSampler()
00031 {
00032     SG_GCDEBUG("%s destroyed (%p)\n", this->get_name(), this)
00033 }
00034 
00035 void CNormalSampler::precompute()
00036 {
00037     m_num_samples=1;
00038 }
00039 
00040 SGVector<float64_t> CNormalSampler::sample(index_t idx) const
00041 {
00042     // ignore idx since it doesnt matter, all samples are independent
00043     SGVector<float64_t> s(m_dimension);
00044 
00045     for (index_t i=0; i<m_dimension; ++i)
00046         s[i]=sg_rand->std_normal_distrib();
00047 
00048     return s;
00049 }
00050 
00051 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation