Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
prodigy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tobias Winkler
prodigy
Commits
aade3839
Commit
aade3839
authored
2 years ago
by
Tobias Winkler
Browse files
Options
Downloads
Patches
Plain Diff
implemented Dist.marginal with list of variables
parent
139c5c68
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
python/bindings.cpp
+1
-0
1 addition, 0 deletions
python/bindings.cpp
src/Dist.cpp
+3
-1
3 additions, 1 deletion
src/Dist.cpp
src/Dist.h
+2
-1
2 additions, 1 deletion
src/Dist.h
with
6 additions
and
2 deletions
python/bindings.cpp
+
1
−
0
View file @
aade3839
...
...
@@ -39,6 +39,7 @@ PYBIND11_MODULE(pygin, m) {
.
def
(
"mass"
,
[](
const
Dist
&
dist
)
{
return
toString
(
dist
.
mass
());
})
.
def
(
"normalize"
,
&
Dist
::
normalize
)
.
def
(
"marginal"
,
[](
const
Dist
&
dist
,
const
string
&
x
)
{
return
dist
.
marginal
(
x
);})
.
def
(
"marginal"
,
[](
const
Dist
&
dist
,
const
std
::
vector
<
string
>&
vars
)
{
return
dist
.
marginal
(
vars
);})
.
def
(
"is_zero"
,
&
Dist
::
isZero
)
.
def
(
"is_trivial"
,
&
Dist
::
isTrivial
)
.
def
(
"update"
,
&
Dist
::
update
)
...
...
This diff is collapsed.
Click to expand it.
src/Dist.cpp
+
3
−
1
View file @
aade3839
...
...
@@ -158,12 +158,14 @@ namespace prodigy {
return
Dist
{
res
};
}
Dist
Dist
::
marginal
(
std
::
initializer_list
<
std
::
string
>
vars
)
const
{
Dist
Dist
::
marginal
(
const
std
::
vector
<
std
::
string
>
&
vars
)
const
{
for
(
const
auto
&
v
:
vars
)
{
EXPECTS
(
!
isKnownAsParam
(
v
),
"given symbol is considered a parameter"
);
}
ex
res
{
_gf
};
// go over all variables v we currently know
for
(
const
auto
&
v
:
_vars
)
{
// if v is not in the given list vars then project it away
if
(
std
::
find
(
vars
.
begin
(),
vars
.
end
(),
v
.
first
)
==
vars
.
end
())
{
res
=
res
.
subs
(
v
.
second
==
1
);
}
...
...
This diff is collapsed.
Click to expand it.
src/Dist.h
+
2
−
1
View file @
aade3839
...
...
@@ -144,7 +144,8 @@ namespace prodigy {
* returns marginal distribution in given variable(s)
*/
Dist
marginal
(
const
std
::
string
&
x
)
const
;
Dist
marginal
(
std
::
initializer_list
<
std
::
string
>
vars
)
const
;
Dist
marginal
(
const
std
::
vector
<
std
::
string
>&
vars
)
const
;
Dist
marginal
(
std
::
initializer_list
<
std
::
string
>
vars
)
const
{
return
this
->
marginal
(
std
::
vector
<
std
::
string
>
{
vars
});
}
/*
* attempts to prove that *this is the zero distribution (mass 0)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment