Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • mapMCDA mapMCDA
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 31
    • Issues 31
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • UMR-ASTRE
  • mapMCDAmapMCDA
  • Issues
  • #21

Closed
Open
Created Apr 10, 2019 by Facundo Muñoz@famuvie®️Owner

Alternative risk-scaling functions

Created by: famuvie

Currently, the only scaling functions are linear, with the option to be reversed.

Please add radio buttons to choose various links for standardization (see code at the end of this post, as a suggestion only)

Feature requested by @vporphyre in #19 (closed)

# function link_fun (à integrer dans risk_layer à la place de lin_fun) BETA VERSION (V.Porphyre) #### 
# arg invert à associer au bouton 'Inverser'
# x1 and x2 Threshold values

lin_fun <- function(r, type="linear", invert=FALSE, x1=0, x2=0, source=scale_source, target=scale_target){
	if (type=="linear"){
		slope <- diff(target)/diff(source)
		ans <- target[1] + slope * (r - source[1])
	} 
	
	if (type=="crisp"){ tmp <- r
		if (invert==FALSE) {
			tmp[tmp<x1] <- target[1]
			tmp[tmp>=x1] <- target[2]
		}
		if (invert==TRUE){
			tmp[tmp<x1] <- target[2]
			tmp[tmp>=x1] <- target[1]
		}
	ans <- tmp
	}
	
	if (type=="double"){ tmp <- r
		if(invert==FALSE){	
			tmp[tmp<x1] <- target[1]
			tmp[tmp>=x1 & tmp<x2] <- target[2]
			tmp[tmp>=x2] <- target[1]}
		if(invert==TRUE){
			tmp[tmp<x1] <- target[2]
			tmp[tmp>=x1 & tmp<x2] <- target[1]
			tmp[tmp>=x2] <- target[2]
		}
	ans <- tmp
	}
	
	# if (type=="fuzzy"){} # to be developped
	# if (type=="sigmoid"){
	# 	#ans <- target[2]*(1/(1 + ((1/target[1])-1)*exp(-x1*r)))
	# }  # WRONG
		
			return(ans)
}
Assignee
Assign to
Time tracking