2
$\begingroup$

I am trying to understand the difference between f(x) and g(x) below. I am not a mathematician or statistician, so please bear with me.

Basically, I'm trying to specifically understand:

  1. what g is doing to the data
  2. what motivation, if any, there is to use g
  3. what relationship there is, if any, between f, and g (I do not think one can be algebraically derived from the other, but I could be wrong)
  4. what argument one could propose, for or against the use of g or f on the dataset

For example, to me, f(x), or equivalent, minmax(log(x)) seems a more "natural" way of scaling and looking at the values in vals; let us assume that vals can have extremely large integer values, and has a more or less logarithmic distribution.

However, I was told that f simply "shifts" the data by a constant, and that they're essentially the same function. This latter statement seems intuitively incorrect to me, partially because the constant is directly dependent on the data (e.g., min and max of vals or logvals), and also because the data has different distributions for this input (and the input we actually deal with) --- but I do not have a plausible mathematical argument for why, and perhaps I am wrong in my intution.

On a similar note it just looks like to me that it was mistakenly assumed that log(x + b) = log(x) + log(b), and hence it was acceptable to use the function g(x) as a result.

Any help would be much appreciated!

using Plots
gr()

vals = [4213,2607,2088,1847,1799,1799,1799,1662,1554,1462,1408,1399,1399,1399,1342,1299,1272,1265,1265,1265,1240,1217,1202,1199,1199,1196,1179,1167,1159,1159,1159,1155,1146,1138,1132,1132,1132,1127,1120,1114,1113,1113,1112,1107,1101,1099,1099,1099,1097,1092,1088,1087,1087,1086,1082,1079,1079,1079,1076,1073,1071,1071,1071,1068,1066,1065,1065,1064,1062,1060,1060,1060,1058,1056,1056,1056,1055,1053,1052,1052,1052,1050,1049,1049,1049,1047,1046,1046,1046,1044,1043,1043,1043,1042,1041,1041,1041,1040,1039,1039,1038,1037,1037,1037,1036,1035,1035,1035,1034,1033,1033,1033,1032,1032,1032,1031,1031,1031,1030,1029,1029,1029,1029,1028,1028,1028,1027,1027,1026,1026,1026,1026,1025,1025,1025,1024,1024,1024,1024,1024,1023,1023,1023,1023,1022,1022,1022,1021,1021,1021,1021,1021,1021,1020,1020,1020,1020,1020,1019,1019,1019,1019,1019,1019,1018,1018,1018,1018,1018,1018,1017,1017,1017,1017,1017,1017,1016,1016,1016,1016,1016,1016,1016,1015,1015,1015,1015,1015,1015,1015,1014,1014,1014,1014,1014,1014,1014,1013,1013,1013,1013,1013,1013,1013,1013,1013,1012,1012,1012,1012,1012,1012,1012,1012,1012,1011,1011,1011,1011,1011,1011,1011,1011,1011,1011,1010,1010,1010,1010,1010,1010,1010,1010,1010,1010,1010,1010,1010,1009,1009,1009,1009,1009,1009,1009,1009,1009,1009,1009,1009,1009,1009,1009,1008,1008,1008,1008,1008,1008,1008,1008,1008,1008,1008,1008,1008,1008,1008,1007,1007,1007,1007,1007,1007,1007,1007,1007,1007,1007,1007,1007,1007,1007,1007,1007,1007,1007,1007,1007,1006,1006,1006,1006,1006,1006,1006,1006,1006,1006,1006,1006,1006,1006,1006,1006,1006,1006,1006,1006,1006,1006,1006,1005,1005,1005,1005,1005,1005,1005,1005,1005,1005,1005,1005,1005,1005,1005,1005,1005,1005,1005,1005,1005,1005,1005,1005,1005,1005,1005,1005,1005,1005,1005,1004,1004,1004,1004,1004,1004,1004,1004,1004,1004,1004,1004,1004,1004,1004,1004,1004,1004,1004,1004,1004,1004,1004,1004,1004,1004,1004,1004,1004,1004,1004,1004,1003,1003,1003,1003,1003,1003,1003,1003,1003,1003,1003,1003,1003,1003,1003,1003,1003,1003,1003,1003,1003,1003,1003,1003,1003,1003,1003,1003,1003,1003,1003,1003,1003,1003,1003,1003,1003,1003,1003,1003,1003,1003,1003,1003,1003,1003,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000]

(min, max) = extrema(vals)

logvals = map(log, vals)
(logmin, logmax) = extrema(logvals)

f(n, min, max) = (log(n) - log(min)) / (log(max) - log(min))
g(n, min, max) = (log(n - min + 1)) / log(max - min + 1)
minmaxscale(n, min, max) = (n - min) / (max - min)

fDistribution         = map((n -> f(n, min, max)), vals)
gDistribution         = map((n -> g(n, min, max)), vals)
minmaxlogDistribution = map((n -> minmaxscale(n, logmin, logmax)), logvals)

println("Input values: ", vals)
println("f(x): ", fDistribution)
println("g(x): ", gDistribution)
println("minmax(log(x)): ", minmaxlogDistribution)

assert(minmaxlogDistribution == fDistribution)
assert(fDistribution != gDistribution)

p = histogram(fDistribution,  yaxis=(:log), bins=100, linecolor=:black, linewidth=1, fillrange=0, fillcolor=:lightpink, fillalpha=0.25, lab="f(x) Histogram")
histogram!(gDistribution, yaxis=(:log), bins=100, linecolor=:black, linewidth=1, fillrange=0, fillcolor=:lightblue, fillalpha=0.25, lab="g(x) Histogram")

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.