How to calculate mean or variance in a string ?

34 views (last 30 days)
Hi, I have a jumbled text and i wish to straighten it out using machine learning . I wanted to calculate the variance of the jumbled text . Can anyone suggest me a method on how to do it ?
Star Strider
Star Strider on 26 Aug 2014
What do you mean by ‘jumbled text’? Is it a replacement cipher, with one letter replacing another repeatedly ( i.e. a=m, g=b, q=e ) or some such?

Sign in to comment.

Accepted Answer

Andrew Reibold
Andrew Reibold on 26 Aug 2014
Edited: Andrew Reibold on 28 Aug 2014
You can convert to ascii equivalent, then find variance.
jumble_text = 'alskdjbfalksjbdf'
ascii_text = double(jumble_text)
mean_text = mean(ascii_text)
squared_dif = (ascii_text - mean_text).^2
variance = mean(squared_dif)

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by