Reputation: 962
I have a MySQL table with three columns: height, weight, gender. This table is being used as a model for my project. Is there a function of method in RoR that will allow me to calculate a normal distribution based on the data?
For example I would like to create a bell curve for men, and a bell curve for women, and then be able to determine the likelihood of any give height/weight value set as being male or female. New data will always be getting added, so the distributions will not be static.
Should I try to create a function in MySQL that creates the distributions, and then have a RoR method that evaluates input against the distribution, or can this all be done in RoR?
I am using Ruby 2.3 and rails 5.1.6.
Upvotes: 1
Views: 558
Reputation: 962
I made this more complicated than it needed to be. I used AVG() to get the mean and STDDEV() to get the standard deviation for each height and weight. I then added then subtracted the SD from the mean for the lower bound, and added the SD to the mean to the upper bound, and then evaluated first if the height was within one standard deviation of target, and then weight, and then used that to find probability.
Upvotes: 0