blob: bcbd528eb93273118351ba22c06c6f8c02a8b746 [file] [log] [blame]
#-------------------------------------------------------------
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
#-------------------------------------------------------------
# generates random numbers from a distribution
# with specified mean, standard deviation,
# skewness, kurtosis
# mean and standard deviation are taken in as
# arguments by this script
# a,b,c,d are coefficients computed by some
# equation solver determined from the specified
# skewness and kurtosis using power method
# polynomials
#
# for more details see:
# Statistical Simulation: Power Method Polynomials
# and Other Transformations
# Author: Todd C. Headrick
# Chapman & Hall/CRC, Boca Raton, FL, 2010.
# ISBN 978-1-4200-6490-2
# $1 is the number of random points to be sampled
# $2 is specified mean
# $3 is specified standard deviation
# $4-$7 are a,b,c,d obtained by solving a system
# of equations using specified kurtosis and skewness
# $8 is the file to write out the generated data to
numSamples = $1
mu = $2
sigma = $3
a = $4
b = $5
c = $6
d = $7
print("a=" + a + " b=" + b + " c=" + c + " d=" + d)
X = Rand(rows=numSamples, cols=1, pdf="normal", seed=0)
Y = a + b*X + c*X^2 + d*X^3
Z = Y*sigma + mu
write(Z, $8, format="binary")