SHOGUN
3.2.1
首页
相关页面
模块
类
文件
文件列表
文件成员
全部
类
命名空间
文件
函数
变量
类型定义
枚举
枚举值
友元
宏定义
组
页
src
shogun
mathematics
linalg
ratapprox
tracesampler
NormalSampler.cpp
浏览该文件的文档.
1
/*
2
* This program is free software; you can redistribute it and/or modify
3
* it under the terms of the GNU General Public License as published by
4
* the Free Software Foundation; either version 3 of the License, or
5
* (at your option) any later version.
6
*
7
* Written (W) 2013 Soumyajit De
8
*/
9
10
#include <
shogun/lib/common.h
>
11
#include <
shogun/lib/SGVector.h
>
12
#include <
shogun/mathematics/Random.h
>
13
#include <
shogun/mathematics/linalg/ratapprox/tracesampler/NormalSampler.h
>
14
15
namespace
shogun
16
{
17
18
CNormalSampler::CNormalSampler
()
19
:
CTraceSampler
()
20
{
21
SG_GCDEBUG
(
"%s created (%p)\n"
, this->
get_name
(),
this
)
22
}
23
24
CNormalSampler::CNormalSampler
(
index_t
dimension)
25
:
CTraceSampler
(dimension)
26
{
27
SG_GCDEBUG
(
"%s created (%p)\n"
, this->
get_name
(),
this
)
28
}
29
30
CNormalSampler::~CNormalSampler
()
31
{
32
SG_GCDEBUG
(
"%s destroyed (%p)\n"
, this->
get_name
(),
this
)
33
}
34
35
void
CNormalSampler::precompute
()
36
{
37
m_num_samples
=1;
38
}
39
40
SGVector<float64_t>
CNormalSampler::sample
(
index_t
idx)
const
41
{
42
// ignore idx since it doesnt matter, all samples are independent
43
SGVector<float64_t>
s(
m_dimension
);
44
45
for
(
index_t
i=0; i<
m_dimension
; ++i)
46
s[i]=
sg_rand
->
std_normal_distrib
();
47
48
return
s;
49
}
50
51
}
SHOGUN
机器学习工具包 - 项目文档