@@ -382,69 +382,3 @@ function Dist.fit(d::Type{<:UnivariateFinite},
382
382
end
383
383
384
384
385
- # ## ARITHMETIC
386
-
387
- const ERR_DIFFERENT_SAMPLE_SPACES = ArgumentError (
388
- " Adding two `UnivariateFinite` objects whose " *
389
- " sample spaces have different labellings is not allowed. " )
390
-
391
- import Base: + , * , / , -
392
-
393
- function _plus (d1, d2, T)
394
- classes (d1) == classes (d2) || throw (ERR_DIFFERENT_SAMPLE_SPACES)
395
- S = d1. scitype
396
- decoder = d1. decoder
397
- prob_given_ref = copy (d1. prob_given_ref)
398
- for ref in keys (prob_given_ref)
399
- prob_given_ref[ref] += d2. prob_given_ref[ref]
400
- end
401
- return T (S, decoder, prob_given_ref)
402
- end
403
- + (d1:: U , d2:: U ) where U <: UnivariateFinite = _plus (d1, d2, UnivariateFinite)
404
- + (d1:: U , d2:: U ) where U <: UnivariateFiniteArray =
405
- _plus (d1, d2, UnivariateFiniteArray)
406
-
407
- function _minus (d, T)
408
- S = d. scitype
409
- decoder = d. decoder
410
- prob_given_ref = copy (d. prob_given_ref)
411
- for ref in keys (prob_given_ref)
412
- prob_given_ref[ref] = - prob_given_ref[ref]
413
- end
414
- return T (S, decoder, prob_given_ref)
415
- end
416
- - (d:: UnivariateFinite ) = _minus (d, UnivariateFinite)
417
- - (d:: UnivariateFiniteArray ) = _minus (d, UnivariateFiniteArray)
418
-
419
- function _minus (d1, d2, T)
420
- classes (d1) == classes (d2) || throw (ERR_DIFFERENT_SAMPLE_SPACES)
421
- S = d1. scitype
422
- decoder = d1. decoder
423
- prob_given_ref = copy (d1. prob_given_ref)
424
- for ref in keys (prob_given_ref)
425
- prob_given_ref[ref] -= d2. prob_given_ref[ref]
426
- end
427
- return T (S, decoder, prob_given_ref)
428
- end
429
- - (d1:: U , d2:: U ) where U <: UnivariateFinite = _minus (d1, d2, UnivariateFinite)
430
- - (d1:: U , d2:: U ) where U <: UnivariateFiniteArray =
431
- _minus (d1, d2, UnivariateFiniteArray)
432
-
433
- # TODO : remove type restrction on `x` in the following methods if
434
- # https://github.com/JuliaStats/Distributions.jl/issues/1438 is
435
- # resolved. Currently we'd have a method ambiguity
436
-
437
- function _times (d, x, T)
438
- S = d. scitype
439
- decoder = d. decoder
440
- prob_given_ref = copy (d. prob_given_ref)
441
- for ref in keys (prob_given_ref)
442
- prob_given_ref[ref] *= x
443
- end
444
- return T (d. scitype, decoder, prob_given_ref)
445
- end
446
- * (d:: UnivariateFinite , x:: Real ) = _times (d, x, UnivariateFinite)
447
- * (d:: UnivariateFiniteArray , x:: Real ) = _times (d, x, UnivariateFiniteArray)
448
-
449
- * (x:: Real , d:: SingletonOrArray ) = d* x
450
- / (d:: SingletonOrArray , x:: Real ) = d* inv (x)
0 commit comments