Jack Aubrey is based on a real-life person, Thomas Cochrane. Aubrey's history loosely matches Cochrane's, with additions, and O'Brian uses many of Cochrane's exploits in his books, but some of the things Cochrane did were so wildly improbable that you couldn't get away with them in fiction, and O'Brian had to tone them down. Think capturing the entire navy of a South American country with one ship and a lot of chutzpah. Or, with a small ship manned by 54 men, carrying 14 4-pound (pretty small and short-range) guns, actually boarding and capturing a much larger Spanish ship manned by 320 men, armed with 37 guns, most much larger, all done with a combination of clever bluffing, totally unorthodox strategy, and incredible seamanship. This battle is described in "Master and Commander". Aubrey's Sophie and the Spanish Cacafuego were really Speedy and Gamo, but the description in the book doesn't do full justice to how astonishingly clever the battle really was.
At least 2 other authors have used Cochrane as a model. Frederick Marryat, who served under Cochrane, used him as Captain Savage, and he is also C. S. Forester's Horatio Hornblower.
Stephen Maturin was in part an alter ego for O'Brian himself.
Thanks, Jude, for giving me a chance to spout off about one of my hobby horses.