displ: Heavy-tailed distributions

Description Arguments Value Fields Copying objects Examples

Description

The poweRlaw package supports a number of distributions:

displ

Discrete power-law

dislnorm

Discrete log-normal

dispois

Discrete Poisson

disexp

Discrete Exponential

conpl

Continuous power-law

conlnorm

Continuous log-normal

conexp

Continuous exponential

Each object inherits the discrete_distribution or the ctn_distribution class.

Arguments

...

The object is typically created by passing data using the dat field. Each field has standard setters and getters.

Value

a reference object

Fields

Each distribution object has four fields. However, the object is typically created by passing data, to the dat field. Each field has standard setters and getters. See examples below

dat

The data set.

xmin

The lower threshold, xmin. Typically set after initialisation. For the continuous power-law, xmin >= 0 for the discrete distributions, xmin >0

pars

A parameter vector. Typically set after initialisation. Note the lognormal distribution has two parameters.

internal

A list. This list differs between objects and shouldn't be altered.

Copying objects

Distribution objects are reference classes. This means that when we copy objects, we need to use the copy method, i.e. obj$copy(). See the examples below for further details.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
##############################################################
#Load data and create distribution object                    #
##############################################################
data(moby)
m = displ$new(moby)

##############################################################
#Xmin is initially the smallest x value                      #
##############################################################
m$getXmin()
m$getPars()

##############################################################
#Set Xmin and parameter                                      #
##############################################################
m$setXmin(2)
m$setPars(2)


##############################################################
#Plot the data and fitted distribution                       #
##############################################################
plot(m)
lines(m)
##############################################################
#Copying                                                     #
##############################################################
## Shallow copy
m_cpy = m
m_cpy$setXmin(5)
m$getXmin()
## Instead
m_cpy = m$copy()

Example output

[1] 1
NULL
[1] 5

poweRlaw documentation built on April 25, 2020, 9:06 a.m.