Skip to content
Snippets Groups Projects
Commit ceb9ea46 authored by Tobias Winkler's avatar Tobias Winkler
Browse files

extended python demo file and minor cleanup

parent ab5ecd20
Branches
No related tags found
No related merge requests found
import pygin
# pygin python bindings demo
import pygin as pg
FALSE = pg.troolean(0)
TRUE = pg.troolean(1)
UNKNOWN = pg.troolean(2)
def check_if_zero(dist):
if dist.is_zero() == FALSE:
print("given distribution does not have zero mass")
elif dist.is_zero() == TRUE:
print("given distribution has zero mass")
elif dist.is_zero() == UNKNOWN:
print("it is unknown if given distribution has zero mass")
if __name__ == "__main__":
dist = pygin.geometric("x", "1/2")
print(dist.E("x"))
geom_param = "p"
var = "x"
dist = pygin.Dist("1");
dist = pg.geometric(var, geom_param)
print(f"expected value of a {geom_param}-geometric distribution is {dist.E(var)}")
check_if_zero(dist)
check_if_zero(pg.Dist("0"))
......@@ -63,16 +63,19 @@ namespace prodigy {
_params.clear();
_vars.clear();
}
private:
static str2sym paramsAndVars();
public:
static bool isSymbKnown(const std::string& s);
static bool isKnownAsVar(const std::string& s);
static bool isKnownAsParam(const std::string& s);
static bool test() { return true; }
private:
static bool isSymbKnown(const symbol& s);
static bool isKnownAsVar(const symbol& s);
static bool isKnownAsParam(const symbol& s);
......@@ -83,6 +86,7 @@ namespace prodigy {
* new symbols are created for unknown names, but they are not registered
*/
static ex parseWithKnownSymbs(const std::string& s);
static void registerAllUnknownSymbsAsVars(const ex& e);
static void registerAllUnknownSymbsAsParams(const ex& e);
static void registerAsVar(const symbol& p);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment