Did you know ... Search Documentation:
Packs (add-ons) for SWI-Prolog

Package "cplint_r"

Title:R plotting predicates for cplint
Rating:Not rated. Create the first rating!
Latest version:1.0.0
SHA1 sum:fd5b30be423a557e80d5c9a60dd12311c4c1fa3e
Author:Franco Masotti <franco.masotti@student.unife.it>
Maintainer:Franco Masotti <franco.masotti@student.unife.it>
Packager:Franco Masotti <franco.masotti@student.unife.it>
Home page:https://github.com/frnmst/cplint_r
Requires:cplint
rserve_client

Reviews

No reviews. Create the first review!.

Details by download location

VersionSHA1#DownloadsURL
0.0.03a52f94f63c5a11d91c21c6661f96763088465941https://github.com/frnmst/cplint_r.git
486085647312f3e16a12b11e134456cb74cdb5b31https://github.com/frnmst/cplint_r.git
80740c92c34ae86fe1eda259a4741e6974c86b041https://github.com/frnmst/cplint_r.git
a5f49f2295c92cb03e60fd8771daf4370750520d3https://github.com/frnmst/cplint_r.git
b9f948fcfd5e0f53e4d5f412bcdfaae8c5da15281https://github.com/frnmst/cplint_r.git
dfb77295cd10a8a73d68499d5ab73e345c1e775c1https://github.com/frnmst/cplint_r.git
0.0.15edc349fa794e1a0aea8780e420fb0b18af328eb2https://github.com/frnmst/cplint_r.git
60fdd43f9e252a2fd006e3adc7a1a5edfe6efc7a1https://github.com/frnmst/cplint_r.git
fa7b21278b5589db478aa66812944df8b489ba171https://github.com/frnmst/cplint_r.git
1.0.001ae954019ac16f197c43692c9c6ab4bafb1dc132https://github.com/friguzzi/cplint_r.git
1236459fea13b07c12c7062aca9a33ff3cf0ba9c7https://github.com/frnmst/cplint_r.git
38d199f545aae8c0018397814981d6f88ab7a56c1https://github.com/friguzzi/cplint_r.git
895cc7b4249b58a3d5beadcd149612bf670aaec01https://github.com/friguzzi/cplint_r.git
b4432bb02886b215045ceb095ee3a3cd1a2a70e817https://github.com/frnmst/cplint_r.git
d3e1062b95c2168759ec45d370f698d415887c9a3https://github.com/friguzzi/cplint_r.git
fd5b30be423a557e80d5c9a60dd12311c4c1fa3e58https://github.com/friguzzi/cplint_r.git

cplint_r

An SWI Prolog library to plot ggplot2 charts for Cplint on SWISH.

Description

This library is to be used with Cplint on SWISH.

At the moment, it is included as part of the installation process in the swish-cplint package for the Arch GNU/Linux distribution (and derivatives).

The structure of this repository follows (more or less) some interesting guidelines written by Raivo Laanemets.

Example

Taken from here

/*
Mixture of two Gaussians. A biased coin is thrown, if it lands heads X in
mix(X)
is sampled from a Gaussian with mean 0 and variance 1. if it lands tails X is
sampled from a Gaussian with mean 5 and variance 2.
The example illustrates the use of continuous random variables and
the use of sampling, including
rejection sampling and Metropolis/Hastings. Moreover the example
illustrates the use of the predicate histogram/2 for graphing the
probability density function of continuous random variables.
*/
:- use_module(library(mcintyre)).
:- use_module(library(cplint_r)).

:- mc.
:- begin_lpad.

heads:0.6;tails:0.4.
% a coin is thrown. The coin is biased: with probability 0.6 it lands heads,
% with probabiity 0.4 it lands tails

g(X): gaussian(X,0, 1).
% X in g(X)  follows a Gaussian distribution with mean 0 and variance 1
h(X): gaussian(X,5, 2).
% X in h(X)  follows a Gaussian distribution with mean 5 and variance 2

mix(X) :- heads, g(X).
% if the coin lands heads, X in mix(X) is given by g(X)
mix(X) :- tails, h(X).
% if the coin lands tails, X in mix(X) is given by h(X)

:- end_lpad.

hist_uncond(Samples,NBins):-
  mc_sample_arg(mix(X),Samples,X,L0),
  histogram_r(L0,NBins).
% take SAmples samples of X in mix(X) and draw a histogram with NBins bins
representing
% the probability density of X

The query

?- hist_uncond(10000,40).

Gives the following

<img src="images/histogram_r_example.png" alt="histogram_r_example.png" width="256"/>

Installation

?- pack_install('cplint_r').

Full documentation (including API)

https://frnmst.github.io/cplint_r

Running tests

In the package root, execute into swipl:

?- [tests/tests].
?- run_tests.

or, if you cloned the repo:

$ make test

Changelogs

2017-01-30 version 1.0.0. API change. Rendering improvement in density functions. Lots of fixes.

2017-01-13 version 0.0.3. Fixed minor issues.

2017-01-13 version 0.0.2. Fixed densities_r/3. Better error handling.

2017-01-07 version 0.0.1. First release including documentation.

Bugs

  • Unable to view the plots within swipl. It should be possible to save a pdf file of the corresponding plot anyway.

License

Copyright (c) 2016-2017 Franco Masotti (franco.masotti@student.unife.it)

This is free software: you can redistribute it and/or modify it under the terms of the Artistic License 2.0 as published by The Perl Foundation.

This source is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Artistic License 2.0 for more details.

You should have received a copy of the Artistic License 2.0 along the source as a LICENSE file. If not, obtain it from http://www.perlfoundation.org/artistic_license_2_0.

Contents of pack "cplint_r"

Pack contains 20 files holding a total of 140K bytes.