Skip to content

Commit 2e5da94

Browse files
author
Hernán Morales Durand
authored
Merge branch 'PolyMathOrg:master' into iss_reverse_binomial
2 parents 2e93965 + d93dfc5 commit 2e5da94

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1522
-160
lines changed

.github/workflows/smalltalk-ci.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: CI matrix
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
# Allows you to run this workflow manually from the Actions tab
10+
workflow_dispatch:
11+
12+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
13+
jobs:
14+
build:
15+
strategy:
16+
matrix:
17+
os: [ macos-latest, windows-latest, ubuntu-latest]
18+
smalltalk: [ Pharo64-8.0 ]
19+
runs-on: ${{ matrix.os }}
20+
name: ${{ matrix.smalltalk }} on ${{ matrix.os }}
21+
steps:
22+
- uses: actions/checkout@v2
23+
- name: Setup smalltalkCI
24+
uses: hpi-swa/setup-smalltalkCI@v1
25+
with:
26+
smalltalk-image: ${{ matrix.smalltalk }}
27+
- name: Load Image and Run Tests
28+
run: smalltalkci -s ${{ matrix.smalltalk }}
29+
env:
30+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31+
timeout-minutes: 15

.travis.yml

Lines changed: 0 additions & 15 deletions
This file was deleted.

README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,19 @@
1212
</p>
1313
</p>
1414

15-
[![Pharo version](https://img.shields.io/badge/Pharo-7.0-%23aac9ff.svg)](https://pharo.org/download)
1615
[![Pharo version](https://img.shields.io/badge/Pharo-8.0-%23aac9ff.svg)](https://pharo.org/download)
17-
[![Build Status](https://travis-ci.org/PolyMathOrg/PolyMath.svg?branch=master)](https://travis-ci.org/PolyMathOrg/PolyMath)
18-
[![Build status](https://ci.appveyor.com/api/projects/status/3tvarh2xi22max8h?svg=true)](https://ci.appveyor.com/project/SergeStinckwich/polymath-88bea)
16+
[![CI matrix](https://github.com/PolyMathOrg/PolyMath/actions/workflows/smalltalk-ci.yml/badge.svg)](https://github.com/PolyMathOrg/PolyMath/actions/workflows/smalltalk-ci.yml)
1917
[![Coverage Status](https://coveralls.io/repos/github/PolyMathOrg/PolyMath/badge.svg?branch=master)](https://coveralls.io/github/PolyMathOrg/PolyMath?branch=master)
2018
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/PolyMathOrg/PolyMath/master/LICENSE)
2119

2220
<img width="1675" alt="Screenshot 2019-04-24 at 11 12 57" src="https://user-images.githubusercontent.com/327334/56652094-66eb7780-6682-11e9-9753-101be18df67c.png">
2321

2422

25-
You can load PolyMath 1.0.2 into a fresh Pharo 8.0 image with:
23+
You can load PolyMath 1.0.3 into a fresh Pharo 8.0 image with:
2624

2725
```Smalltalk
2826
Metacello new
29-
repository: 'github://PolyMathOrg/PolyMath:v1.0.2';
27+
repository: 'github://PolyMathOrg/PolyMath:v1.0.3';
3028
baseline: 'PolyMath';
3129
load
3230
```

appveyor.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.

src/BaselineOfPolyMath/BaselineOfPolyMath.class.st

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ BaselineOfPolyMath >> baseline: spec [
113113
with: [ spec requires: #('Math-Complex') ];
114114
package: 'Math-Tests-Core'
115115
with: [ spec requires: #('Math-Core') ];
116+
package: 'Math-Tests-Core-Distribution'
117+
with: [ spec requires: #('Math-Core-Distribution') ];
116118
package: 'Math-Tests-Core-Process'
117119
with: [ spec requires: #('Math-Core-Process') ];
118120
package: 'Math-Tests-Numerical'
@@ -163,7 +165,7 @@ BaselineOfPolyMath >> baseline: spec [
163165
#('Math-Clustering' 'Math-Number-Extensions' 'Math-Chromosome' 'Math-PrincipalComponentAnalysis' 'Math-FunctionFit' 'Math-AutomaticDifferenciation' 'Math-KernelSmoothing' 'Math-Permutation' 'Math-KolmogorovSmirnov');
164166
group: 'Tests'
165167
with:
166-
#('Math-Tests-Matrix' 'Math-Tests-Clustering' 'Math-Tests-Numerical' 'Math-Tests-Complex' 'Math-Tests-Quaternion' 'Math-Tests-Random' 'Math-Tests-ODE' 'Math-Tests-KDTree' 'Math-Tests-FunctionFit' 'Math-Tests-AutomaticDifferenciation' 'Math-Tests-FastFourierTransform' 'Math-Tests-Accuracy' 'Math-Tests-ArbitraryPrecisionFloat' 'Math-Tests-KolmogorovSmirnov' 'Math-Tests-Quantile' 'Math-Tests-Polynomials' 'Math-Tests-PrincipalComponentAnalysis' 'Math-Tests-KernelSmoothing' 'Math-Tests-Number-Extensions' 'Math-Tests-Permutation' 'Math-Tests-TSNE' 'Math-Tests-Core-Process' 'Math-Tests-Core');
168+
#('Math-Tests-Matrix' 'Math-Tests-Clustering' 'Math-Tests-Numerical' 'Math-Tests-Complex' 'Math-Tests-Quaternion' 'Math-Tests-Random' 'Math-Tests-ODE' 'Math-Tests-KDTree' 'Math-Tests-FunctionFit' 'Math-Tests-AutomaticDifferenciation' 'Math-Tests-FastFourierTransform' 'Math-Tests-Accuracy' 'Math-Tests-ArbitraryPrecisionFloat' 'Math-Tests-KolmogorovSmirnov' 'Math-Tests-Quantile' 'Math-Tests-Polynomials' 'Math-Tests-PrincipalComponentAnalysis' 'Math-Tests-KernelSmoothing' 'Math-Tests-Number-Extensions' 'Math-Tests-Permutation' 'Math-Tests-TSNE' 'Math-Tests-Core-Process' 'Math-Tests-Core-Distribution' 'Math-Tests-Core');
167169
group: 'default'
168170
with: #('Core' 'Extensions' 'Tests' 'Benchmarks' 'Accuracy') ]
169171
]

src/Math-Complex/Number.extension.st

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,21 @@ Number >> i: aNumber [
2828
aNumber isNumber ifFalse: [self error: 'Badly formed complex number'].
2929
^PMComplex real: self imaginary: aNumber
3030
]
31+
32+
{ #category : #'*Math-Complex' }
33+
Number >> isComplexConjugateOf: aNumber [
34+
"A complex conjugate of a real number is same real number"
35+
^ self = aNumber
36+
]
37+
38+
{ #category : #'*Math-Complex' }
39+
Number >> isComplexConjugateOfAComplexNumber: aComplexNumber [
40+
"A complex conjugate of a real number is same real number"
41+
^ self isComplexConjugateOf: aComplexNumber
42+
]
43+
44+
{ #category : #'*Math-Complex' }
45+
Number >> isRealNumber [
46+
"Answer true if receiver is a real number. All instances of Number are real numbers."
47+
^ true
48+
]

src/Math-Complex/Object.extension.st

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,10 @@ Object >> isComplexNumber [
77
^ false
88

99
]
10+
11+
{ #category : #'*Math-Complex' }
12+
Object >> isRealNumber [
13+
"Answer true if receiver is a real number. False by default."
14+
^ false
15+
16+
]

src/Math-Complex/PMComplex.class.st

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,18 @@ PMComplex >> imaginary [
522522
^ imaginary
523523
]
524524

525+
{ #category : #testing }
526+
PMComplex >> isComplexConjugateOf: aNumber [
527+
"Answer true if self and aNumber are complex conjugates of each other. The complex conjugate of a complex number is the number with an equal real part and an imaginary part equal in magnitude but opposite in sign."
528+
^ aNumber isComplexConjugateOfAComplexNumber: self
529+
]
530+
531+
{ #category : #testing }
532+
PMComplex >> isComplexConjugateOfAComplexNumber: aComplexNumber [
533+
"Answer true if self and aComplexNumber are complex conjugates of each other. The complex conjugate of a complex number is the number with an equal real part and an imaginary part equal in magnitude but opposite in sign."
534+
^ (aComplexNumber real = real) and: [ aComplexNumber imaginary = (-1 * imaginary) ]
535+
]
536+
525537
{ #category : #testing }
526538
PMComplex >> isComplexNumber [
527539
^ true

src/Math-Complex/PMComplex.extension.st

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,20 @@ PMComplex >> productWithVector: aVector [
1717
^ aVector collect: [ :each | each * self ]
1818
]
1919

20-
{ #category : #'*Math-Complex' }
21-
PMComplex class >> random [
22-
"Answers a random number with abs between 0 and 1."
23-
24-
^ self abs: 1.0 random arg: 2 * Float pi random
25-
]
26-
2720
{ #category : #'*Math-Complex' }
2821
PMComplex >> random [
2922
"analog to Number>>random. However, the only bound is that the abs of the produced complex is less than the length of the receive. The receiver effectively defines a disc within which the random element can be produced."
3023
^ self class random * self
3124

3225
]
3326

27+
{ #category : #'*Math-Complex' }
28+
PMComplex class >> random [
29+
"Answers a random number with abs between 0 and 1."
30+
31+
^ self abs: 1.0 random arg: 2 * Float pi random
32+
]
33+
3434
{ #category : #'*Math-Complex' }
3535
PMComplex >> subtractToPolynomial: aPolynomial [
3636
^ aPolynomial addNumber: self negated
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
Class {
2+
#name : #PMMultivariateNormalDistribution,
3+
#superclass : #PMProbabilityDensity,
4+
#instVars : [
5+
'meanVector',
6+
'covarianceMatrix'
7+
],
8+
#category : #'Math-Core-Distribution'
9+
}
10+
11+
{ #category : #'instance creation' }
12+
PMMultivariateNormalDistribution class >> meanVector: aMeanVector covarianceMatrix: aCovarianceMatrix [
13+
^ self new
14+
initializeMeanVector: aMeanVector
15+
covarianceMatrix: aCovarianceMatrix;
16+
yourself
17+
]
18+
19+
{ #category : #information }
20+
PMMultivariateNormalDistribution >> average [
21+
^ self meanVector
22+
]
23+
24+
{ #category : #transformation }
25+
PMMultivariateNormalDistribution >> changeParametersBy: aVector [
26+
"Modify the parameters of the receiver by aVector."
27+
meanVector := meanVector + aVector first.
28+
covarianceMatrix := covarianceMatrix + aVector second.
29+
]
30+
31+
{ #category : #information }
32+
PMMultivariateNormalDistribution >> covarianceMatrix [
33+
^ covarianceMatrix
34+
]
35+
36+
{ #category : #information }
37+
PMMultivariateNormalDistribution >> distributionValue: aNumber [
38+
"Answers the probability of observing a random variable distributed according to the receiver with a value lower than or equal to aNumber. Also known as the cumulative density function (CDF)."
39+
40+
self shouldBeImplemented
41+
]
42+
43+
{ #category : #initialization }
44+
PMMultivariateNormalDistribution >> initializeMeanVector: aMeanVector covarianceMatrix: aCovarianceMatrix [
45+
meanVector := aMeanVector.
46+
covarianceMatrix := aCovarianceMatrix.
47+
]
48+
49+
{ #category : #information }
50+
PMMultivariateNormalDistribution >> kurtosis [
51+
"Kurtosis is a measure of the 'tailedness' of the probability distribution of a real-valued random variable. Not defined for a multivariate normal distribution"
52+
self shouldNotImplement
53+
]
54+
55+
{ #category : #information }
56+
PMMultivariateNormalDistribution >> meanVector [
57+
^ meanVector
58+
]
59+
60+
{ #category : #information }
61+
PMMultivariateNormalDistribution >> parameters [
62+
"Returns an Array containing the parameters of the distribution.
63+
It is used to print out the distribution and for fitting."
64+
65+
^ { meanVector . covarianceMatrix }
66+
]
67+
68+
{ #category : #information }
69+
PMMultivariateNormalDistribution >> power [
70+
"Number of dimensions of a multivariate normal distribution"
71+
^ meanVector size
72+
]
73+
74+
{ #category : #information }
75+
PMMultivariateNormalDistribution >> random [
76+
"Answer a vector of random numbers distributed accroding to the receiver."
77+
| standardNormalRandom upperTriangular |
78+
79+
standardNormalRandom := (1 to: self power) asPMVector
80+
collect: [ :each | PMNormalDistribution random ].
81+
82+
upperTriangular := covarianceMatrix choleskyDecomposition.
83+
84+
^ upperTriangular transpose * standardNormalRandom + meanVector
85+
]
86+
87+
{ #category : #information }
88+
PMMultivariateNormalDistribution >> skewness [
89+
"Skewness is a measure of the asymmetry of the probability distribution of a real-valued random variable about its mean. Not defined for a multivariate normal distribution"
90+
self shouldNotImplement
91+
]
92+
93+
{ #category : #information }
94+
PMMultivariateNormalDistribution >> value: aVector [
95+
"Answers the probability that a random variable distributed according to the receiver gives a value between aVector and aVector + espilon (infinitesimal interval)."
96+
97+
^ (-1/2 * (aVector - meanVector) * covarianceMatrix inverse * (aVector - meanVector)) exp / (((2 * Float pi) raisedTo: self power) * covarianceMatrix determinant) sqrt
98+
]

0 commit comments

Comments
 (0)