Skip to contents

This function generates log means for a specified number of OTUs (Operational Taxonomic Units) based on the provided parameters. If a single mean is specified, the log means are drawn from a normal distribution. If multiple means and corresponding weights are specified, the log means are drawn from a mixture of normal distributions.

Usage

logmean_sim_fun(logmean_param, notu)

Arguments

logmean_param

A list containing the parameters for the distribution:

  • mu: A single value or a vector of mean(s) for the normal or mixture distribution.

  • sigma: The standard deviation(s) for the normal or mixture distribution.

  • lambda: (Optional) A vector of weights for the components of the mixture distribution. Required only if mu has more than one value.

notu

An integer specifying the number of OTUs to simulate.

Value

A numeric vector of simulated log means for the specified number of OTUs.

Examples

# Example 1: Single normal distribution
params_single <- list(mu = 0, sigma = 1)
logmean_sim_fun(logmean_param = params_single, notu = 100)
#>   [1] -1.263531394  0.789599170 -1.207329901  2.049174890 -0.383907435
#>   [6]  0.803024323 -0.426665290 -0.706989364  0.266977750  1.091071201
#>  [11] -1.296699868 -0.481445484 -1.370472990  0.473992799 -0.570382639
#>  [16] -0.859123151  0.180325498 -2.325261975  0.229191075  1.101121605
#>  [21]  0.671537032 -1.609930315  1.499586846 -0.426386654 -0.365605089
#>  [26]  1.404223850 -0.212578772  0.482178799 -1.147854771  0.838797701
#>  [31] -1.294699506 -0.079191022 -1.579021704 -1.168583332  1.738174285
#>  [36]  1.495282774  0.785266346  1.766573459 -0.549211199 -0.861438203
#>  [41] -0.957781278 -0.480108430  0.198667783 -0.713043452  0.344730737
#>  [46] -1.098110551 -0.281452741  0.262643214  0.231411501 -0.570551186
#>  [51]  1.475872638 -1.040191060 -0.658482751 -0.687583240 -0.300459628
#>  [56] -0.011998610 -0.343787837 -1.341885019  0.543970389  1.571399767
#>  [61] -0.929071451 -0.142124167  0.359607554  0.278549692  0.710441236
#>  [66]  0.529936150  1.995687506 -1.356357513  0.973130544 -0.571547408
#>  [71]  0.175244844 -0.570455446 -0.160898597 -1.024100473  0.692937808
#>  [76]  0.222826016 -0.866935747 -0.690429525  0.104408012 -0.445639388
#>  [81] -2.235680670 -0.725806641 -0.556964551 -2.264780814 -0.482236425
#>  [86] -1.059888203 -2.006952362 -0.671304625  0.180234653  0.523397858
#>  [91]  0.655110326 -1.913157471  1.818301934  0.162843827  0.003678043
#>  [96] -0.229860059 -0.347640674 -0.433225141 -0.898025154  0.402207034

# Example 2: Mixture of normal distributions
params_mixture <- list(
  mu = c(-1, 1),
  sigma = c(0.5, 0.5),
  lambda = c(0.4, 0.6)
)
logmean_sim_fun(logmean_param = params_mixture, notu = 100)
#>   [1]  0.1037875  1.3601606 -0.6717271  0.7460232 -1.0094903  1.4797832
#>   [7]  1.3581081 -1.2450457 -1.2394050  1.2240723 -0.6942849  0.9278251
#>  [13] -1.0047951 -0.6197033  1.5873032 -1.1989345  1.6592226  1.4951024
#>  [19]  0.8836983  1.9139176  0.9040098  0.9035879 -1.1547118  0.4643802
#>  [25] -1.3285503  0.9799409  0.9537444  1.2937320  0.2181232  0.9031083
#>  [31] -0.4814074 -1.6252349  1.3601794 -1.2540405  1.3474740 -1.3727279
#>  [37]  0.9911389 -0.5041911  1.0922001  0.6275823 -1.1413771  0.8871811
#>  [43]  0.3854336 -1.6951394  1.7412246 -0.6631358  0.6914110  1.0390460
#>  [49]  1.2854966 -2.0833822 -1.6517705  0.7760481  0.7119217  1.2496213
#>  [55] -0.8126248  1.0673845  1.2325832 -0.7533859  0.2013839  0.8951888
#>  [61]  1.0647778  0.7685888  2.0671197  0.8114451  0.6838967  0.5252225
#>  [67]  1.3038115 -1.2743737  0.7590150 -1.8230549 -0.7592751  0.3251286
#>  [73]  1.6003720  0.6033125  1.1967829 -0.1298138  0.7337579 -0.7314509
#>  [79]  1.6884261  0.9736169 -0.4499445  1.4497337  1.8808582  1.1797716
#>  [85]  1.6673794  1.4672022  2.5571766  1.2402886 -0.7765254  1.7941689
#>  [91]  1.2196524 -0.8449066  0.4796123  0.6084875 -2.0798743  0.5942093
#>  [97]  0.9400237  1.0206493  1.3975704 -0.9166554