Skip to content

Commit

Permalink
Merge pull request #6 from Kimitsuna-Goblin/develop
Browse files Browse the repository at this point in the history
v1.0.3
  • Loading branch information
Kimitsuna-Goblin authored Feb 4, 2024
2 parents 24b5146 + 63f1f75 commit 7395ed5
Show file tree
Hide file tree
Showing 71 changed files with 2,104 additions and 1,912 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: ggd
Type: Package
Title: Gradational Gaussian Distribution Reference Class
Version: 1.0.2
Version: 1.0.3
Authors@R: c(
person( given = "Kimitsuna",
family = "Ura",
Expand Down
2 changes: 1 addition & 1 deletion R/cmn.bisection.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
################################################################################################
#' [Non-exported] Bisection method
#'
#' Solves a equation via bisection method.
#' Solves an equation via bisection method.
#' @param f The destination function to solve.
#' @param interval A numeric vector of length 2 indicating the range of x value
#' on which the solution is to be searched.
Expand Down
13 changes: 6 additions & 7 deletions R/cmn.csv.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,17 @@
################################################################################################
#' [Non-exported] Output a table to a file
#'
#' Prints the argument \code{x} (it should be a data frame or matrix)
#' to a file or \link[base]{connection} with the CSV format.
#' This function use \link[base]{cat} to output.
#' When outputting real numbers, the precision can be specified with \code{digits} argument.
#' @param x The object to be written, should be a matrix or data frame.
#' Outputs a data frame or a matrix to a file or \link[base]{connection} with the CSV format
#' using \link[base]{cat}.
#' The precision for real numbers can be indicated with \code{digits} argument.
#' @param x The object to be output, should be a matrix or data frame.
#' @param file A \link[base]{connection},
#' or a character string naming the file to print to.
#' If \code{""} (the default), it prints to the standard output connection,
#' the console unless redirected by \link[base]{sink}.
#' @param top.text A character string to be output as the first element of the header.
#' @param digits The number of significant digits to print (see \link[base]{signif}).
#' Valid values are integers from 1 to 22 with default 15.
#' @param digits The number of significant digits (see \link[base]{signif}) to print.
#' Integers from \code{1} to \code{22} with default \code{15} are allowed.
#' @return An invisible \code{NULL}.
#' @examples
#' ggd:::cat.table( data.frame( a = 1:6 * pi, b = pi^(1:6) ), top.text = "PI", digits = 10 )
Expand Down
44 changes: 22 additions & 22 deletions R/cmn.norm.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@
################################################################################################
#' Sigma-unit distance from the mean of a normal distribution
#'
#' Calculates how many sigmas are the distances from the mean of a normal distribution
#' to the values of the quantile function for the given probabilities.
#' The mean and standard deviation are not need for this function, because sigma-unit distances
#' do not depend on them.
#' Calculates how many sigmas are the distance from the mean of a normal distribution
#' to the x-coordinate of the quantile which has the indicated probability.
#' The mean and standard deviation are not needed for this function
#' because the sigma-unit distance does not depend on them.
#' @export
#' @param p A vector of probabilities.
#' @return A vector of sigma-unit distances from the mean to the quantiles for
#' the probabilities.
#' @param p A vector of the probabilities of the quantiles.
#' @return A vector of sigma-unit distances
#' from the mean to the x-coordinates of the quantiles.
#' @importFrom stats qnorm
#' @examples
#' sqnorm( 0.5 ) # 0
#' sqnorm( pnorm( -2, 0, 1 ) ) # -2
#' sqnorm( seq( 0, 1, 0.1 ) ) # increces from -Inf to Inf
#' sqnorm( 0.5 ) ## 0
#' sqnorm( pnorm( -2, 0, 1 ) ) ## -2
#' sqnorm( seq( 0, 1, 0.1 ) ) ## increases from -Inf to Inf
################################################################################################
sqnorm <- function( p )
{
Expand All @@ -34,20 +34,20 @@ sqnorm <- function( p )
################################################################################################
#' Standard deviation of a normal distribution
#'
#' Calculates the standard deviations of the normal distribution
#' satisfying the given mean and one other quantile.
#' Calculates the standard deviation of the normal distribution
#' which has the indicated mean and passes through one other quantile.
#' @export
#' @param mean A vector of the mean values of the normal distributions.
#' @param x A vector of x-coordinates of the quantiles.
#' Each value of \code{x} must not be equal to the mean value.
#' @param p A vector of the probabilities for the quantiles.
#' In other word, the value of the cumulative distribution function of
#' a normal distribution for the \code{x}. The value must not be \code{0.5}.
#' @return The vector of the standard deviations.
#' @return A vector of the standard deviations.
#' @examples
#' sd.norm.mxp( 0, qnorm( 0.3, 0, 1 ), 0.3 ) # 1
#' sd.norm.mxp( rep( 0, 5 ), 1:5, pnorm( 1:5, 0, 1 ) ) # 1 1 1 1 1
#' sd.norm.mxp( c( -0.1, 0, 0.3 ), c( -0.3, -0.1, 0.4 ), c( 0.38, 0.47, 0.53 ) ) # [2] == [3]
#' sd.norm.mxp( 0, qnorm( 0.3, 0, 1 ), 0.3 ) ## 1
#' sd.norm.mxp( rep( 0, 5 ), 1:5, pnorm( 1:5, 0, 1 ) ) ## 1 1 1 1 1
#' sd.norm.mxp( c( -0.1, 0, 0.3 ), c( -0.3, -0.1, 0.4 ), c( 0.38, 0.47, 0.53 ) ) ## [2] == [3]
################################################################################################
sd.norm.mxp <- function( mean, x, p )
{
Expand All @@ -58,22 +58,22 @@ sd.norm.mxp <- function( mean, x, p )
#' Mean and standard deviation of a normal distribution
#'
#' Calculates the mean and standard deviation of the normal distribution
#' satisfying the given two quantiles.
#' which passes through the indicated two quantiles.
#' This is the body of \code{ggd.trace.q(kind = "Normal Distribution")}.
#' @export
#' @param x The x-coordinates of the quantiles. It must be a vector with 2 numerics.
#' @param x The x-coordinates of the quantiles. It must be a vector with 2 elements.
#' @param p The probabilities for the quantiles.
#' In other word, the values of the cumulative distribution function of
#' a normal distribution for \code{x}. It must be also a vector with 2 numerics.
#' a normal distribution for \code{x}. It must be also a vector with 2 elements.
#' @return A list containing components
#' \item{mean}{
#' The mean value of the normal distribution.}
#' \item{sd}{
#' The standard deviation of the normal distribution.}
#' @examples
#' ms.norm.xp( x = c( -1, 1 ), p = pnorm( c( -1, 1 ), 0, 1 ) ) # list( mean = 0, sd = 1 )
#' ms.norm.xp( x = c( 0, 1 ), p = pnorm( c( 0, 1 ), 0, 2 ) ) # list( mean = 0, sd = 2 )
#' ms.norm.xp( x = c( -2, 1 ), p = c( 0.3, 0.7 ) ) # list( mean = 0.5, sd = 2.86 ) (about)
#' ms.norm.xp( x = c( -1, 1 ), p = pnorm( c( -1, 1 ), 0, 1 ) ) ## list( mean = 0, sd = 1 )
#' ms.norm.xp( x = c( 0, 1 ), p = pnorm( c( 0, 1 ), 0, 2 ) ) ## list( mean = 0, sd = 2 )
#' ms.norm.xp( x = c( -2, 1 ), p = c( 0.3, 0.7 ) ) ## list( mean = -0.5, sd = about 2.86 )
################################################################################################
ms.norm.xp <- function( x, p )
{
Expand Down
Loading

0 comments on commit 7395ed5

Please sign in to comment.